Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rcal-700 Update exposure pipeline to correct cal_step and suffixes #971

Merged
merged 4 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I expected COMPLETE here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When tweakreg is run with the option "--steps.tweakreg.skip=True" it is not honoring that and setting the step to skipped. So for the test RCAL-665 to pass this needs to be manually set to "SKIPPED".

This should not remain in place. My plan is to write a function that will check the skip flag that is passed to the step and set it appropriately and use this for all the pipeline steps. I think we should have a uniform method. I checked JWST and they seem to handle this flag in a non-uniform manner and I don't want to reproduce that. I'd like to fix this after B12.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, thanks.


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