Skip to content
This repository has been archived by the owner on Nov 21, 2023. It is now read-only.

Examples

James Davenport edited this page May 1, 2015 · 11 revisions

The goal is to make pyDIS as easy to use as possible, taking away the fear of spectroscopy. Be sure to check out the step-by-step guide to manual data reduction using pyDIS, it's highly recommended for understanding the basic steps involved in 1-d spectroscopy.

Auto-reduce my data!

Here is an example of a script you might run over and over throughout the night while observing to reduce all your data, or reduce the whole night once you're home:

# if pyDIS isn't in the currnet working directory, add to path
import sys
sys.path.append('/path/to/pydis/')

# must import, of course
import pydis
    
# reduce and extract the data with the fancy autoreduce script
pydis.autoreduce('objlist.r.txt', 'flatlist.r.txt', 'biaslist.r.txt',
                   'HeNeAr.0005r.fits', stdstar='spec50cal/fiege34.dat')

More information on the autoreduce function can be found at this page.

Auto-reduce and co-add my data!

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 pydis
import numpy as np
import matplotlib.pyplot as plt

# function returns 3 arrays: wavelength, flux, fluxerror

# do the RED chip
wr, fr, er = pydis.ReduceCoAdd('robj.lis','rflat.lis', 'rbias.lis',
                   'UT150115/HeNeAr.0030r.fits', HeNeAr_prev=True,
                   stdstar='spec50cal/fiege34.dat',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 = pydis.ReduceCoAdd('bobj.lis','bflat.lis', 'bbias.lis',
                   'UT150115/HeNeAr.0030b.fits', HeNeAr_prev=True,
                   stdstar='spec50cal/fiege34.dat',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()

Manually reduce stuff!

You can also use each component of the reduction process. For example, if you wanted to combine all your flat and bias frames:

bias = pydis.biascombine('biaslist.txt')
flat, mask = pydis.flatcombine('flatlist.txt', bias)

There are many other functions available for the reduction process. Check out the step-by-step guide to manual data reduction using pyDIS for more information!

Clone this wiki locally