Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RCAL-950: CRDS Keywords & Misc #423

Merged
merged 7 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"})
Copy link
Collaborator

@mairanteodoro mairanteodoro Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity, is there a way to fetch version and context from CRDS so that we don't have to hardcode it here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just found out about stpipe.crds_client's get_svn_version() and get_context_used(). Is there a reason for not using them?


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):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should set a global var with the default shape to prevent repetition?

"""
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