Skip to content

Commit

Permalink
RCAL-884: Sky Background (#370)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
PaulHuwe and pre-commit-ci[bot] authored Aug 6, 2024
1 parent de954da commit 33a9491
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
===================

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand Down
18 changes: 18 additions & 0 deletions src/roman_datamodels/maker_utils/_common_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
11 changes: 10 additions & 1 deletion tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 33a9491

Please sign in to comment.