Skip to content

Commit

Permalink
skip tweakreg when a fully saturated input is found
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram committed Nov 20, 2024
1 parent b8d0a57 commit fa7d4c5
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions romancal/pipeline/exposure_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ def process(self, input):
else:
lib = ModelLibrary([input])

# Flag to track if any of the input models are fully saturated
any_saturated = False

with lib:
for model_index, model in enumerate(lib):
self.dq_init.suffix = "dq_init"
Expand All @@ -94,6 +97,12 @@ def process(self, input):
if is_fully_saturated(result):
log.info("All pixels are saturated. Returning a zeroed-out image.")
result = self.create_fully_saturated_zeroed_image(result)

# Track that we've seen a fully saturated input
any_saturated = True
log.warning(
"tweakreg will not be run due to a fully saturated input"
)
else:
result = self.refpix.run(result)
result = self.linearity.run(result)
Expand All @@ -112,15 +121,20 @@ def process(self, input):
log.info("Tweakreg step is being SKIPPED")
result.meta.cal_step.flat_field = "SKIPPED"
result.meta.cal_step.photom = "SKIPPED"
# FIXME source_catalog ain't in the schema
# result.meta.cal_step.source_catalog = "SKIPPED"
result.meta.cal_step.source_detection = "SKIPPED"

if any_saturated:
# the input association contains a fully saturated model
# where source_catalog can't be run which means we
# also can't run tweakreg.
result.meta.cal_step.tweakreg = "SKIPPED"
lib.shelve(result, model_index)

# Now that all the exposures are collated, run tweakreg
# Note: this does not cover the case where the asn mixes imaging and spectral
# observations. This should not occur on-prem
self.tweakreg.run(lib)
if not any_saturated:
self.tweakreg.run(lib)

log.info("Roman exposure calibration pipeline ending...")

Expand All @@ -144,14 +158,14 @@ def create_fully_saturated_zeroed_image(self, input_model):

# Set all subsequent steps to skipped
for step_str in [
"refpix" "linearity",
"refpix",
"linearity",
"dark",
"ramp_fit",
"assign_wcs",
"flat_field",
"photom",
# FIXME source_catalog ain't in the schema
# "source_catalog",
"source_detection",
]:
fully_saturated_model.meta.cal_step[step_str] = "SKIPPED"

Expand Down

0 comments on commit fa7d4c5

Please sign in to comment.