From fa153ccace2da3a7425f82ad9fee4b5b7f080042 Mon Sep 17 00:00:00 2001 From: Robert Jedrzejewski Date: Thu, 4 Apr 2024 08:50:01 -0400 Subject: [PATCH] JP-3151: Don't make associations for NRS2 IFU if detector not illuminated (#8395) Co-authored-by: Howard Bushouse --- CHANGES.rst | 6 ++++++ jwst/associations/lib/rules_level2b.py | 7 ++++++- jwst/associations/mkpool.py | 3 ++- jwst/associations/tests/test_exposerr.py | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index de15c485f4..226e869f7d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,12 @@ 1.14.1 (unreleased) =================== +associations +------------ + +- Ensure NRS IFU exposures don't make a spec2 association for grating/filter combinations + where the nrs2 detector isn't illuminated. Remove dupes in mkpool. [#8395] + documentation ------------- diff --git a/jwst/associations/lib/rules_level2b.py b/jwst/associations/lib/rules_level2b.py index 4b652522f9..5217591266 100644 --- a/jwst/associations/lib/rules_level2b.py +++ b/jwst/associations/lib/rules_level2b.py @@ -320,7 +320,12 @@ def __init__(self, *args, **kwargs): ) ], reduce=Constraint.notany - ) + ), + SimpleConstraint( + value=True, + test=lambda value, item: nrsifu_valid_detector(item), + force_unique=False + ), ]) # Now check and continue initialization. diff --git a/jwst/associations/mkpool.py b/jwst/associations/mkpool.py index 38deb461c0..8cc7a6039f 100644 --- a/jwst/associations/mkpool.py +++ b/jwst/associations/mkpool.py @@ -106,9 +106,10 @@ def mkpool(data, params = params.difference(IGNORE_KEYS) params = [item.lower() for item in params] + # Make sure there's no duplicates + params = list(set(params)) params.sort() defaults = {param: 'null' for param in params} - pool = AssociationPool(names=params, dtype=[object] * len(params)) # Set default values for user-settable non-header parameters diff --git a/jwst/associations/tests/test_exposerr.py b/jwst/associations/tests/test_exposerr.py index e9d6ce8bdd..9d48b8ed3a 100644 --- a/jwst/associations/tests/test_exposerr.py +++ b/jwst/associations/tests/test_exposerr.py @@ -21,7 +21,7 @@ def test_exposerr(): pool=pool ) asns = generated.associations - assert len(asns) > 1 + assert len(asns) == 1 for asn in asns: any_degraded = False for product in asn['products']: