From 2ed849801a18c6c5e0b236d5538326bfef056de0 Mon Sep 17 00:00:00 2001 From: PaulHuwe Date: Fri, 13 Oct 2023 17:40:31 -0400 Subject: [PATCH] Added optional dq array to science raw maker utility and test --- src/roman_datamodels/maker_utils/_datamodels.py | 9 ++++++++- tests/test_models.py | 5 ++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/roman_datamodels/maker_utils/_datamodels.py b/src/roman_datamodels/maker_utils/_datamodels.py index bdd94bec..681c04cd 100644 --- a/src/roman_datamodels/maker_utils/_datamodels.py +++ b/src/roman_datamodels/maker_utils/_datamodels.py @@ -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. @@ -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. @@ -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) diff --git a/tests/test_models.py b/tests/test_models.py index dcd211bf..78f0357a 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -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) @@ -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