-
Notifications
You must be signed in to change notification settings - Fork 27
Examples
The goal is to make SPECTRA as easy to use while observing as possible. Here is an example of a script you might run over and over throughout the night to reduce all your data:
# if SPECTRA isn't in the currnet working directory, add to path
import sys
sys.path.append('/path/to/spectra/')
# must import, of course
import spectra
# reduce and extract the data with the fancy autoreduce script
wave, flux = spectra.autoreduce('objlist.r.txt', 'flatlist.r.txt', 'biaslist.r.txt',
'HeNeAr.0005r.fits', stdstar='fiege34')
More information on the autoreduce
function can be found at this page on the wiki.
So far the only variant of the autoreduce
function is ReduceCoAdd
. This behaves exactly like the former, but is a special version where all target frames are assumed to be of the same target. These frames are reduced (flats, biases), and then the images median combined. The normal extraction and calibration are then performed on this combined image!
Here is a reduction script where I reduced and co-added both the RED and BLUE channels for DIS, and plotted the results:
import spectra
import numpy as np
import matplotlib.pyplot as plt
# function returns 3 arrays: wavelength, flux, fluxerror
# do the RED chip
wr, fr, er = spectra.ReduceCoAdd('robj.lis','rflat.lis', 'rbias.lis',
'UT150115/HeNeAr.0030r.fits', HeNeAr_prev=True,
stdstar='feige34',skydeg=0,
apwidth=6, skysep=1, skywidth=7, HeNeAr_order=5,
ntracesteps=15, HeNeAr_interac=True,
display=False, trace1=True)
# do the BLUE chip
wb, fb, er = spectra.ReduceCoAdd('bobj.lis','bflat.lis', 'bbias.lis',
'UT150115/HeNeAr.0030b.fits', HeNeAr_prev=True,
stdstar='feige34',skydeg=0,
apwidth=6, skysep=1, skywidth=7,HeNeAr_order=2,
ntracesteps=7, HeNeAr_interac=True,
display=False, trace1=True)
x1 = np.where((wb<5400) & (wb>3500))
x2 = np.where((wr>5300))
plt.figure()
plt.plot(wb[x1],fb[x1],'b',alpha=0.7)
plt.plot(wr[x2],fr[x2],'r',alpha=0.7)
plt.ylim((-0.2e-15,0.4e-15))
plt.xlim((3500,9800))
plt.show()
You can also use each component of the reduction process. For example, if you wanted to combine all your flat and bias frames:
bias = spectra.biascombine('biaslist.txt')
flat, mask = spectra.flatcombine('flatlist.txt', bias)
The resulting flat and bias frames are returned as numpy arrays. By default these functions will write files called BIAS.fits and FLAT.fits, unless a different name is specified using the output = 'file.fits'
keyword.
Note also that flatcombine
returns both the data array and a 1-d "mask" array, which determines from the flat the portion of the CCD that is illuminated.