From 8bb7970d70ed1fd22d9368b2bf102b19caec3859 Mon Sep 17 00:00:00 2001 From: Curtis McCully Date: Wed, 9 Aug 2023 10:57:14 -0400 Subject: [PATCH] Fix a bug that wouldn't allow only grouping by instrument --- CHANGES.md | 4 ++++ banzai/calibrations.py | 4 ++++ banzai/stages.py | 12 +++++++++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 09c461208..6bcd2f3b1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +1.11.0 (2023-08-09) +------------------- +- Added the process_by_group keyword to stages to fix a bug that wouldn't allow grouping only by instrument + 1.10.1 (2023-05-31) ------------------- - Updated the logging scheme diff --git a/banzai/calibrations.py b/banzai/calibrations.py index 20c836642..9b5c96ccf 100644 --- a/banzai/calibrations.py +++ b/banzai/calibrations.py @@ -49,6 +49,10 @@ class CalibrationStacker(CalibrationMaker): def __init__(self, runtime_context): super(CalibrationStacker, self).__init__(runtime_context) + @property + def process_by_group(self): + return True + def make_master_calibration_frame(self, images): make_calibration_name = file_utils.make_calibration_filename_function(self.calibration_type, self.runtime_context) diff --git a/banzai/stages.py b/banzai/stages.py index ee774205a..57bba3f16 100755 --- a/banzai/stages.py +++ b/banzai/stages.py @@ -22,6 +22,10 @@ def stage_name(self): def group_by_attributes(self): return [] + @property + def process_by_group(self): + return False + def get_grouping(self, image): grouping_criteria = [image.instrument.site, image.instrument.id] if self.group_by_attributes: @@ -31,11 +35,13 @@ def get_grouping(self, image): def run(self, images): if not images: return images - if not self.group_by_attributes: - image_sets = images - else: + if self.group_by_attributes or self.process_by_group: images.sort(key=self.get_grouping) image_sets = [list(image_set) for _, image_set in itertools.groupby(images, self.get_grouping)] + else: + # Treat each image individually + image_sets = images + processed_images = [] for image_set in image_sets: try: