extract



Note: Although still available, extract is no longer supported and will soon be replaced with a new and much improved 1-d extraction routine.
extract uses map files to extract 1 or 2-dimensional spectra from spectrum files. Spectra are extracted onto a 1 or 2-dimensional array of wavelength [and slit position]. Output data are stored as a set of image extensions in a 1 or 2-dimensional fits file, one spectrum per extension. extract automatically handles nod&shuffle data (in 2-d mode; not yet in 1-d mode).
extract optionally cleans cosmic rays from the spectra by fitting the data to a bivariate b-spline, then rejecting positive outliers from the fit.


USAGE
extract
INPUT

OUTPUT
spectrumname_[1][2]spec.fits
PARAMETERS
deltalambda
wavelength interval of extracted spectrum
deltaslit
slitposition interval of extracted spectrum, in arc sec
minlambda
minimum wavelength of extracted spectrum
maxlambda
maximum wavelength of extracted spectrum
telscale
telescope scale arc sec/mm
lambda_order
order of CR rejection spline fit along wavelength axis
slit_order
order of CR rejection spline fit along slit axis
lambda_knot
CR rejection spline knot spacing along wavelength axis, in pixels
slit_knot
CR rejection spline knot spacing along slit axis, in pixels
strip
half-width of 1-d extraction strip, in pixels
search
half-width of spectrum search region, in pixels
clean
clean cosmic rays? [Y/N]
siglimit
CR rejection threshold, in sigmas
noise
CCD read noise
gain
CCD gain
dimension
dimension of extracted spectrum [1/2]
optimal
do optimal 1-d extraction? [Y/N]
diag
diagnostic axis [slit/lambda/none]


Details:

extract  uses one or more map files to extract spectral exposures onto a coordinate grid of wavelength [and slit position if 2-d spectra are desired]. Because a separate map file can be specified for each exposure, extract can combine exposures even if spectrograph flexures has produced positional shifts (as long as suitable comparison arc exposures were obtained for each spectrum). Using the mapping information in the map file, extract does a linear sub-pixel interpolation to measure the intensity of the spectrum at each interval of wavelength [and slit position]. The output spectrum is the sum of the interpolated intensities of each of the input spectra.

Input
extract prompts for pairs of map files and spectrum files. If CR rejection and/or optimal 1-d extraction is specified and the spectrum file headers do not contain exposure times (files produced with early versions of the COSMOS routine biasflat will not), extract will prompt for them. If only one spectrum file is used, the name of the output file will be taken from the root name of the input file (e.g. ccd1234_s will result in ccd1234_1spec.fits or ccd1234_2spec.fits); if more than one spectrum file is to be combined, extract will prompt for the name of the output file.
Input spectra will normally be sky-subtracted frames named ccd1234_s. If CR rejection and/or optimal 1-d extraction is specified, extract also needs the unsubtracted frames ccd1234_f in order to calculate the pixel statistics. If they are not available in the same directory containing the sky-subtracted frames, the program will die.

spectrum search
the map file for each spectrum contains information on the expected location, along the slit, of the object spectrum. This information comes from the SMF file used to produce the slit mask. Unless the astrometry used to produce the mask, and the alignment of the mask on the sky, are both perfect, these predicted spectrum locations may be slightly in error. If search is set to a non-zero value, extract searches about the expected position to determine the actual slit location of the object.

1-d spectra
extract uses only data within strip pixels of the slit location of the object. If optimal extraction is specified, data within this strip is summed in a statistically optimal manner; otherwise, intensities within the strip are just summed.

Cosmic ray rejection
If at least 2 input spectra are provided, extract can reject cosmic rays. The input data are fit to a bivariate b-spline, and points which are more than siglimit sigmas above the fit will be rejected. Values of siglimit of around 4.0 seem to work well: removing almost all CRs without affecting strong emission lines. The values of the spline parameters must be chosen with care. The fit order may be 1,3, or 5; 1 or 3 is recommended. The optimal knot spacing depends on the fit order; values of 1.25 pixels and 2.5 pixels work well for 1st and 3rd order, respectively. First order is recommended, for speed and best fit.
The diagnostic mode can be used to test spline fitting parameters. If the diagnostic axis is set to lambda, extract plots flux vs lambda in the region around the 5577A night sky line, showing data points and spline fit. (Note that this will only work if the input spectrum is not sky-subtracted!)  If set to slit, extract plots flux vs slit position. In diagnostic mode, no output file is written.

Warning: bivariate b-spline fits to large data sets (like 2-d IMACS spectra) are very slow and quite touchy. Sometimes extract does good CR rejection, sometimes it does not, but always it does it very slowly. A somewhat less elegant but much quicker and more reliable procedure for combining 2-d spectra with CR rejection is to use extract-2dspec on each exposure, then combine the exposures with sumspec.


Nod & shuffle mode

In 2-d extraction, the shuffle region is extracted along with the primary slit region and subtracted from the primary slit data. In 1-d extraction, the spectra at the two object positions are added, and the spectra at the two sky positions are subtracted from the summed object spectrum.



Output
The header of the first spectrum contains the following parameters:

N_SLITS = number of slits extracted
D_SLIT   =  interval along slit, in arc seconds
CRVAL1 = wavelength of first pixel
CDELT1 =  wavelength interval of pixels

The headers of all spectra contain the following parameters:

CNTRLINE = the line in the 2-d spectrum centered on the object [if a 2-d extraction]
OBJECT      = object name, as defined in the SMF file for the mask
SLITNUM   =  slit number in SMF file for the mask




Back to programs