Skip to content

Commit

Permalink
rcal-700 Update exposure pipeline to correct cal_step and suffixes (#971
Browse files Browse the repository at this point in the history
)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
ddavis-stsci and pre-commit-ci[bot] authored Nov 3, 2023
1 parent 630aa98 commit 6b6c3ec
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 2 additions & 0 deletions romancal/lib/suffix.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"jump",
"rampfit",
"saturation",
"sourcedetection",
"dark_current",
"darkcurrent",
"outlier_detection",
Expand Down Expand Up @@ -85,6 +86,7 @@
"linearitystep",
"dark_current",
"jump",
"sourcedetection",
"sourcedetectionstep",
"tweakregstep",
"outlierdetectionstep",
Expand Down
43 changes: 36 additions & 7 deletions romancal/pipeline/exposure_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def process(self, input):
"refpix",
"linearity",
"ramp_fit",
"tweakreg",
]:
result.meta.cal_step[step_str] = "SKIPPED"

Expand All @@ -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}"
Expand All @@ -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
Expand All @@ -183,24 +190,46 @@ 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...")

return results

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):
"""
Expand Down

0 comments on commit 6b6c3ec

Please sign in to comment.