Skip to content

Commit

Permalink
RCAL-707 Update elp to replace list as input to tweakreg (#985)
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 10, 2023
1 parent e62468b commit 5cc07ee
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 3 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 elp pipeline code to capture a list from tweakreg [#985]

- Update pipeline code to correct cal_step and suffixes [#971]

- Update pipeline code to run through tweakreg with single files and associations [#960]
Expand Down
2 changes: 1 addition & 1 deletion romancal/lib/suffix.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

# Suffixes that are discovered but should not be considered.
# Used by `find_suffixes` to remove undesired values it has found.
SUFFIXES_TO_DISCARD = ["pipeline", "step"]
SUFFIXES_TO_DISCARD = ["highlevelpipeline", "pipeline", "step"]


# Calculated suffixes.
Expand Down
3 changes: 1 addition & 2 deletions romancal/pipeline/exposure_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ def process(self, input):
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])
mc_result = ModelContainer(result)
if hasattr(ModelContainer(result), "_models") and mc_result._models:
result = mc_result._models.pop()
else:
Expand Down
80 changes: 80 additions & 0 deletions romancal/pipeline/highlevel_pipeline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/usr/bin/env python
import logging
from os.path import basename

import romancal.datamodels.filetype as filetype
from romancal.datamodels import ModelContainer
from romancal.outlier_detection import OutlierDetectionStep
from romancal.resample import ResampleStep

# step imports
from romancal.skymatch import SkyMatchStep

from ..stpipe import RomanPipeline

__all__ = ["HighLevelPipeline"]

# Define logging
log = logging.getLogger()
log.setLevel(logging.DEBUG)


class HighLevelPipeline(RomanPipeline):
"""
HighLevelPipeline: Apply all calibration steps to the roman data
to produce level 3 products. Included steps are:
skymatch, Outlierdetectionn and resample.
"""

class_alias = "roman_hlp"

spec = """
save_results = boolean(default=False)
"""

# Define aliases to steps
step_defs = {
"skymatch": SkyMatchStep,
"outlierdet": OutlierDetectionStep,
"resample": ResampleStep,
}

# start the actual processing
def process(self, input):
"""Process the Roman WFI data from Level 2 to Level 3"""

log.info("Starting Roman high level calibration pipeline ...")
if isinstance(input, str):
input_filename = basename(input)
else:
input_filename = None

# open the input file
file_type = filetype.check(input)
asn = None
if file_type == "asdf":
log.info("The level three pipeline input needs to be an association")
return

if file_type == "asn":
asn = ModelContainer.read_asn(input)
self.skymatch.suffix = "skymatch"
result = self.skymatch(input)
self.skymatch.suffix = "outlierdetection"
result = self.outlierdetection(asn)
self.skymatch.suffix = "i2d"
result = self.resample(result)
if input_filename:
result.meta.filename = input_filename

return result

def setup_output(self, input):
"""Determine the proper file name suffix to use later"""
if input.meta.cal_step.ramp_fit == "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 = "cal"

0 comments on commit 5cc07ee

Please sign in to comment.