Skip to content

Commit

Permalink
Merge pull request #166 from roman-corgi/walker_with_dataset
Browse files Browse the repository at this point in the history
Use dataset instead of single frame for guessing recipes
  • Loading branch information
maxwellmb authored Aug 21, 2024
2 parents db49c04 + 98b22aa commit 49df4b4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions corgidrp/walker.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ def autogen_recipe(filelist, outputdir, template=None):
Returns:
json: the JSON recipe to process the filelist
"""
# load the first frame to check what kind of data and identify recipe
first_frame = data.autoload(filelist[0])
# load the data to check what kind of recipe it is
dataset = data.Dataset(filelist)
first_frame = dataset[0]

# if user didn't pass in template
if template is None:
recipe_filename = guess_template(first_frame)
recipe_filename = guess_template(dataset)

# load the template recipe
recipe_filepath = os.path.join(recipe_dir, recipe_filename)
Expand Down Expand Up @@ -107,16 +108,17 @@ def autogen_recipe(filelist, outputdir, template=None):
return recipe


def guess_template(image):
def guess_template(dataset):
"""
Guesses what template should be used to process a specific image
Args:
image (corgidrp.data.Image): an Image file to process
dataset (corgidrp.data.Dataset): a Dataset to process
Returns:
str: the best template filename
"""
image = dataset[0] # first image for convenience
if image.ext_hdr['DATA_LEVEL'] == "L1":
if image.pri_hdr['OBSTYPE'] == "ENG":
recipe_filename = "l1_to_l2a_eng.json"
Expand Down

0 comments on commit 49df4b4

Please sign in to comment.