Fix bug marking background slits as sources in jwst.assign_wcs.nirspec.py #8494
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses a bug where background slits are incorrectly marked as sources in
jwst.assign_wcs.nirspec.py::get_open_msa_slits
, leading them to be marked as sources that were not assigned to slits but were in the source catalog. These incorrectly marked background slits are then extracted as targets.Full explanation:
Previously the code in
jwst.assign_wcs.nirspec.py::get_open_msa_slits
can lead to namespace clashes, where the temporarysource_id
s assigned to the background slits are checked against the full source catalog list and incorrectly match to real sources in the full source catalog, instead of failing the try/except Index error in lines 702-712 to return unique source names ofbackground_{slitlet_id}
. This leads to incorrect targets marked as being assigned slits in the WCS assignment, and background slits extracted as if they were sources in the full reduction pipeline.The source catalog (
msa_file[("SOURCE_INFO", 1)].data
) is originally defined in the APT, and often includes many more objects than are assigned slits (msa_file[('SHUTTER_INFO', 1)]
) in a given MSA configuration. Background slits can therefore be assignedsource_id
s that correspond to actual objects in the source catalog.The desired behavior, that background slits are re-identified and assigned source information appropriately (lines 707-712), can be achieved with the fix of switching from a try/except IndexError to an explicit check if the object
source_id
is less than the identifiedmax_source_id
.Checklist for PR authors (skip items if you don't have permissions or they are not applicable)
CHANGES.rst
within the relevant release sectionHow to run regression tests on a PR