Skip to content

get_infos_obs

Retrieve instrument, mask, and spectral information.

get_ifu_table(i_wl, filtname='YH', instrument='SPHERE-IFS', verbose=False, display=False)

Return spectral information for an instrumental IFU setup.

Parameters:

Name Type Description Default
i_wl int or list of int

One channel, a two-index channel range, or channels to display.

required
filtname str

IFU filter name.

"YH"
instrument str

Instrument name.

"SPHERE-IFS"
verbose bool

Whether to print spectral coverage.

False
display bool

Whether to display the selected channels.

False

Returns:

Type Description
float or ndarray

Selected wavelength or wavelengths in micrometres.

Source code in src/amical/get_infos_obs.py
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
def get_ifu_table(
    i_wl, filtname="YH", instrument="SPHERE-IFS", verbose=False, display=False
):
    """Return spectral information for an instrumental IFU setup.

    Parameters
    ----------
    i_wl : int or list of int
        One channel, a two-index channel range, or channels to display.
    filtname : str, default="YH"
        IFU filter name.
    instrument : str, default="SPHERE-IFS"
        Instrument name.
    verbose : bool, default=False
        Whether to print spectral coverage.
    display : bool, default=False
        Whether to display the selected channels.

    Returns
    -------
    float or numpy.ndarray
        Selected wavelength or wavelengths in micrometres.
    """
    wl = get_wavelength(instrument, filtname) * 1e6

    if verbose:
        print(f"\nInstrument: {instrument}, spectral range: {filtname}")
        print("-----------------------------")
        print(
            f"spectral coverage: {wl[0]:2.2f} - {wl[-1]:2.2f} µm (step = {np.diff(wl)[0]:2.2f})"
        )

    one_wl = True
    multiple_wl = False
    if isinstance(i_wl, list) and (len(i_wl) == 2):
        one_wl = False
        wl_range = wl[i_wl[0] : i_wl[1]]
        sp_range = np.arange(i_wl[0], i_wl[1], 1)
    elif isinstance(i_wl, list) and (len(i_wl) > 2):
        multiple_wl = True
        one_wl = False
    elif i_wl is None:
        one_wl = False
        sp_range = np.arange(len(wl))
        wl_range = wl

    if display:
        from matplotlib import pyplot as plt

        plt.figure(figsize=(4, 3))
        plt.title("--- SPECTRAL INFORMATION (IFU)---")
        plt.plot(wl, label="All spectral channels")
        if one_wl:
            plt.plot(
                np.arange(len(wl))[i_wl],
                wl[i_wl],
                "ro",
                label=f"Selected ({wl[np.atleast_1d(i_wl)[0]]:2.2f} µm)",
            )
        elif multiple_wl:
            plt.plot(
                i_wl,
                wl[i_wl],
                "ro",
                label="Selected",
            )
        else:
            plt.plot(
                sp_range,
                wl_range,
                lw=5,
                alpha=0.5,
                label=f"Selected ({wl_range[0]:2.2f}-{wl_range[-1]:2.2f} µm)",
            )
        plt.legend()
        plt.xlabel("Spectral channel")
        plt.ylabel("Wavelength [µm]")
        plt.tight_layout()

    if one_wl:
        output = wl[i_wl]
    elif multiple_wl:
        output = np.array(wl[i_wl])
    else:
        output = wl_range
    return output

get_mask(ins, mask, first=0)

Return the saved coordinates for an instrument mask.

Parameters:

Name Type Description Default
ins str

Instrument name.

required
mask str

Mask name.

required
first int

Index placed first in the returned coordinate sequence.

0

Returns:

Type Description
ndarray or None

Selected mask-hole coordinates, or None for an unknown mask.

Source code in src/amical/get_infos_obs.py
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
def get_mask(ins, mask, first=0):
    """Return the saved coordinates for an instrument mask.

    Parameters
    ----------
    ins : str
        Instrument name.
    mask : str
        Mask name.
    first : int, default=0
        Index placed first in the returned coordinate sequence.

    Returns
    -------
    numpy.ndarray or None
        Selected mask-hole coordinates, or None for an unknown mask.
    """

    pupil_visir = 8.0
    pupil_visir_mm = 17.67
    off = 0.3
    dic_mask = {
        "ERIS": {
            "g7_K": np.array(
                [
                    [-1.432, -2.901],
                    [2.849, -1.542],
                    [-3.037, 0.084],
                    [-0.464, 1.476],
                    [-1.278, 2.974],
                    [0.417, 2.932],
                    [2.929, 1.402],
                ]
            ),
            "g9_K": np.array(
                [
                    [-1.291, -2.504],
                    [-0.057, -2.554],
                    [-3.079, -1.353],
                    [2.5, -0.535],
                    [3.164, 0.493],
                    [2.036, 2.691],
                    [-1.085, 1.756],
                    [-2.977, 0.778],
                    [-1.655, 2.852],
                ]
            ),
            "g23_K": np.array(
                [
                    [-0.844, -3.306],
                    [0.793, -3.316],
                    [1.343, -3.32],
                    [-2.207, -2.83],
                    [-0.836, -2.353],
                    [2.162, -2.852],
                    [2.712, -1.91],
                    [-3.006, -1.396],
                    [0.257, -1.414],
                    [2.99, -1.437],
                    [-3.548, -0.447],
                    [-1.355, 0.477],
                    [-3.263, 0.022],
                    [-2.988, 1.434],
                    [3.554, 0.451],
                    [3.283, 0.923],
                    [2.738, 1.873],
                    [-1.346, 2.368],
                    [-2.165, 2.845],
                    [1.653, 2.826],
                    [-0.252, 3.31],
                    [0.287, 3.307],
                    [1.386, 3.303],
                ]
            ),
            "g7_L": np.array(
                [
                    [-1.441, -2.93],
                    [2.875, -1.558],
                    [-3.07, 0.078],
                    [-0.466, 1.487],
                    [-1.289, 3.003],
                    [0.421, 2.957],
                    [2.955, 1.403],
                ]
            ),
            "g9_L": np.array(
                [
                    [-1.296, -2.533],
                    [-0.056, -2.583],
                    [-3.113, -1.372],
                    [2.529, -0.549],
                    [3.202, 0.506],
                    [2.058, 2.716],
                    [-1.093, 1.773],
                    [-3.012, 0.788],
                    [-1.672, 2.885],
                ]
            ),
            "g23_L": np.array(
                [
                    [-0.849, -3.336],
                    [0.804, -3.349],
                    [1.358, -3.353],
                    [-2.224, -2.854],
                    [-0.841, -2.375],
                    [2.18, -2.879],
                    [2.737, -1.929],
                    [-3.039, -1.413],
                    [0.265, -1.428],
                    [3.019, -1.446],
                    [-3.588, -0.455],
                    [-1.375, 0.484],
                    [-3.307, 0.024],
                    [-3.025, 1.449],
                    [3.59, 0.458],
                    [3.311, 0.933],
                    [2.763, 1.891],
                    [-1.355, 2.392],
                    [-2.184, 2.879],
                    [1.672, 2.853],
                    [-0.251, 3.339],
                    [0.292, 3.335],
                    [1.401, 3.335],
                ]
            ),
        },
        "NIRISS": {
            "g7": np.array(
                [
                    [0, -2.64],
                    [-2.28631, 0],
                    [2.28631, -1.32],
                    [-2.28631, 1.32],
                    [-1.14315, 1.98],
                    [2.28631, 1.32],
                    [1.14315, 1.98],
                ]
            ),
            "g7_bis": np.array(
                [
                    [0, 2.9920001],
                    [2.2672534, 0.37400016],
                    [-2.2672534, 1.6829998],
                    [2.2672534, -0.93499988],
                    [1.1336316, -1.5895000],
                    [-2.2672534, -0.93500012],
                    [-1.1336313, -1.5895000],
                ]
            ),
            "g7_sb": np.array(
                [
                    [0, -2.64],  # 0
                    [-2.28631, 0],  # 1
                    [-2.28631 + off, 0],
                    [-2.28631 - off / np.sqrt(2), 0 + off / np.sqrt(2)],
                    [-2.28631 - off / np.sqrt(2), 0 - off / np.sqrt(2)],
                    [2.28631, -1.32],  # 2
                    [-2.28631, 1.32],  # 3
                    [-1.14315, 1.98],  # 4
                    [-1.14315 + off, 1.98],
                    [-1.14315 - off / np.sqrt(2), 1.98 + off / np.sqrt(2)],
                    [-1.14315 - off / np.sqrt(2), 1.98 - off / np.sqrt(2)],
                    [2.28631, 1.32],  # 5
                    [2.28631 + off, 1.32],
                    [2.28631 - off / np.sqrt(2), 1.32 + off / np.sqrt(2)],
                    [2.28631 - off / np.sqrt(2), 1.32 - off / np.sqrt(2)],
                    [1.14315, 1.98],  # 6
                ]
            ),
        },
        "GLINT": {
            "g4": np.array(
                [[2.725, 2.317], [-2.812, 1.685], [-2.469, -1.496], [-0.502, -2.363]]
            )
        },
        "NACO": {
            "g7": np.array(
                [
                    [-3.51064, -1.99373],
                    [-3.51064, 2.49014],
                    [-1.56907, 1.36918],
                    [-1.56907, 3.61111],
                    [0.372507, -4.23566],
                    [2.31408, 3.61111],
                    [4.25565, 0.248215],
                ]
            )
            * (8 / 10.0),
        },
        "SPHERE": {
            "g7": 1.05
            * np.array(
                [
                    [-1.46, 2.87],
                    [1.46, 2.87],
                    [-2.92, 0.34],
                    [-1.46, -0.51],
                    [-2.92, -1.35],
                    [2.92, -1.35],
                    [0, -3.04],
                ]
            )
        },
        "SPHERE-IFS": {
            "g7": 1
            * np.array(
                [
                    [-2.07, 2.71],
                    [0.98, 3.27],
                    [-3.11, -0.2],
                    [-1.43, -0.81],
                    [-2.79, -1.96],
                    [3.3, -0.85],
                    [0.58, -3.17],
                ]
            )
        },
        "VISIR": {
            "g7": (pupil_visir / pupil_visir_mm)
            * np.array(
                [
                    [-5.707, -2.885],
                    [-5.834, 3.804],
                    [0.099, 7.271],
                    [7.989, 0.422],
                    [3.989, -6.481],
                    [-3.790, -6.481],
                    [-1.928, -2.974],
                ]
            ),
        },
        "VAMPIRES": {
            "g18": np.array(
                [
                    [0.821457, 2.34684],
                    [-2.34960, 1.49034],
                    [-2.54456, 2.55259],
                    [1.64392, 3.04681],
                    [2.73751, -0.321102],
                    [1.38503, -3.31443],
                    [-3.19337, -1.68413],
                    [3.05126, 0.560011],
                    [-2.76083, 1.14035],
                    [3.02995, -1.91449],
                    [0.117786, 3.59025],
                    [-0.802156, 3.42140],
                    [-1.47228, -3.28982],
                    [-1.95968, -0.634178],
                    # [-3.29085, -1.15300],
                    [0.876319, -3.13328],
                    [2.01253, -1.55220],
                    [-2.07847, -2.57755],
                ]
            )
        },
    }

    #

    try:
        xycoords = dic_mask[ins][mask]
        nrand = [first]
        for x in np.arange(len(xycoords)):
            if x not in nrand:
                nrand.append(x)
        xycoords_sel = xycoords[nrand]
    except KeyError:
        rprint(
            f"[red]\n-- Error: maskname ({mask}) unknown for {ins}.", file=sys.stderr
        )
        xycoords_sel = None
    return xycoords_sel

get_wavelength(ins, filtname)

Return the central wavelength and width for an instrument filter.

Parameters:

Name Type Description Default
ins str

Instrument name.

required
filtname str

Filter name.

required

Returns:

Type Description
ndarray

Filter information in metres.

Raises:

Type Description
KeyError

If the instrument or filter is unknown.

Source code in src/amical/get_infos_obs.py
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
def get_wavelength(ins, filtname):
    """Return the central wavelength and width for an instrument filter.

    Parameters
    ----------
    ins : str
        Instrument name.
    filtname : str
        Filter name.

    Returns
    -------
    numpy.ndarray
        Filter information in metres.

    Raises
    ------
    KeyError
        If the instrument or filter is unknown.
    """
    from astropy.io import fits

    datadir = importlib_resources.files("amical") / "internal_data"
    YJfile = datadir / "ifs_wave_YJ.fits"
    YJHfile = datadir / "ifs_wave_YJH.fits"

    with fits.open(YJfile) as fd:
        wave_YJ = fd[0].data
    with fits.open(YJHfile) as fd:
        wave_YJH = fd[0].data

    dic_filt = {
        "ERIS": {
            "J": [1.28, 0.20],
            "H": [1.66, 0.31],
            "Ks": [2.18, 0.39],
            "Short-Lp": [3.32, 0.43],
            "Lp": [3.79, 0.60],
            "L-Broad": [3.57, 1.04],
            "Mp": [4.78, 0.58],
            "Pa-b": [1.282, 0.021],
            "Fe-II": [1.644, 0.020],
            "H2-cont": [2.068, 0.064],
            "H2-1-0S": [2.120, 0.020],
            "Br-g": [2.172, 0.020],
            "K-peak": [2.198, 0.099],
            "IB-2.42": [2.420, 0.049],
            "IB-2.48": [2.479, 0.051],
            "Br-a-cont": [3.965, 0.108],
            "Br-a": [4.051, 0.023],
        },
        "NIRISS": {
            "F277W": [2.776, 0.715],
            "F380M": [3.828, 0.205],
            "F430M": [4.286, 0.202],
            "F480M": [4.817, 0.298],
        },
        "SPHERE": {
            "H2": [1.593, 0.052],
            "H3": [1.667, 0.054],
            "H4": [1.733, 0.057],
            "K1": [2.110, 0.102],
            "K2": [2.251, 0.109],
            "CntH": [1.573, 0.023],
            "CntK1": [2.091, 0.034],
            "CntK2": [2.266, 0.032],
        },
        "SPHERE-IFS": {"YJ": wave_YJ, "YH": wave_YJH},
        "GLINT": {"F155": [1.55, 0.01], "F430": [4.3, 0.01]},
        "VISIR": {"10_5_SAM": [10.56, 0.37], "11_3_SAM": [11.23, 0.55]},
        "VAMPIRES": {"750-50": [0.75, 0.05]},
    }

    if ins not in dic_filt.keys():
        raise KeyError(
            f"--- Error: instrument <{ins}> not found ---\n"
            "Available: %s" % list(dic_filt.keys())
        )
    if filtname not in dic_filt[ins]:
        raise KeyError(
            f"Missing input: filtname <{filtname}> not found for {ins} (Available: {list(dic_filt[ins])})"
        )
    return np.array(dic_filt[ins][filtname]) * 1e-6