Skip to content

Commit

Permalink
Merge branch 'main' into JP-3656
Browse files Browse the repository at this point in the history
  • Loading branch information
emolter authored Sep 9, 2024
2 parents 631059b + a49474c commit 84279cf
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

- remove uses of now unused ``ignore_version_mismatch`` [#313]

- Added ``MEDIUMDEEP2`` and ``MEDIUMDEEP8`` to allowed readout patterns
in JWST core schema, ``READPATT``, and ``PREADPATT``. [#315]

2.0.0 (2024-06-24)
===================

Expand Down
2 changes: 1 addition & 1 deletion src/stdatamodels/jwst/datamodels/schemas/core.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ properties:
enum: [ACQ1, ACQ2, BRIGHT1, BRIGHT2, DEEP2, DEEP8, FAST,
FASTGRPAVG, FASTGRPAVG8, FASTGRPAVG16, FASTGRPAVG32, FASTGRPAVG64,
FASTR1, FASTR100, FGS, FGS60, FGS8370, FGS840, FGSRAPID,
FINEGUIDE, ID, MEDIUM2, MEDIUM8, NIS, NISRAPID,
FINEGUIDE, ID, MEDIUM2, MEDIUM8, MEDIUMDEEP2, MEDIUMDEEP8, NIS, NISRAPID,
NRS, NRSIRS2, NRSN16R4, NRSN32R8, NRSN8R2,
NRSRAPID, NRSIRS2RAPID, NRSRAPIDD1, NRSRAPIDD2, NRSRAPIDD6,
NRSSLOW, RAPID, SHALLOW2, SHALLOW4, SLOW, SLOWR1, TRACK, ANY, N/A]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ properties:
pattern: "\
^((ACQ1|ACQ2|BRIGHT1|BRIGHT2|DEEP2|DEEP8|FAST|\
FASTGRPAVG|FASTGRPAVG8|FASTGRPAVG16|FASTGRPAVG32|FASTGRPAVG64|\
FASTR1|FASTR100|FGS|FGS60|FGS8370|FGS840|FGSRAPID|\
FINEGUIDE|ID|MEDIUM2|MEDIUM8|NIS|NISRAPID|\
FASTR1|FASTR100|FGS|FGS60|FGS8370|FGS840|FGSRAPID|\
FINEGUIDE|ID|MEDIUM2|MEDIUM8|MEDIUMDEEP2|MEDIUMDEEP8|NIS|NISRAPID|\
NRS|NRSIRS2|NRSN16R4|NRSN32R8|NRSN8R2|NRSRAPID|\
NRSIRS2RAPID|NRSRAPIDD1|NRSRAPIDD2|NRSRAPIDD6|NRSSLOW|RAPID|\
SHALLOW2|SHALLOW4|SLOW|SLOWR1|TRACK|ANY|N/A)\\s*\\|\\s*)+$"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ properties:
enum: [ACQ1, ACQ2, BRIGHT1, BRIGHT2, DEEP2, DEEP8, FAST,
FASTGRPAVG, FASTGRPAVG8, FASTGRPAVG16, FASTGRPAVG32, FASTGRPAVG64,
FASTR1, FASTR100, FGS, FGS60, FGS8370, FGS840, FGSRAPID,
FINEGUIDE, ID, MEDIUM2, MEDIUM8, NIS, NISRAPID,
FINEGUIDE, ID, MEDIUM2, MEDIUM8, MEDIUMDEEP2, MEDIUMDEEP8, NIS, NISRAPID,
NRS, NRSIRS2, NRSN16R4, NRSN32R8, NRSN8R2,
NRSRAPID, NRSIRS2RAPID, NRSRAPIDD1, NRSRAPIDD2, NRSRAPIDD6,
NRSSLOW, RAPID, SHALLOW2, SHALLOW4, SLOW, SLOWR1, TRACK, ANY, N/A]
Expand Down
24 changes: 23 additions & 1 deletion src/stdatamodels/jwst/datamodels/tests/test_fits.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest

from stdatamodels.jwst import datamodels
from stdatamodels.jwst.datamodels import ImageModel, JwstDataModel, RampModel, SpecModel
from stdatamodels.jwst.datamodels import ImageModel, JwstDataModel, RampModel, SpecModel, FlatModel


@pytest.fixture
Expand Down Expand Up @@ -106,3 +106,25 @@ def test_units_roundtrip(tmp_path):

m = datamodels.open(fn)
assert m.spec_table.columns['WAVELENGTH'].unit == 'nm'


def test_flatmodel_dqdef_roundtrip(tmp_path):
'''Covers an old bug where this roundtrip would fail due to
a mix-up between signed and unsigned integer data types, leading to flag values
like 2147483649 instead of 0'''
flatdata = [(0,1,2),(3,4,5),(6,7,8)]
flatflags = [(0, 1, "DO_NOT_USE", "Bad pixel. Do not use."),
(1, 2, "NON_SCIENCE", "Pixel not on science portion of detector"),
(2, 4, "UNRELIABLE_FLAT", "Flat variance large")]
flatmodel = FlatModel( data=flatdata, dq_def=flatflags )

fn = tmp_path / "test_flat.fits"
flatmodel.save(fn)

with datamodels.open(fn) as flatmodel2:
assert np.allclose(flatmodel2.data, flatdata)
for i, flag in enumerate(flatmodel2.dq_def):
for j in range(2):
# tuples do not directly assert True because datamodels.open() returns np.int32
# which is not technically of type int. So must check their equality directly
assert flag[j] == flatflags[i][j]

0 comments on commit 84279cf

Please sign in to comment.