-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
471 additions
and
510 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}") |
Oops, something went wrong.