Skip to content

Commit

Permalink
updates from review
Browse files Browse the repository at this point in the history
  • Loading branch information
jemorrison committed Feb 19, 2025
1 parent 41b4dd7 commit 3b7c32d
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
---
$schema: "http://stsci.edu/schemas/asdf/asdf-schema-1.1.0"
id: "http://stsci.edu/schemas/jwst_datamodel/specwcs_miri_lrs.schema"
title: MIRI LRS Spec Schema
title: MIRI LRS Fixed Slit Specwcs Schema
allOf:
- $ref: referencefile.schema
- $ref: keyword_pexptype.schema
- $ref: keyword_exptype.schema
- $ref: keyword_readpatt.schema
- $ref: keyword_filter.schema
- $ref: keyword_band.schema
- $ref: subarray.schema
- type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import numpy as np
from stdatamodels.jwst import datamodels


def test_miri_lrs_specwcs():
"""Test the MIRI LRS specwcs data is loaded correctly."""
xc = np.array([1.0, 2.0, 3.0])
yc = np.array([4.0, 5.0, 6.0])
wave = np.array([12.4, 13.4, 14.5])
x0 = np.array([1.0, 2.0, 3.0])
x1 = np.array([1, 2, 3])
x2 = np.array([1, 2, 3])
x3 = np.array([1, 2, 3])
y0 = np.array([1, 2, 3])
y1 = np.array([1, 2, 3])
y2 = np.array([1, 2, 3])
y3 = np.array([1, 2, 3])

d = np.dtype(
[
("x_center", np.float32),
("y_center", np.float32),
("wavelength", np.float32),
("x0", np.float32),
("y0", np.float32),
("x1", np.float32),
("y1", np.float32),
("x2", np.float32),
("y2", np.float32),
("x3", np.float32),
("y3", np.float32),
]
)
wavetable = np.array(
[
(xc[0], yc[0], wave[0], x0[0], y0[0], x1[0], y1[0], x2[0], y2[0], x3[0], y3[0]),
(xc[1], yc[1], wave[1], x0[1], y0[1], x1[1], y1[1], x2[1], y2[1], x3[1], y3[1]),
(xc[2], yc[2], wave[2], x0[2], y0[2], x1[2], y1[2], x2[2], y2[2], x3[2], y3[2]),
],
dtype=d,
)

model = datamodels.MiriLRSSpecwcsModel(x_ref=430, y_ref=400, wavetable=wavetable)
assert model.meta.instrument.name == "MIRI"
assert model.meta.instrument.detector == "MIRIMAGE"
assert model.meta.reftype == "specwcs"
assert model.meta.x_ref == 430
assert model.meta.y_ref == 400

# for slitless case assert the v2/v3 vertices are None if not in the file
assert model.meta.v2_vert1 is None
assert model.meta.v2_vert2 is None
assert model.meta.v2_vert3 is None
assert model.meta.v2_vert4 is None

assert model.meta.v3_vert1 is None
assert model.meta.v3_vert2 is None
assert model.meta.v3_vert3 is None
assert model.meta.v3_vert4 is None
43 changes: 24 additions & 19 deletions src/stdatamodels/jwst/datamodels/wcs_ref_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"NIRCAMGrismModel",
"NIRISSGrismModel",
"WaveCorrModel",
"MiriLRSSpecwcsModel"
"MiriLRSSpecwcsModel",
]


Expand Down Expand Up @@ -430,27 +430,31 @@ class MiriLRSSpecwcsModel(ReferenceFileModel):
v3vert4 : float
slit vertex 4 in V3 frames
wavetable : numpy 2-D array
For each row in the slit hold wavelength, and
x center, ycenter, x and y box region cooresponding to the wavelength
For each row in the slit hold wavelength, and
x center, ycenter, x and y box region corresponding to the wavelength
"""

schema_url = "http://stsci.edu/schemas/jwst_datamodel/specwcs_miri_lrs.schema"
reftype = "specwcs"

def __init__(self, init=None,
wavetable=None,
x_ref=None,
y_ref=None,
x_ref_slitless=None,
y_ref_slitless=None,
v2_vert1=None,
v2_vert2=None,
v2_vert3=None,
v2_vert4=None,
v3_vert1=None,
v3_vert2=None,
v3_vert3=None,
v3_vert4=None,
**kwargs):
def __init__(
self,
init=None,
wavetable=None,
x_ref=None,
y_ref=None,
x_ref_slitless=None,
y_ref_slitless=None,
v2_vert1=None,
v2_vert2=None,
v2_vert3=None,
v2_vert4=None,
v3_vert1=None,
v3_vert2=None,
v3_vert3=None,
v3_vert4=None,
**kwargs,
):
super().__init__(init=init, **kwargs)

if init is None:
Expand Down Expand Up @@ -486,6 +490,7 @@ def populate_meta(self):
self.meta.instrument.name = "MIRI"
self.meta.instrument.detector = "MIRIMAGE"
self.meta.reftype = self.reftype
self.meta.instrument.filter = "P750L"

def validate(self):
super(MiriLRSSpecwcsModel, self).validate()
Expand All @@ -497,7 +502,7 @@ def validate(self):
if self._strict_validation:
raise
else:
warnings.warn(traceback.format_exc(), ValidationWarning)
warnings.warn(traceback.format_exc(), ValidationWarning, stacklevel=2)


class RegionsModel(ReferenceFileModel):
Expand Down

0 comments on commit 3b7c32d

Please sign in to comment.