Skip to content

Commit

Permalink
Merge branch 'main' into release/0.16.x
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyburnett committed Aug 29, 2024
2 parents 6c808ab + 71407e9 commit c1d143a
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 20 deletions.
18 changes: 18 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
0.16.3 (2024-08-29)
===================

mosaic_pipeline
---------------

- Only load patch table when needed. [#1367]

source_catalog
--------------

- Populate segmentation image metadata. [#1391]

resample
--------

- Use association product name for output meta.filename by default [#1391]

0.16.2 (2024-08-23)
===================

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ an [issue](https://github.com/spacetelescope/romancal/issues).
| 0.16.0 | 24Q4_B15 | 063 | Aug 2024 | Release for Build 24Q3_B15 (Build 15) |
| 0.16.1 | 24Q4_B15 | 063 | Aug 2024 | Release for Build 24Q3_B15 (Build 15) |
| 0.16.2 | 24Q4_B15 | 063 | Aug 2024 | Release for Build 24Q3_B15 (Build 15) |
| 0.16.3 | 24Q4_B15 | 063 | Aug 2024 | Release for Build 24Q3_B15 (Build 15) |


Note: CRDS_CONTEXT values flagged with an asterisk in the above table are estimates
Expand Down
2 changes: 1 addition & 1 deletion romancal/outlier_detection/outlier_detection_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def process(self, input_models):
intermediate_files_suffixes = (
"*blot.asdf",
"*median.asdf",
f'*{pars.get("resample_suffix")}*.asdf',
f'*outlier_{pars.get("resample_suffix")}.asdf',
)
for current_path in intermediate_files_paths:
for suffix in intermediate_files_suffixes:
Expand Down
5 changes: 2 additions & 3 deletions romancal/patch_match/patch_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def find_patch_matches(image_corners, image_shape=None):
necessary information about the patches.
"""

if PATCH_TABLE is None:
load_patch_table()
if PATCH_TABLE is None:
raise RuntimeError("No patch table has been loaded")
if isinstance(image_corners, wcs.WCS):
Expand Down Expand Up @@ -250,6 +252,3 @@ def veccoords_to_tangent_plane(vertices, tangent_point_vec):
x_coords = np.dot(x_axis, avertices) * RAD_TO_ARCSEC
y_coords = np.dot(y_axis, avertices) * RAD_TO_ARCSEC
return x_coords, y_coords


load_patch_table()
11 changes: 7 additions & 4 deletions romancal/pipeline/mosaic_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ def process(self, input):

# if this is a valid skycell name load the database and get the skycell record
if re.match(r"r\d{3}\w{2}\d{2}x\d{2}y\d{2}", skycell_name):
if patch_match.PATCH_TABLE is None:
patch_match.load_patch_table()
if patch_match.PATCH_TABLE is None:
raise RuntimeError("No patch table has been loaded")
skycell_record = patch_match.PATCH_TABLE[
np.where(patch_match.PATCH_TABLE["name"][:] == skycell_name)[0][0]
]
Expand Down Expand Up @@ -127,10 +131,9 @@ def process(self, input):
)
wcs_file = asdf.open(self.resample.output_wcs)
self.suffix = "i2d"
result = self.resample(result)
self.output_file = input.asn["products"][0]["name"]
# force the SourceCatalogStep to save the results
self.sourcecatalog.save_results = True
result = self.resample(result)
self.sourcecatalog.output_file = self.output_file
result_catalog = self.sourcecatalog(result)
else:
log.info("resampling a mosaic file is not yet supported")
Expand All @@ -140,7 +143,7 @@ def process(self, input):
self.resample.suffix = "i2d"
self.output_file = input.asn["products"][0]["name"]
result = self.resample(result)
self.sourcecatalog.save_results = True
self.sourcecatalog.output_file = self.output_file
result_catalog = self.sourcecatalog(result) # noqa: F841
self.suffix = "i2d"
if input_filename:
Expand Down
13 changes: 8 additions & 5 deletions romancal/resample/resample_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,14 @@ def process(self, input):
output = input_models.asn["products"][0]["name"]
elif isinstance(input, ModelLibrary):
input_models = input
# set output filename using the common prefix of all datamodels
output = f"{os.path.commonprefix([x['expname'] for x in input_models.asn['products'][0]['members']])}.asdf"
if len(output) == 0:
# set default filename if no common prefix can be determined
output = "resample_output.asdf"
if "name" in input_models.asn["products"][0]:
output = input_models.asn["products"][0]["name"]
else:
# set output filename using the common prefix of all datamodels
output = f"{os.path.commonprefix([x['expname'] for x in input_models.asn['products'][0]['members']])}.asdf"
if len(output) == 0:
# set default filename if no common prefix can be determined
output = "resample_output.asdf"
else:
raise TypeError(
"Input must be an ASN filename, a ModelLibrary, "
Expand Down
17 changes: 14 additions & 3 deletions romancal/source_catalog/source_catalog_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,21 @@ def process(self, input_model):

def save_base_results(self, segment_img, source_catalog_model):
# save the segmentation map and
output_filename = source_catalog_model.meta.filename
segmentation_model = maker_utils.mk_datamodel(
datamodels.MosaicSegmentationMapModel
output_filename = (
self.output_file
if self.output_file is not None
else source_catalog_model.meta.filename
)

if isinstance(source_catalog_model, datamodels.SourceCatalogModel):
seg_model = datamodels.SegmentationMapModel
else:
seg_model = datamodels.MosaicSegmentationMapModel

segmentation_model = maker_utils.mk_datamodel(seg_model)
for key in segmentation_model.meta.keys():
segmentation_model.meta[key] = source_catalog_model.meta[key]

if segment_img is not None:
segmentation_model.data = segment_img.data.astype(np.uint32)
self.save_model(
Expand Down
9 changes: 5 additions & 4 deletions romancal/source_catalog/tests/test_source_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
MosaicModel,
MosaicSegmentationMapModel,
MosaicSourceCatalogModel,
SegmentationMapModel,
SourceCatalogModel,
)
from roman_datamodels.maker_utils import mk_level2_image, mk_level3_mosaic
Expand Down Expand Up @@ -461,7 +462,7 @@ def test_do_psf_photometry_column_names(tmp_path, image_model, fit_psf):
ImageModel,
{
"cat": SourceCatalogModel,
"segm": MosaicSegmentationMapModel,
"segm": SegmentationMapModel,
"sourcecatalog": ImageModel,
},
),
Expand All @@ -474,7 +475,7 @@ def test_do_psf_photometry_column_names(tmp_path, image_model, fit_psf):
SourceCatalogModel,
{
"cat": SourceCatalogModel,
"segm": MosaicSegmentationMapModel,
"segm": SegmentationMapModel,
},
),
(
Expand All @@ -486,7 +487,7 @@ def test_do_psf_photometry_column_names(tmp_path, image_model, fit_psf):
ImageModel,
{
"cat": SourceCatalogModel,
"segm": MosaicSegmentationMapModel,
"segm": SegmentationMapModel,
},
),
(
Expand All @@ -498,7 +499,7 @@ def test_do_psf_photometry_column_names(tmp_path, image_model, fit_psf):
SourceCatalogModel,
{
"cat": SourceCatalogModel,
"segm": MosaicSegmentationMapModel,
"segm": SegmentationMapModel,
},
),
),
Expand Down

0 comments on commit c1d143a

Please sign in to comment.