Skip to content

Commit

Permalink
Don't extract fixed slits if neither background nor primary
Browse files Browse the repository at this point in the history
  • Loading branch information
melanieclarke committed May 20, 2024
1 parent 873eea4 commit 5f6f4a9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
12 changes: 9 additions & 3 deletions jwst/assign_wcs/nirspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,9 @@ def get_open_msa_slits(msa_file, msa_metadata_id, dither_position,
open_shutters = [x['shutter_column'] for x in slitlets_sid]

# How many shutters in the slitlet are labeled as "main" or "primary"?
# How many are labeled background?
n_main_shutter = len([s for s in slitlets_sid if s['primary_source'] == 'Y'])
n_background = len([s for s in slitlets_sid if s['background'] == 'Y'])

# Check for fixed slit sources defined in the MSA file
is_fs = [False] * len(slitlets_sid)
Expand All @@ -672,7 +674,6 @@ def get_open_msa_slits(msa_file, msa_metadata_id, dither_position,
# One fixed slit open for the source
slitlet = slitlets_sid[0]
slit_name = slitlet['fixed_slit']
log.debug(f'Found fixed slit {slit_name} with primary target')

# use standard number for fixed slit shutter id
slitlet_id = slit_name
Expand All @@ -690,14 +691,19 @@ def get_open_msa_slits(msa_file, msa_metadata_id, dither_position,
source_id = slitlet['source_id']
source_xpos = slitlet['estimated_source_in_shutter_x']
source_ypos = slitlet['estimated_source_in_shutter_y']
else:
log.info(f'Found fixed slit {slitlet_id} with source_id = {source_id}.')
elif n_background == 1:
# source is background only
source_id = _get_bkg_source_id(bkg_counter, max_source_id)
source_xpos = 0.5
source_ypos = 0.5
log.info(f'Slitlet_id {slitlet_id} is background only; '
f'assigned source_id = {source_id}')
f'assigned source_id = {source_id}.')
bkg_counter += 1
else:
log.info(f'Fixed slit {slitlet_id} is neither background nor source; '
f'skipping it.')
continue

elif any(is_fs):
# Unsupported fixed slit configuration
Expand Down
Binary file modified jwst/assign_wcs/tests/data/msa_fs_configuration.fits
Binary file not shown.
10 changes: 10 additions & 0 deletions jwst/assign_wcs/tests/test_nirspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,16 @@ def test_msa_fs_configuration():
0.0, 0.0, 0.0, 0.0, 0.0)
_compare_slits(slitlet_info[1], ref_slit)

# FS S200B1 is in the MSA file but neither background nor primary:
# it should not be defined. The rest should be there.
fs_slits_defined = ['S200A1', 'S200A2', 'S400A1', 'S1600A1']
n_fixed = 0
for slit in slitlet_info:
if slit.quadrant == 5:
assert slit.name in fs_slits_defined
n_fixed += 1
assert n_fixed == len(fs_slits_defined)


def test_msa_fs_configuration_unsupported(tmp_path):
"""
Expand Down

0 comments on commit 5f6f4a9

Please sign in to comment.