-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug preventing NirspecQuadFlatModel instantiation from NirspecFla…
…tModel (#401)
- Loading branch information
Showing
3 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix bug preventing NirspecQuadFlatModel instantiation from NirspecFlatModel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/stdatamodels/jwst/datamodels/tests/test_nirspec_flat.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""Tests for nirspec flat field models.""" | ||
|
||
import numpy as np | ||
import pytest | ||
from stdatamodels.jwst.datamodels import NirspecFlatModel, NirspecQuadFlatModel | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def flatmodel(): | ||
rng = np.random.default_rng() | ||
data = rng.random((100, 100)) | ||
dq = rng.integers(0, 2, (100, 100)) | ||
model = NirspecFlatModel(data, dq=dq) | ||
model.meta.instrument.name = "NIRSPEC" | ||
model.meta.reftype = "FLAT" | ||
model.meta.author = "STSCI" | ||
model.meta.description = "Test flat field model" | ||
model.meta.pedigree = "GROUND" | ||
model.meta.useafter = "2025-02-12T00:00:00" | ||
return model | ||
|
||
|
||
def test_initialize_quad_from_flat(flatmodel): | ||
""" | ||
Cover a bug where attempting to initialize a quad flat model from a flat model would fail. | ||
""" | ||
quadmodel = NirspecQuadFlatModel(flatmodel) | ||
assert isinstance(quadmodel, NirspecQuadFlatModel) | ||
assert np.allclose(quadmodel.quadrants[0].data, flatmodel.data) | ||
assert np.allclose(quadmodel.quadrants[0].dq, flatmodel.dq) |