Skip to content

Commit

Permalink
Add check for uncalibrated filters for NIRISS SOSS (#8549)
Browse files Browse the repository at this point in the history
Co-authored-by: Howard Bushouse <bushouse@stsci.edu>
  • Loading branch information
melanieclarke and hbushouse authored Jun 14, 2024
1 parent 5a49fcc commit a818479
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ associations

- Add NIRSpec optical path constraints for TSO associations. [#8537]

- Exclude NIRISS SOSS data taken with uncalibrated filter F277W from spec2 and
tso3 associations. [#8549]

combine_1d
----------

Expand Down
25 changes: 23 additions & 2 deletions jwst/associations/lib/dms_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
'nrs_brightobj'
]

# Define the valid optical paths vs detector for NIRSpect Fixed-slit Science
# Define the valid optical paths vs detector for NIRSpec Fixed-slit Science
# Tuples are (SLIT, GRATING, FILTER, DETECTOR)
# All A-slits are represented by SLIT == 'a'.
NRS_FSS_VALID_OPTICAL_PATHS = (
Expand Down Expand Up @@ -204,7 +204,7 @@
('g140m', 'flat4', 'nrs2'),
)

# Define the valid optical paths vs detector for NIRSpect IFU Science
# Define the valid optical paths vs detector for NIRSpec IFU Science
# Tuples are (GRATING, FILTER, DETECTOR)
# The only combinations that result in data on the NRS2 detector are
# g140h/f100lp, g235h/f170lp, and g395h/f290lp.
Expand All @@ -223,6 +223,13 @@
('g395h', 'f290lp', 'nrs2'),
)


# Define the uncalibrated filters for NIRISS SOSS
# Data taken with these filters should not be processed beyond
# level 2a.
NIS_SOSS_UNCALIBRATED_FILTERS = ('f277w',)


# Key that uniquely identifies members.
MEMBER_KEY = 'expname'

Expand Down Expand Up @@ -1158,3 +1165,17 @@ def nrccoron_valid_detector(item):
return True
else:
return True


def nissoss_calibrated_filter(item):
"""Check that a NIRISS filter is calibrated."""
_, exp_type = item_getattr(item, ['exp_type'])
if exp_type != 'nis_soss':
return True

try:
_, filter = item_getattr(item, ['filter'])
except KeyError:
return False

return filter not in NIS_SOSS_UNCALIBRATED_FILTERS
21 changes: 20 additions & 1 deletion jwst/associations/lib/rules_level2b.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
Constraint_WFSC,
format_list,
item_getattr,
nissoss_calibrated_filter,
nrccoron_valid_detector,
nrsfss_valid_detector,
nrsifu_valid_detector,
Expand Down Expand Up @@ -482,7 +483,7 @@ def __init__(self, *args, **kwargs):
DMSAttrConstraint(
name='exp_type',
sources=['exp_type'],
value=('nrs_brightobj')
value='nrs_brightobj'
),
SimpleConstraint(
value=False,
Expand All @@ -492,6 +493,24 @@ def __init__(self, *args, **kwargs):
]),
],
reduce=Constraint.notany
),
# Don't allow NIRISS SOSS with uncalibrated filters
Constraint(
[
Constraint([
DMSAttrConstraint(
name='exp_type',
sources=['exp_type'],
value='nis_soss'
),
SimpleConstraint(
value=False,
test=lambda value, item: nissoss_calibrated_filter(item) == value,
force_unique=False
),
]),
],
reduce=Constraint.notany
)
])

Expand Down
33 changes: 24 additions & 9 deletions jwst/associations/lib/rules_level3.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
import logging

from jwst.associations.registry import RegistryMarker
from jwst.associations.lib.dms_base import (Constraint_TargetAcq, Constraint_TSO, nrsfss_valid_detector, nrsifu_valid_detector)
from jwst.associations.lib.dms_base import (nrccoron_valid_detector)
from jwst.associations.lib.dms_base import (
Constraint_TargetAcq, Constraint_TSO,
nissoss_calibrated_filter, nrccoron_valid_detector,
nrsfss_valid_detector, nrsifu_valid_detector)
from jwst.associations.lib.process_list import ListCategory
from jwst.associations.lib.rules_level3_base import *
from jwst.associations.lib.rules_level3_base import (
dms_product_name_sources, dms_product_name_nrsfs_sources, dms_product_name_noopt, dms_product_name_coronimage,
dms_product_name_sources, dms_product_name_nrsfs_sources,
dms_product_name_noopt, dms_product_name_coronimage,
format_product
)

Expand Down Expand Up @@ -881,12 +884,12 @@ def __init__(self, *args, **kwargs):
DMSAttrConstraint(
name='restricted_grism',
sources=['exp_type'],
value=('nrc_tsgrism')
value='nrc_tsgrism'
),
DMSAttrConstraint(
name='grism_clear',
sources=['pupil'],
value=('clear')
value='clear'
),
]),
Constraint([
Expand All @@ -904,19 +907,31 @@ def __init__(self, *args, **kwargs):
],
reduce=Constraint.notany
),
# Don't allow NIRISS SOSS with NINTS=1 in tso3
# Don't allow NIRISS SOSS with NINTS=1 or uncalibrated filters
Constraint(
[
Constraint([
DMSAttrConstraint(
name='exp_type',
sources=['exp_type'],
value=('nis_soss')
value='nis_soss'
),
DMSAttrConstraint(
name='nints',
sources=['nints'],
value=('1')
value='1'
),
]),
Constraint([
DMSAttrConstraint(
name='exp_type',
sources=['exp_type'],
value='nis_soss'
),
SimpleConstraint(
value=False,
test=lambda value, item: nissoss_calibrated_filter(item) == value,
force_unique=False
),
]),
],
Expand All @@ -929,7 +944,7 @@ def __init__(self, *args, **kwargs):
DMSAttrConstraint(
name='exp_type',
sources=['exp_type'],
value=('nrs_brightobj')
value='nrs_brightobj'
),
SimpleConstraint(
value=False,
Expand Down

0 comments on commit a818479

Please sign in to comment.