Skip to content

Commit

Permalink
Merge branch 'feature/sky-ab'
Browse files Browse the repository at this point in the history
  • Loading branch information
leejjoon committed May 19, 2017
2 parents f00d6d5 + 209c943 commit 8fbbf23
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 10 deletions.
8 changes: 6 additions & 2 deletions igrins/libs/recipe_base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#from products import PipelineProducts

from igrins.libs.logger import logger

def _parse_starting_obsids(starting_obsids):
if starting_obsids is not None:
starting_obsids = map(int, starting_obsids.split(","))
Expand Down Expand Up @@ -34,8 +36,8 @@ def filter_a0v(a0v, a0v_obsid, group2):

def get_selected(recipes, recipe_name, starting_obsids, groups):
if starting_obsids is not None:
print ("'starting-obsids' option is deprecated, "
"please use 'groups' option.")
logger.warn("'starting-obsids' option is deprecated, "
"please use 'groups' option.")
if groups is not None:
raise ValueError("'starting-obsids' option is not allowed"
" when 'groups' option is used.")
Expand All @@ -49,9 +51,11 @@ def get_selected(recipes, recipe_name, starting_obsids, groups):

selected = recipes.select_fnmatch_by_groups(recipe_name,
groups_parsed)
logger.info("selected recipe: {}".format(selected))

return selected


class RecipeBase(object):
""" The derived mus define RECIPE_NAME attribute and must implement
run_selected_bands method.
Expand Down
25 changes: 22 additions & 3 deletions igrins/libs/recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,15 @@ def select_fnmatch_by_groups(self, recipe_fnmatch, groups=None):

p_match = get_multi_fnmatch_pattern(recipe_fnmatch_list)

_ = []
for recipe_item in self.recipe_list:
for recipe_name in recipe_item[0].split("|"):
if p_match(recipe_name):
recipe_item_new = (recipe_name, ) + recipe_item[1:]
_.append((recipe_item[-1]["GROUP1"], recipe_item_new))

from collections import OrderedDict
dict_by_group = OrderedDict((recipe_item[-1]["GROUP1"], recipe_item) \
for recipe_item in self.recipe_list \
if p_match(recipe_item[0]))
dict_by_group = OrderedDict(_)

if groups is None:
groups = dict_by_group.keys()
Expand Down Expand Up @@ -265,6 +270,7 @@ def _test1():
r.subset(starting_obsid=[11, 105])
r.subset(recipe=["SKY", "EXTENDED_ONOFF"])


def _test2():
fn = "../../recipe_logs/20141023.recipes"
# r = load_recipe(fn)
Expand All @@ -273,5 +279,18 @@ def _test2():
s1 = r2.select_deprecate("A0V_AB")
s2 = r2.select_fnmatch("A0V_AB")


def _test3():
fn = "../../recipe_logs/20150120.recipes"
# r = load_recipe(fn)
recipes = Recipes(fn)

recipe_name = "SKY*"
groups_parsed = None
selected = recipes.select_fnmatch_by_groups(recipe_name,
groups_parsed)
print selected


if __name__ == "__main__":
pass
8 changes: 6 additions & 2 deletions igrins/recipes/process_wvlsol_v0.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# import numpy as np

from igrins.libs.products import PipelineProducts, PipelineImageBase
from igrins.libs.logger import logger

# from igrins.libs.apertures import Apertures


Expand Down Expand Up @@ -501,8 +503,10 @@ def process_band(utdate, recipe_name, band,
obsids, frametypes, aux_infos,
config_name, **kwargs):

if recipe_name.upper().endswith("_AB") and not kwargs.pop("do_ab"):
return
if recipe_name.upper() != "SKY_AB":
if recipe_name.upper().endswith("_AB") and not kwargs.pop("do_ab"):
logger.info("ignoring {}:{}".format(recipe_name, groupname))
return

from igrins import get_caldb, get_obsset
caldb = get_caldb(config_name, utdate)
Expand Down
3 changes: 1 addition & 2 deletions igrins/recipes/recipe_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"THAR", process_band)

_recipe_class_register_sky = new_recipe_class("RecipeRegisterSky",
["SKY", "*_AB"],
#["SKY"],
["SKY", "SKY_AB"],
process_band)

_command_names = []
Expand Down
3 changes: 2 additions & 1 deletion igrins/recipes/recipe_wvlsol_sky2.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,9 @@ def process_band(utdate, recipe_name, band,

from igrins.libs.recipe_factory import new_recipe_class, new_recipe_func

# If the recipe is != "SKY", the resulting combined image will be A-B.
_recipe_class_wvlsol_sky = new_recipe_class("RecipeWvlsolSky",
"SKY", process_band)
["SKY", "SKY_AB"], process_band)

wvlsol_sky = new_recipe_func("wvlsol_sky",
_recipe_class_wvlsol_sky)
Expand Down

0 comments on commit 8fbbf23

Please sign in to comment.