Repository: spacetelescope/jwst

Issue:
MOS background sources are assigned lower left source position
_Issue [JP-3612](https://jira.stsci.edu/browse/JP-3612) was created on JIRA by [Melanie Clarke](https://jira.stsci.edu/secure/ViewProfile.jspa?name=mclarke):_

In assign_wcs for NIRSpec MOS observations, for background-only slits, any input x and y position for the source is ignored ('estimated_source_in_shutter_x', 'estimated_source_in_shutter_y' in the MSA file).  The 'source_xpos' and 'source_ypos' values for the slit are set to 0.0 (line 665-666, jwst/assign_wcs/nirspec.py).  However, these values are later corrected by -0.5, to account for the difference between the MSA coordinate origin and the model coordinate origin (line 724-725, jwst/assign_wcs/nirspec.py).  This puts the background source location at -0.5, -0.5, which is the lower left corner of the slit.

I think it was probably intended to put the source position for the background at the center of the slit, not the lower left corner.  Line 665-666 should be corrected to set the background slit source position to 0.5, 0.5.  This will impact the point source pathloss correction, computed and stored by default for every slit, but should not otherwise impact processing for background slits, since they are always treated as uniform sources.

Discussion:
melanieclarke: Regression test changes are only in the SRCXPOS and SRYPOS keywords, and in the PATHLOSS_PS extension in intermediate files, as expected.  PATHLOSS_PS is now all 1.0, as expected for a centered source.

Patch:
diff --git a/CHANGES.rst b/CHANGES.rst
index cffcd7166..20081f4a7 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -15,6 +15,9 @@ assign_wcs
   of pixel row rather than a rotation of the pixel coordinates.  The practical impact is
   to ensure that iso-lambda is along pixel rows after this change. [#8411]
 
+- Move the assigned source position for dedicated NIRSpec MOS background slits from the
+  lower left corner of the slit to the middle of the slit. [#8461]
+
 associations
 ------------
 
diff --git a/jwst/assign_wcs/nirspec.py b/jwst/assign_wcs/nirspec.py
index f106dc4c9..c6e3e8c2e 100644
--- a/jwst/assign_wcs/nirspec.py
+++ b/jwst/assign_wcs/nirspec.py
@@ -662,8 +662,8 @@ def get_open_msa_slits(msa_file, msa_metadata_id, dither_position,
             quadrant = slitlets_sid[0]['shutter_quadrant']
             ycen = j
             xcen = slitlets_sid[0]['shutter_row']  # grab the first as they are all the same
-            source_xpos = 0.0
-            source_ypos = 0.0
+            source_xpos = 0.5
+            source_ypos = 0.5
             source_id = _get_bkg_source_id(bkg_counter, max_source_id)
             log.info(f'Slitlet_id {slitlet_id} is background only; assigned source_id = {source_id}')
             bkg_counter += 1


Test patch:
diff --git a/jwst/assign_wcs/tests/test_nirspec.py b/jwst/assign_wcs/tests/test_nirspec.py
index 7fdbaffd1..a51791683 100644
--- a/jwst/assign_wcs/tests/test_nirspec.py
+++ b/jwst/assign_wcs/tests/test_nirspec.py
@@ -311,7 +311,7 @@ def test_msa_configuration_all_background():
     slitlet_info = nirspec.get_open_msa_slits(msaconfl, msa_meta_id, dither_position,
                                               slit_y_range=[-.5, .5])
     ref_slit = trmodels.Slit(57, 8281, 1, 251, 23, -2.15, 2.15, 4, 0, '1x1', 'background_57', 'bkg_57',
-                             0, -0.5, -0.5)
+                             0, 0.0, 0.0)
     _compare_slits(slitlet_info[0], ref_slit)