diff --git a/CHANGES.rst b/CHANGES.rst index 81dab1f3b..4614c61e2 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -14,6 +14,8 @@ dark general ------- +- Update pipeline code to correct cal_step and suffixes [#971] + - Update pipeline code to run through tweakreg with single files and associations [#960] - Update regression tests with new data and update ramp fitting tests to use ols_cas22 [#911] diff --git a/romancal/lib/suffix.py b/romancal/lib/suffix.py index 9abaf691d..9be896fd6 100644 --- a/romancal/lib/suffix.py +++ b/romancal/lib/suffix.py @@ -53,6 +53,7 @@ "jump", "rampfit", "saturation", + "sourcedetection", "dark_current", "darkcurrent", "outlier_detection", @@ -85,6 +86,7 @@ "linearitystep", "dark_current", "jump", + "sourcedetection", "sourcedetectionstep", "tweakregstep", "outlierdetectionstep", diff --git a/romancal/pipeline/exposure_pipeline.py b/romancal/pipeline/exposure_pipeline.py index 5fbaf652b..12566b15b 100644 --- a/romancal/pipeline/exposure_pipeline.py +++ b/romancal/pipeline/exposure_pipeline.py @@ -137,6 +137,7 @@ def process(self, input): "refpix", "linearity", "ramp_fit", + "tweakreg", ]: result.meta.cal_step[step_str] = "SKIPPED" @@ -158,6 +159,8 @@ def process(self, input): result = self.photom(result) result = self.source_detection(result) if file_type == "asn": + result.meta.cal_step.tweakreg = "SKIPPED" + self.suffix = "sourcedetection" tweakreg_input.append(result) log.info( f"Number of models to tweakreg: {len(tweakreg_input._models), n_members}" @@ -171,8 +174,12 @@ def process(self, input): result.meta.cal_step.photom = "SKIPPED" result.meta.cal_step.source_detection = "SKIPPED" result.meta.cal_step.tweakreg = "SKIPPED" + self.suffix = "cal" # setup output_file for saving + if result.meta.cal_step.tweakreg == "COMPLETE": + self.suffix = "cal" + self.setup_output(result) self.output_use_model = True @@ -183,10 +190,18 @@ def process(self, input): # observations. This should not occur on-prem if result.meta.exposure.type == "WFI_IMAGE": if file_type == "asdf": + result.meta.cal_step.tweakreg = "SKIPPED" + # mc_result = ModelContainer(result) mc_result = self.tweakreg([result]) - result = mc_result._models.pop() + if hasattr(ModelContainer(result), "_models") and mc_result._models: + result = mc_result._models.pop() + else: + result.meta.cal_step.tweakreg == "SKIPPED" + if file_type == "asn": result = self.tweakreg(tweakreg_input) + for model in result._models: + model.meta.cal_step.tweakreg = "SKIPPED" log.info("Roman exposure calibration pipeline ending...") @@ -194,13 +209,27 @@ def process(self, input): def setup_output(self, input): """Determine the proper file name suffix to use later""" - if input.meta.cal_step.ramp_fit == "COMPLETE": + if input.meta.cal_step.tweakreg == "COMPLETE": self.suffix = "cal" - input.meta.filename = input.meta.filename.replace("uncal", self.suffix) - input["output_file"] = input.meta.filename - self.output_file = input.meta.filename - else: - self.suffix = "ramp" + # elif input.meta.cal_step.tweakreg == "SKIPPED" and input.meta.exposure.type == "WFI_IMAGE": + # self.suffix = "sourcedetection" + elif ( + input.meta.cal_step.tweakreg == "INCOMPLETE" + and input.meta.exposure.type == "WFI_IMAGE" + ): + self.suffix = "sourcedetection" + elif ( + input.meta.cal_step.tweakreg == "SKIPPED" + and input.meta.exposure.type != "WFI_IMAGE" + ): + self.suffix = "cal" + + if not self.steps["tweakreg"]["skip"]: + self.suffix = "cal" + + input.meta.filename = input.meta.filename.replace("uncal", self.suffix) + input["output_file"] = input.meta.filename + self.output_file = input.meta.filename def create_fully_saturated_zeroed_image(self, input_model): """