Skip to content

Commit 33f55dc

Browse files
dynamically calculate the GNIRS XD MDF for North-Long-LXD-111
1 parent 1d12e86 commit 33f55dc

2 files changed

Lines changed: 64 additions & 7 deletions

File tree

geminidr/gnirs/lookups/MDF_XD.py

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,64 @@
1010
# primitives_gnirs_crossdispersed imports this dictionary to find the slit
1111
# definitions based on a key generated from the 'telescope', '_prism', 'decker',
1212
# '_grating', and 'camera' attributes of a file.
13+
14+
def get_slit_info(key, central_wavelength=None):
15+
"""
16+
Returns the slit information for GNIRS cross-dispersed data.
17+
18+
Returns
19+
-------
20+
tuple
21+
A tuple containing slit information: x_ccd, y_ccd, and width_pixels.
22+
"""
23+
if callable(slit_info[key]):
24+
info = slit_info[key](central_wavelength)
25+
else:
26+
info = slit_info[key]
27+
28+
return info
29+
30+
def _gem_north_lxd_lcxd_111_longblue(central_wavelength):
31+
"""
32+
Returns slit information for the Gemini North Long camera, 111 l/mm grating,
33+
LXD configuration.
34+
35+
Parameters
36+
----------
37+
central_wavelength : float
38+
The central wavelength in nm to determine the slit positions.
39+
40+
Returns
41+
-------
42+
tuple
43+
A tuple containing x_ccd, y_ccd, and width_pixels.
44+
"""
45+
if central_wavelength is None:
46+
raise ValueError("central_wavelength must be provided for this configuration.")
47+
central_wavelength *= 1.e6 # Convert from meters to um (descriptor default)
48+
49+
# x position calculation based on central wavelength
50+
solutions = {
51+
# order: (slope, constant) 1 degree polynomial
52+
'order3': (-387.148, 1021.51),
53+
'order4': (-294.465, 1032.95),
54+
'order5': (-309.060, 1215.08),
55+
'order6': (-370.932, 1489.49),
56+
'order7': (-438.000, 1776.67), # falls off the detector below 2.06 um
57+
# order 8 is hardly visible in the flats. Also can fall off the
58+
# detector at some wavelength settings.
59+
}
60+
x_ccd = []
61+
for solution in solutions:
62+
slope, constant = solutions[solution]
63+
x_ccd.append(slope * central_wavelength + constant)
64+
65+
x_ccd = tuple(x_ccd)
66+
y_ccd = 512
67+
width_pixels = 100
68+
69+
return (x_ccd, y_ccd, width_pixels)
70+
1371
slit_info = {
1472

1573
# Not all configurations have data present in the archive - some notes:
@@ -64,11 +122,8 @@
64122
),
65123
# North, Long, 111 l/mm, SXD
66124
# North, Long, 111 l/mm, LXD
67-
'Gemini-North_LXD_G5535_LCXD_G5531_111/mm_G5534_LongBlue_G5542': (
68-
(198, 410, 560, 699, 850), # x_ccd
69-
512, # y_ccd
70-
100 # width_pixels
71-
),
125+
'Gemini-North_LXD_G5535_LCXD_G5531_111/mm_G5534_LongBlue_G5542':
126+
_gem_north_lxd_lcxd_111_longblue,
72127

73128
# ------------------------------- Gemini South --------------------------------
74129
# ------------------------------- Short camera
@@ -101,3 +156,5 @@
101156
# but the configuration isn't meaningfully affected. Define such cases here.
102157
slit_info['Gemini-South_SXD_G5509_SC_XD_111/mm_G5505_ShortBlue_G5521'] =\
103158
slit_info['Gemini-South_SXD_G5509_SC_XD_111/mm_G5505_ShortBlue_G5513']
159+
160+

geminidr/gnirs/primitives_gnirs_crossdispersed.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from .primitives_gnirs_spect import GNIRSSpect
1616
from . import parameters_gnirs_crossdispersed
1717
from geminidr.core.primitives_crossdispersed import CrossDispersed
18-
from .lookups.MDF_XD import slit_info
18+
from .lookups.MDF_XD import get_slit_info
1919

2020
# -----------------------------------------------------------------------------
2121
@parameter_override
@@ -55,7 +55,7 @@ def addMDF(self, adinputs=None, suffix=None):
5555
'_grating', 'camera')
5656
mdf_key = "_".join(getattr(ad, desc)()
5757
for desc in mdf_key_parts)
58-
x_ccd, y_ccd, length_pix = slit_info[mdf_key]
58+
x_ccd, y_ccd, length_pix = get_slit_info(mdf_key, ad.central_wavelength())
5959
mdf_table = Table([range(1, len(x_ccd) + 1), x_ccd], names=['slit_id', 'x_ccd'])
6060
mdf_table['y_ccd'] = y_ccd
6161
mdf_table['specorder'] = mdf_table['slit_id'] + 2

0 commit comments

Comments
 (0)