Skip to content

Commit

Permalink
Copy L2/L3 model metadata to source catalog metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
larrybradley committed Apr 30, 2024
1 parent d9ed500 commit f07d627
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 0 additions & 2 deletions romancal/regtest/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def test_catalog_l3(rtdata, ignore_asdf_paths):
catalogfp = asdf.open(outputfn)
catalog = catalogfp["roman"]["source_catalog"]
step = SourceCatalogStep()
fields = catalog.dtype.names
assert check_catalog_fields(catalog, step.log, "L3")

# no compare_asdf on the catalogs
Expand Down Expand Up @@ -98,7 +97,6 @@ def test_catalog_l2(rtdata, ignore_asdf_paths):
catalogfp = asdf.open(outputfn)
catalog = catalogfp["roman"]["source_catalog"]
step = SourceCatalogStep()
fields = catalog.dtype.names

assert check_catalog_fields(catalog, step.log, "L2")
# no compare_asdf on the catalogs
18 changes: 15 additions & 3 deletions romancal/source_catalog/source_catalog_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,21 @@ def process(self, input_model):
"The input model must be an ImageModel or MosaicModel."
)

source_catalog_model = maker_utils.mk_datamodel(
datamodels.MosaicSourceCatalogModel
)
if isinstance(model, ImageModel):
cat_model = datamodels.SourceCatalogModel
else:
cat_model = datamodels.MosaicSourceCatalogModel
source_catalog_model = maker_utils.mk_datamodel(cat_model)

for key in source_catalog_model.meta.keys():
try:
if key == "optical_element":
value = model.meta.instrument[key]
else:
value = model.meta[key]
source_catalog_model.meta[key] = value
except KeyError:
pass

Check warning on line 68 in romancal/source_catalog/source_catalog_step.py

View check run for this annotation

Codecov / codecov/patch

romancal/source_catalog/source_catalog_step.py#L67-L68

Added lines #L67 - L68 were not covered by tests

aperture_ee = (self.aperture_ee1, self.aperture_ee2, self.aperture_ee3)
refdata = ReferenceData(model, aperture_ee)
Expand Down

0 comments on commit f07d627

Please sign in to comment.