Skip to content

Commit

Permalink
use outlier detection from stcal
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram committed Sep 30, 2024
1 parent 3145579 commit f0edcaa
Show file tree
Hide file tree
Showing 6 changed files with 471 additions and 510 deletions.
44 changes: 44 additions & 0 deletions romancal/outlier_detection/_fileio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import logging

from astropy.units import Quantity

log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)


def save_median(example_model, median_data, median_wcs, make_output_path):
_save_intermediate_output(
_make_median_model(example_model, median_data, median_wcs),
"median",
make_output_path,
)


def save_drizzled(drizzled_model, make_output_path):
_save_intermediate_output(drizzled_model, "outlier_i2d", make_output_path)


def _make_median_model(example_model, data, wcs):
model = example_model.copy()
model.data = Quantity(data, unit=model.data.unit)
model.meta.wcs = wcs
return model


def _save_intermediate_output(model, suffix, make_output_path):
"""
Ensure all intermediate outputs from OutlierDetectionStep have consistent file naming conventions
Notes
-----
self.make_output_path() is updated globally for the step in the main pipeline
to include the asn_id in the output path, so no need to handle it here.
"""

# outlier_?2d is not a known suffix, and make_output_path cannot handle an
# underscore in an unknown suffix, so do a manual string replacement
input_path = model.meta.filename.replace("_outlier_", "_")

output_path = make_output_path(input_path, suffix=suffix)
model.save(output_path)
log.info(f"Saved {suffix} model in {output_path}")
Loading

0 comments on commit f0edcaa

Please sign in to comment.