5. Tips and Tricks
5.1. Plot a 1-D spectrum
Here is how to plot an extracted spectrum produced by DRAGONS with Python and matplotlib.
1import matplotlib.pyplot as plt
2import numpy as np
3
4import astrodata
5import gemini_instruments
6
7ad = astrodata.open('S20171022S0087_1D.fits')
8ad.info()
9
10data = ad[0].data
11wavelength = ad[0].wcs(np.arange(data.size)).astype(np.float32)
12units = ad[0].wcs.output_frame.unit[0]
13
14# add aperture number and location in the title.
15# check that plt.xlabel call. Not sure it's right, it works though.
16plt.xlabel(f'Wavelength ({units})')
17plt.ylabel(f'Signal ({ad[0].hdr["BUNIT"]})')
18plt.plot(wavelength, data)
19plt.show()
5.2. Inspect the sensitivity function
Plotting the sensitivity function is not obvious. Using Python, here’s a way to do it.
1from scipy.interpolate import BSpline
2import numpy as np
3import matplotlib.pyplot as plt
4
5import astrodata
6import gemini_instruments
7
8ad = astrodata.open('S20170826S0160_ql_standard.fits')
9
10sensfunc = ad[0].SENSFUNC
11
12order = sensfunc.meta['header'].get('ORDER', 3)
13func = BSpline(sensfunc['knots'].data, sensfunc['coefficients'].data, order)
14std_wave_unit = sensfunc['knots'].unit
15std_flux_unit = sensfunc['coefficients'].unit
16
17w1 = ad[0].wcs(0)
18w2 = ad[0].wcs(ad[0].data.size)
19
20x = np.arange(w1, w2)
21plt.xlabel(f'Wavelength ({std_wave_unit})')
22plt.ylabel(f'{std_flux_unit}')
23plt.plot(x, func(x))
24plt.show()
In the science-approved version of the GMOS longslit support in DRAGONS, there will be an interactive tool to inspect and adjust the sensitivity function.