Ejemplo n.º 1
0
    def __init__(self):

        from igrins_config import IGRINSConfig
        config = IGRINSConfig("../recipe.config")

        def get_refdata(band):
            from master_calib import load_sky_ref_data

            sky_refdata = load_sky_ref_data(config, band)

            return sky_refdata

        sky_ref_data = get_refdata("H")

        self.ohline_indices = sky_ref_data["ohline_indices"]
        self.ohlines_db = sky_ref_data["ohlines_db"]

        import json
        fn = "../calib/primary/20140525/SDCH_20140525_0003.wvlsol_v0.json"
        wvl_solution = json.load(open(fn))
        self.wvl_map = dict(
            zip(wvl_solution["orders"], wvl_solution["wvl_sol"]))

        fn = "../calib/primary/20140525/SDCH_20140525_0029.oned_spec.json"
        s_list = json.load(open(fn))
        self.s_map = dict(zip(s_list["orders"], s_list["specs"]))
Ejemplo n.º 2
0
    def __init__(self, config_name, utdate, recipe_name="",
                 ensure_dir=False):

        from igrins_config import IGRINSConfig
        if isinstance(config_name, str):
            self.config = IGRINSConfig(config_name)
        else:
            self.config = config_name

        self.utdate = utdate
        self.refdate = self.config.get("MASTER_CAL", "REFDATE")

        self._igr_path = IGRINSPath(self.config, utdate,
                                    ensure_dir=ensure_dir)

        self._igr_storage = PipelineStorage(self._igr_path)

        self.recipe_name = recipe_name
Ejemplo n.º 3
0
class RecipeBase(object):
    """ The derived mus define RECIPE_NAME attribute and must implement
        run_selected_bands method.

        RECIPE_NAME can be a string, or a sequence of strings which is
        interpreted as a fnmatch translater.
    """
    def __init__(self, **kwargs):
        self.kwargs = kwargs

    def set_recipe_name(self, recipe_name):
        self.RECIPE_NAME = recipe_name

    def _validate_bands(self, bands):
        if not bands in ["H", "K", "HK"]:
            raise ValueError("bands must be one of 'H', 'K' or 'HK'")

    def get_recipe_name(self, utdate):
        fn = self.config.get_value('RECIPE_LOG_PATH', utdate)
        return fn

    def get_recipes(self, utdate):
        fn = self.get_recipe_name(utdate)
        from recipes import Recipes #load_recipe_list, make_recipe_dict
        return Recipes(fn)

    def run_selected_bands_with_recipe(self, utdate, selected, bands):
        # just ignore recipe
        selected2 = [_[1:] for _ in selected]
        self.run_selected_bands(utdate, selected2, bands)

    def __call__(self, utdate, bands="HK",
                 starting_obsids=None, groups=None,
                 config_file="recipe.config"):
        self.process(utdate, bands, starting_obsids, groups,
                     config_file=config_file)

    def process(self, utdate, bands="HK",
                starting_obsids=None, 
                groups=None,
                config_file="recipe.config",
                **kwargs):

        from igrins_config import IGRINSConfig
        self.config = IGRINSConfig(config_file)

        self.refdate = self.config.get("MASTER_CAL", "REFDATE")

        self._validate_bands(bands)

        recipes = self.get_recipes(utdate)

        selected = get_selected(recipes, self.RECIPE_NAME,
                                starting_obsids, groups)

        self.run_selected_bands_with_recipe(utdate, selected, bands,
                                            **kwargs)
Ejemplo n.º 4
0
    def process(self,
                utdate,
                bands="HK",
                starting_obsids=None,
                groups=None,
                config_file="recipe.config",
                **kwargs):

        from igrins_config import IGRINSConfig
        self.config = IGRINSConfig(config_file)

        self.refdate = self.config.get("MASTER_CAL", "REFDATE")

        self._validate_bands(bands)

        recipes = self.get_recipes(utdate)

        selected = get_selected(recipes, self.RECIPE_NAME, starting_obsids,
                                groups)

        self.run_selected_bands_with_recipe(utdate, selected, bands, **kwargs)
Ejemplo n.º 5
0
    def __init__(self, config_name, utdate, recipe_name=""):

        from igrins_config import IGRINSConfig
        if isinstance(config_name, str):
            self.config = IGRINSConfig(config_name)
        else:
            self.config = config_name

        self.utdate = utdate
        self.refdate = self.config.get("MASTER_CAL", "REFDATE")

        self.igr_path = IGRINSPath(self.config, utdate)

        self.igr_storage = PipelineStorage(self.igr_path)

        self.recipe_name = recipe_name
Ejemplo n.º 6
0
    def process(self, utdate, bands="HK",
                starting_obsids=None, 
                groups=None,
                config_file="recipe.config",
                **kwargs):

        from igrins_config import IGRINSConfig
        self.config = IGRINSConfig(config_file)

        self.refdate = self.config.get("MASTER_CAL", "REFDATE")

        self._validate_bands(bands)

        recipes = self.get_recipes(utdate)

        selected = get_selected(recipes, self.RECIPE_NAME,
                                starting_obsids, groups)

        self.run_selected_bands_with_recipe(utdate, selected, bands,
                                            **kwargs)
Ejemplo n.º 7
0
class RecipeHelper:
    def __init__(self, config_name, utdate, recipe_name=""):

        from igrins_config import IGRINSConfig
        if isinstance(config_name, str):
            self.config = IGRINSConfig(config_name)
        else:
            self.config = config_name

        self.utdate = utdate
        self.refdate = self.config.get("MASTER_CAL", "REFDATE")

        self.igr_path = IGRINSPath(self.config, utdate)

        self.igr_storage = PipelineStorage(self.igr_path)

        self.recipe_name = recipe_name

    def get_caldb(self):
        caldb = CalDB(self, self.utdate)
        return caldb

    def get_filenames(self, band, obsids):
        return self.igr_path.get_filenames(band, obsids)

    def get_basename(self, band, master_obsid):
        filenames = self.get_filenames(band, [master_obsid])
        basename = os.path.splitext(os.path.basename(filenames[0]))[0]
        return basename

    def get_base_info(self, band, obsids):
        filenames = self.get_filenames(band, obsids)
        basename = os.path.splitext(os.path.basename(filenames[0]))[0]
        master_obsid = obsids[0]

        return filenames, basename, master_obsid

    def load_ref_data(self, band, spec):
        from master_calib import load_ref_data
        s = load_ref_data(self.config, band, spec)
        return s
Ejemplo n.º 8
0
class RecipeHelper:
    def __init__(self, config_name, utdate, recipe_name="",
                 ensure_dir=False):

        from igrins_config import IGRINSConfig
        if isinstance(config_name, str):
            self.config = IGRINSConfig(config_name)
        else:
            self.config = config_name

        self.utdate = utdate
        self.refdate = self.config.get("MASTER_CAL", "REFDATE")

        self._igr_path = IGRINSPath(self.config, utdate,
                                    ensure_dir=ensure_dir)

        self._igr_storage = PipelineStorage(self._igr_path)

        self.recipe_name = recipe_name

    def get_caldb(self):
        caldb = CalDB(self, self.utdate)
        return caldb

    def get_filenames(self, band, obsids):
        return self._igr_path.get_filenames(band, obsids)

    def get_filename(self, band, obsid):
        return self._igr_path.get_filename(band, obsid)

    def get_basename(self, band, master_obsid):
        filenames = self.get_filenames(band, [master_obsid])
        basename = os.path.splitext(os.path.basename(filenames[0]))[0]
        return basename

    def get_basename_with_groupname(self, band, groupname):
        if isinstance(groupname, int):
            groupname = str(groupname)
        return self._igr_path.get_basename(band, groupname)

    def get_base_info(self, band, obsids):
        filenames = self.get_filenames(band, obsids)
        basename = os.path.splitext(os.path.basename(filenames[0]))[0]
        master_obsid = obsids[0]

        return filenames, basename, master_obsid

    def load_ref_data(self, band, spec):
        from master_calib import load_ref_data
        s = load_ref_data(self.config, band, spec)
        return s

    def get_item_path(self, item_desc, basename,
                      prevent_split=False, subdir=None):
        return self._igr_storage.get_item_path(item_desc, basename,
                                               prevent_split=prevent_split,
                                               subdir=subdir)

    def load(self, product_descs, mastername, prevent_split=False):
        return self._igr_storage.load(product_descs, mastername,
                                      prevent_split=prevent_split)

    def load_item_from_path(self, item_path):
        return self._igr_storage.load_item_from_path(item_path)

    def load_item(self, item_desc, basename):
        return self._igr_storage.load_item(item_desc, basename)

    def load1(self, product_desc, mastername,
              return_hdu_list=False, prevent_split=False):
        return self._igr_storage.load1(product_desc, mastername,
                                       return_hdu_list=return_hdu_list,
                                       prevent_split=prevent_split)

    def get_masterhdu(self, mastername):
        return self._igr_storage.get_masterhdu(mastername)

    def store_item(self, item_desc, basename, pipeline_image,
                   basename_postfix=None):
        return self._igr_storage.store_item(item_desc, basename,
                                            pipeline_image,
                                            basename_postfix=basename_postfix)

    def store(self, products, mastername, masterhdu=None, cache=True,
              basename_postfix=None):
        return self._igr_storage.store(products, mastername, 
                                       masterhdu=masterhdu, cache=cache,
                                       basename_postfix=basename_postfix)
Ejemplo n.º 9
0
class RecipeBase(object):
    """ The derived mus define RECIPE_NAME attribute and must implement
        run_selected_bands method.

        RECIPE_NAME can be a string, or a sequence of strings which is
        interpreted as a fnmatch translater.
    """
    def __init__(self, **kwargs):
        self.kwargs = kwargs

    def set_recipe_name(self, recipe_name):
        self.RECIPE_NAME = recipe_name

    def _validate_bands(self, bands):
        if not bands in ["H", "K", "HK"]:
            raise ValueError("bands must be one of 'H', 'K' or 'HK'")

    def get_recipe_name(self, utdate):
        fn = self.config.get_value('RECIPE_LOG_PATH', utdate)
        return fn

    def get_recipes(self, utdate):
        fn = self.get_recipe_name(utdate)
        from recipes import Recipes  #load_recipe_list, make_recipe_dict
        return Recipes(fn)

    def run_selected_bands_with_recipe(self, utdate, selected, bands):
        # just ignore recipe
        selected2 = [_[1:] for _ in selected]
        self.run_selected_bands(utdate, selected2, bands)

    def __call__(self,
                 utdate,
                 bands="HK",
                 starting_obsids=None,
                 groups=None,
                 config_file="recipe.config"):
        self.process(utdate,
                     bands,
                     starting_obsids,
                     groups,
                     config_file=config_file)

    def process(self,
                utdate,
                bands="HK",
                starting_obsids=None,
                groups=None,
                config_file="recipe.config",
                **kwargs):

        from igrins_config import IGRINSConfig
        self.config = IGRINSConfig(config_file)

        self.refdate = self.config.get("MASTER_CAL", "REFDATE")

        self._validate_bands(bands)

        recipes = self.get_recipes(utdate)

        selected = get_selected(recipes, self.RECIPE_NAME, starting_obsids,
                                groups)

        self.run_selected_bands_with_recipe(utdate, selected, bands, **kwargs)