Skip to content

Commit

Permalink
rcal-606 Have source detection and tweakreg skip spectral data (#798)
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 Jul 28, 2023
1 parent 200b9d4 commit e938649
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
8 changes: 8 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
0.11.1 (unreleased)
===================

source_detection
----------------
- Skip the step if the data is not imaging mode. [#798]


tweakreg
--------
- Skip the step if the data is not imaging mode [#798]

- Add regression test for TweakReg. [#707]

- WCS fit results are now available in meta.wcs_fit_results. [#714]
Expand Down
7 changes: 6 additions & 1 deletion romancal/pipeline/exposure_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ def process(self, input):
result.meta.cal_step.flat_field = "SKIPPED"

result = self.photom(result)
result = self.source_detection(result)

if result.meta.exposure.type == "WFI_IMAGE":
result = self.source_detection(result)
else:
log.info("Source Detection step is being SKIPPED")
result.meta.cal_step.source_detection = "SKIPPED"

# setup output_file for saving
self.setup_output(result)
Expand Down
10 changes: 8 additions & 2 deletions romancal/source_detection/source_detection_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
ModeEstimatorBackground,
)
from photutils.detection import DAOStarFinder
from roman_datamodels import datamodels as rdd
from roman_datamodels import datamodels as rdm
from roman_datamodels import maker_utils

from romancal.lib import dqflags
Expand Down Expand Up @@ -68,7 +68,13 @@ class SourceDetectionStep(RomanStep):
"""

def process(self, input):
with rdd.open(input, lazy_load=False) as input_model:
with rdm.open(input, lazy_load=False) as input_model:
if input_model.meta.exposure.type != "WFI_IMAGE":
# Check to see if attempt to find sources in non-Image data
log.info("Skipping source detection for spectral exposure.")
input_model.meta.cal_step.source_detection = "SKIPPED"
return input_model

# remove units from data in this step.
# DAOStarFinder requires unitless input
if hasattr(input_model.data, "unit"):
Expand Down
7 changes: 7 additions & 0 deletions romancal/tweakreg/tweakreg_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ def process(self, input):

# Build the catalogs for input images
for i, image_model in enumerate(images):
if image_model.meta.exposure.type != "WFI_IMAGE":
# Check to see if attempt to run tweakreg on non-Image data
self.log.info("Skipping TweakReg for spectral exposure.")
# Uncomment below once rad & input data have the cal_step tweakreg
# image_model.meta.cal_step.tweakreg = "SKIPPED"
return image_model

if hasattr(image_model.meta, "source_detection"):
is_tweakreg_catalog_present = hasattr(
image_model.meta.source_detection, "tweakreg_catalog"
Expand Down

0 comments on commit e938649

Please sign in to comment.