Skip to content

Commit

Permalink
RCAL-950: CRDS Keywords & Misc (#423)
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 Nov 13, 2024
1 parent 11c731a commit 6689b55
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions changes/423.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Corrected CRDS keywords.
Updated for Build 17 release of the RAD software package.
4 changes: 2 additions & 2 deletions src/roman_datamodels/maker_utils/_common_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def mk_ref_file(**kwargs):
ref_file["inverse_linearity"] = kwargs.get("inverse_linearity", "N/A")
ref_file["photom"] = kwargs.get("photom", "N/A")
ref_file["area"] = kwargs.get("area", "N/A")
ref_file["crds"] = kwargs.get("crds", {"sw_version": "12.3.1", "context_used": "roman_0815.pmap"})
ref_file["crds"] = kwargs.get("crds", {"version": "12.3.1", "context": "roman_0815.pmap"})

return ref_file

Expand Down Expand Up @@ -675,7 +675,7 @@ def mk_ref_epsf_meta(**kwargs):
"""
meta = mk_ref_common("EPSF", **kwargs)
meta["oversample"] = kwargs.get("oversample", NONUM)
meta["effective_temperature"] = kwargs.get("effective_temperature", np.arange(1, 10).tolist())
meta["spectral_type"] = kwargs.get("spectral_type", ["None"])
meta["defocus"] = kwargs.get("defocus", np.arange(1, 10).tolist())
meta["pixel_x"] = kwargs.get("pixel_x", np.arange(1, 10, dtype=np.float32).tolist())
meta["pixel_y"] = kwargs.get("pixel_y", np.arange(1, 10, dtype=np.float32).tolist())
Expand Down
10 changes: 5 additions & 5 deletions src/roman_datamodels/maker_utils/_ref_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def mk_distortion(*, filepath=None, **kwargs):
return save_node(distortionref, filepath=filepath)


def mk_epsf(*, shape=(3, 9, 361, 361), filepath=None, **kwargs):
def mk_epsf(*, shape=(3, 6, 9, 361, 361), filepath=None, **kwargs):
"""
Create a dummy ePSF instance (or file) with arrays and valid values
for attributes required by the schema.
Expand All @@ -252,15 +252,15 @@ def mk_epsf(*, shape=(3, 9, 361, 361), filepath=None, **kwargs):
-------
roman_datamodels.stnode.EpsfRef
"""
if len(shape) != 4:
shape = (3, 9, 361, 361)
warnings.warn("Input shape must be 4D. Defaulting to (3, 9, 361, 361)")
if len(shape) != 5:
shape = (3, 6, 9, 361, 361)
warnings.warn("Input shape must be 5D. Defaulting to (3, 6, 9, 361, 361)")

epsfref = stnode.EpsfRef()
epsfref["meta"] = mk_ref_epsf_meta(**kwargs.get("meta", {}))

epsfref["psf"] = kwargs.get("psf", np.zeros(shape, dtype=np.float32))
epsfref["extended_psf"] = kwargs.get("extended_psf", np.zeros(shape[2:], dtype=np.float32))
epsfref["extended_psf"] = kwargs.get("extended_psf", np.zeros(shape[-2:], dtype=np.float32))

return save_node(epsfref, filepath=filepath)

Expand Down
6 changes: 3 additions & 3 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,12 @@ def test_make_distortion():

# ePSF tests
def test_make_epsf():
epsf = utils.mk_epsf(shape=(2, 4, 8, 8))
epsf = utils.mk_epsf(shape=(2, 3, 4, 8, 8))
assert epsf.meta.reftype == "EPSF"
assert isinstance(epsf.meta["pixel_x"], list)
assert isinstance(epsf.meta["pixel_x"][0], float)
assert epsf["psf"].shape == (2, 4, 8, 8)
assert isinstance(epsf["psf"][0, 0, 0, 0], (float, np.float32))
assert epsf["psf"].shape == (2, 3, 4, 8, 8)
assert isinstance(epsf["psf"][0, 0, 0, 0, 0], (float, np.float32))

# Test validation
epsf_model = datamodels.EpsfRefModel(epsf)
Expand Down

0 comments on commit 6689b55

Please sign in to comment.