Skip to content

Commit

Permalink
Added optional dq array to science raw maker utility and test
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulHuwe committed Oct 13, 2023
1 parent 17cf1e5 commit 2ed8498
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/roman_datamodels/maker_utils/_datamodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from ._tagged_nodes import mk_cal_logs


def mk_level1_science_raw(*, shape=(8, 4096, 4096), filepath=None, **kwargs):
def mk_level1_science_raw(*, shape=(8, 4096, 4096), dq=False, filepath=None, **kwargs):
"""
Create a dummy level 1 ScienceRaw instance (or file) with arrays and valid
values for attributes required by the schema.
Expand All @@ -24,6 +24,10 @@ def mk_level1_science_raw(*, shape=(8, 4096, 4096), filepath=None, **kwargs):
(8 integrations, 4088 x 4088 represent the science pixels, with the
additional being the border reference pixels).
dq : bool
(optional, keyword-only) Toggle to add a data quality array for
dropout pixels
filepath : str
(optional, keyword-only) File name and path to write model to.
Expand All @@ -42,6 +46,9 @@ def mk_level1_science_raw(*, shape=(8, 4096, 4096), filepath=None, **kwargs):

wfi_science_raw["data"] = kwargs.get("data", u.Quantity(np.zeros(shape, dtype=np.uint16), u.DN, dtype=np.uint16))

if dq:
wfi_science_raw["resultantdq"] = kwargs.get("resultantdq", np.zeros(shape, dtype=np.uint8))

# add amp 33 ref pix
wfi_science_raw["amp33"] = kwargs.get(
"amp33", u.Quantity(np.zeros((n_groups, 4096, 128), dtype=np.uint16), u.DN, dtype=np.uint16)
Expand Down
5 changes: 2 additions & 3 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,6 @@ def test_make_associations():
member_shapes = (3, 8, 5, 2)
association = utils.mk_associations(shape=member_shapes)

print("XXX association.products = " + str(association.products))

assert association.asn_type == "image"
assert len(association.products) == len(member_shapes)

Expand Down Expand Up @@ -591,7 +589,8 @@ def test_make_wfi_img_photom():

# WFI Level 1 Science Raw tests
def test_make_level1_science_raw():
wfi_science_raw = utils.mk_level1_science_raw(shape=(2, 8, 8))
shape=(2, 8, 8)
wfi_science_raw = utils.mk_level1_science_raw(shape=shape, dq=True)

assert wfi_science_raw.data.dtype == np.uint16
assert wfi_science_raw.data.unit == u.DN
Expand Down

0 comments on commit 2ed8498

Please sign in to comment.