8. Tips and Tricks

8.1. Getting Bad Pixel Masks from the archive

Starting with DRAGONS v3.1, the static bad pixel masks (BPMs) are now handled as calibrations. They are downloadable from the archive instead of being packaged with the software. There are various ways to get the BPMs.

Note that at this time there no static BPMs for Flamingos-2 data.

8.1.2. Associated calibrations

The BPMs are now handled like other calibrations. This means that they are also downloaded from the archive. From the archive search form, once you have identified your science data, select the “Load Associated Calibrations” (which turns to “View Calibrations” once the table is loaded). The BPM will show up with the green background.

_images/bpmassociated.png


If a BPM does not show up, see if you find one using the manual search explained in the previous section, Manual search.

8.2. 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()

8.3. Inspect the sensitivity function

Plotting the sensitivity function is not obvious. Using Python, here’s a way to do it.

 1import numpy as np
 2import matplotlib.pyplot as plt
 3
 4import astrodata
 5import gemini_instruments
 6from gempy.library import astromodels as am
 7
 8ad = astrodata.open('S20170826S0160_standard.fits')
 9
10sensfunc = am.table_to_model(ad[0].SENSFUNC)
11
12w = ad[0].wcs(np.arange(ad[0].data.size))
13
14std_wave_unit = ad[0].SENSFUNC['knots'].unit
15std_flux_unit = ad[0].SENSFUNC['coefficients'].unit
16
17plt.xlabel(f'Wavelength ({std_wave_unit})')
18plt.ylabel(f'{std_flux_unit}')
19plt.plot(w, sensfunc(w))
20plt.show()

8.4. Useful parameters

8.4.1. skip_primitive

I might happen that you will want or need to not run a primitive in a recipe. You could copy the recipe over and edit it. Or you could invoke the skip_primitive parameter to tell DRAGONS to completely skip that step.

Let’s say that you want the data aligned but not stacked. You would do:

reduce @sci.lis -p stackFrames:skip_primitive=True

8.4.2. write_outputs

When debugging or when there’s a need to inspect intermediate products, you might want to write the output of a specific primitive to disk. This is done with the write_outputs parameter.

For example, to write the extracted spectrum before it is flux calibrated, you would do:

reduce @sci.lis -p extractSpectra:write_outputs=True