From 33a949138cb432b961ff720ce55e74a19d8e32a9 Mon Sep 17 00:00:00 2001 From: Paul Huwe <42071634+PaulHuwe@users.noreply.github.com> Date: Tue, 6 Aug 2024 13:50:19 -0400 Subject: [PATCH] RCAL-884: Sky Background (#370) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- CHANGES.rst | 3 +++ pyproject.toml | 2 +- .../maker_utils/_common_meta.py | 18 ++++++++++++++++++ tests/test_models.py | 11 ++++++++++- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index b4cb6d09..98382282 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -9,6 +9,9 @@ - Fix to preserve extra TVAC specific data when processed through DQ Init. [#369] +- Added maker utilities and a test for sky background metadata. [#370] + + 0.20.0 (2024-05-15) =================== diff --git a/pyproject.toml b/pyproject.toml index dbe0d23e..1cb8f94c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ dependencies = [ "gwcs >=0.19.0", "numpy >=1.22", "astropy >=5.3.0", - "rad >= 0.20.0", + "rad >= 0.21.0", # "rad @ git+https://github.com/spacetelescope/rad.git", "asdf-standard >=1.1.0", ] diff --git a/src/roman_datamodels/maker_utils/_common_meta.py b/src/roman_datamodels/maker_utils/_common_meta.py index 3b132b04..36f6ee29 100644 --- a/src/roman_datamodels/maker_utils/_common_meta.py +++ b/src/roman_datamodels/maker_utils/_common_meta.py @@ -141,6 +141,23 @@ def mk_outlier_detection(**kwargs): return od +def mk_sky_background(**kwargs): + """ + Create a dummy Sky Background instance with valid values for attributes + required by the schema. Utilized by the model maker utilities below. + + Returns + ------- + roman_datamodels.stnode.SkyBackground + """ + sb = stnode.SkyBackground() + sb["level"] = kwargs.get("level", NONUM * (u.MJy / u.sr)) + sb["method"] = kwargs.get("method", "None") + sb["subtracted"] = kwargs.get("subtracted", False) + + return sb + + def mk_ephemeris(**kwargs): """ Create a dummy Ephemeris instance with valid values for attributes @@ -474,6 +491,7 @@ def mk_photometry_meta(**kwargs): meta = mk_common_meta(**kwargs) meta["photometry"] = mk_photometry(**kwargs.get("photometry", {})) meta["outlier_detection"] = mk_outlier_detection(**kwargs.get("outlier_detection", {})) + meta["background"] = mk_sky_background(**kwargs.get("background", {})) return meta diff --git a/tests/test_models.py b/tests/test_models.py index 3df8a345..42b73cf3 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -20,7 +20,13 @@ EXPECTED_COMMON_REFERENCE = {"$ref": "ref_common-1.0.0"} # Nodes for metadata schema that do not contain any archive_catalog keywords -NODES_LACKING_ARCHIVE_CATALOG = [stnode.OutlierDetection, stnode.MosaicAssociations, stnode.IndividualImageMeta, stnode.Resample] +NODES_LACKING_ARCHIVE_CATALOG = [ + stnode.OutlierDetection, + stnode.MosaicAssociations, + stnode.IndividualImageMeta, + stnode.Resample, + stnode.SkyBackground, +] def datamodel_names(): @@ -732,6 +738,9 @@ def test_append_individual_image_meta_level3_mosaic(): assert wfi_mosaic_model.meta.individual_image_meta.program["pi_name"][1] == "Grace" assert wfi_mosaic_model.meta.individual_image_meta.program["pi_name"][2] == "Roman" + # Test that the mosaic validates with IIM filled + assert wfi_mosaic_model.validate() is None + # FPS tests def test_make_fps():