# Path: ugali/utils/logger.py
# class SpecialFormatter(logging.Formatter):
#     FORMATS = {'DEFAULT'       : "%(message)s",
#                logging.WARNING : "WARNING: %(message)s",
#                logging.ERROR   : "ERROR: %(message)s"}
#     def format(self, record):
# def file_found(filename,force):


import os, glob
import time
import fitsio
import numpy as np
import ugali.candidate.associate
from os.path import exists, join
from ugali.analysis.pipeline import Pipeline
from ugali.analysis.search import CandidateSearch
from ugali.utils.logger import logger
from ugali.utils.shell import mkdir
        from ugali.utils.www import create_index_html
#!/usr/bin/env python
"""Perform object finding and association."""




components = ['label','objects','associate','candidate','plot','www']

def load_candidates(filename,threshold=0):
    """ Load candidates for plotting """
    candidates = fitsio.read(filename,lower=True,trim_strings=True)
    candidates = candidates[candidates['ts'] >= threshold]

    return candidates

def run(self):
    if 'label' in self.opts.run:
        logger.info("Running 'label'...")
        if not hasattr(self,'search'): 
            self.search = CandidateSearch(self.config)
        if exists(self.search.labelfile) and not self.opts.force:
            logger.info("  Found %s; skipping..."%self.search.labelfile)
        else:
            #self.search.createLabels3D()
            #self.search.loadLikelhood()
            #self.search.loadROI()
            self.search.createLabels2D()
            self.search.writeLabels()
    if 'objects' in self.opts.run:

# Path: ugali/utils/logger.py
# class SpecialFormatter(logging.Formatter):
#     FORMATS = {'DEFAULT'       : "%(message)s",
#                logging.WARNING : "WARNING: %(message)s",
#                logging.ERROR   : "ERROR: %(message)s"}
#     def format(self, record):
# def file_found(filename,force):


# Path: ugali/pipeline/run_04.0_peak_finder.py
import os, glob
import time
import fitsio
import numpy as np
import ugali.candidate.associate
from os.path import exists, join
from ugali.analysis.pipeline import Pipeline
from ugali.analysis.search import CandidateSearch
from ugali.utils.logger import logger
from ugali.utils.shell import mkdir
        from ugali.utils.www import create_index_html

#!/usr/bin/env python
"""Perform object finding and association."""




components = ['label','objects','associate','candidate','plot','www']

def load_candidates(filename,threshold=0):
    """ Load candidates for plotting """
    candidates = fitsio.read(filename,lower=True,trim_strings=True)
    candidates = candidates[candidates['ts'] >= threshold]

    return candidates

def run(self):
    if 'label' in self.opts.run:
        logger.info("Running 'label'...")
        if not hasattr(self,'search'): 
            self.search = CandidateSearch(self.config)
        if exists(self.search.labelfile) and not self.opts.force:
            logger.info("  Found %s; skipping..."%self.search.labelfile)
        else:
            #self.search.createLabels3D()
            #self.search.loadLikelhood()
            #self.search.loadROI()
            self.search.createLabels2D()
            self.search.writeLabels()
    if 'objects' in self.opts.run:

        logger.info("Running 'objects'...")