This page was created by the IDL library routine
make_html_help. For more information on
this routine, refer to the IDL Online Help Navigator
or type:
? make_html_help
at the IDL command line prompt.
Last modified: Mon Feb 20 19:36:32 2006.
NAME:
apoall
PURPOSE:
Run APOREDUCE on one or many nights of data.
CALLING SEQUENCE:
apoall, [ mjd=, mjstart=, mjend=, minexp=, copydir= ]
INPUTS:
OPTIONAL INPUTS:
mjd - Look for raw data files in RAWDIR/MJD; default to '*' to
search all subdirectories. Note that this need not be
integer-valued, but could be for example '51441_test'.
mjstart - Starting MJD.
mjend - Ending MJD.
minexp - Minimum exposure time for science frames; default to 0 sec.
copydir - Copy the output log files to this directory; default to none.
OUTPUT:
COMMENTS:
The files are sorted before being sent to APOREDUCE. For each plate,
reduce all the biases/darks, then all the flats, then all the arcs,
and finally all of the science/smear frames.
Look for the raw sdR files in $RAWDATA_DIR/$MJD, the plPlugMapM files
in $ASTROLOG_DIR/$MJD, and put the outputs in $SPECTROLOG_DIR/$MJD.
If that last environment variable is not set, then put the outputs
in the same directory as the sdR files.
EXAMPLES:
Rerun the SOS code on the spectro data from MJD 53682, putting
the results in the current directory:
IDL> setenv, 'RAWDATA_DIR=.'
IDL> apoall, mjd=53682
BUGS:
PROCEDURES CALLED:
aporeduce
djs_filepath()
get_mjd_dir()
sdsshead()
sxpar()
REVISION HISTORY:
27-May-2000 Written by David Schlegel, Princeton.
(See pro/apo2d/apoall.pro)
NAME:
apofix
PURPOSE:
Add line to sdHdrFix file to denote change in FITS header for sdR files.
CALLING SEQUENCE:
apofix, expnum, [ card, value, camera=, /bad, /test, /not_sos ]
INPUTS:
expnum - Exposure number
OPTIONAL INPUTS:
card - FITS header keyword to change; this is case-insensitive,
so that 'exptime' is the same as 'EXPTIME'.
value - New value for FITS header keyword.
camera - Camera name in which to change values, e.g. 'b1', 'r1',
'b2' or 'r2'. A '?' can be used as a wildcard, for example
'?2' to denote a change to both 'b2' and 'r2'. Default to
'??' to denote a change to sdR files for all 4 cameras.
bad - If set, then declare the specified exposure number to be bad.
This is equivalent to setting QUALITY='bad'.
test - If set, then declare the specified exposure number to be test.
This is equivalent to setting QUALITY='test'.
not_sos - This keyword can be set to run this proc on a machine
that is not named "sos". This would only be done for
testing purposes, or if Son-of-Spectro has been moved
to another machine.
OUTPUT:
OPTIONAL OUTPUTS:
COMMENTS:
Only the following keywords can be modified with this procedure:
CAMERAS, FLAVOR, PLATEID, NAME, EXPTIME, TAI-BEG, TAI-END, TAI,
FFS, FF, NE, HGCD, OBSCOMM, QUALITY
The AIRMASS is not read from the header, but computed from RADEG,DECDEG
and the TAI-BEG,TAI-END keywords.
Refer to the Son-of-Spectro documentation for the specifics of
valid values for each keyword.
Note that string values must be enclosed in single- or double-quotes.
Numeric values should not be in quotes. Double-precision numbers should
be written with "d" notation, for example 3.14d7 instead of 3.14e7.
EXAMPLES:
Fix the exposure time for exposure #1234 to be 900 sec:
IDL> apofix, 1234, 'exptime', 900
Fix the TAI time for exposure #1234 to be 4.443852968d+09
(use the "d" notation for double-precision, even though it
will appear in the sdHdrFix file with an "e"):
IDL> apofix, 1234, 'TAI', 4.443852968d+09
Declare exposure #1234 as bad:
IDL> apofix, 1234, /bad
or equivalently:
IDL> apofix, 1234, 'quality', 'bad'
Only declare the 'b1' camera bad for exposure number 1234:
IDL> apofix, 1234, /bad, camera='b1'
The wrong NAME is in the header, which is necessary to identify
the proper plug-map file. If the correct plug-map file
is plPlugMapM-0328-52277-01, then edit as follows:
IDL> apofix, 1234, 'name', '0328-52277-01'
BUGS:
PROCEDURES CALLED:
djs_lockfile()
djs_modfits
djs_unlockfile
fileandpath()
fits_wait
headfits()
struct_append
sxpar()
yanny_read
REVISION HISTORY:
22-Apr-2002 Written by D. Schlegel, Princeton
(See pro/apo2d/apofix.pro)
NAME:
apofluxcalib
PURPOSE:
Generate the flux-calibration vectors for use by APOPLOT.
CALLING SEQUENCE:
apofluxcalib, [ platenum, mjd= ]
INPUTS:
platenum - Plate number for obtaining the fluxing vectors; default to 406
mjd - Modified Julian Date for above plate; default to plate 406
on MJD 51817 if neither is specified
OPTIONAL INPUTS:
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
The output files spFluxcalib-$CAMERA.fits should be moved to
the directory $IDLSPEC2D_DIR/examples for use by APOPLOT.
For reference (excerpted from PR #6766):
Here is the list of 10 main-survey plates with the
highest S/N per minute in all cameras (where I've looked
up to plate 650 in the Spectro-2D v5 beta reductions):
398 51789
402 51793
406 51817
406 51900
411 51817
416 51811
418 51817
431 51877
436 51883
439 51877
EXAMPLES:
BUGS:
PROCEDURES CALLED:
bspline_iterfit()
bspline_valu()
headfits()
mrdfits()
mwrfits
readspec
traceset2xy
REVISION HISTORY:
04-Dec-2001 Written by D. Schlegel, Princeton
(See pro/apo2d/apofluxcalib.pro)
NAME:
apoheader
PURPOSE:
Print the subset of interesting header keywords from the raw sdR files.
CALLING SEQUENCE:
apoheader, expnum, [ mjd= ]
INPUTS:
expnum - Exposure number
OPTIONAL INPUTS:
mjd - Optionally specify the MJD for the subdirectory in which
to search for the file. This will greatly speed things up.
OUTPUT:
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
Print out all FITS header keywords of interest for exposure # 14728
(assuming that exposure is still on disk somewhere under $RAWDATA_DIR):
IDL> apoheader, 14728
BUGS:
PROCEDURES CALLED:
fileandpath()
fits_wait
sdsshead()
sxpar()
REVISION HISTORY:
24-Apr-2002 Written by D. Schlegel, Princeton
(See pro/apo2d/apoheader.pro)
NAME:
apoplot
PURPOSE:
Routine for plotting spectra from the Son-of-Spectro outputs at APO.
CALLING SEQUENCE:
apoplot, plate, [ fiberid, mjd=, expnum=, nsmooth=, nmed=, psfile=, $
/magsort, /netimage, _EXTRA= ]
INPUTS:
plate - Plate number
OPTIONAL INPUTS:
fiberid - Fiber number(s); if not set, then plot all fibers for plate.
mjd - MJD number; if not set, then select the most recent MJD
in the $SPECTROLOG_DIR directory.
expnum - If set, then plot only these exposure numbers for this plate
rather than all exposure numbers for this plate.
nsmooth - If set, then boxcar smooth the object spectra with a
width equal to NSMOOTH.
nmed - If set, then median filter the object spectra with a
width equal to NMED.
psfile - If set, then send plot to a PostScript file instead of
to the SPLOT interactive widget. The PostScript file name
can be set explicitly, e.g. with PSFILE='test.ps'. Or if
you simply set this as a flag, e.g. with /PSFILE, then the
default file name is spec-pppp-mmmmm-fff.ps,
where pppp=plate number, mmmmm=MJD, fff=fiber ID.
magsort - If set and FIBERID is not, then plot all fibers from
the brightest object to the faintest.
netimage - If set, then launch a Netscape browser with the object
image from Steve Kent's web site. This only works if
Netscape is running and has permissions at the site
"http://sdssmosaic.fnal.gov:8015".
This is disabled if PSFILE is set.
_EXTRA - Kewords for SPLOT, such as XRANGE, YRANGE, THICK.
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
The Son-of-Spectro outputs are first read from the file:
$SPECTROLOG_DIR/$MJD/logsheet-$MJD.fits
This then points to the other files that are read:
$SPECTROLOG_DIR/$MJD/fflat-$MJD-$PLATE-$EXPNUM-$CAMERA.fits
$SPECTROLOG_DIR/$MJD/wset-$MJD-$PLATE-$EXPNUM-$CAMERA.fits
$SPECTROLOG_DIR/$MJD/sci-$PLATE-$CAMERA-$EXPNUM.fits
If $SPECTROLOG_DIR is not set, then it is assumed to be
/data/spectro/spectrologs
The plotting range is set by the 5th and 95th percentiles of the data.
Note that there are a horrendous amount of cosmic rays in the data
as extracted by Son-of-Spectro.
The flux-calibration is very rudimentary, always using the same
four curves for the four cameras.
EXAMPLES:
Plot the spectrum of plate 401, fiber #100 using the SPLOT plotting tool:
IDL> apoplot, 401, 100
The spectra from the first exposure (blue and red) are shown as white.
Other exposures are shown in other colors, and are labelled as such.
The mouse buttons will zoom in (left), recenter (center), or zoom out
(right). The frame can be saved as a PostScript file by selecting
File->WriteEPS from the left-hand corner.
Make the same plot, but boxcar-smooth the spectrum and limit the
wavelength range to [4000,5000] Angstroms:
IDL> apoplot, 401, 100, nsmooth=10, xrange=[5000,6000]
Some plates are observed on multiple nights. To select one of the two
observations of plate 306:
IDL> apoplot, 306, 20, mjd=51690
This will only work if you have the Son-of-Spectro outputs for that
date on your disk.
Loop through all the spectra for plate 401, interactively:
IDL> apoplot, 401
Plot all the spectra from plate 401 to a single PostScript file:
IDL> apoplot, 401, /psfile
BUGS:
DATA FILES:
$IDLSPEC2D_DIR/examples/spFluxcalib-$CAMERA.fits
PROCEDURES CALLED:
djs_maskinterp()
djs_median()
djs_oplot
djs_plot
fcalib_default()
get_mjd_dir()
soplot
splot
sdss_flagname()
sxyouts
INTERNAL SUPPORT ROUTINES:
apoplot1
REVISION HISTORY:
04-Dec-2001 Written by D. Schlegel, Princeton
(See pro/apo2d/apoplot.pro)
NAME:
apoplotarc
PURPOSE:
Routine for plotting arc spectra from the Son-of-Spectro outputs at APO.
CALLING SEQUENCE:
apoplotarc, expnum, [ camname=, mjd=, everyn=, psfile=, _EXTRA= ]
INPUTS:
expnum - Exposure number
OPTIONAL INPUTS:
camname - Camera name; default to 'r1'
mjd - MJD; must be set if this exposure is not in the most
recent MJD directory
everyn - Plot every EVERYN-th spectrum; default to 40, which will
plot fiber numbers 1, 41, 81, ...281.
psfile - If set, then send plot to a PostScript file instead of
to the SPLOT interactive widget. The PostScript file name
can be set explicitly, e.g. with PSFILE='test.ps'. Or if
you simply set this as a flag, e.g. with /PSFILE, then the
default file name is arc-pppp-cc-eeeeeeee.ps,
where pppp=plate number, cc=camname, eeeeeeee=exposure number.
_EXTRA - Kewords for SPLOT, such as XRANGE, YRANGE, THICK.
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
The arc spectrum is plotted as a red line. The individual
arc values at each pixel in the arc fibers are plotted as points.
The Son-of-Spectro outputs are first read from the file:
$SPECTROLOG_DIR/$MJD/logsheet-$MJD.fits
This then points to the other files that are read:
$SPECTROLOG_DIR/$MJD/fflat-$MJD-$PLATE-$EXPNUM-$CAMERA.fits
$SPECTROLOG_DIR/$MJD/wset-$MJD-$PLATE-$EXPNUM-$CAMERA.fits
$SPECTROLOG_DIR/$MJD/sci-$PLATE-$CAMERA-$EXPNUM.fits
If $SPECTROLOG_DIR is not set, then it is assumed to be
/data/spectro/spectrologs
EXAMPLES:
Plot the arc spectrum for exposure number 9437 taken in the most
recent night's data in the r1-camera, using the SPLOT plotting tool:
IDL> apoplotarc, 9437
The mouse buttons will zoom in (left), recenter (center), or zoom out
(right). The frame can be saved as a PostScript file by selecting
File->WriteEPS from the left-hand corner.
Make the same plot, but change the Y limits and write a PostScript file:
IDL> apoplotarc, 9437, yrange=[0,1000], /psfile
BUGS:
PROCEDURES CALLED:
djs_oplot
djs_plot
get_mjd_dir()
soplot
splot
REVISION HISTORY:
20-Nov-2002 Written by D. Schlegel, Princeton
(See pro/apo2d/apoplotarc.pro)
NAME:
apoplotgeom
PURPOSE:
Routine for plotting arc geometry from the Son-of-Spectro outputs at APO.
CALLING SEQUENCE:
apoplotgeom, plate, [ camname=, mjd=, psfile=, _EXTRA= ]
INPUTS:
plate - Plate number
OPTIONAL INPUTS:
camname - Camera name; default to 'r1'
mjd - MJD; must be set if this exposure is not in the most
recent MJD directory
psfile - If set, then send plot to a PostScript file instead of
to the SPLOT interactive widget. The PostScript file name
can be set explicitly, e.g. with PSFILE='test.ps'. Or if
you simply set this as a flag, e.g. with /PSFILE, then the
default file name is arc-pppp-cc-eeeeeeee.ps,
where pppp=plate number, cc=camname, eeeeeeee=exposure number.
_EXTRA - Kewords for SPLOT, such as XRANGE, YRANGE, THICK.
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
The arc spectrum is plotted as a red line. The individual
arc values at each pixel in the arc fibers are plotted as points.
The Son-of-Spectro outputs are first read from the file:
$SPECTROLOG_DIR/$MJD/logsheet-$MJD.fits
This then points to the other files that are read:
$SPECTROLOG_DIR/$MJD/fflat-$MJD-$PLATE-$EXPNUM-$CAMERA.fits
$SPECTROLOG_DIR/$MJD/wset-$MJD-$PLATE-$EXPNUM-$CAMERA.fits
$SPECTROLOG_DIR/$MJD/sci-$PLATE-$CAMERA-$EXPNUM.fits
If $SPECTROLOG_DIR is not set, then it is assumed to be
/data/spectro/spectrologs
EXAMPLES:
Plot the arc spectrum for exposure number 9425 taken in the most
recent night's data in the r1-camera, using the SPLOT plotting tool:
IDL> apoplotgeom, 9425
The mouse buttons will zoom in (left), recenter (center), or zoom out
(right). The frame can be saved as a PostScript file by selecting
File->WriteEPS from the left-hand corner.
Make the same plot, but change the Y limits and write a PostScript file:
IDL> apoplotgeom, 9425, yrange=[0,1000], /psfile
BUGS:
PROCEDURES CALLED:
djs_oplot
djs_plot
get_mjd_dir()
soplot
splot
REVISION HISTORY:
20-Nov-2002 Written by D. Schlegel, Princeton
(See pro/apo2d/apoplotgeom.pro)
NAME:
apoplotsky
PURPOSE:
Routine for plotting sky spectra from the Son-of-Spectro outputs at APO.
CALLING SEQUENCE:
apoplotsky, expnum, [ camname=, mjd=, psfile=, _EXTRA= ]
INPUTS:
expnum - Exposure number
OPTIONAL INPUTS:
camname - Camera name; default to 'r1'
mjd - MJD; must be set if this exposure is not in the most
recent MJD directory
psfile - If set, then send plot to a PostScript file instead of
to the SPLOT interactive widget. The PostScript file name
can be set explicitly, e.g. with PSFILE='test.ps'. Or if
you simply set this as a flag, e.g. with /PSFILE, then the
default file name is sky-pppp-cc-eeeeeeee.ps,
where pppp=plate number, cc=camname, eeeeeeee=exposure number.
_EXTRA - Kewords for SPLOT, such as XRANGE, YRANGE, THICK.
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
The supersky spectrum is plotted as a red line. The individual
sky values at each pixel in the sky fibers are plotted as points.
The Son-of-Spectro outputs are first read from the file:
$SPECTROLOG_DIR/$MJD/logsheet-$MJD.fits
This then points to the other files that are read:
$SPECTROLOG_DIR/$MJD/fflat-$MJD-$PLATE-$EXPNUM-$CAMERA.fits
$SPECTROLOG_DIR/$MJD/wset-$MJD-$PLATE-$EXPNUM-$CAMERA.fits
$SPECTROLOG_DIR/$MJD/sci-$PLATE-$CAMERA-$EXPNUM.fits
If $SPECTROLOG_DIR is not set, then it is assumed to be
/data/spectro/spectrologs
EXAMPLES:
Plot the sky spectrum for exposure number 9425 taken in the most
recent night's data in the r1-camera, using the SPLOT plotting tool:
IDL> apoplotsky, 9425
The mouse buttons will zoom in (left), recenter (center), or zoom out
(right). The frame can be saved as a PostScript file by selecting
File->WriteEPS from the left-hand corner.
Make the same plot, but change the Y limits and write a PostScript file:
IDL> apoplotsky, 9425, yrange=[0,1000], /psfile
BUGS:
PROCEDURES CALLED:
djs_oplot
djs_plot
get_mjd_dir()
soplot
splot
REVISION HISTORY:
20-Nov-2002 Written by D. Schlegel, Princeton
(See pro/apo2d/apoplotsky.pro)
NAME:
aporeduce
PURPOSE:
Quick on-the-mountain reduction pipeline for 1 file at a time.
CALLING SEQUENCE:
aporeduce, filename, [ indir=, outdir=, $
plugfile=, plugdir=, minexp=, $
copydir=, /no_diskcheck ]
INPUTS:
filename - Raw spectroscopic image file name(s) of any flavor; this
can be an array of file names, but cannot include wildcards
OPTIONAL INPUTS:
indir - Input directory for FILENAME; default to './'
outdir - Output directory for reduced data and log files;
default to INDIR
plugfile - Name of plugmap file (Yanny parameter file); default to
'plPlugMapM-'+NAME+'.par', where NAME is taken from that
keyword in the file FILENAME
plugdir - Input directory for PLUGFILE; default to INDIR
minexp - Minimum exposure time for science frames; default to 0 sec
so that any frame with a non-negative exposure time is
reduced.
copydir - If set, then copy the output log files to this directory using
"scp" copy (not "scp1" any longer). Make an additional copy
of the HTML file called 'logsheet-current.html'.
no_diskcheck- If set, then do not do the check for filling input or
output disks. (This option is always set by the APOALL proc).
OUTPUT:
OPTIONAL OUTPUTS:
COMMENTS:
After reducing any 'r2' frame, we re-generate the HTML file and optionally
copy it to the file specified by COPYDIR.
The copy of the file "logsheet-current.html" also has a line of Java-script
added that does an auto-refresh every 60 seconds.
EXAMPLES:
BUGS:
scp1 does not exist on sos.apo.nmsu.edu, reverted to scp
INTERNAL SUPPORT ROUTINES:
apo_diskcheck
PROCEDURES CALLED:
apo_appendlog
apo_log2html
apo_plotsn
djs_filepath()
fits_wait()
get_tai
idlspec2d_version()
idlutils_version()
quickextract()
quicktrace()
quickwave()
splog
tai2airmass()
REVISION HISTORY:
30-Apr-2000 Written by D. Schlegel & S. Burles, APO
(See pro/apo2d/aporeduce.pro)
NAME: apo_appendlog PURPOSE: Append to logfile as written by APOREDUCE. CALLING SEQUENCE: apo_appendlog, logfile, rstruct, tstruct INPUTS: logfile - FITS logfile as written by APOREDUCE. rstruct - Structure to append to the log file with reduced data info tstruct - Structure to append to the log file with WARNING/ABORT strings OPTIONAL INPUTS: OUTPUT: OPTIONAL OUTPUTS: COMMENTS: EXAMPLES: BUGS: PROCEDURES CALLED: djs_lockfile() djs_modfits djs_unlockfile headfits() idlutils_version() idlspec2d_version() modfits mrdfits() mwrfits splog sxaddpar struct_append() REVISION HISTORY: 02-Dec-2000 Written by D. Schlegel, Princeton
(See pro/apo2d/apo_appendlog.pro)
NAME:
apo_checklimits()
PURPOSE:
Convert output FITS file from APOREDUCE to HTML format.
CALLING SEQUENCE:
markstring = apo_checklimits(flavor, field, camera, value, [ /html ] )
INPUTS:
flavor - FLAVOR to match in the opLimits file.
field - FIELD to match in the opLimits file.
camera - CAMERA to match in the opLimits file.
value - Value to test in the opLimits file. If this is a
string value, then one matches to STRVAL in that file.
Otherwise, test for values within [LOVALUE,HIVALUE].
OPTIONAL INPUTS:
html - If set, then convert the color name in MARKSTRING into
an HTML string. For example, a return value of 'red'
becomes '<B><FONT COLOR="#FF0000">'.
OUTPUT:
markstring - Return the COLOR from the opLimits file.
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
BUGS:
PROCEDURES CALLED:
DATA FILES:
$IDLSPEC2D_DIR/examples/opLimits.par
REVISION HISTORY:
30-Apr-2000 Written by D. Schlegel, APO
(See pro/apo2d/apo_checklimits.pro)
NAME:
apo_log2html
PURPOSE:
Convert output FITS file from APOREDUCE to HTML format.
CALLING SEQUENCE:
apo_log2html, logfile, [ htmlfile ]
INPUTS:
logfile - Input log file as a FITS binary file with an extension
for each frame reduced; this file is written by APOREDUCE.
OPTIONAL INPUTS:
htmlfile - Output log file in HTML format; default to the same name
as LOGFILE, replacing the '.fits' extension with '.html'
OUTPUT:
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
BUGS:
PROCEDURES CALLED:
apo_checklimits()
copy_struct_inx
djs_filepath()
djs_findfile()
djs_lockfile()
djs_unlockfile
fileandpath()
headfits()
mrdfits
repstr()
sxpar()
INTERNAL SUPPORT ROUTINES:
apo_color2hex()
apo_log_header()
apo_log_endfile()
apo_log_tableline()
apo_log_beginplate()
apo_log_endplate()
apo_log_fields()
REVISION HISTORY:
30-Apr-2000 Written by D. Schlegel, APO
(See pro/apo2d/apo_log2html.pro)
NAME:
apo_plotbias
PURPOSE:
Plot the histogram of bias values for all 4 cameras of a single exposure
CALLING SEQUENCE:
apo_plotbias, expnum, [ plotfile= ]
INPUTS:
expnum - Exposure number
OPTIONAL INPUTS:
plotfile - Plot file; if set, then send plot to this PostScript file
rather than to the default (X) display.
OUTPUT:
OPTIONAL OUTPUTS:
COMMENTS:
The histogram of bias values is plotted for all (4) camera files that
match the given exposure number.
A fiducial line is drawn as a thick blue line. This line approximates
what we expect to see for each camera.
If $RAWDATA_DIR is not set, then it is assumed to be
/data/spectro
EXAMPLES:
BUGS:
PROCEDURES CALLED:
dfpsclose
dfpsplot
djs_filepath()
djs_icolor()
djs_xyouts
fileandpath()
headfits()
plothist
quickbias
sdssproc
struct_append()
sxpar()
REVISION HISTORY:
06-Dec-2000 Written by D. Schlegel, Princeton
(See pro/apo2d/apo_plotbias.pro)
NAME:
apo_plotsn
PURPOSE:
Generate S/N plot for one plate from a FITS logfile written by APOREDUCE.
CALLING SEQUENCE:
apo_plotsn, logfile, plate, [ plugdir=, plotfile= ]
INPUTS:
logfile - Logfile as written by APOREDUCE. This is a FITS file
with an HDU of information for each reduced frame.
plate - Plate number to plot.
OPTIONAL KEYWORDS:
plugdir - Input directory for PLUGFILE; default to '.'
The name of the plugmap file is taken from the first
structure in the LOGFILE.
plotfile - Name of plot file; if not specified then send plot to
current device.
OUTPUT:
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
BUGS:
PROCEDURES CALLED:
apo_checklimits()
djs_lockfile()
djs_unlockfile
mrdfits
plotsn
sortplugmap()
splog
readplugmap()
REVISION HISTORY:
02-May-2000 Written by D. Schlegel, APO
(See pro/apo2d/apo_plotsn.pro)
NAME:
arcfit_guess
PURPOSE:
Determine initial wavelength solution by comparing spectrum to arc spectrum
CALLING SEQUENCE:
wset = arcfit_guess( spec, loglam, intensity, color=color, $
[ func=func, bestcorr=bestcorr, acoeff=, dcoeff=, nsteps= ] )
INPUTS:
spec - 1-D spectrum
loglam - Log-lambda of arc lines
intensity - Intensity of arc lines
REQUIRED KEYWORDS:
color - 'red' or 'blue'
OPTIONAL KEYWORDS:
func - Name of fitting function; default to 'legendre'
acoeff - central values of coefficents to explore
dcoeff - range (-.5*dcoeff to .5*dcoeff) of values to explore
nsteps - array of steps to use
OUTPUTS:
wset - traceset (pix -> lambda)
OPTIONAL OUTPUTS:
bestcorr - Correlation coefficient with simulated arc spectrum
COMMENTS:
EXAMPLES:
BUGS:
INTERNAL SUPPORT PROCEDURES:
tset_struc()
arcfit_iter()
PROCEDURES CALLED:
traceset2xy()
xy2traceset
REVISION HISTORY:
18-Nov-1999 Written by D. Schlegel, Princeton.
Excised code from FITARCIMAGE.
01-Dec-2000 added acoeff, dcoeff, nsteps keywords
(See pro/spec2d/arcfit_guess.pro)
NAME:
atmdisp_cor
PURPOSE:
Atmospheric dispersion causes wavelength dependent lightloss from
fiber spectra. The mean atmospheric dispersion experienced by the
standard stars on each plate is automatically corrected for as part of
the flux calibration. However, any shift in the centering of the
spectroscopic targets in the fibers across the plate will result in
differences in atmospheric dispersion as a function of plate position.
These centering errors -- caused by small errors in the plate scale or
rotation -- can produce flux calibration errors of up to 20%. This
procedure is designed to correct for these.
Synthetic magnitudes are computed from the spectra on 1 half-plate and
compared to the photo fiber magnitudes. The residuals are fit as a
function of plate x/y position with a 3rd order polynomial. The (g-r)
offsets of this fit are then mapped into an atmospheric dispersion
correction. This mapping makes use of models of the atmospheric dispersion
of point sources observed with 2" seeing through 3" fibers at a variety
of airmasses. The absolute light loss is mapped using the r-band mag
residuals. A vector of wavelength dependent corrections is returned.
CALLING SEQUENCE:
atm_model = atmdisp_cor(loglam, flux, plugtag, hdr, title = title, $
surfgr_sig = surfgr_sig)
INPUTS:
loglam - wavelength array of input spectra in log10(Angstroms) [npix]
flux - flux array from 1 half plate [npix, nfiber] (nfiber~320)
plugtag - plugmap [nfiber] -- used for mags, plate x/y, sky & standard ID
hdr - image header -- used for aquiring airmass info (maybe also
seeing and guiding in the future)
OUTPUT:
A model of the atmospheric dispersion correction for each fiber is
returned [npix, nfiber]. (To correct: flux_cor = flux / atm_model)
Plots are generated showing the (g-r) and r mag offsets as a function
of plate x/y before and after the correction. Histograms are produced
as well.
KEYWORDS:
title - title of output plots (usually plate/mjd/specid)
surfgr_sig - sigma of 2d fit to the (g-r) offsets -- this is a good
indicator of how big the correction is.
COMMENTS:
This function requires an external source of info about the effects
of atmospheric dispersion as a function of wavelength. This info is
stored in structures in IDLSPEC2D_DIR/etc/. They are named
'atmdisp_vec_am' + airmass + 'see2.0.fit' where airmass is a value from
1.1 - 1.5.
BUGS:
Galaxies and stars respond differently to atmospheric dispersion beause
of thier different spatial extent. The mean correction which is
derived here is really that appropriate for the average galaxy --
so corrections for point sources are likely to be underestimated a bit.
To do this right the spatial profile of each object should be taken into
account.
EXAMPLES:
PROCEDURES CALLED:
djs_icolor()
djs_iterstat()
djs_oplot
djs_sfit_iter()
filter_thru()
gaussfit()
legend
linterp
mrdfits
plothist
traceset2xy
INTERNAL SUPPORT ROUTINES:
sphoto_xy
REVISION HISTORY:
Created 12-Aug-2003 by C. Tremonti, Steward Observatory
(See pro/fluxfix/atmdisp_cor.pro)
NAME: atvrawspec PURPOSE: Display a 2D spectroscopic image with bad columns marked in red. CALLING SEQUENCE: atvrawspec, filename, _EXTRA=KeywordsForATV INPUTS: filename - Either a raw SDSS file name, or a 2D pixel flat or 2D bias OPTIONAL KEYWORDS: _EXTRA - Extra keywords for ATV, such as MIN,MAX OUTPUTS: OPTIONAL OUTPUTS: COMMENTS: EXAMPLES: Display a 2D pixel flat with a reasonable display stretch: IDL> atvrawspec, 'pixflat-52069-b1.fits', min=0.9, max=1.1 Display a 2D bias with a reasonable display stretch: IDL> atvrawspec, 'pixbias-52069-b1.fits', min=-5, max=10 BUGS: PROCEDURES CALLED: atv atvplot djs_filepath() findopfile() headfits() sdssproc yanny_free yanny_read DATA FILES: $IDLSPEC2D_DIR/examples/opBC*par REVISION HISTORY: 26-Feb-2002 Written by D. Schlegel, Princeton
(See pro/apo2d/atvrawspec.pro)
NAME: badfmags PURPOSE: Find any F stars where the magnitudes in the calibObj files are grossly discrepent from the plug-map files. CALLING SEQUENCE: badfmags, [ maxdiff= ] INPUTS: OPTIONAL INPUTS: maxdiff - Maximum r-band magnitude difference; default to 0.4 OUTPUTS: OPTIONAL OUTPUTS: COMMENTS: This routine looks for calibration F stars that have very discrepent magnitudes in the plug-map file vs. the calibObj files. Only the r-band magnitudes are compared, and they must differ by at least MAXDIFF in order to trigger a warning. Before comparing the magnitudes, first offset all the F star magnitudes by their median difference. EXAMPLES: BUGS: PROCEDURES CALLED: platelist readspec splog REVISION HISTORY: 10-Feb-2004 Written by D. Schlegel, Princeton
(See pro/plan/badfmags.pro)
NAME:
badfstars
PURPOSE:
Find bad F stars used for spectro-photometry in the Spectro-2D reductions
CALLING SEQUENCE:
badfstars, [ /doplot ]
INPUTS:
OPTIONAL INPUTS:
doplot - If set, then use PLOTSPEC to plot all the bad spectra
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
This procedure looks at all the objects labelled as either
OBJTYPE='SPECTROPHOTO_STD' or 'REDDEN_STD' in the spAll.fits file.
These are considered to be bad F stars if the following conditions
are satisfied:
WCOVERAGE > 0.10
(|cz| > 500 km/sec) OR (not an B,A,F,G-type star)
These objects are then listed in the file 'badfstars.log', and then
plotted if /DOPLOT is set.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
hogg_mrdfits()
plotspec
REVISION HISTORY:
06-Feb-2004 Written by D. Schlegel, Princeton
(See pro/plan/badfstars.pro)
NAME: bandpassfilter PURPOSE: CALLING SEQUENCE: newdata = bandpassfilter( datafft, [ klo_cut=, khi_cut= ] ) INPUTS: datafft - Vector of Fourier-transformed data OPTIONAL KEYWORDS: klo_cut - Low-frequency cutoff khi_cut - High-frequency cutoff OUTPUTS: newdata - Filtered version of DATAFFT OPTIONAL OUTPUTS: COMMENTS: Units??? EXAMPLES: BUGS: PROCEDURES CALLED: REVISION HISTORY: 30-Mar-2000 Written by D. Schlegel, APO
(See pro/spec1d/bandpassfilter.pro)
NAME:
bandpassinfo
PURPOSE:
Return information about SDSS bandpasses u,g,r,i,z.
COMMENTS:
This routine can be used to convert filternames into numbers and back.
If band is passed as a string, it gets whitespace-trimmed before use.
CALLING SEQUENCE:
bandpassinfo, band,index=index,name=name,wave=wave,fwhm=fwhm,zero=zero
INPUTS:
band - a name (ugriz) or index (01234), or a vector of them
OPTIONAL KEYWORDS:
OUTPUTS:
OPTIONAL OUTPUTS:
index - the band's index number (0-4)
name - name ('u' through 'z')
wave - central wavelength in Angstroms
fwhm - width of the bandpass in Angstroms
zero - the flux in Jy of a zero-magnitude source
blueindex - the index (0-3) of the blue bandpass of the k-correction color
redindex - the index (1-4) of the red bandpass of the k-correction color
colorname - the name of the color ('(u-g)' through '(i-z)')
BUGS:
Returns 0's (u's) or 4's (z's) where the input is wacky.
Computes even unnecessary things (this could be fixed with some calls to
keyword_set().
PROCEDURES CALLED:
REVISION HISTORY:
2000-Jun-28 Written by Hogg (IAS)
(See pro/science/bandpassinfo.pro)
NAME:
batch1d
PURPOSE:
Batch process Spectro-1D reductions based upon existing 2D plate files.
CALLING SEQUENCE:
batch1d, [ fullplatefile, topdir=, upsversion=, nice=, /clobber ]
INPUTS:
OPTIONAL INPUTS:
fullplatefile - Plate files to reduce; default to all files matching
'*/spPlate*.fits' from the top-level directory.
topdir - Top directory for reductions; default to current directory.
upsversion - If set, then do a "setup idlspec2d $UPSVERSION" on the
remote machine before executing the IDL job. This allows
you to batch jobs using a version other than that which
is declared current under UPS.
nice - Unix nice-ness for spawned jobs; default to 19.
clobber - If set, then reduce all specified plates, overwriting
any previous reductions.
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
The list of hosts and protocols should be in the Yanny parameter file
specified in the file TOPDIR/batch1d.par if it exists, or the default
file "$IDLSPEC2D_DIR/examples/batch1d.par" is used.
If using machines in Peyton, set
topdir='/peyton/scr/spectro0/data/2d_v4'
A plate is considered not reduced if any of the "spPlate*.par" files
do not have a corresponding "spDiag1d*.log" file.
The command is piped to the bash shell on the remote machine, so IDL
and the idlspec2d product must be present when running "bash --login".
Normally, your .bashrc file should set up all the necessary path info.
If the UPSVERSION keyword is used, then the UPS "setup" command must
also be set up in the .bashrc file.
The command that is spawned will look something like (but all in one line):
ssh1 wire1.princeton.edu 'cd /u/dss/spectro;
echo "DISPLAY=; setup idlspec2d v4_9_6; /bin/nice -n 10
idl 0406/spPlate-0406-51817.batch" | bash --login >& /dev/null'
The $DISPLAY environment variable is always set to "" on the remote
machine to make certain that we only use one IDL license per machine.
(Any IDL jobs that have the same the username, machine name, and $DISPLAY
use the same license.)
EXAMPLES:
BUGS:
DATA FILES:
$IDLSPEC2D_DIR/examples/batch1d.par
PROCEDURES CALLED:
djs_batch
djs_filepath()
fileandpath()
splog
yanny_free
yanny_read
REVISION HISTORY:
17-Oct-2000 Written by D. Schlegel, Princeton
(See pro/spec1d/batch1d.pro)
NAME:
batch2d
PURPOSE:
Batch process Spectro-2D reductions based upon already-built plan files.
CALLING SEQUENCE:
batch2d, [ platenums, topdir=, platestart=, plateend=, $
mjd=, mjstart=, mjend=, upsversion=, nice=, /clobber ]
INPUTS:
OPTIONAL INPUTS:
platenums - Plate numbers to reduce; default to '*'
topdir - Top directory for reductions; default to current directory.
platestart - Starting plate number.
plateend - Ending plate number.
mjd - MJD dates to reduce; default to all.
Select based upon the MJD of the combine plan file, and
reduce data from all nights needed for that combined plate+MJD.
mjstart - Starting MJD dates to reduce.
mjend - Ending MJD dates to reduce.
upsversion - If set, then do a "setup idlspec2d $UPSVERSION" on the
remote machine before executing the IDL job. This allows
you to batch jobs using a version other than that which
is declared current under UPS.
nice - Unix nice-ness for spawned jobs; default to 19.
clobber - If set, then reduce all specified plates, overwriting
any previous reductions.
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
The list of hosts and protocols should be in the Yanny parameter file
specified in the file TOPDIR/batch2d.par if it exists, or the default
file "$IDLSPEC2D_DIR/examples/batch2d.par" is used.
If using machines in Peyton, set
topdir='/peyton/scr/spectro0/data/2d_v4'
A plate is considered not reduced if any of the "spPlan2d*.par" files
do not have a corresponding "spDiag2d*.log" file.
The command is piped to the bash shell on the remote machine, so IDL
and the idlspec2d product must be present when running "bash --login".
Normally, your .bashrc file should set up all the necessary path info.
If the UPSVERSION keyword is used, then the UPS "setup" command must
also be set up in the .bashrc file.
The command that is spawned will look something like (but all in one line):
ssh1 wire1.princeton.edu 'cd /u/dss/spectro;
echo "DISPLAY=; setup idlspec2d v4_9_6; /bin/nice -n 10
idl 0406/spPlancomb-0406-51817.batch" | bash --login >& /dev/null'
The $DISPLAY environment variable is always set to "" on the remote
machine to make certain that we only use one IDL license per machine.
(Any IDL jobs that have the same the username, machine name, and $DISPLAY
use the same license.)
EXAMPLES:
BUGS:
DATA FILES:
$IDLSPEC2D_DIR/examples/batch2d.par
PROCEDURES CALLED:
concat_dir()
djs_batch
djs_filepath()
fileandpath()
get_mjd_dir()
mjd_match()
repstr()
splog
yanny_free
yanny_read
yanny_par()
INTERNAL SUPPORT ROUTINES:
batch2d_nolog()
batch2d_rawfiles()
batch2d_combfiles()
REVISION HISTORY:
17-Oct-2000 Written by D. Schlegel, Princeton
(See pro/spec2d/batch2d.pro)
NAME: bin_spectra PURPOSE: Make binned spectra for the purposes of fitting for the bandpasses CALLING SEQUENCE: bin_spectra, flux, binbounds INPUTS: flux - flux in a set of spectra [NPIX,NSPEC] invvar - inverse variance in a set of spectra [NPIX,NSPEC] binbounds - boundaries of desired bins OPTIONAL INPUTS: OPTIONAL KEYWORDS: OUTPUTS: binflux - binned flux COMMENTS: Not currently binning the variances. Sorry. EXAMPLES: PROCEDURES CALLED: DATA FILES: REVISION HISTORY: 05-APr-2000 Written by M. Blanton, Fermiland
(See pro/spec1d/bin_spectra.pro)
NAME:
calcscatimage
PURPOSE:
Just return smoothed scattered light image
CALLING SEQUENCE:
scatfit = calcscatimage(ansimage, yrow, nscatbkpts=nscatbkpts, $
ymin=ymin, ymax=ymax, fullrows=fullrows)
INPUTS:
ansimage - Keyword Output from extract_image
yrow - Array of rows extracted in first pass
OPTIONAL KEYWORDS:
ymin - lower limit for chebyshev background (default 0)
ymax - upper limit for chebyshev background (default 2047)
fullrows - number of rows in full image (default 2048)
OUTPUTS:
scatfit - Image of scattered light from smoothing polynomials
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
BUGS:
PROCEDURES CALLED:
bspline_valu()
bspline_iterfit()
fchebyshev()
REVISION HISTORY:
29-Sep-2000 Written by S. Burles, FNAL, adopted from fitansimage
(See pro/spec2d/calcscatimage.pro)
NAME:
catplot
PURPOSE:
Modified version of SPLOT by Tremonti for inspecting spectra.
CALLING SEQUENCE:
catplot, [x], y, $
[color=, psym=, symsize=, thick= ]
soplot, [x], y, [/autoscale], $
[color=, psym=, symsize=, thick= ]
sxyouts, x, y, string, [alignment=, charsize=, charthick=, color=, $
font=, orientation= ]
serase, [nerase, /norefresh]
INPUTS:
OUTPUT:
COMMENTS:
This code is based upon Aaron Barth's ATV procedure.
SpInspect added to menu bar. "Open SpInspect File" brings up a
dialogue box. The spInspect File must have the format
spInspect-pppp-mmmmm-inspector.par. Upon loading this file, plotspec
is called to loop through the fibers on the specified plate. No
changes are written to the spInspect File until "Update SpInspect File"
is selected from the menu bar.
EXAMPLES:
BUGS:
Doesn't use the passed XRANGE, YRANGE properly yet...
Move around widgets to be more compact above plotting window.
Write splot_readfits.
Make POSITION= changeable based upon CHARSIZE.
Gaussian fitting or integrated gaussian fitting.
Allow one to step through an image row at a time? Or link to ATV?
Use the WCS in splot_gettrack.
Add widget button option to fix Y range or let it float, or fix YMIN=0.
Include options for plotting contours, etc?
Options for XLOG, YLOG
For FITS files, take XTITLE, YTITLE from header
Option to pass header as param in SPLOT
SpInspect only reads the 1st of semi-colon separated variables in
the manual_comments field. (Writes them just fine!)
PROCEDURES CALLED:
fits_read
INTERNAL SUPPORT ROUTINES:
splot_gausspix
splot_startup
splot_clearkeylist
splot_displayall
splot_readfits
splot_writeeps
splot_cleartext
splot_zoom
splot_gettrack
splot_event
splot_shutdown
splot_resize
splot_icolor()
splot_setheader
splot_headinfo
splot_headinfo_event
splot_plot1plot
splot_plot1text
splot_plotwindow
splot_plotall
sxyouts
splot_move_cursor
splot_set_minmax
splot_get_minmax
splot_refresh
splot_help
splot_help_event
splot_plotparam_refresh
splot_plotparam
splot_plotparam_event
serase
splot_autoscale
soplot
splot
splot_spinspect_new
splot_spinspect_update
splot_spinspect_event
splot_spinspect
REVISION HISTORY:
28-Sep-1999 Written by David Schlegel, Princeton.
19-Jun-2001 Gaussfit amplitude was wrong - fixed - D. Finkbeiner
17-Jun-2002 Added spInspect procedures - C. Tremonti
Modified splot_startup, splot_events
(See pro/spec1d/catplot.pro)
NAME: chunkinfo PURPOSE: Return chunk information for a given plate number. CALLING SEQUENCE: cinfo = chunkinfo(plateid) INPUTS: OPTIONAL INPUTS: plateid - Plate ID number; scalar or array of integers OUTPUTS: cinfo - Structure with chunk information for each plate OPTIONAL OUTPUTS: COMMENTS: EXAMPLES: BUGS: DATA FILES: $IDLSPEC2D_DIR/etc/spChunkList.par PROCEDURES CALLED: yanny_free yanny_read REVISION HISTORY: 08-Feb-2001 Written by D. Schlegel, Princeton
(See pro/spec2d/chunkinfo.pro)
NAME:
collimate
PURPOSE:
Compute the spectrograph collimation focus from Hartmann mask exposures.
CALLING SEQUENCE:
collimate, expnum1, [ expnum2, docams=, indir=, nregx=, nregy=, $
maxshift=, /nocheck ]
INPUTS:
expnum1 - First exposure number of raw sdR file.
OPTIONAL KEYWORDS:
expnum2 - Second exposure number; default to EXPNUM1+1.
docams - Cameras to analyze; default to ['b1','b2','r1','r2'].
indir - Input directory for files; default to searching for
files in $RAWDATA_DIR/*. If $RAWDATA_DIR is not set,
then it is assumed to be /data/spectro.
nregx - Number of sub-regions in the X dimension; default to 8.
nregy - Number of sub-regions in the Y dimension; default to 8.
maxshift - Maximum pixel shift to search in both X and Y; default to 3.
nocheck - If set, then assume that the 1st exposure is Hartmann-l,
and the 2nd exposure is Hartmann-r, rather than looking at
the OBSCOMM header keyword. This correct keywords are
added by the SOP goSpecFocus command, but will not be if
you simply move the collimator and shutters yourself.
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
The focus of the collimator is measured by comparing two Hartmann
exposures of arc lamps, and looking for shifts in the arc line positions.
A linear correlation coefficient is computed independently in NREGX
by NREGY regions on each CCD as a function of pixel shifts of the 2nd
image in both X and Y. The best-focus value is found in each region
by maximizing the linear correlation in the Y (wavelength) direction.
The following files are output for each camera:
Collimate-$MJD-$CAMERA-$EXPNUM1.log
Collimate-$MJD-$CAMERA-$EXPNUM1.ps
The position of the Hartmann shutters is read from the OBSCOMM header
keywords. It is expected to be '{focus, hartmann l}' for one exposure
and '{focus, hartmann r}' for the other (in either order). It is assumed
that the collimator position is identical for both exposures.
The sense of the pixel shifts reported is what one would have to shift
the Hartmann-r exposure by in Y to agree with the Hartmann-l exposure.
EXAMPLES:
Solve for the focus of all 4 CCD's from exposures 10812+10813
on MJD 52161 (assuming the files exist in /data/spectro/52161):
IDL> collimate, 10812
BUGS:
PROCEDURES CALLED:
dfpsclose
dfpsplot
djs_filepath()
djs_icolor()
djs_svdfit()
sdssproc
splog
sxpar()
INTERNAL SUPPORT ROUTINES:
collimate_obscomm()
REVISION HISTORY:
28-Mar-2002 Written by D. Schlegel, Princeton.
(See pro/apo2d/collimate.pro)
NAME:
combine1fiber
PURPOSE:
Combine several spectra of the same object, or resample a single spectrum.
CALLING SEQUENCE:
combine1fiber, inloglam, objflux, [ objivar, finalmask=, indisp=, skyflux=,$
newloglam=, newflux=, newivar=, andmask=, ormask=, newdisp=, newsky=, $
nord=, binsz=, bkptbin=, maxsep=, _EXTRA=KeywordsForReject, /verbose ]
INPUTS:
inloglam - Wavelengths in log10-Angstroms [NPIX,NSPEC]
objflux - Flux [NPIX,NSPEC]
REQUIRED KEYWORDS:
newloglam - Wavelengths for output evaluation, also in log10-Angstroms
[NNEWPIX]
OPTIONAL INPUTS:
objivar - Inverse variance [NPIX,NSPEC]
finalmask - Pixel mask [NPIX,NSPEC]
indisp - Dispersion values [NPIX,NSPEC]
skyflux - Sky flux vectors [NPIX,NSPEC]
binsz - Bin separation for INLOGLAM; if not set, then default
to INLOGLAM[1]-INLOGLAM[0].
nord - Order of spline fit; default to 3.
bkptbin - Break point binning; default to 1.2 * BINSZ.
maxsep - Maximum separation between input wavelengths. The spline
fit is split into pieces, with the breaks wherever this
spacing is exceeded. Default to 2.0 * BINSZ.
_EXTRA - Keywords for DJS_REJECT().
verbose - If set, then output messages about bad break points and
masked data points.
OUTPUTS:
OPTIONAL OUTPUTS:
finalmask - Modified from its input by setting the COMBINEREJ bit
for deviant pixels in individual spectra that have
been rejected.
objivar - Modified from itts input by setting to zero wherever
the COMBINEREJ bit has been set in FINALMASK.
newflux - Resampled flux [NNEWPIX].
newivar - Resampled inverse variance [NNEWPIX].
andmask - Resampled mask. For each mask bit, set that bit only if
every input spectrum at this wavelength has that bit set
(e.g., this is a logical AND) [NNEWPIX].
ormask - Resampled mask. For each mask bit, set that bit if any
of the input spectra at this wavelength has that bit set
(e.g., this is a logical OR) [NNEWPIX].
newdisp - Resampled dispersion values [NNEWPIX].
newsky - Resampled sky flux [NNEWPIX].
COMMENTS:
One can pass this routine a single spectrum to be fit by a spline and
re-sampled, in which case all the inputs (such as FLUX) are 1-dimensional
arrays. Or, one can pass it several spectra, in which case these inputs
are 2-dimensional arrays.
There's also some code in here to grow masked regions by another pixel
on either end if the region is more than 3 pixels wide.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
bspline_iterfit()
bspline_valu()
djs_laxisgen()
djs_maskinterp()
djs_median()
pixelmask_bits()
splog
REVISION HISTORY:
02-Jan-2000 Written by D. Schlegel; modified from COMBINE2DOUT
(See pro/spec2d/combine1fiber.pro)
NAME:
computechi2
PURPOSE:
Solve the linear set of equations Ax=b using SVD
CALLING SEQUENCE:
chi2 = computechi2( bvec, sqivar, amatrix, $
[ acoeff=, dof=, yfit=, covar=, var= ] )
INPUTS:
bvec - b vector in Ax=b [N]
sqivar - Errors in b as 1/sigma [N]
amatrix - A matrix in Ax=b [N,M]
OPTIONAL INPUTS:
OUTPUTS:
chi2 - Chi^2 of the fit
OPTIONAL OUTPUTS:
acoeff - Fit parameters x in Ax=b [M]
dof - Degrees of freedom in the fit, equal to the number of
equations where SQIVAR is not zero minus the number of
fit parameters (M)
yfit - Evaluation of the best-fit at each data point [N]
covar - Covariance matrix [M,M]
var - Variances [M], which is equivalent to the diagonal
entries of COVAR
COMMENTS:
EXAMPLES:
The following example creates a data vector with 20 measurements
and their errors. A linear fit is performed using the LINFIT()
function and this function, which are equivalent:
n = 20
x = dindgen(n)
y = 10.d0 * smooth(randomu(-1234,n),10)
sqivar = 0.5 + randomu(-4321,n)
acoeff = linfit(x,y,measure_errors=1./sqivar,covar=covar)
print, acoeff, covar
templates = [[dblarr(n)+1],[dindgen(n)]]
chi2 = computechi2(y,sqivar,templates,acoeff=acoeff,covar=covar)
print, acoeff, covar
BUGS:
PROCEDURES CALLED:
REVISION HISTORY:
07-Aug-2000 Written by D. Schlegel, Princeton
(See pro/spec1d/computechi2.pro)
NAME: correct_dlam PURPOSE: Correct ADU/pixel to ADU/d(log-lambda) CALLING SEQUENCE: correct_dlam, flux, fluxivar, wset, dlam=dlam INPUTS: flux - Flux fluxivar - Flux inverse variance wset - Wavelength coefficient trace-set OPTIONAL KEYWORDS: dlam - Log-lambda pixel size to convert to; default to 1.0d-4 OUTPUTS: flux - (Modified.) fluxivar - (Modified.) OPTIONAL OUTPUTS: COMMENTS: Make a map of the size of each pixel in delta-(log10-Angstroms), and re-normalize the flux to ADU/d(log10-Angstroms). EXAMPLES: BUGS: PROCEDURES CALLED: divideflat traceset2xy REVISION HISTORY: 04-Oct-2000 Written by S. Burles, FNAL
(See pro/spec2d/correct_dlam.pro)
NAME: daytime_test PURPOSE: Look for spectro exposures taken during the day and not marked as test. CALLING SEQUENCE: daytime_test INPUTS: OPTIONAL INPUTS: OUTPUT: OPTIONAL OUTPUTS: COMMENTS: Find all the files matching '$RAWDATA_DIR/$MJD/sdR-b1-????????.fit*', and print a warning message for any science, flat, or arc exposures that are not marked as test exposures, and were taken during the daytime. The warnings are also printed to the file 'daytime.log'. EXAMPLES: BUGS: PROCEDURES CALLED: djs_diff_angle() get_mjd_dir() get_tai headfits() sdsshead() splog sunpos sxpar() zenpos INTERNAL SUPPORT PROCEDURES: daytime_test1 REVISION HISTORY: 27-Apr-2003 Written by David Schlegel, Princeton (not checked in then)
(See pro/plan/daytime_test.pro)
NAME:
design_multiplate
PURPOSE:
Routine to design a plate with several pointings.
CALLING SEQUENCE:
design_multiplate, stardata, [ tilenums=, platenums=, racen=, deccen=, $
guidetiles=, apotemperature=apotemperature, /addfund, /norename ]
INPUTS:
stardata - Structure with data for each star; must contain the
fields RA, DEC, MAG[5], PRIORITY, HOLETYPE, TILENUM.
HOLETYPE can be either 'OBJECT' or 'GUIDE'; objects with
other values are ignored. Other elements in the structure
will be copied into the output plug-map files.
If OBJTYPE is not passed in this structure, then it is set to
'SERENDIPITY_MANUAL' for all HOLETYPE='OBJECT'.
Stars with TILENUM=0 can only be used as guide stars.
racen - RA center for each tile
deccen - DEC center for each tile
OPTIONAL INPUTS:
tilenums - Array of tile numbers; default to the unique list of
tile numbers in STARDATA.TILENUM, but exclude the number zero.
platenums - Array of plate numbers; default to the same as TILENUMS.
guidetiles - Tile number for each of the 11 guide fibers. There exist
default values for the cases 1,2,3 or 4 tiles.
apotemperature - Design temperature for APO; default to 5 deg C.
addfund - If set, then add one more tile+plate with 9 or 10 holes
in a line of declination from guide fiber #11 for the
nearest of the 5 SDSS fundamental standard stars.
We try to place 10 of these holes, spaced by 1 arcmin, but
one can be knocked out by the guide-fiber alignment hole.
This tile is given the TILEID=max(TILEID)+1, PLATEID=0.
norename - The default is to rename the output plugMapP files to
plate names like 800,800B,800C,... if the first plate
number is 800. Set this keyword to keep the names as
they are passed in PLATENUMS.
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
There is no attempt to move plate centers such that a guide fiber
can be re-used in another pointing.
Objects are assigned according to their priority. If none are specified
with STARDATA.PRIORITY, then random priorities between 1 and 100 are
assigned. We reserve priorities of 0 and [2^31-2,2^31] for internal
purposes.
EXAMPLES:
BUGS:
These SDSS primary standards coordinates were not quite correct
in the design of the initial set of special plates. See the comments
in the code.
PROCEDURES CALLED:
concat_dir()
cpbackup
current_mjd()
djs_diff_angle()
djs_laxisgen()
plate_rotate
yanny_free
yanny_par()
yanny_read
yanny_write
INTERNAL SUPPORT ROUTINES:
design_append()
REVISION HISTORY:
21-Nov-2001 Written by D. Schlegel, Princeton
(See pro/plate/design_multiplate.pro)
NAME:
design_plate
PURPOSE:
Routine to design a single plate.
CALLING SEQUENCE:
design_plate, stardata, [ racen=, deccen=, tilenum=, platenum=, $
airtemp=, nstd=, nminsky=, nextra=, ngtarg=, /southern ]
INPUTS:
stardata - Structure with data for each star; must contain the
fields RA, DEC, MAG[5], HOLETYPE, OBJTYPE.
HOLETYPE should be either 'OBJECT' or 'GUIDE'.
Special values of OBJTYPE are 'SKY' and 'SPECTROPHOTO_STD'.
Other elements in the structure (such as PRIMTARGET,...)
will be copied into the output plug-map files.
racen - RA center for tile
deccen - DEC center for tile
OPTIONAL INPUTS:
tilenum - Tile number; default to 1.
platenum - Plate number; default to the same as TILENUMS.
airtemp - Design temperature for APO; default to 5 deg C.
nstd - Number of spectro-photo standards; default to 8.
This will be split with NSTD/2 standards on the North
half of the plate, and the same number on the South.
nminsky - Minimum number of sky fibers; default to 32.
nextra - Number of extra fibers to assign, beyond the 640 science
fibers. In principle, this should be 0. In practice,
the "fiberPlates" code in the PLATE product will either
crash or multiply-assign fibers to the same object unless
there are extra objects. Default to 10.
ngtarg - Number of times to target a guide star for each guide
star position; default to 1 (e.g., exactly 11 guide stars).
Selecting more gives the PLATE code more options, and
may prevent it from crashing in some cases.
southern - If set, then set the Southern target-selection bit
in both PRIMTARGET and SECTARGET for all objects.
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
Priorities can be specified with PRIORITY in the input structure;
otherwise, they are assigned randomly.
We always assign guide stars first, then spectro-photo standards,
then objects, then skies. So the priorities are relevant only
within each of those categories.
This script generates the following files:
plObs.par
plPlan.par
plPlugMapT-$TILE.par
The commands from the SDSS "plate" product generate the following files:
makePlates - Generate plPlugMapP-$PLATE.par
fiberPlates - Generate plOverlay-$PLATE.par, and **overwrite**
the file plPlugMapP-$PLATE.par
makeFanuc - Generate plFanuc-$PLATE.par
makeDrillPos - Generate plMeas-$PLATE.par, plDrillPos-$PLATE.par
use_cs3 - Generates no files. Simply reports fiber collisions.
makePlots - Generate plOverlay-$PLATE.ps
When there is a problem, the "fiberPlates" script outputs error
messages like:
collision at 554 = {307 125 6 160 47} OBJECT with...
collision at 565 = {307 125 2 168 4015} COHERENT_SKY with...
EXAMPLES:
BUGS:
PROCEDURES CALLED:
concat_dir()
current_mjd()
djs_diff_angle()
splog
yanny_readone()
yanny_write
INTERNAL SUPPORT ROUTINES:
radec_to_xyfocal
design_append()
REVISION HISTORY:
14-Jan-2002 Written by D. Schlegel, Princeton
(See pro/plate/design_plate.pro)
NAME:
divideflat
PURPOSE:
Divide an extracted image with a fiber-flat
CALLING SEQUENCE:
divideflat, flux, fflat, [ invvar=, minval=, /quiet ]
INPUTS:
flux - Array of extracted flux from a flat-field image [Nrow,Ntrace]
fflat - Array of flat-field flat-field vectors [Nrow,Ntrace]
OPTIONAL KEYWORDS:
invvar - Inverse variance map for FLUX [Nrow,Ntrace]
minval - Minimum value to consider good for flat-field;
default to 0.03.
quiet - don't print to splog?
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
We no longer utilize or set FIBERMASK
Wherever the fiber is denoted bad in FIBERMASK, or wherever FFLAT is
<= MINVAL, we set FLUX=FLUXIVAR=0.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
splog
REVISION HISTORY:
17-Nov-1999 Written by S. Burles, Chicago
23-Nov-1999 Modified by D. Schlegel, Princeton
(See pro/spec2d/divideflat.pro)
NAME:
djs_iter_sfit
PURPOSE:
Surface-fitting code to tabulated data (with iterateive rejection).
CALLING SEQUENCE:
acoeff = djs_sfit_iter(fval, xval, yval, degreex, degreey, $
sqivar=, yfit=, mask=, maxdev=, maxrej=, $
upper=, lower=, maxiter=, freeiter=, outmask=)
INPUTS:
fval - Function values at XVAL,YVAL.
xval - X coordinate values
yval - Y coordinate values
degreex - Degree of polynomial fit in X; 1 for linear, 2 for quadratic
degreey - Degree of polynomial fit in Y; 1 for linear, 2 for quadratic
OPTIONAL INPUTS:
sqivar - Inverse sigma, which are the weights
mask - Input mask for fitting and rejection (1=good, 0=bad)
maxdev - Rejcet pts w/ abs(data - model) > maxdev (passed to djs_reject)
upper - Rejcet pts w/ data > model + upper*sigma (passed to djs_reject)
lower - Rejcet pts w/ data > model + lower*sigma (passed to djs_reject)
maxiter - Maximum # of rejection iterations
freeiter - Rejected points accumulate for this # of iterations,
then the mask is reset to the input mask
OUTPUTS:
acoeff - Fit coefficients as [DEGREEX+1,DEGREEY+1] array
OPTIONAL OUTPUTS:
yfit - Fit values
outmask - Masked points used in final iteration (1=used, 0=rejected)
COMMENTS:
EXAMPLES:
BUGS:
Doesn't like NaNs
PROCEDURES CALLED:
djs_reject
splog
REVISION HISTORY:
12-Aug-2003 Adapted from djs_sfit by C. Tremonti, Steward Observatory
(See pro/fluxfix/djs_sfit_iter.pro)
NAME: dr1list_best PURPOSE: Determine which plates *should* have been in DR1 that match the tiles of those actually chosen. CALLING SEQUENCE: dr1list_best INPUTS: OPTIONAL INPUTS: OUTPUT: OPTIONAL OUTPUTS: COMMENTS: Outputs are written to the file 'jill.out'. EXAMPLES: BUGS: PROCEDURES CALLED: platelist struct_print REVISION HISTORY: 22-Aug-2002 Written by David Schlegel, Princeton (not checked in then)
(See pro/plan/dr1list_best.pro)
NAME:
elodie_best
PURPOSE:
Find the best-fit Elodie spectrum to a set of spectra.
CALLING SEQUENCE:
res = elodie_best(objflux, objivar, $
hdr=, objloglam0=, objdloglam=, zmin=, zmax=, fitindx= ])
INPUTS:
objflux - Flux for spectra [NPIX,NOBJECT]
objivar - Inverse variance of flux [NPIX,NOBJECT]
OPTIONAL INPUTS:
hdr - FITS header for objects, used to construct the wavelengths
from the following keywords: COEFF0, COEFF1.
Must be specified if OBJLOGLAM0,OBJDLOGLAM are not set.
objloglam0 - Zero-pint of log-10(Angstrom) wavelength mapping of OBJFLUX.
objdloglam - Wavelength spacing for OBJFLUX in log-10(Angstrom).
zmin - Minimum redshift to consider; default to -0.00333
(-1000 km/sec).
zmax - Minimum redshift to consider; default to +0.00333
(+1000 km/sec).
fitindx - If set, then only fit for the objects specified by
these indices. Set to -1 to not fit any objects (but
return empty output structures); default to fitting all.
OUTPUTS:
res - Output structure with result for each object [NOBJECT].
The following elements are from the FITS header of the
best-fit Elodie spectrum:
ELODIE_FILENAME - Filename
ELODIE_OBJECT - Object name
ELODIE_SPTYPE - Spectral type
ELODIE_BV - (B-V) color
ELODIE_TEFF - T_effective
ELODIE_LOGG - Log10(gravity)
ELODIE_FEH - [Fe/H]
ELODIE_Z_MODELERR - The standard deviation in redshift
amongst the 12 best-fit stars
The following elements are from the ZFIND() function:
ELODIE_Z - Redshift
ELODIE_Z_ERR - Redshift error
ELODIE_RCHI2 - Reduced chi^2
ELODIE_DOF - Degrees of freedom for fit
OPTIONAL OUTPUTS:
COMMENTS:
Any stars labelled as possible binary or triple stars are ignored.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
djs_maskinterp()
read_elodie()
splog
sxpar()
zfind()
INTERNAL SUPPORT ROUTINES:
elodie_struct()
REVISION HISTORY:
11-Mar-2002 Written by D. Schlegel, Princeton
(See pro/spec1d/elodie_best.pro)
NAME: extract_boxcar PURPOSE: Extract the total flux within a boxcar window at many positions. CALLING SEQUENCE: fextract = extract_boxcar( fimage, xcen, ycen, [radius=radius] ) INPUTS: fimage - Image xcen - Initial guesses for X centers ycen - Y positions corresponding to "xcen" (expected as integers) OPTIONAL KEYWORDS: radius - Radius of extraction; default to 3.0 OUTPUTS: fextract - Extracted flux at each position specified by (xcen, ycen) OPTIONAL OUTPUTS: COMMENTS: EXAMPLES: PROCEDURES CALLED: Dynamic link to extract_boxcar.c REVISION HISTORY: 24-Mar-1999 Written by David Schlegel, Princeton.
(See pro/spec2d/extract_boxcar.pro)
NAME:
extract_image
PURPOSE:
Extract the fiber profile flux for an entire image
CALLING SEQUENCE:
extract_image(fimage, invvar, xcen, sigma, flux, [finv, yrow=,
ymodel=, fscat=, proftype=, ansimage=,
wfixed=, mask=mask, pixelmask=, reject=, wsigma=,
nPoly=, maxIter=, highrej=, lowrej=,
fitans=, whopping=, /relative,
nband= ])
INPUTS:
fimage - Image [NCOL,NROW]
invvar - Inverse variance [NCOL,NROW]
xcen - Initial guesses for X centers [NROW,NFIBER]
sigma - Input sigma of gaussian profile; default to 1.0 pixels.
This can be a scalar, an [NFIBER] vector, or
an [NROW,NFIBER] array.
OPTIONAL KEYWORDS:
yrow - List of row numbers (0-indexed) to extract; default to all.
proftype - currently, one can only use 1: Gaussian (scalar)
- or 2: Exp Cubic
- or 3: Double Gaussian
- or 4: Exp Cubic with doublewide Gaussian
wfixed - array of 1's and zero's which set which parameters are fixed.
e.g. [1] just gaussian's with fixed width sigma
[1, 1] fit gaussian + sigma correction
[1, 0, 1] fit gaussian + center correction
[1, 1, 1] fit gaussian + sigma and center corrections.
mask - byte mask: 1 is good and 0 is bad [NCOL,NROW]
pixelmask - bits set due to extraction rejection [NROW,NFIBER]
reject - Array setting rejection threshholds; defaults are set
in EXTRACT_ROW().
nPoly - order of chebyshev scattered light background; default to 4
nband - band-width of full covariance fiber profile matrix;
default to 1.
maxIter - maximum number of profile fitting iterations; default to 20
highrej - positive sigma deviation to be rejected (default 10.0)
lowrej - negative sigma deviation to be rejected (default 10.0)
fitans - ratio of profiles to do in single profile fitting
relative - Scale rejection thresholds by reduced chi-squared (default 0)
whopping - traces which have WHOPPINGingly high counts, and need extra
background terms
wsigma - sigma width of whopping profile (exponential, default 25)
oldreject - ???
OUTPUTS:
flux - Total extracted flux in each profile [nRowExtract,NFIBER]
OPTIONAL OUTPUTS:
ansimage - Coefficients of fit for each row [nCoeff,nRow]
mask - Modified by setting the values of bad pixels to 0
finv - Estimated inverse variance each profile [nRowExtract,NFIBER]
ymodel - Model best fit of row [NCOL,NROW]
fscat - Scattered light contribution in each fiber [NROW,NFIBER]
pimage - ???
chisq - Chi^2 of each row [NROW]
COMMENTS:
EXAMPLES:
PROCEDURES CALLED:
calcflux
extract_row()
pixelmask_bits()
splog
REVISION HISTORY:
08-Aug-1999 Written by Scott Burles, Chicago
22-Aug-2000 Added banded-matrix possibility
(See pro/spec2d/extract_image.pro)
NAME:
extract_object
PURPOSE:
Performs all object extraction tasks
0) Locate bright fibers, and test image background
1) 4 Step Optimal extraction
2) Tweak to sky lines
3) Sky subtraction
4) Flux calibration
5) Telluric correction
CALLING SEQUENCE:
extract_object, outname, objhdr, image, invvar, plugsort, wset, $
xarc, lambda, xtrace, fflat, fibermask, proftype=, color=, $
[ widthset=, dispset=, skylinefile=, plottitle=, superflatset=, $
/do_telluric ]
INPUTS:
outname - Name of outputs FITS file
objhdr - Header cards from object image
image - Object image [nx,ny]
invvar - Inverse Variance of object image [nx,ny]
plugsort - Plugmap structure for [ntrace] spectra
wset - Wavelength solution from arc line spectra
xarc - centroids measured in arc line spectra
lambda - air wavelengths corresponding to xarc
xtrace - spatial traces from flat field
fflat - 1d flat field vectors
fibermask - Fiber status bits, set nonzero for bad status [NFIBER]
proftype - Which type of profile should we use, (default=1 Gaussian)
superflatset- If present, then divide by median superflat! ???
color - ???
widthset - ???
dispset - ???
skylinefile- ???
REQUIRED KEYWORDS:
color - camera color (red or blue)
OPTIONAL KEYWORDS:
plottitle - Prefix for titles in QA plots.
do_telluric- If set, then perform telluric-corrections for the red CCDs;
the default is to no longer do this, because the v5 code
does this in the later flux-calibration steps
OUTPUTS:
A fits file is output in outname, which contains
FLOAT flambda [NX,NTRACE]
FLOAT flambda_invvar [NX,NTRACE]
LONG finalmask [NX,NTRACE]
STRUCT vacuum wavelengths
STRUCT wavelength dispersion
STRUCT plugmap [NTRACE]
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
BUGS:
PROCEDURES CALLED:
calcscatimage()
divideflat
djs_median()
djs_oplot
djs_plot
extract_boxcar()
extract_image
fibermask_bits()
fitsn()
fitvacset()
get_tai
heliocentric()
locateskylines
mwrfits
pixelmask_bits()
qaplot_scatlight
qaplot_skydev
qaplot_skyline
qaplot_skyshift
qaplot_skysub
skyline_dispersion()
skysubtract
smooth_halo2d()
spadd_guiderinfo
splog
sxaddpar
sxpar()
telluric_corr
traceset2xy
find_whopping()
INTERNAL SUPPORT ROUTINES:
REVISION HISTORY:
24-Jan-2000 Written by S. Burles, Chicago
26-Jul-2001 Also pass proftype and superflatset
(See pro/spec2d/extract_object.pro)
NAME:
extract_profile
PURPOSE:
Extract the flux with profile weighting at centroid positions.
CALLING SEQUENCE:
fextract = extract_profile( fimage, invvar, xcen, ycen,
[ferror=ferror, fscattered=fscattered, fwidth=fwidth,
sigma=sigma, nPoly=nPoly, maxIter=maxIter,
refit=refit, highrej=highrej, lowrej=lowrej, boxap=boxap])
INPUTS:
fimage - Image[nCol,nRow]
invvar - Inverse Variance[nCol,nRow]
xcen - Initial guesses for X centers[nFibers,nRow]
ycen - Y positions corresponding to "xcen[nFibers]" [nRow]
OPTIONAL KEYWORDS:
ferror - error array (-1 if bad pixel)
fscattered - scattered light contribution
fwidth - final profile width used
sigma - sigma of gaussian profile; default to 1.0
nPoly - order of chebyshev scattered light background; default to 5
maxIter - maximum number of profile fitting iterations; default to 5
refit - order of chebyshev to fit to profile widths vs. row,
default is 0, which does no refitting
highrej - positive sigma deviation to be rejected (default 5.0)
lowrej - negative sigma deviation to be rejected (default 5.0)
boxap - boxcar aperture size in pixels
default is 0, which does no boxcar extraction
OUTPUTS:
fextract - Extracted flux at each position specified by (xcen, ycen)
[nFibers,nRow]
2: Scattered light estimate
3: Final profile width
4: Boxcar extracted flux
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
PROCEDURES CALLED:
Dynamic link to extract_profile.c
REVISION HISTORY:
24-Mar-1999 David Schlegel, Princeton.
24-Jun-1999 Stolen and modified by Scott Burles, Chicago.
(See pro/spec2d/extract_profile.pro)
NAME:
extract_row
PURPOSE:
Fit the fiber profiles and background in a single row with least squares
CALLING SEQUENCE:
ans = extract_row( fimage, invvar, xcen, sigma, [ymodel=, fscat=,
proftype=, wfixed=, inputans=, iback=, bfixarr=, xvar=,
mask=, relative=, diagonal=, fullcovar=, wfixarr=, npoly=,
maxiter=, lowrej=, highrej=, niter=, squashprofile=,
whopping=, wsigma=, pixelmask=, reject=, reducedChi=,
nBand= ])
INPUTS:
fimage - Vector [nCol]
invvar - Inverse variance [nCol]
xcen - Initial guesses for X centers [nFiber]
sigma - Sigma of gaussian profile; (scalar or [nFiber])
OPTIONAL KEYWORDS:
proftype - Select profile type:
1: Gaussian
2: (exponential)^3
3: (exponential)^2.5
Default to 1.
inputans - Input fit, excluding background and whopping terms
[ncoeff*nFiber]
The array is sorted as follows:
[ncoeff] values for fiber #0
...
[ncoeff] values for fiber #(nFiber-1)
relative - Set to use reduced chi-square to scale rejection threshold
squashprofile - ???
npoly - Order of chebyshev scattered light background; default to 5
nband - Band-width of covariance matrix of fiber profiles: default 1
maxiter - Maximum number of profile fitting iterations; default to 10
lowrej - Negative sigma deviation to be rejected; default to 5
highrej - Positive sigma deviation to be rejected; default to 5
whopping - X locations to center additional "whopping" terms to describe
the exponentail tails of flux near bright fibers; default
to -1, which means not to use any such terms.
wsigma - Sigma width for exponential whopping profiles; default to 25
reject - Three-element array setting partial and full rejection
thresholds for profiles; default [0.2, 0.6, 0.6].
When there is less than REJECT[2] of the area is left,
then drop fitting of all higher-order terms.
When there is less than REJECT[1] of the area is left,
then the pixel is rejected (inverse variance is set to 0).
When there is less than REJECT[0] of the area is left,
then assume that there's no fiber there, and don't fit
for that fiber at all.
MODIFIED INPUTS (OPTIONAL):
wfixed - Array to describe which parameters to fix in the profile;
0=fixed, 1=float; default to [1].
The number of parameters to fit per fiber is determined
this way; e.g. nCoeff = n_elements(wfixed), so the default
is to fit only 1 parameter per fiber. For the (default)
Gaussian profile, this is the height of the Gaussian.
Note that WFIXED is used to build the array WFIXARR.
iback - 1D array of input background coeff
(needed if fixed parameters are non-zero)
bfixarr - 1D integer array to specify which terms of the background
coefficients to fix; 0=fixed, 1=float.
wfixarr - 1D integer array to specify which parameters in the full fit
to fix; 0=fixed, 1=float.
The array is sorted as follows:
[ncoeff] values for fiber #0
...
[ncoeff] values for fiber #(nFiber-1)
[npoly] values for the background polynomial terms
[whoppingct] values for the whopping terms
xvar - X values of fimage and invvar; default is findgen(NX).
mask - Image mask: 1=good, 0=bad [NX]
pixelmask - Bits set for each fiber due to extraction rejection [nFiber]
OUTPUTS:
ans - Output fit [ncoeff*nFiber+npoly+whoppingct]
The array is sorted as follows:
[nFiber] values for coefficient #0
...
[nFiber] values for coefficient #(nCoeff-1)
[npoly] values for the background polynomial terms
[whoppingct] values for the whopping terms
Note this array is **not** sorted as INPUTANS or WFIXARR!
OPTIONAL OUTPUTS:
ymodel - Evaluation of best fit [nCol]
fscat - Scattered light contribution in each fiber [nFiber]
diagonal - 1D diagonal of covariance matrix. Currently, this is
the diagonal from the Cholesky decompostion, which is
1/error[j]. [ncoeff*nFiber+npoly+whoppingct]
fullcovar - 2D covariance matrix. This is a symmetric matrix, and we
only fill the lower triangle. Computing this increases CPU
time by a factor of 2 or 3.
niter - Number of rejection iterations performed
reducedChi - Reduced chi ???
COMMENTS:
BUGS:
Still need to do:
limits on chebyshev polynomial are assumed to be 0.0 <--> nx
these may need to be optional if only partial rows are being fit
Error codes need to be returned, currently no such codes are returned
EXAMPLES:
PROCEDURES CALLED:
Dynamic link to extract_row.c
REVISION HISTORY:
8-Aug-1999 Written by Scott Burles, Chicago
(See pro/spec2d/extract_row.pro)
NAME:
extract_row
PURPOSE:
Fit the fiber profiles and background in a single row with least squares
Wrapper to extract row, which does extra testing
CALLING SEQUENCE:
ans = extract_row_safe( fimage, invvar, xcen, sigma, [ymodel=, fscat=,
proftype=, wfixed=, inputans=, iback=, bfixarr=, xvar=,
mask=, relative=, diagonal=, fullcovar=, wfixarr=, npoly=,
maxiter=, lowrej=, highrej=, niter=, squashprofile=,
whopping=, wsigma=, pixelmask=, reject=, reducedChi= ])
INPUTS:
fimage - Vector [nCol]
invvar - Inverse variance [nCol]
xcen - Initial guesses for X centers [nFiber]
sigma - Sigma of gaussian profile; (scalar or [nFiber])
OPTIONAL KEYWORDS:
proftype - Select profile type:
1: Gaussian
2: (exponential)^3
3: (exponential)^2.5
Default to 1.
inputans - Input fit, excluding background and whopping terms
[ncoeff*nFiber]
The array is sorted as follows:
[ncoeff] values for fiber #0
...
[ncoeff] values for fiber #(nFiber-1)
relative - Set to use reduced chi-square to scale rejection threshold
squashprofile - ???
npoly - Order of chebyshev scattered light background; default to 5
maxiter - Maximum number of profile fitting iterations; default to 10
lowrej - Negative sigma deviation to be rejected; default to 5
highrej - Positive sigma deviation to be rejected; default to 5
whopping - X locations to center additional "whopping" terms to describe
the exponentail tails of flux near bright fibers; default
to -1, which means not to use any such terms.
wsigma - Sigma width for exponential whopping profiles; default to 25
reject - Two-element array setting partial and full rejection
thresholds for profiles; default [0.8, 0.2].
What does this mean???
When this was hardwired, it was [0.8,0.4].
MODIFIED INPUTS (OPTIONAL):
wfixed - Array to describe which parameters to fix in the profile;
0=fixed, 1=float; default to [1].
The number of parameters to fit per fiber is determined
this way; e.g. nCoeff = n_elements(wfixed), so the default
is to fit only 1 parameter per fiber. For the (default)
Gaussian profile, this is the height of the Gaussian.
Note that WFIXED is used to build the array WFIXARR.
iback - 1D array of input background coeff
(needed if fixed parameters are non-zero)
bfixarr - 1D integer array to specify which terms of the background
coefficients to fix; 0=fixed, 1=float.
wfixarr - 1D integer array to specify which parameters in the full fit
to fix; 0=fixed, 1=float.
The array is sorted as follows:
[ncoeff] values for fiber #0
...
[ncoeff] values for fiber #(nFiber-1)
[npoly] values for the background polynomial terms
[whoppingct] values for the whopping terms
xvar - X values of fimage and invvar; default is findgen(NX).
mask - Image mask: 1=good, 0=bad [NX]
pixelmask - Bits set for each fiber due to extraction rejection [nFiber]
OUTPUTS:
ans - Output fit [ncoeff*nFiber+npoly+whoppingct]
The array is sorted as follows:
[nFiber] values for coefficient #0
...
[nFiber] values for coefficient #(nCoeff-1)
[npoly] values for the background polynomial terms
[whoppingct] values for the whopping terms
Note this array is **not** sorted as INPUTANS or WFIXARR!
OPTIONAL OUTPUTS:
ymodel - Evaluation of best fit [nCol]
fscat - Scattered light contribution in each fiber [nFiber]
diagonal - 1D diagonal of covariance matrix. Currently, this is
the diagonal from the Cholesky decompostion, which is
1/error[j]. [ncoeff*nFiber+npoly+whoppingct]
fullcovar - 2D covariance matrix. This is a symmetric matrix, and we
only fill the lower triangle. Computing this increases CPU
time by a factor of 2 or 3.
niter - Number of rejection iterations performed
reducedChi - Reduced chi ???
COMMENTS:
BUGS:
Still need to do:
limits on chebyshev polynomial are assumed to be 0.0 <--> nx
these may need to be optional if only partial rows are being fit
Error codes need to be returned, currently no such codes are returned
EXAMPLES:
PROCEDURES CALLED:
Dynamic link to extract_row.c
REVISION HISTORY:
4-Feb-1999 Written by Schlegel
(See pro/spec2d/extract_row_safe.pro)
NAME:
fcalib_default
PURPOSE:
Return a default flux-calibration vector
CALLING SEQUENCE:
calibfac = fcalib_default(camname, loglam, [exptime] )
INPUTS:
camname - Camera name; 'b1', 'b2', 'r1' or 'r2'
loglam - Wavelengths [log-10 Angstroms]
OPTIONAL INPUTS:
exptime - Rescale the fluxing vector to this exposure time [sec];
default to the value in the spFluxcalib file header
(probably 900 sec)
OUTPUTS:
calibfac - Flux-calibration values, set to 0 if outside
the knonwn wavelengths; the spectra in ADU should be
divided by this
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
BUGS:
DATA FILES:
$IDLSPEC2D_DIR/examples/spFluxcalib-$CAMERA.fits
PROCEDURES CALLED:
bspline_valu()
headfits()
mrdfits()
sxpar()
REVISION HISTORY:
17-Dec-2005 Written by D. Schlegel, LBL
(See pro/spec2d/fcalib_default.pro)
NAME:
fiberflat
PURPOSE:
Construct the flat-field vectors from an extracted flat-field image.
CALLING SEQUENCE:
fflat = fiberflat( flux, fluxivar, wset, [ fibermask=fibermask, $
minval=, ncoeff=, pixspace=, /dospline, nord=, lower=, upper=,
/dospline, /nonorm, plottitle= ])
INPUTS:
flux - Array of extracted flux from a flat-field image [Nrow,Ntrace]
fluxivar - Inverse variance map for FLUX.
wset - Wavelength solution
OPTIONAL KEYWORDS:
fibermask - Fiber status bits, set nonzero for bad status [NFIBER]
minval - Minimum value to use in fits to flat-field vectors;
default to 3% of the median of FLUX.
ncoeff - Number of coefficients used in constructing FFLAT;
default to 3 (cubic)
pixspace - Approximate spacing in pixels for break points in the
spline fits to individual fibers; default to 10 pixels.
dospline - If this keyword is set, then fit the flat-field vectors
to splines (using PIXSPACE) rather than to a Legendre
polynomial (using NCOEFF).
This is now what we use?
plottitle - Title for QA plot; if not set, then do not plot.
nonorm - Do not normalize the fluxes in FFLAT by the super-flat.
superflatset-Bspline set to reconstruct superflat
PARAMETERS FOR SLATEC_SPLINEFIT:
nord
lower
upper
OUTPUTS:
fflat - Array of flat-field flat-field vectors for each fiber
that remove relative flat-field variations as a function
of wavelength between fibers [Nrow, Ntrace]
OPTIONAL OUTPUTS:
fibermask - (Modified)
COMMENTS:
The user should first "flat-field" the input array to take out
pixel-to-pixel variations.
The parameters for SLATEC_SPLINEFIT are only used when generating the
"superflat".
The 'BADFLAT' bit is set in FIBERMASK if the mean throughput for
a fiber is less than 0.7 times the median of all good-fiber throughputs.
In any given fiber, set FFLAT=0 wherever there are at least 5 contiguous
bad pixels.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
fibermask_bits()
bspline_valu()
bspline_iterfit()
splog
superflat()
traceset2xy
xy2traceset
REVISION HISTORY:
14-Oct-1999 Written by D. Schlegel, APO
3-Oct-2000 Changed over to IDL bspline routines
(See pro/spec2d/fiberflat.pro)
NAME:
fibermask_bits
PURPOSE:
Return mask value corresponding to a mask condition for FIBERMASK.
CALLING SEQUENCE:
mask = fibermask_bits(label)
INPUTS:
label - String name specifying bit
OUTPUTS:
mask - Signed long set to 2^BIT, with BIT specified by LABEL.
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
mask = fibermask_bits('NOPLUG')
BUGS:
PROCEDURES CALLED:
pixelmask_bits()
REVISION HISTORY:
23-Jan-2000 Written by S. Burles, Chicago
14-Jul-2000 Combine with PIXELMASK_BITS() (DJS).
(See pro/spec2d/fibermask_bits.pro)
NAME: fiber_rollcall PURPOSE: Print the "roll call" of how many plug-map bits are set. CALLING SEQUENCE: fiber_rollcall, andmask, loglam INPUTS: andmask - Bit mask loglam - Wavelength mapping in log10(Ang) OPTIONAL INPUTS: OUTPUTS: OPTIONAL OUTPUTS: COMMENTS: EXAMPLES: BUGS: DATA FILES: PROCEDURES CALLED: splog sdss_flagname() INTERNAL SUPPORT ROUTINES: REVISION HISTORY: 17-Feb-2004 Written by D. Schlegel & S. Burles; copied from PLATESN.
(See pro/spec2d/fiber_rollcall.pro)
NAME: filter_check PURPOSE: Fit for the filter curves by comparing photometry and spectrophotometry CALLING SEQUENCE: filter_check,spallfile,binboundsfile INPUTS: spallfile - spectro info OPTIONAL INPUTS: binboundsfile - bin boundaries OPTIONAL KEYWORDS: OUTPUTS: binRfile - file containing output stuff COMMENTS: BUGS: EXAMPLES: PROCEDURES CALLED: DATA FILES: REVISION HISTORY: 05-APr-2000 Written by M. Blanton, Fermiland
(See pro/spec1d/filter_check.pro)
NAME: filter_check_chi2 PURPOSE: Calculate the chi^2 for a particular set of bandpass residuals. CALLING SEQUENCE: chi2 = filter_check_chi2(binflux, binR, photocounts) INPUTS: binflux - binned flux binR - parameters to use for flux photocounts - psf_band + (fiber_r-psf_r) (not dereddened) OPTIONAL INPUTS: OPTIONAL KEYWORDS: OUTPUTS: chi2 - resulting chi2 COMMENTS: BUGS: EXAMPLES: PROCEDURES CALLED: DATA FILES: REVISION HISTORY: 05-APr-2000 Written by M. Blanton, Fermiland
(See pro/spec1d/filter_check_chi2.pro)
NAME:
filter_select
PURPOSE:
Gather spectra based on an input file of the form
created by platemerge (the spAll file). Calculate the
ugriz throughput for each object in the plates, possibly
putting limits on target type, MJD, or signal-to-noise
(essentially by requiring survey quality).
CALLING SEQUENCE:
filter_select, spallfile, outfile, [mjdlimits= , primtarget=,
filter_prefix=, mingisn2=, rpsfmodel=]
INPUTS:
spallfile - spAll.fit file as created by platemerge
filter_prefix - Use alternate prefix for filter curves to use
(allowed are sdss or doi)
OPTIONAL INPUTS:
OPTIONAL KEYWORDS:
mjdlimits - Only look in a certain range of MJDs
primtarget - Require a certain target type
mingisn2 - Minimum plate SN^2 in g AND i
OUTPUTS:
outfile - Fits file with all the spAll.fit info, but with
synthetic ugriz replaced with the desired filter
curves
COMMENTS:
BUGS:
Depends on spec_append, internal routine of readspec
EXAMPLES:
PROCEDURES CALLED:
filter_thru()
spec_append
readspec
mrdfits()
mwrfits
REVISION HISTORY:
05-APr-2000 Written by M. Blanton, Fermiland
(See pro/spec1d/filter_select.pro)
NAME: filter_solve PURPOSE: Minimize the chi^2 by varying the filter residuals. Basically solve Ax=b. CALLING SEQUENCE: filter_solve,binflux,photocounts,binR INPUTS: binflux - binned flux photocounts - psf_band + (fiber_r-psf_r) (not dereddened) OPTIONAL INPUTS: OPTIONAL KEYWORDS: OUTPUTS: binR - best fit filter parameters COMMENTS: BUGS: EXAMPLES: PROCEDURES CALLED: DATA FILES: REVISION HISTORY: 05-APr-2000 Written by M. Blanton, Fermiland
(See pro/spec1d/filter_solve.pro)
NAME:
filter_thru
PURPOSE:
Compute throughput in SDSS filters
CALLING SEQUENCE:
res = filter_thru( flux, [waveimg=, wset=, mask=, filter_prefix=, /toair ])
INPUTS:
flux - Flux image [NX,NTRACE]
OPTIONAL INPUTS:
OPTIONAL KEYWORDS:
waveimg - Wavelength image in Angstroms [NX,NTRACE], or this could
be a single vector if the wavelength mapping is the same
for all traces (note the latter is faster to compute)
wset - Wavelength solution in log-lambda; required if WAVEIMG not set
mask - Linearly interpolate over pixels where MASK is nonzero.
[NX,NTRACE]
filter_prefix - Use alternate prefix for filter curves to use
(allowed are sdss, doi, sdss_jun2001) [sdss_jun2001]
toair - Convert the wavelengths to air from vacuum before computing
OUTPUTS:
res - Integrated response in all 5 SDSS filters, ordered ugriz;
dimensions are [NTRACE,5] or [5] if NTRACE=1.
COMMENTS:
The filter curve files are assumed to be in $IDLUTILS_DIR/data/filters.
EXAMPLES:
BUGS:
Needs waveimg to be equally spaced in log lambda (MRB 4.5.01) ???
Now calculates pixel size in log lambda to do correct spectrophotometry
PROCEDURES CALLED:
vactoair
djs_maskinterp()
readcol
traceset2xy
REVISION HISTORY:
10-Mar-2000 Written by D. Schlegel, Princeton
05-Apr-2001 Modified by Michael Blanton to allow alternate filters
(See pro/spec2d/filter_thru.pro)
NAME:
findspec
PURPOSE:
Routine for finding SDSS spectra that match a given RA, DEC.
CALLING SEQUENCE:
findspec, [ra, dec, infile=, outfile=, searchrad=, slist=, $
/best, /print ]
INPUTS:
OPTIONAL INPUTS:
ra - Right ascension; scalar or array in degrees.
dec - Declination; scalar or array in degrees.
infile - Input file with RA, DEC positions, one per line.
If set, then this over-rides values passed in RA,DEC.
outfile - If set, then print matches to this file.
searchrad - Search radius in degrees; default to 3./3600 (3 arcsec).
best - If set, then return the best match for each location, where
best is defined to be the closest object on the plate with
the best S/N.
This also forces the return of one structure element in SLIST
per position, so that you get exactly a paired list between
RA,DEC and SLIST.
print - If set, then print matches to the terminal.
OUTPUTS:
OPTIONAL OUTPUTS:
slist - Structure containing information for each match.
COMMENTS:
The search radius is set to within 1.55 degress of a plate center,
then within 3 arcsec of an object.
EXAMPLES:
Make a file "file.in" with the following two lines:
218.7478 -0.3745007
217.7803 -0.8900855
Then run the command:
IDL> findspec,infile='file.in'
This should print:
PLATE MJD FIBERID RA DEC
----- ----- ------- ------------- --------------
306 51637 101 218.7478 -0.3745007
306 51637 201 217.7803 -0.8900855
BUGS:
PROCEDURES CALLED:
djs_readcol
djs_diff_angle()
platelist
readspec
struct_print
REVISION HISTORY:
15-Feb-2001 Written by David Schlegel, Princeton.
(See pro/spec1d/findspec.pro)
NAME:
find_nminima
PURPOSE:
Find one or several minima in a vector of chi^2 values.
CALLING SEQUENCE:
xpeak = find_nminima( yflux, [ xvec, dofarr=, nfind=, minsep=, $
width=, ypeak=, xerr=, errcode=, npeak=, plottitle=, /doplot, /debug ]
INPUTS:
yflux - Y values
OPTIONAL INPUTS:
xvec - X values, which must either be sorted in ascending
or descending order; default to 0-indexed integers.
dofarr - If set, then fit to the minima in the function
YFLUX/DOFARR, but avoiding any points where DOFARR
is set to zero.
nfind - Number of minima to find; default to 1. It is possible
to find fewer than NFIND minima.
minsep - Minimum separation between local minima. If a peak
is found closer than MINSEP to an existing peak, then
the latter peak is discarded.
width - Width to use when selecting the points used in the fit.
Only use points where XVEC is within WIDTH of the
the lowest-values point (which is used as the initial
guess); default to using all points.
OUTPUTS:
ypeak - Fit value for either chi^2 or chi^2/DOF at the minima.
If the fit value is less than zero, then change it to zero.
OPTIONAL OUTPUTS:
xerr - Formal errors of XPEAK.
errcode - Error codes for each minima; 0 for no errors in the fit.
npeak - The number of peaks found, between [0,NFIND].
plottitle - Title of plot (if /DOPLOT is set).
doplot - If set, then make plots. Discarded peaks are not plotted.
debug - If set, then wait for keystroke after plot.
COMMENTS:
This routine calls SVDFIT for fitting quadratics, or MPFIT for
fitting gaussians.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
djs_icolor()
djs_oplot
djs_plot
mpfitpeak
mpfitpeak_gauss
textoidl
INTERNAL SUPPORT ROUTINES:
zfitmin()
REVISION HISTORY:
22-Aug-2001 Written by D. Schlegel, Princeton
30-Jul-2002 Fixed bug - yrange passed twice to djs_plot
(See pro/spec1d/find_nminima.pro)
NAME:
find_unplugged
PURPOSE:
Find all unplugged fibers that still seemed to get a spectrum
in the reduced data.
CALLING SEQUENCE:
find_unplugged, [ mjd_start ]
INPUTS:
OPTIONAL INPUTS:
mjd_start - If specified, then only search plates with MJDs beyond
this date.
OUTPUT:
OPTIONAL OUTPUTS:
COMMENTS:
Identify all spectra in the reduced data that are labelled as NOPLUG
in the plug-map file, but still have a wavelength coverage of
log(wave) > 0.15 in the reduced spectrum. These may be fibers that
were plugged, but missed by the fiber-mapper.
A companion procedure to this is PLUGFILE_UNMAPPED.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
platelist
readspec
splog
REVISION HISTORY:
10-Sep-2003 Written by David Schlegel, Princeton (not checked in then)
(See pro/plan/find_unplugged.pro)
NAME:
find_whopping
PURPOSE:
Use simple medians to detect whopping fibers
Take care to not choose adjacent fibers
CALLING SEQUENCE:
whopping = find_whopping(flux, thresh, whopct)
INPUTS:
flux - Mean/median flux per object [NFIBER]
thresh - Minimum threshold for median counts in whopping fiber;
default 10000.0
OUTPUTS:
whopping - 0-indexed indices of whopping fiber(s)
OPTIONAL OUTPUTS:
whopct - Number of whopping fibers detected
COMMENTS:
EXAMPLES:
BUGS:
PROCEDURES CALLED:
djs_median()
REVISION HISTORY:
24-Jan-2000 Written by S. Burles, Chicago
4-Apr-2001 Moved to its own routine for use by SoS
(See pro/spec2d/find_whopping.pro)
NAME:
fitansimage
PURPOSE:
Convert output from extract_image (ansimage) into a smooth
function of fiber number and row
CALLING SEQUENCE:
fitans = fitansimage(ansimage, nterms, ntrace, npoly, nfirst, yrow, $
tempflux, fluxm = [1,1,0], scatfit=scatfit, $
smallflux, fluxm=fluxm, nord=nord, nscatbkpts=nscatbkpts, $
ymin=ymin, ymax=ymax, fullrows=fullrows)
INPUTS:
ansimage - Keyword Output from extract_image
nterms - number of profile terms
ntrace - Number of fibers (currently hardwired to 320)
npoly - Order of chebyshev polynomial in scattered light
yrow - Array of rows extracted in first pass
smallflux - Flux extracted in first pass
OPTIONAL KEYWORDS:
fluxm - Factor profile terms contribute to total flux
(asymmetric terms are set to zero)
OUTPUTS:
fitans - Smooth version of ansimage (expanded to 2048 rows)
OPTIONAL OUTPUTS:
scatfit - Image of scattered light from smoothing polynomials
COMMENTS:
fitansimage takes the output from extract_image, and smooths
the corresponding parameters of nfibers and npoly with
functions of order nord
EXAMPLES:
BUGS:
PROCEDURES CALLED:
traceset2xy
xy2traceset
REVISION HISTORY:
??-Oct-1999 Written by S. Burles, Chicago
25-Feb-2000 Modified to be more robust (yeah!)
but requires exactly 320 fibers (boo) ???
(See pro/spec2d/fitansimage.pro)
NAME:
fitarcimage
PURPOSE:
Determine wavelength calibration from arclines
CALLING SEQUENCE:
fitarcimage, arc, arcivar, xcen, ycen, wset, [wfirst=, $
color=color, lampfile=lampfile, fibermask=fibermask, $
func=func, aset=aset, ncoeff=ncoeff, lambda=lambda, $
thresh=thresh, row=row, nmed=nmed, /gauss, $
xdif_tset=xdif_tset, bestcorr=bestcorr ]
INPUTS:
arc - Extracted arc spectra with dimensions [NY,NFIBER]
arcivar - Inverse variance of ARC
OPTIONAL KEYWORDS:
color - 'red' or 'blue'; not required if ANS is set
lampfile - Name of file describing arc lamp lines;
default to the file 'lamphgcdne.dat' in $IDLSPEC2D_DIR/etc.
fibermask - Fiber status bits, set nonzero for bad status [NFIBER]
func - Name of fitting function; default to 'legendre'
aset - Trace set for initial wavelength solution in row number ROW.
ncoeff - Number of coefficients in fits. This may be different than
the number of coefficients in the initial guess ASET.
Default to 5.
thresh - Threshhold counts for significant lines;
default to 200 if COLOR='blue' or 500 if COLOR='red'
row - Row to use in initial guess of wavelength solution;
default to (NFIBER-30)/2
nmed - Number of rows around ROW to median filter for initial
wavelengths solution; default to 5
maxdev - max deviation in log lambda to allow (default 1.0e-5=7 km/s)
gauss - Use gaussian profile fitting for final centroid fit
OUTPUTS:
aset - (Modified)
xcen - pixel position of lines [nfiber, nlambda]
ycen - fiber number [nfiber, nlambda]
wset - traceset (pix -> lambda)
OPTIONAL OUTPUTS:
lampfile - Modified from input to include full path name of file
lambda - Returns wavelengths of good lamp lines [Angstroms]
fibermask - (Modified)
xdif_tset - Fit residual of lamp lines to fit positions [pixels]
bestcorr - Correlation coefficient with simulated arc spectrum
wfirst - traceset from first iteration on arc fits
COMMENTS:
Return from routine after computing BESTCORR if XCEN, YCEN and WSET
are not to be returned.
EXAMPLES:
BUGS:
Not making sure that only the same lines are fit for each fiber.
(Different lines can be rejected in xy2traceset.)
THRESH is unused.
TRACESET2PIX maybe returns the transpose of what is natural?
Check QA stuff at end.
FIBERMASK not yet modified if an arc is atrociously bad.
PROCEDURES CALLED:
arcfit_guess()
djs_median
djsig()
fibermask_bits()
trace_crude()
trace_fweight()
traceset2pix()
traceset2xy()
xy2traceset
DATA FILES:
$IDLSPEC2D_DIR/etc/lamphgcdne.dat
REVISION HISTORY:
15-Oct-1999 Written by S. Burles, D. Finkbeiner, & D. Schlegel, APO.
09-Nov-1999 Major modifications by D. Schlegel, Ringberg.
20-Jan-2000 Gone back to very simple procedure: replacement (S. Burles)
(See pro/spec2d/fitarcimage.pro)
NAME:
fitarcimage
PURPOSE:
Determine wavelength calibration from arclines
CALLING SEQUENCE:
fitarcimage, arc, arcivar, xnew, ycen, wset, $
[ color=color, lampfile=lampfile, fibermask=fibermask, $
func=func, aset=aset, ncoeff=ncoeff, lambda=lambda, $
thresh=thresh, row=row, nmed=nmed, $
xdif_tset=xdif_tset, bestcorr=bestcorr ]
INPUTS:
arc - Extracted arc spectra with dimensions [NY,NFIBER]
arcivar - Inverse variance of ARC
OPTIONAL KEYWORDS:
color - 'red' or 'blue'; not required if ANS is set
lampfile - Name of file describing arc lamp lines;
default to the file 'lamphgcdne.dat' in the IDL path.
fibermask - Fiber status bits, set nonzero for bad status [NFIBER]
func - Name of fitting function; default to 'legendre'
aset - Trace set for initial wavelength solution in row number ROW.
ncoeff - Number of coefficients in fits. This may be different than
the number of coefficients in the initial guess ASET.
Default to 5.
thresh - Threshhold counts for significant lines;
default to 200 if COLOR='blue' or 500 if COLOR='red'
row - Row to use in initial guess of wavelength solution;
default to (NFIBER-30)/2
nmed - Number of rows around ROW to median filter for initial
wavelengths solution; default to 5
OUTPUTS:
aset - (Modified)
xnew - pixel position of lines [nfiber, nlambda]
ycen - fiber number [nfiber, nlambda]
wset - traceset (pix -> lambda)
OPTIONAL OUTPUTS:
lampfile - Modified from input to include full path name of file
lambda - Returns wavelengths of good lamp lines [Angstroms]
fibermask - (Modified)
xdif_tset - Fit residual of lamp lines to fit positions [pixels]
bestcorr - Correlation coefficient with simulated arc spectrum
COMMENTS:
Return from routine after computing BESTCORR if XCEN, YCEN and WSET
are not to be returned.
THIS IS REVISION 1.27 OF FITARCIMAGE, SINCE THE CURRENT VERSION
APPEARS TO BE BUGGY!!!
EXAMPLES:
BUGS:
Not making sure that only the same lines are fit for each fiber.
(Different lines can be rejected in xy2traceset.)
THRESH is unused.
TRACESET2PIX maybe returns the transpose of what is natural?
Check QA stuff at end.
FIBERMASK not yet modified if an arc is atrociously bad.
PROCEDURES CALLED:
arcfit_guess()
djs_median
djsig()
trace_crude()
trace_fweight()
traceset2pix()
traceset2xy()
xy2traceset
DATA FILES:
$IDLSPEC2D_DIR/etc/lamphgcdne.dat
REVISION HISTORY:
15-Oct-1999 Written by S. Burles, D. Finkbeiner, & D. Schlegel, APO.
09-Nov-1999 Major modifications by D. Schlegel, Ringberg.
(See pro/spec2d/fitarcimage_old.pro)
NAME:
fitdispersion
PURPOSE:
Fit polynomials to the line width (dispersion axis) for each fiber bundle
CALLING SEQUENCE:
dispset = fitdispersion(arc_flux, arc_fluxivar, xcen, $
[ ncoeff=, sigma=, xmin=, xmax=, medwidth= ] )
INPUTS:
arc_flux - arc image extracted flux
arc_fluxivar - corresponding inverse variance
xcen - xpeaks of arc lines [ntrace,nlines]
OPTIONAL KEYWORDS:
ncoeff - Order of legendre polynomial to apply to width vs. row;
default to 4.
sigma - The SIGMA input to EXTRACT_IMAGE when determining ANSIMAGE;
default to 1.0 pix. This can be a scalar, an [NFIBER] vector,
or an [NLINE,NFIBER] array.
xmin - Lowest row number for trace set; default to 0.
xmax - Highest row number for trace set; default to 2047.
OUTPUTS:
dispset - Traceset structure containing fit coefficients
OPTIONAL OUTPUTS:
medwidth - Median dispersion widths in each of the 4 quadrants
of the CCD, ordered LL,LR,UL,UR.
COMMENTS:
Used to fill arcstruct.dispset, which can then be applied
to PSF-corrected sky subtraction.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
splog
xy2traceset
REVISION HISTORY:
01-Mar-2000 Written by S. Burles, FNAL
(See pro/spec2d/fitdispersion.pro)
NAME:
fitflatwidth
PURPOSE:
Fit a traceset to the first-order corrected width of the flat field
CALLING SEQUENCE:
widthset = fitflatwidth(flux, fluxivar, ansimage, [ fibermask, $
ncoeff=, sigma=, medwidth= ])
INPUTS:
flux - flat-field extracted flux
fluxivar - corresponding inverse variance
ansimage - output from extract image which contains parameter values
OPTIONAL INPUTS:
fibermask - nTrace bit mask, which marks bad fibers
ncoeff - Order of legendre polynomial to apply to width vs. row;
default to 5.
sigma - The SIGMA input to EXTRACT_IMAGE when determining ANSIMAGE;
default to 1.0 pix. This can be a scalar, an [NFIBER] vector,
or an [NROW,NFIBER] array.
OUTPUTS:
widthset - Traceset structure containing fitted coefficients
OPTIONAL OUTPUTS:
medwidth - Median dispersion widths in each of the 4 quadrants
of the CCD, ordered LL,LR,UL,UR.
COMMENTS:
The widths are forced to be the same as a function of row number
for all 16 fibers in each fiber bundle.
Used to fill flatstruct.widthset, which can then be applied
to object extraction (known profile widths).
EXAMPLES:
BUGS:
PROCEDURES CALLED:
xy2traceset
REVISION HISTORY:
01-Mar-2000 Written by S. Burles, FNAL
(See pro/spec2d/fitflatwidth.pro)
NAME:
fitmeanx
PURPOSE:
Return the position where the wavelength should fall (MX) plus
a fitted-function to the deviations from those positions.
CALLING SEQUENCE:
xdiff = fitmeanx(wset, lambda, xpos, aveinvvar, $
nord=, maxdev=, minsdev=, inmask=, mx=)
INPUTS:
wset - Initial wavelength solution for all fibers
lambda - Air wavelengths corresponding to XPOS (in log-10 Angstroms)
[NLINE]
xpos - Centroid positoins of sky lines in object image [NFIBER,NLINE]
OPTIONAL KEYWORDS:
nord - Order of fit to delta x positions; default to 4
maxdev - Max abs difference (in pix) to reject outlying sky line
positions; default to 0.4
minsdev - Minimum standard deviation for computing AVEINVVAR;
default to 0.01 pix.
inmask - Input mask, set to 1 for good points, 0 for bad points
[NFIBER,NLINE]
OUTPUTS:
xdiff - Smooth fit to difference between measured sky positions
and those predicted from arc wavelength solution [NFIBER,NLINE]
OPTIONAL OUTPUTS:
aveinvvar- Weights in xpos, set to zero for rejected positions [NLINE]
mx - Sky line positions predicted from arc line solution
[NFIBER,NLINE]
COMMENTS:
EXAMPLES:
PROCEDURES CALLED:
djs_iterstat
REVISION HISTORY:
19-Oct-1999 Written by S. Burles, Chicago
(See pro/spec2d/fitmeanx.pro)
NAME:
fitredshift
PURPOSE:
Find the most significant correlation peak (soon to be peaks)
return optional keywords in units of pixels
CALLING SEQUENCE:
fitredshift, fluxfft, starfft, $
[ nsearch=, zfit=, z_err=, veldispfit=, veldisp_err=, /doplot ]
INPUTS:
fluxfft - complex fft of prepared galaxy spectrum
fluxerr - error vector for flux (only test if it is zero)
starfft - complex fft of stellar template
starerr - error vector for flux (only test if it is zero)
OPTIONAL KEYWORDS:
nsearch - number of peaks to search, almost always only 1 is searched
zmin - Minimum z (in pixels) to allow (should be < 0)
doplot - plot the correlation peak and fits in an xwindow
OPTIONAL OUTPUTS:
zfit - best fit z, this should evolve into an array of z's
with accompanying z_errs and z_confidences
z_err - centroid errors from gaussfit of correlation peak
veldisp - sigma of cross-correlation peak
veldisp_err- error on sigma
COMMENTS:
Use doplot keyword to see how well peak is being fit
Still need to work on exact selection criteria for MOST significant peak
or even better: measure all peaks with probability > 1%
EXAMPLES:
BUGS:
Hardwired exclusion of blueshifts greater than 100 pixels
this helps the noisiest cases
PROCEDURES CALLED:
findmaxarea
curvefit
gauss_funct
REVISION HISTORY:
25-Mar-2000 Written by S. Burles, FNAL
26-Jun-2000 D. Finkbeiner - modified to properly weight corr
vector for variable overlap
26-Jun-2000 (v 1.5) altered algorithm to set peak search boundary
at the half height of the peak, rather than zero. This fixes
cases where there is a close double peak.
(See pro/spec1d/fitredshift.pro)
NAME:
fitsn
PURPOSE:
Perform a simple parameter fit to log S/N vs magnitude
CALLING SEQUENCE:
coeffs = fitsn(mag, snvec, [ sigrej=, maxiter=, $
fitmag=, colorband=, sigma= ] )
INPUTS:
mag - Fiber magnitudes
snvec - S/N vector for fibers
OPTIONAL KEYWORDS:
sigrej - Sigma rejection threshold; default to 3
maxiter - Maximum number of rejection iterations; default to 5
fitmag - Magnitude range over which to fit (S/N) as function of mag;
no defaults unless COLOR is set.
colorband - If set, then override FITMAG with the following fitting ranges:
'B' : [18.20, 19.70] <-- Used for Son-of-Spectro
'R' : [17.90, 19.40] <-- Used for Son-of-Spectro
'G' : [18.20, 19.70]
'R' : [18.25, 19.75]
'I' : [17.90, 19.40]
The above ranges will be extended to [0,23] if fewer than
20 points are found in the above ranges, but at least 3
good points at any magnitude.
OUTPUTS:
coeffs - Coefficients from fit; return 0 if fit failed
OPTIONAL OUTPUTS:
sigma - Standard deviation of residuals
fitmag - (Modified if COLOR is set)
COMMENTS:
If there are fewer than 3 points, then return COEFFS=0.
This function is called by the following routes in Son-of-Spectro:
APO_PLOTSN -> PLOTSN -> FITSN
QUICKEXTRACT -> FITSN
This function is called by the following routes in Spectro-2D:
PLATESN -> PLOTSN -> FITSN
EXTRACT_OBJECT -> FITSN
EXAMPLES:
BUGS:
PROCEDURES CALLED:
djs_iterstat
REVISION HISTORY:
15-Apr-2000 Written by S. Burles, FNAL
(See pro/spec2d/fitsn.pro)
NAME:
fitvacset
PURPOSE:
Re-fit the wavelength solution in vacuum wavelengths, and applying shifts
to the pixel positions and heliocentric corrections to wavelengths.
CALLING SEQUENCE:
vacset = fitvacset(xpeak, lambda, wset, arcshift, helio=helio)
INPUTS:
xpeak - Arc line centroids
lambda - Corresponding wavelengths
wset - Initial arc line wavelenthh solution; this is only used
to determine the order of the fit (NCOEFF), and the range
of the fit in pixel space (XMIN,XMAX). The vectors XPEAK,
LAMBDA are used to re-fit the wavelength solution itself.
arcshift - Shifts to apply to arc lines in pix [NROW,NTRACE]
OPTIONAL KEYWORDS:
helio - Heliocentric correction to add to velocities in km/s.
OUTPUTS:
vacset - output wavelength solution which includes shift to
sky lines and conversion to vacuum wavelengths
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
PROCEDURES CALLED:
airtovac
splog
xy2traceset
REVISION HISTORY:
20-Jan-2000 Written by S. Burles, Chicago
(See pro/spec2d/fitvacset.pro)
NAME:
fluxcorr_new
PURPOSE:
Compute the frame-by-frame relative scaling for each object on a plate.
CALLING SEQUENCE:
fluxcorr_new, bsmearfile, rsmearfile, bscifile, rscifile, corrfile
INPUTS:
bsmearfile - spFrame fits file chosen as blue smear image
rsmearfile - spFrame fits file chosen as red smear image
bscifile - spFrame fits file(s) blue science image
rscifile - spFrame fits file(s) red science image
corrfile - Fits file to output flux correction vectors.
OPTIONAL KEYWORDS:
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
fluxcorr_new is used to calculate and write to file a low order
polynomial function which registers the flux in the science exposures
to the median flux levels in the smear exposures.
Based on S/N, the produced function per fiber can be given by one
of three methods. For the highest S/N fibers, typically 10\% of the
fibers including spectrophoto stds, the full 3rd order fit is done.
For medium S/N fibers, only a one parameter scaling of the best
spectrophoto correction is produced.
For the lowest S/N fibers, the spectrophoto correction is used without
any scaling. Beware, this means a stellar spectrophoto correction
is applied to all low S/N fibers, even if they are not
seeing-limited targets.
EXAMPLES:
BUGS:
Blue wavelength region is hardwired: b1 = findgen(60)*4.0e-3 + 3.568
Red wavelength region is hardwired : r1 = findgen(54)*4.0e-3 + 3.756
Order of polynomial is hardwired: 3
PROCEDURES CALLED:
djs_iterstat
mrdfits()
mwrfits
pixelmask_bits()
traceset2xy
xy2traceset
INTERNAL SUPPORT ROUTINES:
median_rebin(): Used to rebin spectra in large wavelength blocks
passed in parameter range
REVISION HISTORY:
17-Oct-2000 Written by S. Burles
(See pro/spec2d/fluxcorr_new.pro)
NAME:
flux_distortion
PURPOSE:
Compute the flux-distortion image for an entire plate.
CALLING SEQUENCE:
corrimg = flux_distortion(objflux, objivar, andmask, ormask, plugmap=, $
loglam=, [ minflux=, minobj=, maxdelta=, platefile=, plotfile=, hdr=, $
coeff= ] )
INPUTS:
objflux - Fluxes [NPIX,NFIBER]
objivar - Inverse variances [NPIX,NFIBER]
andmask - AND pixel mask [NPIX,NFIBER]
ormask - OR pixel mask [NPIX,NFIBER]
plugmap - Plug-map structure [NFIBER], where CALIBFLUX,CALIBFLUX_IVAR
will be used in preference over MAG for the photometric fluxes
loglam - Wavelength vector in log10(Ang), which must be the same
for all objects [NPIX]
OPTIONAL INPUTS:
minflux - Minimum flux levels for objects to be used in the fit;
default to 5 nMgy in all three (gri) bands, corresponding
to 20.7-th mag.
minobj - Minimum number of objects that have good fluxes in all
three gri-bands for computing the corrections; default to 50;
if fewer than this many, then CORRIMG is returned with all 1's
maxdelta - Maximum peak deviation in flux distortion image allowed
per iteration from a change in any one parameter; default
to 0.03
platefile - If set, then read OBJFLUX and all the other inputs from
this spPlate file instead of using those inputs;
also, generate PostScript plots using the PLATESN procedure.
plotfile - If set, then make a contour plot of the distortion
corrections to this PostScript file
hdr - If set, then get the PLATE and MJD from this FITS header
OUTPUTS:
corrimg - Flux-distortion image by which OBJFLUX should be multiplied
[NPIX,NFIBER]
OPTIONAL OUTPUTS:
coeff - Best-fit coefficients for the distortion terms
COMMENTS:
The the correction vectors are parameterized in terms of magnitude
(i.e. log-flux) that are achromatic with x, y, x^2, y^2, x*y,
where those are linear coordinates XFOCAL,YFOCAL from the plug-map.
There are also chromatic terms that scale as 1-(5070/wavelength)^2,
since that function gives an equal effect between 3900 and 5070 Ang
as between 5070 ang 9000 Ang.
There are also magnitude offsets as a function of spectrograph ID,
and a chromatic offset as a function of spectrograph ID.
In detail, the formulae is as follows (with 14 terms):
NEWFLUX = FLUX * [1 + a0*(SPECID EQ 1) + a1*(SPECID EQ 2)]
* exp{ a2*x + a3*y + a4*x*y + a5*x^2 + a6*y^2
+ a7*x*LL + a8*y*LL
+ a9*LL*(SPECID EQ 1) + a10*LL*(SPECID EQ 2) }
+ a11*LL^2*(SPECID EQ 1) + a12*LL^2*(SPECID EQ 2) }
where x=XFOCAL, y=YFOCAL, LL = 1 - (5100 Ang/wavelength)^2
EXAMPLES:
BUGS:
PROCEDURES CALLED:
airtovac
dfpsclose
dfpsplot
djs_maskinterp()
djs_oplot
djs_plot
djs_reject()
flux_distort_corrvec()
flux_distort_fn()
linterp
mpfit
platesn
readcol
splog
INTERNAL SUPPORT ROUTINES:
REVISION HISTORY:
17-Feb-2004 Written by D. Schlegel, Princeton
(See pro/spec2d/flux_distortion.pro)
NAME:
focushistory
PURPOSE:
Plot the history of wavelength focus based upon the reduced spPlate files.
CALLING SEQUENCE:
focushistory, [ mjdrange= ]
INPUTS:
OPTIONAL INPUTS:
mjdrange - 2-element vector of plotting range in MJD; default to
using all MJDs.
OUTPUT:
COMMENTS:
A single PostScript file is created "Focushistory-$MJDSTART-$MJDEND.ps".
The plate list must exist for the PLATELIST procedure, and the spPlate
files should be in $SPECTRO_DATA.
EXAMPLES:
Make plots of history of wavelength focus for all time:
IDL> focushistory
Make plots of history of wavelength focus between MJD 52000 and MJD 52100:
IDL> focusistory, mjdrange=[5200,52100]
BUGS:
PROCEDURES CALLED:
dfpsclose
dfpsplot
djs_icolor()
fileandpath()
mjd2datelist
platelist
readspec
splog
yanny_free
yanny_par()
yanny_read
REVISION HISTORY:
21-Mar-2002 Written by David Schlegel, Princeton.
(See pro/apo2d/focushistory.pro)
NAME:
fourier_difference
PURPOSE:
Perform a chi2 fit to the fourier difference between a single
galaxy and a broadened stellar template to calculate velocity dispersion
and uncertainty on velocity dispersion
CALLING SEQUENCE:
answers = fourier_difference(galfft, starfft, galvar0, starvar0, $
testsigma=, lowlimit=, highlimit=, $
deltachisq=deltachisq, /doplot)
INPUTS:
galfft - Fourier transform of galaxy
starfft - Fourier transform of stellar template
galvar0 - error in galaxy fft (0th element of galaxy error FFT)
starvar0 - error in stellar fft (0th element of stellar error FFT)
OPTIONAL KEYWORDS:
testsigma - Array of sigma values to calculate chi2
lowlimit - lower boundary of chi2 sum (in knums units)
highlimit - upper boundary of chi2 sum (in knums units)
deltachisq - chi2 difference from minimum to set error on velocity dispersion
doplot - Output plots to xwindow
OUTPUTS:
answers - Four element array with:
[minchi2, minsigma, errsigma, bestalpha]
bestalpha is the normalization constant between galaxy and star
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
BUGS:
Currently, this is very slow, as we have to check 11 normalizations
for each element in testsigma array
Need to ensure that confidence level returned as errsigma is proper
PROCEDURES CALLED:
REVISION HISTORY:
25-Mar-2000 Written by S. Burles, FNAL
(See pro/spec1d/fourier_difference.pro)
NAME:
fourier_quotient
PURPOSE:
Perform a chi2 fit to the fourier quotient of a single
galaxy and a broadened stellar template to calculate velocity dispersion
and uncertainty on velocity dispersion
CALLING SEQUENCE:
answers = fourier_quotient(galfft, starfft, galvar0, starvar0, $
testsigma=, lowlimit=, highlimit=, $
deltachisq=, /doplot)
INPUTS:
galfft - Fourier transform of galaxy
starfft - Fourier transform of stellar template
galvar0 - error in galaxy fft (0th element of galaxy error FFT)
starvar0 - error in stellar fft (0th element of stellar error FFT)
OPTIONAL KEYWORDS:
testsigma - Array of sigma values to calculate chi2
lowlimit - lower boundary of chi2 sum (in knums units)
highlimit - upper boundary of chi2 sum (in knums units)
deltachisq - chi2 difference from minimum to set error on velocity dispersion
doplot - Output plots to xwindow
OUTPUTS:
answers - Four element array with:
[minchi2, minsigma, errsigma, bestalpha]
bestalpha is the normalization constant between galaxy and star
OPTIONAL OUTPUTS:
COMMENTS:
Same inputs and outputs as fourier_difference
EXAMPLES:
BUGS:
Need to ensure that confidence level returned as errsigma is proper
PROCEDURES CALLED:
REVISION HISTORY:
25-Mar-2000 Written by S. Burles, FNAL
27-Jun-2000 Completely rewritten - Finkbeiner & SWAT team
(See pro/spec1d/fourier_quotient.pro)
NAME:
frame_flux_calib
PURPOSE:
To derive the flux calibration appropriate to one frame. This routine
takes as input a set of "flux correction vectors" which are formed by
ratioing each standard with it's best fit model and smoothing the result.
The average correction vector, created from a PCA of all the frames (of
one of the CCDs b1/r1/b2/r2) is first divided out. This gets rid of the
low order shape. The residuals are then fit with a 4th order legendere.
The average low order residual is found by medianing the Legendere
coefficients. High order terms are fit by first dividing out the low order
terms and then medianing the result. These are included in the final fit
if "fit_wiggles" is set. The flux calibration vecotor for the frame is
constructed by multiplying the average for all frames, the lower order
residual fit to this frame, and the high order residual fit (if desired).
This vector is then fit with a bspline and the coefficients are returned.
CALLING SEQUENCE:
calibset = frame_flux_calib(loglam, corvector, corvivar, avgcorvset, $
cormed, framename, fit_wiggles=, fsig=, fcor=, final=, noplot=)
INPUTS:
loglam - wavelength array (log10(Angstroms)) [npix]
corvector - array of "flux correction vectors" -- these are
formed by ratioing each standard with it's best fit model
and smoothing the result [npix, nstar]
corvivar - inverse variance of correction vectors -- used in rejecting
points from low order fit [npix, nstar]
avgcorvset - a set of bspline coefficients which describes the average
flux correction of all frames. Not needed if "final" is set
cormed - The median value of each raw correction vector. Before being
fed into this code they are all normalized at 5700 -- 6300 A
(see spdata2model) [nstar]
OUTPUT:
A structure holding the coefficients of a bspline fit to the average
flux correction vector for the frame is returned. Unless "noplot" is set,
diagnostic plots are created. If "outfile" is set the structure is stored
as a FITS binary file.
KEYWORDS:
framename - Name of frame (to be used in plot titles)
outfile - Name of output FITS binary file -- if not set no file is
written
fit_wiggles - if set a fit is done to the high order (as well as low
order) residuals. This should only be set when the S/N
is good. Note that the high order fit is plotted even if
it is not used.
fsig - the variance between each of the flux correction vectors
and the average -- this is a good measure of the spectro-
photometric quality
fcor - average flux correction for the frame (not the spline fit)
final - if set, the average flux correction from a PCA of all the
frames is not used -- this is useful for a final evaluation
of the spectrophotometric quality of the combined exposures
noplot - toggles plotting
COMMENTS:
BUGS:
Not sure if it is mathematically OK to median the Legendre coeffs! (But
it seems to work well ...)
EXAMPLES:
PROCEDURES CALLED:
bspline_bkpts
bspline_iterfit
bspline_valu
divideflat
djs_icolor()
djs_iterstat()
djs_median()
djs_oplot
djs_plot
mwrfits
splot
sxaddpar
traceset2xy
xytraceset
INTERNAL SUPPORT ROUTINES:
REVISION HISTORY:
12-Aug-2003 Created by C. Tremonti Steward Observatory
(See pro/fluxfix/frame_flux_calib.pro)
NAME:
frame_flux_tweak
PURPOSE:
To genreate low order correctons to each red-blue exposure pair which
match the flux (on a fiber-by-fiber basis) to that in a fiducial exposure
selected to have the best S/N and spectrophotometry. This is necessary
so that multiple exposures can be combined with effective cosmic ray
rejection. The flux vectors of each exposure should be multiplied by the
resultant 4th order legnedre polynomial.
CALLING SEQUENCE:
frame_flux_tweak, bloglam, rloglam, bflux, rflux, bivar, rivar, $
best_exp, plugtag, corrfile, diag=, title=
INPUTS:
bloglam - blue wavelength array in (log10 Ang.) [nblue_pix, nfiber*nexp]
rloglam - red wavelength array in (log10 Ang.) [nred_pix, nfiber*nexp]
bflux - blue flux array (uncalibrated) [nblue_pix, nfiber*nexp]
rflux - red flux array (uncalibrated) [nred_pix, nfiber*nexp]
bivar - blue inverse variance [nblue_pix, nfiber*nexp]
rivar - red inverse variance [nred_pix, nfiber*nexp]
best_exp - string containing the exposure ID of the "best" exposure --
this is used as the fiducial exposure against which the
others are ratioed
plugtag - plugmap-like structure which also contains the exposure ID of
each spectrum [nfiber*nexp]
corrfile - names of output FITS files (1/exposure) [nexp]. The traditional
names are spFluxcorr-eeeeeeee-s.fits where "eeeeeeee" is the
exposure ID and "s" is the spectrograph ID (1/2)
OPTIONAL KEYWORDS:
diag - if set show plots of individual fibers at the 3 S/N levels
OUTPUTS:
FITS files named in "corrfile" are generated containing the 4th order
legendere coefficients of the ratio of the best exposure and each of
the others (on a fiber-to-fiber basis). Plots are also generated.
OPTIONAL OUTPUTS:
COMMENTS:
Objects with high S/N are fit with a 4th order legendre
Objects with medium S/N are fit with a 3rd order legendre
Objects with Low S/N are assigned the median correction of the five nearest
fibers. The zeropoint is then fit.
Bad fits -- those wildly deviant from the others -- are replaced with a
zeropoint shift.
EXAMPLES:
BUGS:
The median corrections assigned to low S/N fibers are probably imperfect
because of the mix of point and extended sources on the plate. Also
the shape of the correction may not be well fit by a low order polynomial
-- particularly if there is a mis-match in the dichroic region.
Mask bits not currently returned!! (no record of hi/med/low S/N correction)
PROCEDURES CALLED:
djs_iterstat
djs_oplot
djs_plot
legend
mwrfits
pixelmask_bits()
splog
spmedian_rebin()
traceset2xy
xy2traceset
INTERNAL SUPPORT ROUTINES:
REVISION HISTORY:
17-Oct-2000 Formerly fluxcorr_new -- written by S. Burles
09-Oct-2002 Revised by C. Tremonti to calibrate point sources to the
smear and galaxies to the calib images.
12-Aug-2003 Changed by C. Tremonti to work on pairs of science images.
Split off "spmedian_rebin" & altered handling of medium and
low S/N cases
(See pro/fluxfix/frame_flux_tweak.pro)
NAME:
fstars_plot
PURPOSE:
Make color-color plots of spectro-photometric stars as compared
to the stellar locus and BD+17.
CALLING SEQUENCE:
fstars_plot, [ /deredden ]
INPUTS:
OPTIONAL INPUTS:
deredden - If set, the de-redden the spectroscopic F stars,
and the stellar locus stars from run 94. Do not
de-redden the colors of BD+17.
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
For finding colors of stars on the stellar locus, this routine
reads tsObj files for run 94 rerun 7, which must be on disk.
EXAMPLES:
BUGS:
DATA FILES:
$SPECTRO_DATA/spAll.fits
$PHOTO_DATA/94/7/calibChunks/$CAMCOL/tsObj-000094-$CAMCOL-7-$FIELD.fit
PROCEDURES CALLED:
dfpsclose
dfpsplot
djs_filepath()
djs_oplot
djs_plot
djs_xyouts
mrdfits()
objc_select()
rdss_obj()
REVISION HISTORY:
12-Sep-2002 Written by D. Schlegel, Princeton
(See pro/plan/fstars_plot.pro)
NAME:
fundamental_line
PURPOSE:
Crush the fundamental plane to a measly line.
CALLING SEQUENCE:
INPUTS:
OPTIONAL INPUTS:
KEYWORDS
OUTPUTS:
COMMENTS:
BUGS:
Using RA and Dec for matches rather than OBJID because tsObj files
sometimes busted; search code for "HACK".
EXAMPLES:
PROCEDURES CALLED:
REVISION HISTORY:
25-Jun-2000 Written by Hogg (IAS)
(See pro/spec1d/fundamental_line.pro)
NAME:
genflatmask
PURPOSE:
Read or generate a mask for pixels to ignore when generating flat-fields.
CALLING SEQUENCE:
maskimg = genflatmask( [ flatname, spectrographid=, color=, indir=, ] )
OPTIONAL INPUTS:
flatname - Name of flat-field image
Note that many flats from many nights can be combined.
OPTIONAL KEYWORDS:
spectrographid - Spectrograph ID (1 or 2); reqired if FLATNAME not set.
color - Spectrograph color ('red' or 'blue');
reqired if FLATNAME not set.
indir - Input directory for FLATNAME; default to '.'
OUTPUTS:
maskimg - Mask image with 0=good, 1=bad
COMMENTS:
If FLATNAME is specified, then a bad pixel mask is generated from
that flat-field image assuming it has a mean value approximately equal
to one. If not, then read the mask from the distribution of IDLSPEC2D
in the "etc" subdirectory.
Mask values =0 for good pixels, =1 for bad.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
mrdfits()
readfits()
DATA FILES:
$IDLSPEC2D_DIR/etc/flatmask-b1.fits.gz
$IDLSPEC2D_DIR/etc/flatmask-b2.fits.gz
$IDLSPEC2D_DIR/etc/flatmask-r1.fits.gz
$IDLSPEC2D_DIR/etc/flatmask-r2.fits.gz
REVISION HISTORY:
16-Dec-1999 Written by D. Schlegel, Princeton
(See pro/spec2d/genflatmask.pro)
NAME:
get_mjd_dir
PURPOSE:
Get directory list of matching MJD directories.
CALLING SEQUENCE:
mjdlist = get_mjd_dir( [topdir, mjd=, mjstart=, mjend= ])
INPUTS:
OPTIONAL INPUTS:
topdir - Search for MJD directories under this top level directory.
mjd - Look for raw data files in TOPINDIR/MJD; default to all
subdirectories. Note that this need not be integer-valued,
but could be for example '51441_test'. Wildcards are allowed,
e.g. '514*'. Leading zeros are significant, so that '1*'
will not match the directory '0123'.
mjstart - Starting MJD.
mjend - Ending MJD.
OUTPUT:
mjdlist - List of matching directories (string array).
COMMENTS:
Do not include in the output list any empty directories.
EXAMPLES:
If the path '/data/rawdata' contains the subdirectories '0123', '0124',
'0200', 'test0123' and the file '0125', then:
IDL> print, get_mjd_dir('/data/rawdata')
0123 0124 0200 test
IDL> print, get_mjd_dir('/data/rawdata', mjstart=124)
0124 0200
IDL> print, get_mjd_dir('/data/rawdata', mjd='012*')
0123 0124
BUGS:
Note we assume Unix directory names and we spawn the Unix 'ls' command.
PROCEDURES CALLED:
fileandpath()
REVISION HISTORY:
30-May-2000 Written by David Schlegel, Princeton.
(See pro/spec2d/get_mjd_dir.pro)
NAME:
guidermovie
PURPOSE:
Plot the guider images for an entire night using ATV.
CALLING SEQUENCE:
guidermovie, [ mjd=, plate=, expnum=, _EXTRA=KeywordsForATV ]
INPUTS:
OPTIONAL INPUTS:
mjd - MJD number; if not set, then select the most recent MJD
in the $RAWDATA_DIR directory.
plate - Plate number; if specified, then select all exposures
within the time frame for the science+smear exposures
for this plate during the night in question.
expnum - Exposure numbers (for the gimg*.fits guider images)
as an array.
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
Display the horrendous guider images for plate 889 on MJD=52346:
IDL> guidermovie, mjd=52346, plate=889
BUGS:
DATA FILES:
$RAWDATA_DIR/$MJD/guider/gimg*.fits.gz
$RAWDATA_DIR/$MJD/sdR-b1-????????.fit.gz
PROCEDURES CALLED:
atv
atvxyouts
djs_filepath()
fileandpath()
get_tai
jdcnv
mrdfits()
splog
sdsshead()
REVISION HISTORY:
13-May-2002 Written by D. Schlegel, Princeton
(See pro/apo2d/guidermovie.pro)
NAME:
guidermpeg
PURPOSE:
Create an MPEG guider movie.
Plot the guider images for an entire night.
CALLING SEQUENCE:
guidermovie, [ mjd=, expnum=, _EXTRA=KeywordsForATV ]
INPUTS:
OPTIONAL INPUTS:
mjd - MJD number; if not set, then select the most recent MJD
in the $RAWDATA_DIR directory.
expnum - Exposure numbers as an array
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
Make a movie of the horrible guider images while the slit-head
became unlatched while observing plate 889 on MJD 52346:
IDL> guidermpeg, mjd=52346, expnum=805+lindgen(25)
BUGS:
DATA FILES:
$RAWDATA_DIR/$MJD/guider/gimg*.fits.gz
PROCEDURES CALLED:
djs_filepath()
fileandpath()
mrdfits()
splog
REVISION HISTORY:
13-May-2002 Written by D. Schlegel, Princeton
(See pro/apo2d/guidermpeg.pro)
NAME: idlspec2d_version PURPOSE: Return the version name for the product idlspec2d CALLING SEQUENCE: vers = idlspec2d_version() INPUTS: OUTPUTS: vers - Version name for the product idlspec2d COMMENTS: If this version is not tagged by CVS, then we return 'NOCVS:TOPLEVEL' where TOPLEVEL is the last directory in the environment variable $IDLSPEC2D_DIR. For example, if you are using a version of the code in the directory '/u/schlegel/idlspec2d/v0_0', then this returns 'NOCVS:v0_0'. BUGS: PROCEDURES CALLED: REVISION HISTORY: 01-Dec-1999 Written by D. Schlegel, Princeton.
(See pro/spec2d/idlspec2d_version.pro)
NAME:
inspectfiles
PURPOSE:
Create empty spInspect file(s) for manual inspection of classifications
CALLING SEQUENCE:
inspectfiles, [ plate, mjd=, inspector=, /clobber ]
INPUTS:
OPTIONAL INPUTS:
plate - Plate number(s); if not set, then select all plates that
are reduced according to the platelist file.
mjd - MJD number(s); if not set, then select the most recent
data for each plate (largest MJD).
inspector - Name of inspector, which should be a string without
any whitespace. If set, then output file is
"spInspect-$PLATE-$MJD-$INSPECTOR.par", otherwise it is
"spInspect-$PLATE-$MJD.par" with inspector='yourname'
in the inspector fields of this file.
clobber - If set, then overwrite any files with the same name
in the current directory.
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
Create spInspect files for all reduced plates and write them in
the current directory:
IDL> inspectfiles
Create the file spInspect-0400-51820-knapp.par file for plate 400 observed
on MJD=51820, filling in the "inspector" fields with the name "knapp":
IDL> inspectfiles, 400, mjd=51820, inspector='knapp'
BUGS:
PROCEDURES CALLED:
inspectgen
platelist
readspec
splog
yanny_write
REVISION HISTORY:
20-May-2002 Written by David Schlegel, Princeton.
(See pro/inspect/inspectfiles.pro)
NAME:
inspectfiles
PURPOSE:
Create empty spInspect file(s) for manual inspection of classifications
CALLING SEQUENCE:
inspectgen, plate, mjd=, [ inspector=, specinspect=, $
spectext=, specblend=, hdr=, structs= ]
INPUTS:
plate - Plate number
MJD - MJD number
OPTIONAL INPUTS:
inspector - Name of inspector, which should be a string without
any whitespace. If not set, then use inspector='yourname'.
OUTPUTS:
OPTIONAL OUTPUTS:
specinspect- SPECINSPECT structure (640 elements)
spectext - SPECTEXT structure, with one empty element with fiberid=0
specblend - SPECBLEND structure, with one empty element with fiberid=0
hdr - String array with Yanny header
structs - String array with Yanny structure definitions
COMMENTS:
EXAMPLES:
BUGS:
PROCEDURES CALLED:
readspec
sdss_flagval()
REVISION HISTORY:
20-May-2002 Written by David Schlegel, Princeton.
(See pro/inspect/inspectgen.pro)
NAME:
jeg_sphoto_coef
PURPOSE:
Compute coefficients which can be used to correct the spectrophotometry
CALLING SEQUENCE:
coef = jeg_sphoto_coef(wave, flux, ivar, phot_mag, /plot, $
x = x, xavg=xavg, x2avg=x2avg)
INPUTS:
wave - wavelength array [npix]
flux - 2d flux array in 10-17 erg/s/cm^2/A [npix, nfiber]
ivar - inverse variance [npix, nfiber]
phot_mag - photo fiber mag [5, nfiber]
OUTPUTS:
an array of coefficients for reconstructing the loss function [3, nfiber]
loss = 10.0^(-0.4 *(coef[0] + coef[1]*x + coef[2]x^2))
spec_obs = spec_true * loss
OPTIONAL OUTPUTS:
x - the array of x values used to compute the loss [npix] (see paper
by Jim Gunn for full explanation)
xavg - array of average x values for the g,r,i filters [3, npix]
x2avg - array of average x^2 values for the g,r,i filters [3, npix]
doplot - if set a plot is generated showing the original spectrum in white,
the corrected spectrum in blue, the loss function in red, and
the 3 points used to compute the loss function in green
COMMENTS:
See paper by Jim Gunn for a full explanation
BUGS:
Not sure what happens when the mags are bad
PROCEDURES CALLED:
filter_thru
linterp
REVISION HISTORY:
2-Feb-2004 Written by C. Tremonti, U of Az
(See pro/fluxfix/jeg_sphoto_coef.pro)
NAME: k-correct PURPOSE: Take 5-band photometry and redshift and return k-corrected magnitude. COMMENTS: CALLING SEQUENCE: restphot= k-correct(obsphot,z) INPUTS: obsphot - 5xN array of SDSS photometry in observed frame z - N-vector of redshifts OPTIONAL INPUTS: obserr - 5xN array of uncertainties in obsphot KEYWORDS: OUTPUTS: restphot - 5xN array of SDSS photometry in rest frame OPTIONAL OUTPUTS: resterr - 5xN array of propagated uncertainties in restphot PROCEDURES CALLED: BUGS: MAKES NO USE OF ERRORS. GIVES CRAP WHEN EXTRAPOLATING. This uses an incredibly stupid interpolation scheme. REVISION HISTORY: 2000-Jun-28 Written by Hogg (IAS)
(See pro/science/k_correct.pro)
NAME:
kurucz_fitsfile
PURPOSE:
Generate a single FITS file from a list of ASCII-formatted Kurucz models
CALLING SEQUENCE:
kurucz_fitsfile, [ fileprefix, outfile ]
INPUTS:
OPTIONAL INPUTS:
fileprefix - Use all files in the current directory matching this string;
default to 'a*.spc'
outfile - Name of output FIST file; default 'kurucz_stds_raw_v5.fits'
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
The input ASCII files were generated by Christy Tremonti using
Kurucz' code. The file name is assumed to encode the stellar
parameters of metallicity (FEH), effective temperature (TEFF)
and gravity (G). For example, the file 'am05k2_5000_4.0.spc'
is interpreted to have FEH=-0.5, TEFF=5000, G=4.0. I don't know
what the "k2" in the filename means.
HDU#0 of the output file has the fluxes.
HDU#1 of the output file is a FITS binary table with the stellar parameters.
EXAMPLES:
PROCEDURES CALLED:
mwrfits
sxpaddpar
REVISION HISTORY:
18-Jan-2003 Written by D. Schlegel, Princeton
(See pro/spec1d/kurucz_fitsfile.pro)
NAME:
kurucz_restore
PURPOSE:
Read back Kurucz models from FITS and apply an empirical correction
CALLING SEQUENCE:
kurucz_restore, kwave, kflux, nkflux=, hdr=, kindx=, smoothpix=
INPUTS:
OPTIONAL INPUTS:
smoothpix - smooth models by this number of pixels -- useful for
comparisons to non-SDSS data
OUTPUT:
kwave - wavelength in Angstroms of Kurucz models (binning is in log-10 A)
[npix]
kflux - flux of Kuruz models [npix, nmodel]
OPTIONAL OUTPUTS:
nkflux - normalized model flux [npix, nmodel]
hdr - header of FITS file
kindx - structure containing info on each model (Teff, logg, [Fe/H], mags)
COMMENTS:
The model file called "kurucz_stds_v5.fit' is assumed to be in
$IDLSPEC2D_DIR/etc. The models have been produced by the SPECTRUM code
(R.0. Gray & C. J. Corbally, 1994, AJ, 107, 742) using the latest Kurucz
model atmospheres. The 0th HDU contains the flux in ergs/s/cm^2/A --
the absolute value of the flux is arbitrary. The spectra have been
convolved to SDSS resolution (approximately) and rebinned to dloglam
= 1e-4. The 1st HDU contains information about each model such as
effective temperature, surface gravity, and metallicity. The wavelength
information is in the header. The second HDU contains information about
an empirical correction which should be applied to the models.
BUGS:
The empirical correction which is applied is derived from comparing
hot DA white dwarfs in SDSS to models. This only corrects the low order
shape of the spectra. A different correction is probably needed for each
T_eff and [Fe/H].
EXAMPLES:
kurucz_restore, kwave, kflux
plot, kwave, kflux[*, 5]
PROCEDURES CALLED:
filter_thru()
mrdfits()
rectify
sxpar()
traceset2xy
INTERNAL SUPPORT ROUTINES:
REVISION HISTORY:
12-Aug-2003 Created by C. Tremonti, Steward Observatory
(See pro/fluxfix/kurucz_restore.pro)
NAME:
linebackfit
PURPOSE:
Fit emission lines and background terms to a spectrum.
CALLING SEQUENCE:
result = linebackfit(lambda, loglam, flux, invvar=, $
linename=, zindex=, windex=, findex=, fvalue=, zlimits=, siglimits=, $
background=, zguess=, sigguess=, yfit=, bfit=, bterms= )
INPUTS:
lambda - Rest-frame vacuum wavelength of lines to fit in Ang [NLINE]
loglam - Wavelengths for spectrum in vacuum log-10 Angstroms [NPIX]
flux - Flux for spectrum [NPIX]
invvar - Inverse variance for spectrum [NPIX]
OPTIONAL INPUTS:
linename - String name(s) of line(s) to be copied to output structure.
zindex - Lines with the same ZINDEX are constrained to have the
same redshift; default to a unique list of indices [NLINE].
windex - Lines with the same WINDEX are constrained to have the
same width [NLINE]; default to a unique list of indices.
findex - Lines with the same FINDEX are constrained to have the
same flux ratio as input in FVALUE; defult to a unique
list of indices [NLINE].
fvalue - If FINDEX is specified, then constrain the lines to have
the same flux ratios as in FVALUE [NLINE]; default to
all values of 1. These values are also used as the
initial guesses for the line strengths.
zlimits - Optional limits in velocity, either as a 2-elements array
for the low/high limit of every line, or as a [2,NLINE] array
with different limits for each line [km/s]
siglimits - Optional limits in sigma, either as a 2-elements array
for the low/high limit of every line, or as a [2,NLINE] array
with different limits for each line [km/s]
background - Background vector(s) to fit simultaneously with the lines,
where the scaling of each vector is fit [NPIX,NBACK].
The redshift of these background vectors is not fit, but
rather we maintain the one-to-one correspondence of each
BACKGROUND pixel to each FLUX pixel. The initial guess
for the scaling of each background vector is unity.
zguess - Initial guess for redshifts of all lines (scalar or vector
with one entry per line); default to 0.
sigguess - Initial guess for sigmas of all lines in log-10 Angstroms
(scalar or vector with one entry per line); default to 1.5d-4
(105 km/sec).
OUTPUTS:
result - Output structure with result of line fits [NLINE].
The elements are as follows:
LINENAME - String name of line copied from input
parameter by the same name, or else
constructed from the rounded-down wavelength
of each line in air (not vacuum)
LINEWAVE - Rest-frame wavelength in vacuum [Ang]
(copy of LAMBDA)
LINEZ - Redshift [dimensionless]
LINEZ_ERR - Error in above
LINESIGMA - Sigma of gaussian [km/s]
LINESIGMA_ERR - Error in above
LINEAREA - Area of line [flux-units * Ang]
LINEAREA_ERR - Error in above
LINEEW - Line equivalent width [Ang]; or 0 if the
background level is <= 0.
LINEEW_ERR - Error in above; or -1L if the background
level is <= 0. We approximate this error
as sqrt((LINEAREA_ERR/LINEAREA)^2
+(LINECONTLEVEL_ERR/LINECONTLEVEL)^2) * LINEEW
LINECONTLEVEL - Continuum level at line center [flux-units];
if the line center is outside the wavelength
range, then return the nearest value (either
the first or last value)
LINECONTLEVEL_ERR - Error in above, or -1L if the line center
is outside the wavelength range.
LINENPIXLEFT - Number of pixels from the line center to
-3 sigma that have INVVAR > 0.
LINENPIXRIGHT - Number of pixels from the line center to
+3 sigma that have INVVAR > 0.
LINEDOF - LINENPIXLEFT+LINENPIXRIGHT minus the number
of terms fit for that line, which could be
fractional (if one parameter is fixed between
N lines, then we say only 1/N-th of that
parameter is fit in each of those lines).
This can be zero or negative.
LINECHI2 - Chi^2 for all points within +/- 3 sigma of
the line center; -1L if no such points.
OPTIONAL OUTPUTS:
yfit - Fit spectrum including lines and background terms [NPIX].
bfit - Fit spectrum including only background terms [NPIX].
bterms - Coefficients for background terms [NBACK].
COMMENTS:
If a line was dropped from the fit (for example, no points to fit),
then set the LINEAREA to 0 and the LINEAREA_ERR to -1L.
Also, if LINENPIX=0 for a line, then remove that line from the fit.
EXAMPLES:
BUGS:
Do not use lines with no points to fit in the computation of
degrees of freedom for other lines.
DATA FILES:
PROCEDURES CALLED:
create_linestruct()
mpfitfun
INTERNAL SUPPORT ROUTINES:
onegauss()
manygauss()
REVISION HISTORY:
05-Feb-2002 Written by D. Schlegel, Princeton
(See pro/spec1d/linebackfit.pro)
NAME: listchi PURPOSE: List the extraction chi of all individual spectro frames CALLING SEQUENCE: listchi INPUTS: OPTIONAL INPUTS: OUTPUT: OPTIONAL OUTPUTS: COMMENTS: The exposure times of all files $SPECTRO_DATA/????/spFrame-??-????????.fits are logged to the file 'listchi.log'. Also, a save-set is written to the file 'listchi.ss'. EXAMPLES: BUGS: PROCEDURES CALLED: headfits() splog REVISION HISTORY: 03-Sep-2003 Written by David Schlegel, Princeton.
(See pro/plan/listchi.pro)
NAME: listexptime PURPOSE: List the exposure times of all (reduced) spectroscopic frames. CALLING SEQUENCE: listexptime INPUTS: OPTIONAL INPUTS: OUTPUT: OPTIONAL OUTPUTS: COMMENTS: The exposure times of all files $SPECTRO_DATA/????/spFrame-b1-????????.fits are logged to the file 'listexp.log'. This proc just looks at the b1 exposures to save time. EXAMPLES: BUGS: PROCEDURES CALLED: headfits() splog REVISION HISTORY: 03-Sep-2003 Written by David Schlegel, Princeton.
(See pro/plan/listexptime.pro)
NAME:
locateskylines
PURPOSE:
Compute shifts for arc lines used in wavelength calibration.
CALLING SEQUENCE:
locateskylines, skylinefile, fimage, ivar, wset, xarc, arcshift=arcshift,
[ xsky=, ysky=, skywaves=, skyshift= ]
INPUTS:
skylinefile - Name of skyline file (with air wavelengths in Angstroms)
fimage - Flattened image containing skylines [NPIX,NFIBER]
ivar - Inverse variance of FIMAGE
wset - Wavelength solution traceset (pix -> lambda)
xarc - Arc line positions from arc frame [pix]
OUTPUTS:
arcshift - Shifts to apply to arc lines in pix [NROW,NTRACE]
OPTIONAL OUTPUTS:
xsky - Pixel position of sky lines [NFIBER,NLINE]
skywaves - Wavelengths of sky lines used for computing shifts (Ang)
skyshift - Shifts to apply to sky lines in pix [NROW,NTRACE]
COMMENTS:
The wavelength as a function of fiber number is only allowed to
vary quadratically. The scale
EXAMPLES:
BUGS:
PROCEDURES CALLED:
djs_iterstat
fitmeanx()
trace_fweight()
trace_gweight()
traceset2pix()
traceset2xy
xy2traceset
REVISION HISTORY:
15-Oct-1999 Written by S. Burles, D. Finkbeiner, & D. Schlegel, APO
18-Nov-1999 Moved skyline QA to fit_skyset (SMB)
(See pro/spec2d/locateskylines.pro)
NAME:
locateskylines_test
PURPOSE:
Compute shifts for arc lines used in wavelength calibration.
CALLING SEQUENCE:
locateskylines, skylinefile, fimage, ivar, wset, xarc, arcshift=arcshift,
[ nord=, xsky=, ysky=, skywaves=, skyshift= ]
INPUTS:
skylinefile - Name of skyline file (with air wavelengths in Angstroms)
fimage - Flattened image containing skylines [NPIX,NFIBER]
ivar - Inverse variance of FIMAGE
wset - Wavelength solution traceset (pix -> lambda)
xarc - Arc line positions ???
OPTIONAL INPUTS:
nord - Order of fit to delta x positions; default to 4
OUTPUTS:
arcshift - Shifts to apply to arc lines in pix [NROW,NTRACE]
OPTIONAL OUTPUTS:
xsky - Pixel position of sky lines [NFIBER,NLINE]
skywaves - Wavelengths of sky lines used for computing shifts (Ang)
skyshift - Shifts to apply to sky lines in pix [NROW,NTRACE]
COMMENTS:
The wavelength as a function of fiber number is only allowed to
vary quadratically. The scale is only allowed to vary by the same
factor for the entire image.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
djs_iterstat
trace_fweight()
trace_gweight()
traceset2pix()
traceset2xy
REVISION HISTORY:
15-Oct-1999 Written by S. Burles, D. Finkbeiner, & D. Schlegel, APO
18-Nov-1999 Moved skyline QA to fit_skyset (SMB)
(See pro/spec2d/locateskylines_test.pro)
NAME:
logsheet
PURPOSE:
Make a summary of header keywords in a directory of raw SDSS spectro files.
CALLING SEQUENCE:
logsheet, [mjd=, camera=, outfile=]
INPUTS:
OPTIONAL INPUTS:
mjd - Directory name; default to largest numbered MJD
matching the directory "$RAWDATA_DIR/?????".
camera - Camera name of files to list; default to '??'
for all cameras.
outfile - Output file
OUTPUTS:
COMMENTS:
First look at files matching "sdR*.fit.gz" in the directory
$RAWDATA_DIR/$MJD, and if none found then look for files
matching "sdR*.fit".
EXAMPLES:
Print a log sheet of the most recent MJD:
IDL> logsheet
Print a log sheet of the most recent MJD, but only for the 'b1' camera:
IDL> logsheet, camera='b1'
Print a log sheet of the spectroscopic data from MJD=52000 (if it
still exists on disk), and write to the file 'junk.log'.
IDL> logsheet, mjd=52000, outfile='junk.log'
PROCEDURES CALLED:
djs_filepath()
sdsshead()
sxpar()
REVISION HISTORY:
06-Oct-1999 Written by David Schlegel, Princeton.
(See pro/spec2d/logsheet.pro)
NAME: lrgmodel_errors PURPOSE: Make plots of photo-z's where we increase the errors. CALLING SEQUENCE: lrgmodel_errors INPUTS: OPTIONAL INPUTS: OUTPUTS: OPTIONAL OUTPUTS: COMMENTS: EXAMPLES: BUGS: PROCEDURES CALLED: dfpsclose dfpsplot djs_oplot djs_plot hogg_scatterplot lrgmodel_photoz() REVISION HISTORY: 22-Dec-2003 Written by D. Schlegel, Princeton
(See pro/photoz/lrgmodel_errors.pro)
NAME:
lrgmodel_photoz
PURPOSE:
Simple photo-z finder for LRGs using Bruzual-Charlot models.
CALLING SEQUENCE:
zfit = lrgmodel_photoz(pflux, pflux_ivar, [ /abcorrect, extinction=, $
abfudge=, ageburst=, zmetal=, filterlist=, adderr=, $
zsplinearr=, synfluxarr=, z_err=, chi2=, fitflux=, plotfile= ] )
INPUTS:
pflux - Object fluxes in the 5 SDSS filters [5,NOBJ]; if not set,
then simply return with the optional ZSPLINEARR,SYNFLUXARR.
pflux_ivar - Inverse variances for FLUX [5,NOBJ]
OPTIONAL INPUTS:
abcorrect - If set, then convert the input fluxes from the 2.5-m
natural system to AB fluxes
extinction - If set, then apply these extinction corrections [5,NOBJ]
abfudge - Additional AB "fudge factors"; default to adding
[0,0,0,0,0] mag to input magnitudes, where a positive
value makes that flux fainter
ageburst - Age of the Universe at the single-burst; default
to value from previous call, or 2.5 Gyr
zmetal - Metallicity at the single-burst; default
to value from previous call, or Z=0.018
(where Z=0.02 is solar)
filterlist - List of filter indices to use in fits; default to
using all five filters [0,1,2,3,4]
adderr - Fractional error to add in quadrature; default to 0.03
plotfile - If set, then send debugging plots to this file
OUTPUTS:
zfit - Best-fit redshift [NOBJ]
OPTIONAL OUTPUTS:
zsplinearr - Array of test redshifts used in the fits [NTEST]
synfluxarr - Array of the fluxes vs. redshift from the models [5,NTEST]
z_err - Redshift error, or a negative value if an error
occurred in the quadratic minimization estimate [NOBJ]
chi2 - Best-fit chi^2 [NOBJ]
fitflux - Fluxes for the best-fit model, useful for knowing the
colors of the best-fit model
COMMENTS:
The fluxes should be AB fluxes, or SDSS 2.5-m natural system fluxes
if /ABCORRECT is set.
The fluxes should already be extinction-corrected, unless
the EXTINCTION keyword is passed.
EXAMPLES:
BUGS:
Note that I allow the Bruzual-Charlot models to be extrapolated
beyond the ages and metallicities that they provide. This is done
via linear interpolation in log(age)-log(metals)-log(flux) spec.
This may not be valid.
PROCEDURES CALLED:
computechi2()
filter_thru()
find_nminima()
readcol
sdssflux2ab
sxpar()
REVISION HISTORY:
09-Dec-2003 Written by D. Schlegel, Princeton
(See pro/photoz/lrgmodel_photoz.pro)
NAME:
lrgmodel_plots
PURPOSE:
Generate goodness-of-fit plots from the LRG model photo-z fits.
CALLING SEQUENCE:
lrgmodel_plots, [ suffix, public=, /recalibrate, /colorcut, $
subsamp=, _EXTRA= ]
INPUTS:
OPTIONAL INPUTS:
suffix - Suffix name for plot names, which is 'photoz'+SUFFIX+'.ps'
public - Select public data; this keyword is passed
to LRGMODEL_READ_SPALL()
recalibrate - Recalibrate the photometry using SDSS_RECALIBRATE
colorcut - If set, then make Nikhil's color-cuts on the 2dF data
subsamp - Subsample the spAll galaxies by this factor; default to 4
_EXTRA - Additional keywords to pass to LRGMODEL_PHOTOZ(),
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
This routine reads both the SDSS spectra from spAll, and the SDSS-2dF
redshifts.
Some of the plots are replicated with the SDSS-2dF points in color.
The SDSS-2dF 2003A objects are in green, and the 2003B objects are in blue.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
dfpsclose
dfpsplot
djs_oplot
djs_plot
hogg_scatterplot
lrgmodel_append_twodf()
lrgmodel_read_spall()
plothist
sdss_recalibrate
REVISION HISTORY:
18-Dec-2003 Written by D. Schlegel, Princeton
(See pro/photoz/lrgmodel_plots.pro)
NAME:
lrgmodel_train
PURPOSE:
Calling script for LRGMODEL_TWEAK_TEMPLATE for training the Bruzual-
Charlot models for use with photo-z's.
CALLING SEQUENCE:
lrgmodel_train, [ public=, /regenerate, twodf=, zrange=, dzweight=, $
/absdev, _EXTRA=]
INPUTS:
OPTIONAL INPUTS:
public - If set, then use the requested version of the spAll
file rather than all objects; for example, 'EDR', 'DR1',
'DR2', or simply /PUBLIC to select all public data.
regenerate - If set, then regenerate the trimmed spAll file.
twodf - Suffix for which 2dF files to use; default to the two
set of files specified by ['2003A', '2003B']
zrange - Trim to objects in this redshift range; default [0.1,1.0].
dzweight - Re-weight the galaxies such that all objects within each
redshift interval DZWEIGHT share unit weight; default
to 0.02; set to 0 to disable this re-weighting.
absdev - If set, then minimize the absolute value of the redshift
deviations, rather than the more conventional square of
those deviations. This should be more robust.
_EXTRA - Keywords for LRGMODEL_PHOTOZ(), such as ABCORRECT,
EXTINCTION, ABFUDGE, ADDERR, FILTERLIST.
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
This routine minimizes the parameters used for the Bruzual-Charlot
models in computing photometric redshifts. There are two parameters
on which we minimize:
AGEBURST - age of the Universe at the burst [Gyr]
ZMETAL - metallicity of the burst
This routine first tries a coarse grid of AGEBURST,ZMETAL.
The best-fit from that grid is used for the initial guess
that's passed to MPFIT() for a full minimization.
BUGS:
Note that the reported chi^2 values are really just sums of the
squares of redshift errors (multiplied by the weights).
DATA FILES:
Both SDSS redshifts and 2dF redshifts are used, reading the files:
$SPECTRO_DATA/spAll.fits
$SPECTRO_DATA/spAll-$PUBLIC.fits (if PUBLIC is specified)
$SDSS_2DF/data/calibObj-2003A.fits
$SDSS_2DF/data/calibObj-2003B.fits
$SDSS_2DF/data/catalogue2003A.fits
$SDSS_2DF/data/catalogue2003B.fits
EXAMPLES:
BUGS:
PROCEDURES CALLED:
hogg_mrdfits()
lrgmodel_photoz()
lrgmodel_tweak_template()
mrdfits()
splog
REVISION HISTORY:
18-Dec-2003 Written by D. Schlegel, Princeton
(See pro/photoz/lrgmodel_train.pro)
NAME:
lrgmodel_tweak_template
PURPOSE:
Compute the corrections to the input LRG template used for LRG_PHOTOZ().
CALLING SEQUENCE:
lrgmodel_tweak_template, pflux, pflux_ivar, zz, [ weights=, $
maxiter=, ageguess=, metalguess=, agerange=, metalrange=, /absdev, $
coeff=, _EXTRA= ]
INPUTS:
pflux - Object fluxes in the 5 SDSS filters [5,NOBJ]
pflux_ivar - Inverse variances for FLUX [5,NOBJ]
zz - Spectroscopic redshifts [NOBJ]
OPTIONAL INPUTS:
weights - Weights for each object in the minimization
(this is multiplied by the chi^2 of each point)
maxiter - Maximum number of iterations; default to 40
ageguess - Starting guess for AGEBURST; default to 2.5 Gyr
metalguess - Starting guess for ZMETAL; default to Z=0.2
agerange - Range of possible values for AGEBURST; default
to [0.0, 6.0] Gyr
metalrange - Range of possible values for ZMETAL; default
to [0.008, 0.05]
absdev - If set, then minimize the absolute value of the redshift
deviations, rather than the more conventional square of
those deviations. This should be more robust.
_EXTRA - Keywords for LRGMODEL_PHOTOZ(), such as ABCORRECT,
EXTINCTION, ABFUDGE, ADDERR, FILTERLIST
OUTPUTS:
coeff - Best-fit coefficients for tweaking input LRG template
OPTIONAL OUTPUTS:
COMMENTS:
This routine minimizes the parameters used for the Bruzual-Charlot
models in computing photometric redshifts. There are two parameters
on which we minimize:
AGEBURST - age of the Universe at the burst [Gyr]
ZMETAL - metallicity of the burst
EXAMPLES:
BUGS:
PROCEDURES CALLED:
lrgmodel_photoz()
mpfit()
splog
INTERNAL SUPPORT ROUTINES:
lrgmodel_tweak_fn()
REVISION HISTORY:
10-Dec-2003 Written by D. Schlegel, Princeton
(See pro/photoz/lrgmodel_tweak_template.pro)
NAME:
lrg_photoz
PURPOSE:
Very simple photo-z finder for LRGs using a single template.
CALLING SEQUENCE:
zfit = lrg_photoz(pflux, pflux_ivar, [ /abcorrect, extinction=, $
abfudge=, filterlist=, adderr=, z_err=, chi2= ] )
INPUTS:
pflux - Object fluxes in the 5 SDSS filters [5,NOBJ]
pflux_ivar - Inverse variances for FLUX [5,NOBJ]
OPTIONAL INPUTS:
abcorrect - If set, then convert the input fluxes from the 2.5-m
natural system to AB fluxes
extinction - If set, then apply these extinction corrections [5,NOBJ]
abfudge - Additional AB "fudge factors"; default to adding
[0,-0.03,0,0,0] mag to input magnitudes, where a positive
value makes that flux fainter
filterlist - List of filter indices to use in fits; default to
using all five filters [0,1,2,3,4]
adderr - Fractional error to add in quadrature; default to 0.03
OUTPUTS:
zfit - Best-fit redshift [NOBJ]
OPTIONAL OUTPUTS:
z_err - Redshift error, or a negative value if an error
occurred in the quadratic minimization estimate [NOBJ]
chi2 - Best-fit chi^2 [NOBJ]
COMMENTS:
The fluxes should be AB fluxes, or SDSS 2.5-m natural system fluxes
if /ABCORRECT is set.
The fluxes should already be extinction-corrected, unless
the EXTINCTION keyword is passed.
EXAMPLES:
BUGS:
The LRG template is not quite correct. I have modified the spectrum
on large scales by multiplying by an empirically-determined function.
Also, I've extrapolated the two ends of the spectrum
to be essentially flat in f_lambda.
The 3-sigma-clipped scatter appears to be 0.023 at z>0.1.
PROCEDURES CALLED:
computechi2()
filter_thru()
find_nminima()
mrdfits()
sdssflux2ab
sxpar()
REVISION HISTORY:
15-Oct-2003 Written by D. Schlegel, Princeton
(See pro/photoz/lrg_photoz.pro)
NAME:
lrg_tweak_template
PURPOSE:
Compute the corrections to the input LRG template used for LRG_PHOTOZ().
CALLING SEQUENCE:
lrg_tweak_template, pflux, pflux_ivar, zz, $
[ /abcorrect, extinction=, abfudge=, filterlist=, adderr=, $
maxiter=, coeff= ]
INPUTS:
pflux - Object fluxes in the 5 SDSS filters [5,NOBJ]
pflux_ivar - Inverse variances for FLUX [5,NOBJ]
zz - Spectroscopic redshifts [NOBJ]
OPTIONAL INPUTS:
abcorrect - If set, then convert the input fluxes from the 2.5-m
natural system to AB fluxes
extinction - If set, then apply these extinction corrections [5,NOBJ]
abfudge - Additional AB "fudge factors"; default to adding
[0,-0.03,0,0,0] mag to input magnitudes, where a positive
value makes that flux fainter
filterlist - List of filter indices to use in fits; default to
using all five filters [0,1,2,3,4]
adderr - Fractional error to add in quadrature; default to 0.03
maxiter - Maximum number of iterations; default to 40
OUTPUTS:
coeff - Best-fit coefficients for tweaking input LRG template
OPTIONAL OUTPUTS:
COMMENTS:
This routine computes the modifications to an input LRG spectrum
that gives a better total chi^2 when computing photometric redshifts.
The form of the transformation is:
Flux = Flux * Wave^COEFF[0] * (1 + COEFF[1] * z * Wave)
The fluxes should be AB fluxes, or SDSS 2.5-m natural system fluxes
if /ABCORRECT is set.
The fluxes should already be extinction-corrected, unless
the EXTINCTION keyword is passed.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
computechi2()
filter_thru()
mrdfits()
sdssflux2ab
sxpar()
REVISION HISTORY:
21-Oct-2003 Written by D. Schlegel, Princeton
(See pro/photoz/lrg_tweak_template.pro)
NAME:
make_regress1d
PURPOSE:
Generate a regression table from spectro 1-D from Chicago-1D outputs files.
CALLING SEQUENCE:
make_regress1d, [listfile, indir=, outfile= ]
INPUTS:
OPTIONAL INPUTS:
listfile - List with plate number and MJD (one such pair per line)
for plates to use. Default to the file
$IDLSPEC2D_DIR/etc/regress1d_all.plates, which lists plates
300 to 309.
indir - Input directory for the Chicago-1D output files, of the
format 'spDiag1d-'+mjd+'-'+plate+'.par, i.e.
'spDiag1d-51666-0300.par'; default to '.'
outfile - Name of output file; default to
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
An ASCII file with minimal object information and redshifts is tabulated
from the Chicago-1D outputs.
The Chicago outputs are changed in some special cases that are assumed
to be missing or wrong.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
djs_readcol
INTERNAL SUPPORT ROUTINES:
create_zregress()
DATA FILES:
$IDLSPEC2D_DIR/etc/regress1d_all.plates
REVISION HISTORY:
27-Jun-2000 Written by D. Schlegel, Princeton
(See pro/spec1d/make_regress1d.pro)
NAME:
make_skyinvvar
PURPOSE:
To reconstruct the contribution of the sky and detector background
to the total variance. Use spPlate*fits files.
CALLING SEQUENCE:
skyinvvar = make_skyinvvar(filename)
INPUTS:
filename - Input spPlate file name
i.e. 'spPlate-0858-52316.fits'
OPTIONAL INPUTS:
OUTPUT:
skyinnvar - Inverse variance as derived from a polynomial fit of
variance vs. flux (size [npix])
OPTIONAL OUTPUTS:
COMMENTS:
Return 0's on failure
EXAMPLES:
BUGS:
PROCEDURES CALLED:
INTERNAL SUPPORT ROUTINES:
REVISION HISTORY:
18-Jun-2002 Written by Scott Burles, MIT
(See pro/spec2d/make_skyinvvar.pro)
NAME:
match_trace
PURPOSE:
Tweak flat field trace to match object trace
with a 2d continuous surface fit to low order
CALLING SEQUENCE:
xnow = match_trace(image, invvar, xtrace, [xpoly=, ypoly=, $
first=, maxiter= ])
INPUTS:
image - two-dimensional object image
invvar - associated inverse variance image
xtrace - array of best fit flat-field traces [nrow, nfiber]
OPTIONAL KEYWORDS:
xpoly - Order of chebyshev polynomial in first dimension (default 3)
ypoly - Order of chebyshev polynomial in second dimension (default 3)
first - Final fweight centroids of object image
maxiter - Maximum number of rejection iterations for 2d surface fit (default 10)
OUTPUTS:
xnow - Best fit trace positions when tweaked to match image
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
xnow = match_trace(image, invvar, xtrace)
bestlag = median(xnow-xtrace)
splog, 'Shifting traces by match_trace ', bestlag
BUGS:
PROCEDURES CALLED:
djs_reject()
fchebyshev()
trace_fweight()
REVISION HISTORY:
16-Oct-2000 Written by S. Burles, FNAL
25-Feb-2002 Added radius keyword, radius=2 is much better when wings of
bright neighboring fibers affects centroiding
(See pro/spec2d/match_trace.pro)
NAME:
multisynthspec
PURPOSE:
Construct synthetic spectrum from eigen-templates.
CALLING SEQUENCE:
synflux = multisynthspec(zans, [ loglam=, hdr=, eigendir= ])
INPUTS:
zans - Structure(s) with redshift-fit information (from SPREDUCE1D).
OPTIONAL KEYWORDS:
loglam - Log-10 wavelengths at which to synthesize the spectrum;
this can either be a single vector if all spectra have
the same wavelength mapping, or an array of [NPIX,NOBJ].
hdr - If specified, then use this header to construct LOGLAM.
Either LOGLAM or HDR must be specified.
eigendir - Directory for EIGENFILE; default to $IDLSPEC2D/templates.
OUTPUTS:
synflux - Synthetic spectra
COMMENTS:
This routine is meant to be faster than SYNTHSPEC when generating
many spectra that share the same templates. This works by generating
the B-spline coefficients only once per template, then evaluating
these B-splines at the exact wavelengths of each output spectrum.
This will NOT be exactly the same as the results from SYNTHSPEC,
because the individual eigen-spectra are spline-shifted before adding
them up, rather than adding them up then spline-shifting (as SYNTHSPEC
does).
EXAMPLES:
BUGS:
DATA FILES:
$IDLSPEC2D_DIR/etc/TEMPLATEFILES
PROCEDURES CALLED:
combine1fiber
concat_dir()
poly_array()
readfits()
sxpar()
REVISION HISTORY:
20-Aug-2000 Written by D. Schlegel, Princeton
(See pro/spec1d/multisynthspec.pro)
NAME:
myfluxcalib
PURPOSE:
Solve for flux-calibration vectors, one for each camera (blue and red)
on a single spectrograph.
CALLING SEQUENCE:
myfluxcalib, filename, calibfile, colors=, adderr=
INPUTS:
filename - Name(s) of input file names, typically one blue and
one red file. The pluggings need not be the same,
but there must be at least one good SPECTROPHOTO or
REDDEN standard in common.
calibfile - Name(s) of output calibration files, one per FILENAME
REQUIRED KEYWORDS:
colors - The name(s) of each camera, 'b' for blue or 'r' for red;
typically, we pass both with COLORS=['b','r']
OPTIONAL INPUTS:
adderr - Fractional errors to add in quadrature to measured errors
at each point in each spectrum; a good value is 0.03 for 3%.
OUTPUT:
COMMENTS:
EXAMPLES:
BUGS:
PROCEDURES CALLED:
bspline_iterfit()
bspline_valu()
correct_dlam
divideflat
djs_diff_angle()
djs_filepath()
djs_maskinterp()
djs_median()
djs_oplot
djs_plot
fibermask_bits()
fileandpath()
filter_thru()
mrdfits()
mwrfits
pca_solve()
readcol
splog
sxaddpar
sxpar()
traceset2xy
INTERNAL SUPPORT ROUTINES
fluxfit()
qgoodfiber()
resortplugmap()
REVISION HISTORY:
08-Sep-2000 Written by D. Schlegel & S. Burles
(See pro/spec2d/myfluxcalib.pro)
NAME:
mysql_write
PURPOSE:
Write an IDL structure to a MySQL-readable file
CALLING SEQUENCE:
mysql_write, filename, pdata, [table=, delim=, modifiers=, /append, $
scriptfile= ]
INPUTS:
filename - Output file name
pdata - Structure to write
OPTIONAL INPUTS:
table - Name of table; default to the structure name or 'anonymous'
delim - MySQL delimiter; default to the tab character
modifiers - Modifiers for all variables, such as 'not null';
default to ''
append - If set, then append to an existing file
scriptfile - Name of file for writing MySQL importing script
OUTPUT:
OPTIONAL OUTPUTS:
COMMENTS:
Unsupported IDL variable types: COMPLEX, DCOMPLEX.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
REVISION HISTORY:
22-Apr-2000 Written by David Schlegel, Princeton.
(See pro/specdb/mysql_write.pro)
NAME:
newspcombine
PURPOSE:
Flux calibrates and combines exposures with a common plugmap.
(Calling script for SPCOADD_FLUXED_FRAMES.)
CALLING SEQUENCE:
newspcombine, [ planfile, docams=, adderr=, /xdisplay, minsn2=, $
best_exposure= ]
INPUTS:
OPTIONAL INPUTS:
planfile - Name(s) of output plan file; default to reducing all
plan files matching 'spPlancomb*.par'
docams - Cameras to combine; default to ['b1', 'b2', 'r1', 'r2']
adderr - Additional error to add to the formal errors, as a
fraction of the flux; default to 0.03 (3 per cent).
xdisplay - Send plots to X display rather than to plot file
minsn2 - Minimum S/N^2 to include science frame in coadd (default 0.2)
best_exposure - string containing the exposure ID of the "best" exposure.
This is the exposure which all exposures will be scaled to
match before the images are coadded. If this is not set, the
exposure with the best S/N and spectrophotometry is chosen.
OUTPUT:
spPlate-PPPP-MMMMM.fits file
Diganostic plots in spDiagcomb-PPPP-MMMMM.ps, spSN2d-PPPP-MMMMM.ps
COMMENTS:
EXAMPLES:
BUGS:
This routine spawns the Unix command 'mkdir'.
For a given exposure to be combined data from all 4 cameras must be
present
PROCEDURES CALLED:
djs_filepath()
cpbackup
idlspec2d_version()
idlutils_version()
lookforgzip()
spcoadd_fluxed_frames
splog
yanny_free
yanny_par()
yanny_read
INTERNAL SUPPORT ROUTINES:
REVISION HISTORY:
12-Aug-2003 Adapted from spcombine by C. Tremonti, Steward Observatory
(See pro/fluxfix/newspcombine.pro)
NAME:
pca_flux_standard
PURPOSE:
Solve for the mean flux-calibration vector of one camera + spectrograph
using data from all available exposures. This is accomplished by matching
the normalized standard star spectra to Kurucz models and then ratioing
the spectrum (in counts) to the best fitting model (in units of
ergs/s/cm^2/A) scaled to match the photo fiber mag. Because the individual
exposures were taken under different conditions, the zeropoint of the
flux calibration vectors from different exposures will be different. To
eliminate this problem all of the vectors are normalized between
5700-6300 A. (The red/blue cameras sample different parts of this
wavelength region.) The average flux correction vector is the first
PCA eigenspectrum.
CALLING SEQUENCE:
pca_flux_standard, loglam, stdflux, stdivar, stdmask, stdinfo, [camid=, $
corvector=, corvivar=, cormed=, fcor=, fsig=, noplot=]
INPUTS:
loglam - wavelength in log10(Angstroms) of the input spectra [npix]
stdflux - array of standard star spectra [npix, nstar*nexp]
stdivar - inverse variance of standard star spectra [npix, nstar*nexp]
stdmask - or mask of the standard star spectra [npix, nstar*exp]
stdinfo - structure containing info about the best model fit produced by
"stype_standard"
OPTIONAL INPUTS:
camid - string giving the camera id for plot titles -- i.e. 'b1'
noplot - toggle plotting
OUTPUT:
A structure containing the coefficients of a spline fit the average
flux correction vector (normalized at 5700-6300 A).
Diagnostic plots are also produced. The flux correction vector produced
from each high S/N standard is plotted in black; the mean of all the
fluxcor vectors in green; and the bspline of the mean vector in red.
OPTIONAL OUTPUTS:
corvector - flux calibrations derived from the individual standard
stars [npix, nstar*nexp]
corvivar - inverse variance of flux calib vectors [npix, nstar*nexp]
fcor - final flux correction vector [npix] (not spline fit)
fsig - standard deviation of the flux calibration derived from
individual stars about the final answer (scalar)
COMMENTS:
EXAMPLES:
BUGS:
The Kurucz models we are using have not been fully tested. Do they
yield reliable broad band fluxes at all T_eff & [Fe/H]??
The mean flux calib vector produced by the PCA sometimes shows abrupt
jumps in flux -- this is somewhat mitigated by the spline fit.
PROCEDURES CALLED:
bspline_bkpts()
bspline_iterfit()
bspline_valu()
djs_iterstat()
djs_median()
pca_solve
skymask()
spdata2model_ratio
INTERNAL SUPPORT ROUTINES
REVISION HISTORY:
12-Aug-2003 Split off corvector creation into "spdata2model"
22-Sep-2002 Revised to use Kurucz models by C. Tremonti, JHU
08-Sep-2000 Formerly newfluxcalib Written by D. Schlegel & S. Burles
(See pro/fluxfix/pca_flux_standard.pro)
NAME:
pca_lrgtest
PURPOSE:
Build PCA templates for LRGs within a specified redshift range.
CALLING SEQUENCE:
pca_lrgtest, [ platenums, nkeep=, zrange= ]
INPUTS:
OPTIONAL INPUTS:
platenums - Plate number(s) from which to select the LRGs; if not set,
then select all 'main' survey plates with QSURVEY=1
in the plate list file (which are required to be unique
tiles with good quality observations)
nkeep - Number of PCA templates to keep (and to use for
noisy data replacement); default to 2.
zrange - 2-element array with redshift range for fitting; if not set,
then call this routine iteratively with redshift ranges
starting at [0,0.05] and extending to [0.45,0.50], spaced
every 0.05 in redshift.
OUTPUT:
OPTIONAL OUTPUTS:
COMMENTS:
The output are written to FITS files named "spLRG_xxx_yyy.fits" where
"xxx" is the starting redshift times 100, and "yyy" is the ending
redshift times ten.
EXAMPLES:
Create a set of PCA templates for LRGs from plates 400 through 409:
IDL> pca_lrgtest, 400+lindgen(10)
BUGS:
PROCEDURES CALLED:
djs_maskinterp()
djs_median
mwrfits
pca_solve()
platelist
readspec
splog
skymask()
sxaddhist
sxaddpar
wavevector()
REVISION HISTORY:
23-Mar-2001 Written by David Schlegel, Princeton.
17-Sep-2003 Modified for N. Padmanabhan
(See pro/spec1d/pca_lrgtest.pro)
NAME:
pca_solve
PURPOSE:
Iteratively find PCA solution for noisy or gappy spectra.
CALLING SEQUENCE:
res = pca_solve( objflux, objivar, objloglam, [ zfit, $
wavemin=, wavemax=, newloglam=, $
maxiter=, niter=, nkeep=, nreturn=, eigenval=, acoeff=, outmask=, $
usemask=, /quiet, _EXTRA= ] )
INPUTS:
objflux - Object fluxes [NPIX,NSPEC]
objivar - Object inverse variances [NPIX,NSPEC]
OPTIONAL INPUTS:
objloglam - Object wavelengths in log10(Angstroms)
[NPIX] if the same wavelength mapping for all spectra,
or [NPIX,NSPEC] if the wavelength mappings are different.
zfit - Redshifts of each input spectrum [NSPEC]; if set, then
each input spectrum is de-redshifted to z=0.
wavemin - Minimum wavelength to use in PCA solution, in Angstroms;
default to the minimum (de-redshifted) input wavelength.
wavemax - Maximum wavelength to use in PCA solution, in Angstroms
default to the minimum (de-redshifted) input wavelength.
newloglam - PCA wavelength sampling in log-10(Angstroms) [NNEWPIX]
maxiter - Number of rejection iterations; default to 0 (no rejection)
niter - Number of PCA iterations; default to 10.
nkeep - Number of PCA components to keep in each iteration
and use in replacing noisy or missing data; default to 3.
nreturn - Number of PCA components to return; default to the same as
NKEEP.
quiet - Minimal output to splog
_EXTRA - Keywords for DJS_REJECT().
OUTPUTS:
res - PCA spectra in rest-frame [NNEWPIX,NKEEP]
OPTIONAL OUTPUTS:
newloglam - PCA wavelength sampling in log-10(Angstroms) [NNEWPIX]
newflux - Rebinned OBJFLUX on the wavelength-mapping NEWLOGLAM.
newivar - Rebinned OBJIVAR on the wavelength-mapping NEWLOGLAM.
eigenval - Eigenvalue for each output eigenspectra [NRETURN]
acoeff - PCA coefficients [NRETURN,NOBJ]
outmask - Output mask from DJS_REJECT() [NNEWPIX,NOBJ]
usemask - Number of unmasked spectra used for each pixel, so these
are integers in the range 0 to NSPEC [NNEWPIX]; this is
equivalent to TOTAL(OUTMASK,2).
COMMENTS:
The best-fit eigenspectra for each of the input spectra can be determined
for object number IOBJ by ACOEFF[*,IOBJ] # RES.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
combine1fiber
computechi2()
djs_mean()
djs_reject()
splog
wavevector()
REVISION HISTORY:
10-Oct-2000 Written by D. Schlegel, Princeton
07-Jul-2003 added quiet keyword - C. Tremonti
(See pro/spec1d/pca_solve.pro)
NAME:
photo_loader
PURPOSE:
Write PHOTO outputs from SDSS_READOBJ() to an ASCII stream for direct input
into Postgres
CALLING SEQUENCE:
photo_loader, runnum, camcol, rerun=, [ table=, /create, /clobber ]
INPUTS:
runnum - Run number
camcol - Camera column
rerun - Rerun name
OPTIONAL INPUTS:
table - Database table name; default to "photo"
create - If set, then assume that the database definition
does not exist and create it
clobber - If set, then clobber any existing table by this name
OUTPUT:
OPTIONAL OUTPUTS:
COMMENTS:
Unsupported IDL variable types: UINT, ULONG, ULONG64, COMPLEX, DCOMPLEX.
IDL type BYTE is converted to a 2-byte integer.
EXAMPLES:
echo "photo_loader,3511,1,rerun=131,/create" | idl | psql foo
BUGS:
PROCEDURES CALLED:
sdss_readobj()
REVISION HISTORY:
02-May-2003 Written by D. Schlegel and D. Hogg, Princeton.
(See pro/specdb/photo_loader.pro)
NAME:
pixelmask_bits
PURPOSE:
Return mask value corresponding to a mask condition for either FIBERMASK
or PIXELMASK.
CALLING SEQUENCE:
mask = pixelmask_bits(label)
INPUTS:
label - String name specifying bit
OUTPUTS:
mask - Signed long set to 2^BIT, with BIT specified by LABEL.
OPTIONAL OUTPUTS:
COMMENTS:
This routine is also called by FIBERMASK_BITS().
EXAMPLES:
mask = pixelmask_bits('FULLREJECT')
BUGS:
PROCEDURES CALLED:
sdss_flagval()
DATA FILES:
REVISION HISTORY:
23-Jan-2000 Written by S. Burles, Chicago
27-Jan-2000 Changed from signed int to signed long.
14-Jul-2000 Combine with FIBERMASK_BITS(), and use data file in /etc
subdirectory (DJS).
02-Apr-2002 Now use the even more generalized call to SDSS_FLAGVAL().
(See pro/spec2d/pixelmask_bits.pro)
NAME: platecen_test PURPOSE: Find where RA,DEC and RADEG,DECDEG disagree in the spPlate headers. CALLING SEQUENCE: platecen_test INPUTS: OPTIONAL INPUTS: OUTPUT: OPTIONAL OUTPUTS: COMMENTS: Find all the files matching '$SPECTRO_DATA/*/spPlate*.fits', and test whether the RA,DEC positions disagree by more than 0.1 degrees from RADEC,DECDEG. This would indicate some inconsistency in the header info that should be fixed. EXAMPLES: BUGS: PROCEDURES CALLED: headfits() splog sxpar() REVISION HISTORY: 19-Dec-2001 Written by David Schlegel, Princeton (not checked in then)
(See pro/plan/platecen_test.pro)
NAME:
platecompare
PURPOSE:
Interactive comparison of descrepant redshifts for the same objects.
CALLING SEQUENCE:
platecompare, plate, [mjd=, topdir=, psfile= ]
INPUTS:
plate - Plate number(s)
OPTIONAL INPUTS:
mjd - MJD for each plate number. If specified, then this
must have one MJD per plate number. If not specified,
then all MJD's associated with each plate are read.
That list of MJD's comes from the PLATELIST command.
topdir - Top-level directory for outputs if comparing different
reductions (i.e., different versions) of the same data.
psfile - If set, then send plot to a PostScript file instead of
to the SPLOT interactive widget. The PostScript file name
can be set explicitly, e.g. with PSFILE='test.ps'. Or if
you simply set this as a flag, e.g. with /PSFILE, then the
default file name is platecompare-pppp.ps,
where pppp is the first plate number.
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
Duplicate objects are found by matching positions to within 1 arcsec.
Plot any objects that show a descrepency in redshifts between any
of the observations, or any objects that have ZWARNING set to zero
in one observation and non-zero in another.
EXAMPLES:
Compare data from different pluggings of the same plate:
IDL> platecompare, [406,406,406], mjd=[51817,51869,51876]
Compare date from two plates, 360 and 362, which are actually the
same tile on the sky:
IDL> platecompare, [360,360,362], mjd=[51780,51816,51999]
Compare different reductions of the same data, in this case plate 401/51788:
IDL> platecompare, 401, mjd=51788, $
IDL> topdir=['/u/dss/spectro','/u/dss/spectro/test']
BUGS:
PROCEDURES CALLED:
dfpsclose
dfpsplot
djs_angle_group
djs_icolor()
djs_oplot
djs_plot
platelist
readspec
sdss_flagname()
struct_append()
REVISION HISTORY:
14-Aug-2001 Written by D. Schlegel, Princeton
(See pro/spec1d/platecompare.pro)
NAME:
platelinks
PURPOSE:
Build links from another directory to the spectroscopic output files.
CALLING SEQUENCE:
platelinks, outdir, [ public= ]
INPUTS:
OPTIONAL INPUTS:
outdir - Directory in which to build all links. These links are
built to the files in $SPECTRO_DATA.
public - If set with /PUBLIC, then build links to any files with
anything in the PUBLIC field of the plate list.
If set to a string, then select those plates that contain
the substring PUBLIC within their PUBLIC field.
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
IDL> platelinks, '/u/schlegel/spectro_EDR', public='EDR'
BUGS:
DATA FILES:
PROCEDURES CALLED:
djs_filepath()
fileandpath()
platelist
splog
REVISION HISTORY:
21-Jan-2003 Written by D. Schlegel, Princeton
(See pro/spec1d/platelinks.pro)
NAME:
platelist
PURPOSE:
Make list of reduced plates
CALLING SEQUENCE:
platelist, [infile, /create, /purge2d, /purge1d, /killpartial, plist= ]
INPUTS:
OPTIONAL INPUTS:
infile - Either a list of combine-plan files or a list of plate files,
which can contain wildcards.
If not specified, then search for all plan files matching
'$SPECTRO_DATA/*/spPlancomb-*.par'.
If no such plan files are found, then search for all plate
files matching
'$SPECTRO_DATA/*/spPlate-*.fits'.
create - If set, then re-generate the "platelist.fits" file;
if not set, then simply read this file from a previous call.
purge2d - If set, then delete all log files for plates that are
considered to be 'RUNNING', but not those that are 'Done',
'Pending' or 'FAILED'. Those plates are then listed as
'Pending'. Setting /PURGE2D also sets /CREATE.
Deleting these log files will cause the next invocation
of BATCH2D to re-reduce those plates.
purge1d - If set, then delete all log files for plates that are
considered to be 'RUNNING', but not those that are 'Done',
'Pending' or 'FAILED'. Those plates are then listed as
'Pending'. Setting /PURGE1D also sets /CREATE.
Deleting these log files will cause the next invocation
of BATCH1D to re-reduce those plates.
killpartial - If set, then delete all files associated with a combine
of only some nights of a multi-night plate. Such files
can be produced by the Spectro-Robot when it fully reduces
data from one night, but then more data is obtained for
that plugging of the same plate on a later date. This
deletes spPlate and spZ files and their logs files.
OUTPUTS:
OPTIONAL OUTPUTS:
plist - Output structure with information for each plate.
COMMENTS:
The following files are generated:
$SPECTRO_DATA/platelist.fits
$SPECTRO_DATA/platelist.txt
$SPECTRO_DATA/platelist.html
$SPECTRO_DATA/platelist-mjdsort.txt
$SPECTRO_DATA/platelist-mjdsort.html
$SPECTRO_DATA/platequality.txt
$SPECTRO_DATA/platequality.html
$SPECTRO_DATA/platequality-mjdsort.txt
$SPECTRO_DATA/platequalitymjdsort.html
If INFILE is a list of plan files, i.e.
spPlancomb-0306-51690.par
then look for the following files for the 2D reductions:
spPlancomb-0306-51690.par
spDiagcomb-0306-51690.log
spPlan2d-0306-51690.par (as specified by 'planfile2d' in spPlancomb)
spDiag2d-0306-51690.log
spPlate-0306-51690.fits (as specified by 'combinefile' in spPlancomb)
and look for the following files for the 1D reductions:
spPlan1d-0306-51690.par
spZbest-0306-51690.fits
spDiag1d-0306-51690.log
PLATESN2 is set to the minimum of the 4 cameras.
PLATEQUALITY defaults to 'good'.
PLATEQUALITY is set to 'marginal' if MINSN2 < 15.0
'bad' if MINSN2 < 13.0
PLATEQUALITY is set to 'marginal' if FBADPIX > 0.05
'bad' if FBADPIX > 0.10
PLATEQUALITY is set to 'marginal' if min(NEXP_*) < 3
'bad' if min(NEXP_*) < 2
Decide which plates constitute unique tiles with the required S/N,
then set QSURVEY=1. Require PLATEQUALITY='good' or 'marginal'.
Also require PROGNAME='main'.
EXAMPLES:
BUGS:
Spawns the Unix command 'tail' to get the last line of log files.
DATA FILES:
$IDLSPEC2D_DIR/etc/spChunkList.par
$IDLSPEC2D_DIR/etc/spPlateList.par
PROCEDURES CALLED:
apo_checklimits()
chunkinfo()
copy_struct_inx
djs_diff_angle()
djs_filepath()
fileandpath()
headfits()
mrdfits()
repstr()
rmfile
splog
struct_print
sxpar()
tai2airmass()
yanny_free
yanny_par()
yanny_read
yanny_readone()
INTERNAL SUPPORT ROUTINES:
platelist_write
REVISION HISTORY:
29-Oct-2000 Written by D. Schlegel, Princeton
(See pro/spec1d/platelist.pro)
NAME:
platemerge
PURPOSE:
Merge all Spectro-1D outputs with tsObj files.
CALLING SEQUENCE:
platemerge, [ plate, mjd=, except_tags=, outroot=, public= ]
INPUTS:
OPTIONAL INPUTS:
plate - Plates to include; default to all files
specified by the PLATELIST routine.
mjd - Optional MJDs corresponding to the specified PLATEs;
if specified, then PLATE and MJD should have the same
number of elements.
except_tags - Tag names to exclude; default to '*COVAR'.
outroot - Root name for output files; default to '$SPECTRO_DATA/spAll';
the files are then 'spAll.fits', 'spAll.dat', 'spAllLine.dat'.
If /PUBLIC is set, then add '-public' to the root name.
If PUBLIC is set to a string, then add that string to the
root name.
public - If set with /PUBLIC, then limit to plates that have
any entry in the PUBLIC field of the plate list.
If set to a string, then select those plates that contain
the substring PUBLIC within their PUBLIC field.
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
The SPECPRIMARY output element is used to select a unique set of
objects in the case of duplicate observations. Any objects observed
multiple times will have SPECPRIMARY=1 for one instance only, and =0
for all other instances. The criteria (in order of importance) are
as follows:
1) Prefer observations with positive SN_MEDIAN
2) Prefer PLATEQUALITY='good' over any other plate quality
3) Prefer observations with ZWARNING=0
4) Prefer objects with larger SN_MEDIAN
Temporary files are created first, such as 'spAll.fits.tmp', which
are renamed at the end of the routine to 'spAll.fits', etc.
EXAMPLES:
BUGS:
DATA FILES:
PROCEDURES CALLED:
copy_struct
copy_struct_inx
djs_filepath()
headfits()
hogg_mrdfits()
mrdfits()
mwrfits_chunks
plug2tsobj()
platelist
readspec
repstr
spheregroup
splog
struct_print
sxaddpar
sxpar()
REVISION HISTORY:
30-Oct-2000 Written by D. Schlegel, Princeton
(See pro/spec1d/platemerge.pro)
NAME:
platesn
PURPOSE:
Generate S/N plots for an entire plate.
CALLING SEQUENCE:
platesn, [ objflux, objivar, andmask, plugmap, loglam, $
filtsz=, hdr=, platefile=, plotfile=, snvec=, synthmag= ]
INPUTS:
OPTIONAL KEYWORDS:
objflux -
objivar -
andmask -
plugmap -
loglam -
filtsz - Filter size for median-filtering the S/N values within
a spectrum; default to 25 pix.
hdr - FITS header; if specified, then keywords are added.
The PLATE and MJD for the plot title are from this header.
platefile - If set, then read OBJFLUX and all the other inputs from
this spPlate file instead of using those inputs;
also, generate PostScript plots using the PLATESN procedure.
plotfile - If set, then write PostScript plot to this file.
OUTPUTS:
OPTIONAL OUTPUTS:
hdr - [Modified]
snvec - S/N vector for g,r,i bands
synthmag - Synthetic magnitudes from convolution with fiducial
filter curves
COMMENTS:
EXAMPLES:
BUGS:
PROCEDURES CALLED:
djs_iterstat
djs_mean()
djs_median()
filter_thru()
pixelmask_bits()
plotsn
sdss_flagval()
sdss_flagname()
splog
sxaddpar
sxpar()
REVISION HISTORY:
06-Oct-2000 Written by S. Burles & D. Schlegel
20-Oct-2002 C. Tremonti added header keywords to access spectrophotometry
(See pro/spec2d/platesn.pro)
NAME:
plate_newcenter
PURPOSE:
Find the new plate center when trying to put an object at the same
position relative to the center.
CALLING SEQUENCE:
plate_rotate, racen1, deccen1, racen2, deccen2, ra1, dec1, ra2, dec2, $
[maxerr= ]
INPUTS:
racen1, deccen1 - Center of pointing 1
ra1, dec1 - positions on plate 1
ra2, dec2 - positions on plate 2
OPTIONAL INPUTS:
maxerr - Maximum error in arcsec; default to 0.01 arcsec
OUTPUTS:
racen2, deccen2 - Center of pointing 2
COMMENTS:
This routine is complementary to PLATE_ROTATE, solving for a
different unknown (the 2nd plate center).
BUGS:
REVISION HISTORY:
2001-Nov-27 Written by D. Schlegel, Princeton.
(See pro/plate/plate_newcenter.pro)
NAME:
plate_rotate
PURPOSE:
Rotate (RA, dec) positions for one plate center to another plate center
CALLING SEQUENCE:
plate_rotate, racen1, deccen1, racen2, deccen2, ra1, dec1, ra2, dec2
INPUTS:
racen1, deccen1 - Center of pointing 1
racen2, deccen2 - Center of pointing 2
ra1, dec1 - positions on plate 1
OUTPUTS:
ra2, dec2 - positions on plate 2
COMMENTS:
This routine determines the rotation that maps (racen1, deccen1)
onto (racen2, deccen2), and applies it to (ra1, dec1) (which may
be vectors. By convention, North is "up" on both plates 1 & 2.
This routine is useful for the bright stars survey, where one must
drill holes for several pointings in the same plate.
BUGS:
REVISION HISTORY:
2001-Sep-07 Written by D. Finkbeiner, Princeton.
(See pro/plate/plate_rotate.pro)
NAME:
plotsignal
PURPOSE:
Plot the signal (not S/N) seen on each plate+exposure+CCD.
CALLING SEQUENCE:
plotsignal, plate, [ expnum, camname=, /addsky ]
INPUTS:
plate - Plate number
OPTIONAL INPUTS:
expnum - Exposure number(s); default to all exposures that have
an spFrame-b1 file on disk
camname - Camera name(s); default to ['b2','r2','b1','r1']
addsky - If set, then add the sky signal back in, rather than
using the sky-subtracted signal
OUTPUT:
OPTIONAL OUTPUTS:
COMMENTS:
Most of our diagnostic plots show the S/N of the spectrographs.
These plots show the signal, and provide plots for each exposure.
One PostScript file is produced, with one page with one page per
exposure number. The file names are:
spSignal-$PLATE.ps
spSignal-$PLATE-addsky.ps -- If /ADDSKY is specified
The spectro magnitudes are scaled to the 1st exposure on each
plate+MJD+camera combination. There is a simple scaling for the
exposure time, but otherwise more-cloudy exposures will show as
negative (red) residuals.
This plots the signal after sky-subtraction, unless /ADDSKY is set.
EXAMPLES:
Plot the signal seen on all exposures for plate 1489:
IDL> plotsignal, 1489
BUGS:
PROCEDURES CALLED:
bspline_valu()
dfpsclose
dfpsplot
djs_filepath()
djs_oplot
djs_plot
djs_xyouts
filter_thru()
mrdfits()
splog
sxpar()
traceset2xy
REVISION HISTORY:
30-Dec-2003 Written by D. Schlegel, Princeton.
(See pro/spec2d/plotsignal.pro)
NAME:
plotsn
PURPOSE:
Plot S/N and residuals in up to 3 bands
CALLING SEQUENCE:
plotsn, snvec, plugmap, [ bands=, plotmag=, fitmag=, snmag=, plottitle=, $
plotfile=, synthmag=, snplate= ]
INPUTS:
snvec - S/N array [nbands, nfibers]
plugmap - Plugmap structure [nfibers]
OPTIONAL KEYWORDS:
bands - Index of bands to fit; default to [1,2,3] for g,r,i bands.
fitmag - Magnitude range over which to fit (S/N) as function of mag;
default to those used by FITSN().
snmag - Fit magnitudes for all 5 bands (even if we don't specify
to use all of them with BANDS); default to
[20.0, 20.2, 20.25, 19.9, 19.0]
plotmag - Magnitude range for plotting; default to [15,21], but
extend the range to include FITMAG if necessary.
plottitle - Title for top of plot
plotfile - Optional plot file
synthmag - Vector of synthetic magnitudes dimensionsed [5,640],
but only the central three mags (gri) are used;
if set, then make more than the first page of plots
OUTPUTS:
OPTIONAL OUTPUTS:
snplate - Best fit (S/N)^2 at fiducial magnitude
COMMENTS:
The fiducial magnitudes at which to evaluate the fit to (S/N) are
[20.0, 20.2, 20.25, 19.9, 19.0] in u,g,r,i,z bands.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
djs_arrow
djs_icolor()
djs_iterstat
djs_oplot
djs_plot
djs_xyouts
fitsn()
splog
INTERNAL SUPPORT ROUTINES:
plotsn_good()
plotsn1
REVISION HISTORY:
28-Jan-2003 Add E(B-V) keyword to allow for spectra which have
foreground reddening removed
20-Oct-2002 Plot range on synthmag vs fiber mag plot changed by C. Tremonti
15-Apr-2000 Written by S. Burles, FNAL
(See pro/spec2d/plotsn.pro)
NAME:
plotspec
PURPOSE:
Routine for plotting spectra from Princeton-1D spectro outputs.
CALLING SEQUENCE:
plotspec, plate, [ fiberid, mjd=, znum=, nsmooth=, /zline, /nosyn, /noerr, $
/sky, /ormask, /andmask, psfile=, /restframe, /netimage, $
/zwarning, /allexp, topdir=, _EXTRA= ]
INPUTS:
plate - Plate number(s)
OPTIONAL INPUTS:
fiberid - Fiber number(s); if not set, then plot all fibers for
each plate specified.
mjd - MJD number(s); if not set, then select the most recent
data for each plate (largest MJD).
znum - If set, then return not the best-fit redshift, but the
ZUM-th best-fit; e.g., set ZNUM=2 for second-best fit.
nsmooth - If set, then boxcar smooth both the object and synthetic
spectra with a width equal to NSMOOTH.
zline - If set, then overplot the emission line fits.
nosyn - If set, then do not overplot the synthetic fit spectrum (blue).
noerr - If set, then do not overplot the error vector (red).
sky - If set, then overplot the sky spectrum (green).
ormask - If set, then plot the OR-mask bits in yellow crosses.
andmask - If set, then plot the AND-mask bits in red squares.
psfile - If set, then send plot to a PostScript file instead of
to the SPLOT interactive widget. The PostScript file name
can be set explicitly, e.g. with PSFILE='test.ps'. Or if
you simply set this as a flag, e.g. with /PSFILE, then the
default file name is "spec-pppp-mmmmm-fff.ps",
where pppp=plate number, mmmmm=MJD, fff=fiber ID.
If FIBERID is specified, then put all plots in a single file
named "spec-pppp-mmmmm.ps".
restframe - If set, then plot the wavelengths in the rest frame,
e.g. divide the wavelengths by (1+z).
netimage - If set, then launch a Netscape browser with the object
image from Steve Kent's web site. This only works if
Netscape is running and has permissions at the site
"http://sdssmosaic.fnal.gov:8015". ???
This is disabled if PSFILE is set.
zwarning - If set, then only select those non-sky fibers where the
ZWARNING flag has been set; can be used with or without
specifying fiber numbers with FIBERID.
allexp - If set, then plot all the individual exposure spectra,
rather than the co-added spectrum.
topdir - Top-level directory for data; default to the environment
variable $SPECTRO_DATA.
_EXTRA - Kewords for SPLOT and XYOUTS, such as XRANGE, YRANGE, THICK.
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
The data are read with READSPEC. See the documentation for that
routine to see how to set environment variables that describe where
the data files are.
EXAMPLES:
Plot the spectrum of plate 401, fiber #100 using the SPLOT plotting tool:
IDL> plotspec, 401, 100
The spectrum is shown in white, the errors in red (except masked points
are set to zero), and the best-fit eigenspectrum in blue. The mouse
buttons will zoom in (left), recenter (center), or zoom out (right).
The frame can be saved as a PostScript file by selecting File->WriteEPS
from the left-hand corner.
Make the same plot, but boxcar-smooth the spectrum and limit the
wavelength range to [4000,5000] Angstroms:
IDL> plotspec, 401, 100, nsmooth=10, xrange=[5000,6000]
Some plates are observed on multiple nights. To select one of the two
observations of plate 306:
IDL> plotspec, 306, 20, mjd=51690
Loop through all the spectra for plate 401, interactively:
IDL> plotspec, 401
Plot all the spectra from plate 401 to a single PostScript file:
IDL> plotspec, 401, /psfile
Plot all the spectra from plate 401 to 640 individual PostScript files:
IDL> plotspec, 401, lindgen(640)+1, /psfile
Plot a list of 3 objects, each with its own plate, MJD, and fiberid:
IDL> plate = [400,400,401]
IDL> mjd = [51820,51820,51788]
IDL> fiberid = [10,11,20]
IDL> plotspec, plate, mjd=mjd, fiberid
BUGS:
If the user interactively rescales in Y, then the labels for ORMASK
and ANDMASK are no longer lined up vertically with the bit mask plot.
PROCEDURES CALLED:
dfpsclose
dfpsplot
djs_icolor()
djs_oplot
djs_plot
djs_xyouts
plotspec_image
readspec
soplot
splot
sdss_flagname()
sxyouts
synthspec()
textoidl()
INTERNAL SUPPORT ROUTINES:
plotspec_mask
plotspec1
REVISION HISTORY:
01-Sep-2000 Written by D. Schlegel, Princeton
(See pro/spec1d/plotspec.pro)
NAME: plotspec_image PURPOSE: Procedure to display an image, launched from PLOTSPEC CALLING SEQUENCE: plotspec_image, ra, dec, [ _EXTRA= ] INPUTS: ra - Right ascension (degrees) dec - Declination (degrees) OPTIONAL INPUTS: _EXTRA - Keywords to pass to FPBIN_TO_FRAME OUTPUTS: OPTIONAL OUTPUTS: COMMENTS: EXAMPLES: BUGS: PROCEDURES CALLED: atv fpbin_to_frame() REVISION HISTORY: 30-Sep-2005 Written by D. Schlegel, Princeton
(See pro/spec1d/plotspec_image.pro)
NAME:
plug2tsobj
PURPOSE:
Construct a tsObj structure that matches all entries in a plugmap structure
CALLING SEQUENCE:
tsobj = plug2tsobj(plateid, [ra, dec, plugmap=, dmin=, /silent ])
INPUTS:
plateid - Plate number; this can be either a scalar, in which case
the same plate is used for all objects, or a vector.
OPTIONAL INPUTS:
ra - Array of right ascension (degrees)
dec - Array of declination (degrees)
plugmap - Plug map structure, which must contain RA, DEC.
This must be set if RA and DEC are not set.
dmin - Minimum separation between input position and position
of the closest match using MATCHRA,MATCHDEC in the calibObj
files; default to 1.0 arcsec.
OUTPUTS:
tsobj - tsObj structure, sorted such that each entry corresponds
to each entry in the PLUGMAP structure; return 0 if the
tsObj file was not found on disk.
OPTIONAL OUTPUTS:
silent - Make the call to MRDFITS silent, but still log warning
messages if the calibObj file is not found or is empty.
COMMENTS:
The calibObj files are assumed to be in the directory $SPECTRO_DATA/calibobj.
These files were to have only the 640 objects for each plate.
But since plates can be re-plugged, we must re-sort these
files to match the object ordering in the plug-map structure.
Print a warning message for non-matched objects only if they are not skies,
according to the PLUGMAP structure.
EXAMPLES:
Read the plug-map for plate 306, fibers 1 to 10, then construct the
calibObj structure:
> readspec, 306, indgen(10)+1, plug=plug
> tsobj = plug2tsobj(306,plugmap=plug)
BUGS:
PROCEDURES CALLED:
djs_diff_angle()
fits_read
mrdfits
splog
REVISION HISTORY:
25-Jun-2000 Written by David Schlegel, Princeton.
(See pro/spec1d/plug2tsobj.pro)
NAME:
plugfile_relabel
PURPOSE:
Relabel the OBJTYPE's for specified objects in all plPlugMapM files.
CALLING SEQUENCE:
plufile_relabel, [ infile, objtype= ]
INPUTS:
OPTIONAL INPUTS:
infile - ASCII file with plate, mjd, fiberid, as written
by BADFSTARS (for example); default to 'badfstars.log'
objtype - New OBJTYPE for these objects; default to 'SERENDIPITY_MANUAL'
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
This procedure was written to get rid of objects from the plPlugMapM
files that were incorrectly being used as F star calibrators
(either SPECTROPHOTO_STD or REDDEN_STD targets). For a specified list
of objects, this proc changes the OBJTYPE to 'SERENDIPITY_MANUAL'.
Note that the target flags are not changed, since they are not used
anyway by Spectro-2D. This means that we will still have the 2 or 32
values set in SECTARGET.
For the input list of objects, I use READSPEC to find the coordinates
of the object, and then the object is changed in all the plPlugMapM
files for that plate.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
djs_diff_angle()
readspec
splog
yanny_read
yanny_write
REVISION HISTORY:
06-Feb-2004 Written by D. Schlegel, Princeton
(See pro/plan/plugfile_relabel.pro)
NAME:
plugfile_unmapped
PURPOSE:
List which fibers in a plPlugMapM file are unmapped, and the info
that might help decide where those fibers should be.
CALLING SEQUENCE:
plugfile_unmapped, filename
INPUTS:
filename - Look for a plPlugMapM file in the speclog directory
matching $SPECLOG_DIR/?????/FILENAME.
OPTIONAL INPUTS:
OUTPUT:
OPTIONAL OUTPUTS:
COMMENTS:
There are two lists of information provided: First, the list of fiber
numbers that are not plugged, and the RA,DEC ranges of the other 19 fibers
in that bundle on this plate. Second, a list of the object information
for the unplugged objects, including their RA,DEC position and the fiber
numbers of the nearest plugged fibers.
Presumably, those unplugged objects will be plugged by one of the fibers
whose neighboring fiber numbers are nearby. This isn't necessarily true,
for example if the pluggers simply skipped one fiber entirely while
plugging, and the unplugged object is in a completely un-reachable
position elsewhere on the plate.
A companion procedure to this is FIND_UNPLUGGED.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
djs_diff_angle()
splog
yanny_readone()
REVISION HISTORY:
10-Sep-2003 Written by David Schlegel, Princeton (not checked in then)
(See pro/plan/plugfile_unmapped.pro)
NAME:
plughistory
PURPOSE:
Plot the history of unplugged fibers based upon plPlugMapM files.
CALLING SEQUENCE:
plughistory, [ mjdrange= ]
INPUTS:
OPTIONAL INPUTS:
mjdrange - 2-element vector of plotting range in MJD; default to
using all MJDs.
OUTPUT:
COMMENTS:
A single PostScript file is created "Plughistory-$MJDSTART-$MJDEND.ps",
with one page per cartridge. The top panel shows the number of fibers
plugged as a function of MJD. The bottom panel shows the fraction
of times each fiber is plugged, with < 90%-plugged fibers labelled
with their fiber number.
EXAMPLES:
Make plots of history of unplugged fibers for all time:
IDL> plughistory
Make plots of history of unplugged fibers between MJD 52000 and MJD 52100:
IDL> plughistory, mjdrange=[52000,52100]
BUGS:
PROCEDURES CALLED:
dfpsclose
dfpsplot
fileandpath()
yanhy_free
yanny_par()
yanny_read
REVISION HISTORY:
27-Feb-2002 Written by David Schlegel, Princeton.
(See pro/apo2d/plughistory.pro)
NAME: plugmap_tycho PURPOSE: Plot bright Tycho stars on a plate CALLING SEQUENCE: plugmap_tycho, plugfile, [ matchdist=, mlimit= ] INPUTS: plugfile - Name of plugmap file (either plPlugMapP or plPlugMapM) OPTIONAL INPUTS: matchdist - Match distance for Tycho stars; default to 5./3600 degrees mlimit - Magnitude limit for Tycho stars in VTMAG; default to 15.0 OUTPUTS: OPTIONAL OUTPUTS: COMMENTS: Plot bright Tycho stars on plates, for the purpose of having these fibers not be plugged at APO. In particular, this procedure was written to deal with the two SEGUE plates 2333 and 2338, as per discussion in the mailing lists on 31 Oct 2005. EXAMPLES: IDL> plugmap_tycho, 'plPlugMapP-2333.par', mlimit=10.5 IDL> plugmap_tycho, 'plPlugMapP-2338.par', mlimit=11.5 BUGS: DATA FILES: PROCEDURES CALLED: djs_oplot djs_plot splog tycho_read() yanny_par() yanny_readone() INTERNAL SUPPORT ROUTINES: tycho_plot_unplugged REVISION HISTORY: 31-Oct-2005 Written by D. Schlegel, Princeton
(See pro/apo2d/plugmap_tycho.pro)
NAME:
postgres_write
PURPOSE:
Write an IDL structure to a Postgres-readable file
CALLING SEQUENCE:
postgres_write, filename, pdata, [table=, delim=, /append, $
scriptfile= ]
INPUTS:
filename - Output file name
pdata - Structure to write
OPTIONAL INPUTS:
table - Name of table; default to the structure name or 'anonymous'
delim - Postgres delimiter; default to the tab character
append - If set, then append to an existing file
scriptfile - Name of file for writing Postgres importing script
OUTPUT:
OPTIONAL OUTPUTS:
COMMENTS:
Unsupported IDL variable types: UINT, ULONG, ULONG64, COMPLEX, DCOMPLEX.
IDL type BYTE is converted to a 2-byte integer.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
REVISION HISTORY:
06-Apr-2000 Written by David Schlegel, Princeton.
(See pro/specdb/postgres_write.pro)
NAME: qaplot_arcline PURPOSE: Generate QA plot for arcline fits CALLING SEQUENCE: qaplot_arcline, xdif, lambda, [color=, fibermask=, title=] INPUTS: xdif - Deviations in arc line fits in pixels, array [NFIBER, NLAMP] lambda - Wavelength for each lamp in Angstroms, vector [NLAMP] OPTIONAL KEYWORDS: color - Specify 'blue' or 'red' to fix plotting limits fibermask - Fiber status bits, set nonzero for bad status [NFIBER] title - TITLE of plot OUTPUTS: OPTIONAL OUTPUTS: COMMENTS: Skip over bad fibers in plots. EXAMPLES: BUGS: PROCEDURES CALLED: djs_iterstat djs_oplot djs_plot errplot fibermask_bits() traceset2xy splog REVISION HISTORY: 15-Oct-1999 Written by D. Finkbeiner, APO 23-Nov-1999 Modified by D. Schlegel, Princeton
(See pro/spec2d/qaplot_arcline.pro)
NAME:
qaplot_fcalibvec
PURPOSE:
Generate QA plot: apparent flux-calibration errors
CALLING SEQUENCE:
qaplot_fcalibvec, loglam, objflux, objivar, synflux, plugmap, zans, $
[plottitle= ]
INPUTS:
loglam - Wavelengths in log-10(Angstroms) [NPIX]
objflux - Object flux [NPIX,NOBJ]
objivar - Object inverse variance [NPIX,NOBJ]
synflux - Best-fit model flux [NPIX,NOBJ]
plugmap - Plug-map structure [NOBJ]
zans - Structure with redshift-fit information [NOBJ]
OPTIONAL KEYWORDS:
plottitle - TITLE of plot
OUTPUTS:
Output plots only
OPTIONAL OUTPUTS:
COMMENTS:
Plot the ratio of the observed spectra divided by the best-fit
model spectra as a function of observed wavelength. Deviations
from unity are an empirical measure of the flux-calibration errors.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
djs_maskinterp()
djs_oplot
djs_xyouts
REVISION HISTORY:
26-Feb-2002 Written by D. Schlegel, Princeton
(See pro/spec1d/qaplot_fcalibvec.pro)
NAME:
qaplot_fflat
PURPOSE:
Generate QA plot for fiber-flats
CALLING SEQUENCE:
qaplot_fflat, fflat, wset, [ fibermask=, dx=, title= ]
INPUTS:
fflat - Array of flat-field flat-field vectors for each fiber
that remove relative flat-field variations as a function
of wavelength between fibers [Nrow, Ntrace]
wset - Wavelength solution
OPTIONAL KEYWORDS:
fibermask - Fiber status bits, set nonzero for bad status [NFIBER]
dx - Bin log-lambda by this number; default to 1.e-3 (about 10 pix)
title - TITLE of plot
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
Do not plot bad fibers or masked pixels in good fibers.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
djs_oplot
djs_plot
fibermask_bits()
traceset2xy
REVISION HISTORY:
23-Nov-1999 Written by D. Schlegel, Princeton
(See pro/spec2d/qaplot_fflat.pro)
NAME:
qaplot_scatlight
PURPOSE:
Generate QA plots for scattered light
CALLING SEQUENCE:
qaplot_scatlight, scatfit, yrow, wset=, xcen=, [ fibermask=, title= ]
INPUTS:
scatfit - Scattered light image after fitting [NX,NY/8]
yrow - extracted rows in scatfit
REQUIRED KEYWORDS:
wset - Wavelength solution
xcen - X positions corresponding to the extracted wavelength sol'n
[NY,NTRACE]
OPTIONAL KEYWORDS:
fibermask - Fiber status bits, set nonzero for bad status [NFIBER]
title - TITLE of plot
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
BUGS:
PROCEDURES CALLED:
djs_median()
djs_oploterr
djs_plot
traceset2xy
REVISION HISTORY:
13-Dec-1999 Written by D. Schlegel, Princeton
22-Jan-2000 Trying to speed up, S. Burles
(See pro/spec2d/qaplot_scatlight.pro)
NAME:
qaplot_skydev
PURPOSE:
Generate QA plot: scatter in sky line positions
CALLING SEQUENCE:
qaplot_skydev, flux, fluxivar, vacset, plugsort, color, $
[fibermask=, title=]
INPUTS:
flux - Pre-skysubtracted flux array [Nrow, Ntrace]
fluxivar - Associated inverse variance
vacset - Vacuum Wavelength solution
plugsort - Plugmap struct [Ntrace]
color - string specifying 'red' or 'blue' spectra
OPTIONAL KEYWORDS:
fibermask - Fiber status bits, set nonzero for bad status [NFIBER]
title - TITLE of plot
OUTPUTS:
Output plots only
OPTIONAL OUTPUTS:
COMMENTS:
This code has been deprecated in favor of QAPLOT_SKYSHIFT.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
djs_oplot
djs_plot
trace_gweight
traceset2xy
traceset2pix
djs_median
REVISION HISTORY:
22-Jan-2000 Written by S. Burles, Chicago
(See pro/spec2d/qaplot_skydev.pro)
NAME:
qaplot_skyline
PURPOSE:
Generate QA plots for flux in particular skylines
CALLING SEQUENCE:
qaplot_skyline, lwave, obj, objivar, objsub, objsubivar, plugsort, wset, $
tai=, [fibermask=, dwave=, title= ]
INPUTS:
lwave -
obj - Image
objivar - Inverse variance for OBJ
objsub - Image after sky-subtraction
objsubivar - Inverse variance for image after sky-subtraction
plugsort - Plugmap structure trimmed to one element per fiber
wset - Wavelength solution
tai - TAI time for computing airmass or elevation for each fiber
OPTIONAL KEYWORDS:
fibermask - Fiber status bits, set nonzero for bad status [NFIBER]
dwave - Half-width about LWAVE for fitting sky line;
default to 5.0 Ang
titel - File name to use for TITLE of plot
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
BUGS:
PROCEDURES CALLED:
djs_iterstat
djs_median
djs_oplot
splog
tai2airmass()
traceset2xy
INTERNAL SUPPORT ROUTINES:
REVISION HISTORY:
01-Jan-2000 Written by D. Schlegel, Princeton
(See pro/spec2d/qaplot_skyline.pro)
NAME: qaplot_skyshift PURPOSE: Generate QA plot: scatter in sky line positions CALLING SEQUENCE: qaplot_skyshift, wset, xsky, skywaves, skyshift, [title= ] INPUTS: wset - Wavelength solution from arc line spectra xsky - Pixel position of sky lines [NFIBER,NLINE] skywaves - Wavelengths of sky lines used for computing shifts (Ang) skyshift - Shifts to apply to sky lines in pix [NROW,NTRACE] OPTIONAL KEYWORDS: title - TITLE of plot OUTPUTS: Output plots only OPTIONAL OUTPUTS: COMMENTS: EXAMPLES: BUGS: PROCEDURES CALLED: djs_laxisgen() djs_oplot djs_plot traceset2pix REVISION HISTORY: 11-Apr-2000 Written by D. Schlegel, Princeton
(See pro/spec2d/qaplot_skyshift.pro)
NAME:
qaplot_skysub
PURPOSE:
Generate QA plots for sky-subtraction
CALLING SEQUENCE:
qaplot_skysub, obj, objivar, objsub, objsubivar, wset, $
iskies, [title= ]
INPUTS:
obj - Image
objivar - Inverse variance for OBJ
objsub - Image after sky-subtraction
objsubivar - Inverse variance for image after sky-subtraction
wset - Wavelength solution
iskies - List of good sky fibers
OPTIONAL KEYWORDS:
title - TITLE of plot
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
BUGS:
PROCEDURES CALLED:
djs_median
djs_oplot
djs_oploterr
djs_plot
splog
traceset2xy
INTERNAL SUPPORT ROUTINES:
skyplot
REVISION HISTORY:
30-Dec-1999 Written by D. Schlegel, Princeton
(See pro/spec2d/qaplot_skysub.pro)
NAME:
quickextract
PURPOSE:
Science frame extraction with scattered light removal and sky subtraction.
S/N is estimated and output for HTML generation.
CALLING SEQUENCE:
rstruct = quickextract(tsetfile, wsetfile, fflatfile, rawfile, outsci, $
[ radius=, filtsz= ])
INPUTS:
tsetfile - Name of fits file which contains matched trace
wsetfile - Name of fits file which contains matched wavelengths
fflatfile - Name of fits file which containes flat field vectors
rawfile - Name of SDSS science frame to extract
outsci - Name of fits file to store workings of quickextract
OPTIONAL INPUTS:
radius - Radius for boxcar extraction (default 3)
filtsz - Median filter size to apply before average S/N is calculated;
default to 25 pixels.
OUTPUT:
rstruct - Results to be added html file upon completion
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
BUGS:
PROCEDURES CALLED:
apo_checklimits()
calcscatimage
divideflat
djs_mean()
djs_median()
extract_image
extract_boxcar()
fibermask_bits()
fileandpath()
find_whopping()
fitflatwidth()
fitsn()
match_trace()
quickboxcar()
mrdfits()
mwrfits
sdssproc
skysubtract()
splog
sxpar()
traceset2xy
REVISION HISTORY:
3-Apr-2000 Written by S. Burles & D. Schlegel, APO
(See pro/apo2d/quickextract.pro)
NAME:
quicktrace
PURPOSE:
Trace and boxcar extract an SDSS flat field image
CALLING SEQUENCE:
rstruct = quicktrace (filename, tsetfile, plugmapfile, nbin=nbin)
INPUTS:
filename - Flat-field filename
tsetfile - Output FITS file
plugmapfile- Yanny parameter file with plugmap data, copied to an HDU
in the output TSETFILE for use by other routines.
OPTIONAL INPUTS:
nbin - Sub-sampling of row numbers for measuring the spatial
profile widths; default to 16 for every 16-th row.
OUTPUT:
rstruct - Results to be added html file upon completion
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
BUGS:
PROCEDURES CALLED:
apo_checklimits()
extract_image
fileandpath()
findfile()
fitflatwidth()
mwrfits
quickboxcar()
readplugmap()
reject_flat()
rmfile
sdssproc
sortplugmap()
splog
trace320crude
traceset2xy
xy2traceset
REVISION HISTORY:
3-Apr-2000 Written by S. Burles & D. Schlegel, APO
28-Feb-2002 Modified to do full tracing, speed difference is critical
(See pro/apo2d/quicktrace.pro)
NAME:
quickwave
PURPOSE:
Perform full wavelength calibration with boxcar extraction
requires trace from a previously output tsetfile
CALLING SEQUENCE:
rstruct = quickwave( arcname, tsetfile, wsetfile, fflatfile, $
radius=radius, doplot=doplot )
INPUTS:
arcname - Raw SDSS Arclamp image to be processed
tsetfile - Name of fits file which contains matched trace
wsetfile - Name of fits file which will contain wavelength solution
fflatfile - Name of fits file which will contain flat field vectors
OPTIONAL INPUTS:
radius - Radius for boxcar extraction (default 3)
doplot - Used for debugging purposes
OUTPUT:
rstruct - Results to be added html file upon completion
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
BUGS:
PROCEDURES CALLED:
apo_checklimits()
extract_boxcar()
fiberflat()
fileandpath()
findfile()
fitarcimage
fitdispersion()
qbadarc
mrdfits()
mwrfits
reject_arc()
rmfile
sdssproc
traceset2xy
REVISION HISTORY:
3-Apr-2000 Written by S. Burles & D. Schlegel, APO
(See pro/apo2d/quickwave.pro)
NAME:
readonespec
PURPOSE:
Routine for reading single exposure spectra from Spectro-2D outputs
CALLING SEQUENCE:
readonespec, plate, fiber, [mjd=, cameras=, flux=, flerr=, invvar=, $
mask=, disp=, sky=, loglam=, wave=, synflux=, lineflux=, $
objhdr=, framehdr=, topdir=, path=, /silent ]
INPUTS:
plate - Plate number (scalar)
fiber - Fiber number (scalar)
OPTIONAL INPUTS:
mjd - MJD number; if not set, then select the most recent
data for this plate (largest MJD).
cameras - If specified, then only match to either the blue ('b')
or red ('r')
topdir - Top-level directory for data; default to the environment
variable $SPECTRO_DATA.
path - Override all path information with this directory name.
silent - If set, then call MRDFITS with /SILENT.
OUTPUTS:
OPTIONAL OUTPUTS:
mjd - If not specified, then this is returned
flux - Flux [NPIXEL,NFILE]
flerr - Flux error [NPIXEL,NFILE]
invvar - Inverse variance [NPIXEL,NFILE]
mask - AND-mask [NPIXEL,NFILE]
disp - Wavelength dispersion [NPIXEL,NFILE]
sky - Sky flux [NPIXEL,NFILE]
loglam - Log10-wavelength in log10-Angstroms [NPIXEL,NFILE]
wave - Wavelength in Angstroms [NPIXEL,NFIBER]
synflux - Best-fit synthetic eigen-spectrum [NPIXEL,NFILE];
return vectors of zeros if the Spectro-1D files
cannot be found
lineflux - Best-fit emission lines fits + background terms [NPIXEL,NFILE];
return vectors of zeros if the Spectro-1D files
cannot be found
objhdr - The FITS header from the spPlate file
framehdr - Pointer array to the FITS headers from all the spCFrame files
COMMENTS:
The environment variable SPECTRO_DATA must be set to tell this routine
where to find the data. The list of spCFrame files to read are determined
from the EXPID header keywords in the spPlate file.
EXAMPLES:
BUGS:
DATA FILES:
$SPECTRO_DATA/$PLATE/spPlate-$PLATE-$MJD.fits
$SPECTRO_DATA/$PLATE/spCFrame-$CAMERA-$EXPOSURE.fits*
PROCEDURES CALLED:
combine1fiber()
readspec
spframe_read
splog
REVISION HISTORY:
10-Feb-2004 Written by David Schlegel, Princeton.
(See pro/spec1d/readonespec.pro)
NAME:
readplugmap
PURPOSE:
Read plugmap file and append tags as requested
CALLING SEQUENCE:
plugmap = readplugmap( plugfile, [ plugdir=, /apotags, /deredden, $
exptime=, hdr=, /calibobj ] )
INPUTS:
plugfile - Name of Yanny-parameter plugmap file
OPTIONAL KEYWORDS:
plugdir - Directory for PLUGFILE
apotags - If set, then add a number of tags to the output structure
constructed from the Yanny header. These tags are:
CARTID, PLATEID, TILEID, RAPLATE, DECPLATE, REDDEN_MED.
Also add the tags FIBERSN[3], SYTHMAG[3] which are used
by the on-the-mountain reductions.
deredden - If set, then deredden the MAG fields using the median
reddening value for the entire plate as found in the
Yanny header of the plugmap file; this is done for the
on-the-mountain reductions.
exptime - Default exposure time SCI_EXPTIME to add to the output;
if there are multiple pointings and EXPTIME is set, then
the exposure time in each pointing is scaled such that
their sum is EXPTIME.
calibobj - If set, then add a CALIBFLUX,CALIBFLUX_IVAR entries based upon
the calibObj files. For stellar objects, this contains the
PSF fluxes in nMgy. For galaxies, it contains the fiber fluxes
multiplied by the median (PSF/fiber) flux ratio for stars.
The MAG fields are left unchanged.
For objects with no calibObj entry, simply set these fields as:
CALIBFLUX = 22.5 - 2.5*alog10(MAG), CALIBFLUX_IVAR = 0.
We apply the putative AB corrections to these fluxes
(but not to the MAG values).
Also add the SFD reddening values as SFD_EBV.
OUTPUTS:
plugmap - Plugmap structure
OPTIONAL OUTPUTS:
hdr - Header from Yanny-formatted plugmap file
COMMENTS:
Do not use the calibObj structure if more than 10% of the non-sky
objects do not have fluxes.
EXAMPLES:
BUGS:
The AB corrections are hard-wired to be the same as in the photoop
product as of 18 Feb 2004.
PROCEDURES CALLED:
djs_filepath()
dust_getval()
euler
plug2tsobj()
sdss_flagval()
splog
struct_addtags()
yanny_par()
yanny_read
REVISION HISTORY:
29-Jan-2001 Written by S. Burles, FNAL
(See pro/spec2d/readplugmap.pro)
NAME:
readspec
PURPOSE:
Routine for reading 2D/1D spectro outputs at Princeton
CALLING SEQUENCE:
readspec, plate, fiber, [mjd=, znum=, flux=, flerr=, invvar=, $
andmask=, ormask=, disp=, sky=, plugmap=, loglam=, wave=, tsobj=, $
zans=, zline=, synflux=, lineflux=, objhdr=, zhdr=, $
topdir=, path=, /align, /silent ]
INPUTS:
plate - Plate number(s)
OPTIONAL INPUTS:
fiber - Fiber number(s), 1-indexed; if not set, or zero, then
read all fibers for each plate. We assume that there
are exactly 640 fibers.
mjd - MJD number(s); if not set, then select the most recent
data for this plate (largest MJD).
znum - If set, then return not the best-fit redshift, but the
ZNUM-th best-fit; e.g., set ZNUM=2 for second-best fit.
topdir - Top-level directory for data; default to the environment
variable $SPECTRO_DATA.
path - Override all path information with this directory name.
align - If set, then align all the spectra in wavelength.
Also, LOGLAM and WAVE will be output as single vectors
(since they are all the same) rather than as one per object.
silent - If set, then call MRDFITS with /SILENT.
OUTPUTS:
OPTIONAL OUTPUTS:
mjd - If not specified, then this is returned as an array of one
MJD per object.
flux - Flux [NPIXEL,NFIBER]
flerr - Flux error [NPIXEL,NFIBER]
invvar - Inverse variance [NPIXEL,NFIBER]
andmask - AND-mask [NPIXEL,NFIBER]
ormask - OR-mask [NPIXEL,NFIBER]
disp - Wavelength dispersion [NPIXEL,NFIBER]
sky - Sky flux [NPIXEL,NFIBER]
plugmap - Plug-map entries [NFIBER]
loglam - Log10-wavelength in log10-Angstroms [NPIXEL,NFIBER],
or the vector [NPIXEL] if /ALIGN is set
wave - Wavelength in Angstroms [NPIXEL,NFIBER],
or the vector [NPIXEL] if /ALIGN is set
tsobj - tsObj-structure output [NFIBER]
zans - Redshift output structure [NFIBER]
zline - Line-fit output structure [NFIBER,NLINE]
synflux - Best-fit synthetic eigen-spectrum [NPIXEL,NFIBER]
lineflux - Best-fit emission line fits + background terms [NPIXEL,NFIBER]
objhdr - The FITS header from the first object spPlate file read.
If spectra from multiple plates are read, then it is
indeterminant which header this will be.
zhdr - The FITS header from the first object spZ file read.
If spectra from multiple plates are read, then it is
indeterminant which header this will be.
COMMENTS:
One can input PLATE and FIBER as vectors, in which case there must
be a one-to-one correspondence between them. Or, one can input FIBER
numbers as a vector, in which case the same PLATE is used for all.
Or, one can input PLATE as a vector, in which case the same FIBER is
read for all.
The environment variable SPECTRO_DATA must be set to tell this routine
where to find the data. The reduced spectro data files are assumed to
be $SPECTRO_DATA/pppp/spPlate-pppp-mmmmm.fits, where pppp=plate number
and mmmm=MJD.
The tsObj files are assumed to be in the directory $SPECTRO_DATA/plates.
EXAMPLES:
BUGS:
DATA FILES:
$SPECTRO_DATA/$PLATE/spPlate-$PLATE-$MJD.fits
$SPECTRO_DATA/$PLATE/spZbest-$PLATE-$MJD.fits
$SPECTRO_DATA/plates/tsObj*-$PLATE.fit
$IDLSPEC2D_DIR/templates/TEMPLATEFILES
PROCEDURES CALLED:
copy_struct_inx
headfits()
lookforgzip()
mrdfits
plug2tsobj()
spec_append
struct_append()
synthspec()
INTERNAL SUPPORT ROUTINES:
rspec_mrdfits()
rspec_zline_append()
readspec1
REVISION HISTORY:
25-Jun-2000 Written by David Schlegel, Princeton.
(See pro/spec1d/readspec.pro)
NAME:
rectify
PURPOSE:
Rectify spectra using a sliding median
CALLING SEQUENCE:
normflux = rectify(flux, [ivar, nivar=, mask=, wave=])
INPUTS:
flux - flux vector [npix, nspec]
OPTIONAL INPUTS:
ivar - inverse variance -- needed if "nivar" is returned [npix, nspec]
mask - if set then mask strong optical absorption feature before doing
sliding median. (To do this "wave" must also be supplied.)
On exit this keyword will hold a copy of the flux array with
masked pixels set to NaN
wave - wavelength vector in Angstroms -- only needed if "mask" is set
OUTPUT:
Rectified flux vector [npix, nspec]
OPTIONAL OUTPUT:
nivar - inverse variance of rectified flux [npix, nspec]
COMMENTS:
If mask is set 16 pixels around the folling lines are masked:
H-delta, Ca_K, Ca_H, G-band, H-gamma H-beta, Mgb, H-alpha
BUGS:
Medianing is done in pixel space not wavelength space -- so for two spectra
to be rectified in the same manner they must have identical wavelength
sampling.
EXAMPLES:
PROCEDURES CALLED:
djs_median()
INTERNAL SUPPORT ROUTINES:
REVISION HISTORY:
12-Aug-2003 Created by C. Tremonti, Steward Observatory
(See pro/fluxfix/rectify.pro)
NAME:
redmonster
PURPOSE:
Search for the Red Monster (contiguous region of bad sky residuals),
and set a pixelmask bit.
CALLING SEQUENCE:
redmonster, relloglam, relchi2, [ objloglam, filtsz=, thresh=, pixelmask= ]
INPUTS:
relloglam - Log10(Angstroms) for RELCHI2 vector
relchi2 - Relative chi^2 vector from sky fiber residuals
OPTIONAL INPUTS:
objlogam - Log10(Angstroms) image for object frame [NPIX,NFIBER];
required input for modifying PIXELMASK
filtsz - Filter size for looking for Red Monster; default to 25 pix,
but not more than the number of pixels in RELLOGLAM
thresh - Treshold in relative chi^2 for identifying REDMONSTER;
in the pixel mask; default to 4.0.
pixelmask - If this and OBJLOGLAM are specified, then add the REDMONSTER
bit to this mask [NPIX,NFIBER]
OUTPUTS:
pixelmask - (Modified.)
COMMENTS:
EXAMPLES:
BUGS:
PROCEDURES CALLED:
pixelmask_bits()
splog
REVISION HISTORY:
14-Mar-2001 Written by D. Schlegel, Princeton
(See pro/spec2d/redmonster.pro)
NAME:
reject_arc
PURPOSE:
Decide whether an arc is bad.
CALLING SEQUENCE:
qbad = reject_arc(img, [ hdr, nsatrow=, fbadpix= ] )
INPUTS:
img - Raw arc image
OPTIONAL INPUTS:
hdr - Header for image
nsatrow - Returned from SDSSPROC()
fbadpix - Returned from SDSSPROC()
OUTPUTS:
qbad - Return 1 if a arc is bad, 0 if good.
OPTIONAL OUTPUTS:
COMMENTS:
Decide if this arc is bad:
Reject if more than 2% of the pixels are marked as bad.
Reject if more than 100 rows are saturated.
Reject if the flat-field screens are not closed, which should appear
as FFS = '1 1 1 1 1 1 1 1' in the header.
Reject if the arc lamps are not turned on, which should appear
as NE = '1 1 1 1' and HGCD = '1 1 1 1' in the header.
Accept if either set of lamps is properly turned on.
Note that the FFS, FF, NE and HGCD keywords only appear at MJD >= 51629.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
REVISION HISTORY:
25-Jan-2001 Written by D. Schlegel, Princeton.
This code is copied out of SPCALIB.
(See pro/spec2d/reject_arc.pro)
NAME:
reject_flat
PURPOSE:
Decide whether a flat is bad.
CALLING SEQUENCE:
qbad = reject_flat(img, [ hdr, nsatrow=, fbadpix= ] )
INPUTS:
img - Raw flat-field image
OPTIONAL INPUTS:
hdr - Header for image
nsatrow - Returned from SDSSPROC()
fbadpix - Returned from SDSSPROC()
OUTPUTS:
qbad - Return 1 if a flat is bad, 0 if good.
OPTIONAL OUTPUTS:
COMMENTS:
Decide if this flat is bad:
Reject if more than 2% of the pixels are marked as bad.
Reject if more than 100 rows are saturated.
Reject if the 80-th percentile is less than 1000 electrons.
Reject if the flat-field screens are not closed, which should appear
as FFS = '1 1 1 1 1 1 1 1' in the header.
Reject if the flat-field lamps are not turned on, which should appear
as FF = '1 1 1 1' in the header.
Note that the FFS, FF, NE and HGCD keywords only appear at MJD >= 51629.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
REVISION HISTORY:
25-Jan-2001 Written by D. Schlegel, Princeton.
This code is copied out of SPCALIB.
(See pro/spec2d/reject_flat.pro)
NAME:
reject_science
PURPOSE:
Decide whether a science exposure is bad.
CALLING SEQUENCE:
qbad = reject_science(img, [ hdr, nsatrow=, fbadpix= ] )
INPUTS:
img - Raw science image
OPTIONAL INPUTS:
hdr - Header for image
nsatrow - Returned from SDSSPROC()
fbadpix - Returned from SDSSPROC()
OUTPUTS:
qbad - Return 1 if a science exposure is bad, 0 if good.
OPTIONAL OUTPUTS:
COMMENTS:
Decide if this science exposure is bad:
Reject if more than 10% of the pixels are marked as bad.
Reject if more than 100 rows are saturated.
Reject if the 25-th percentile is more than 1000 electrons.
This percentile should be very low (of order 10 electrons), since
it will be the counts between fibers.
Reject if any of the flat-field screens are closed. If the FFS keyword
is in the header, it should be FFS = '0 0 0 0 0 0 0 0'
Reject if any of the flat-field lamps are turned on. If the FF keyword
is in the header, it should be FF = '0 0 0 0'
Reject if any of the neon arc lamps are turned on. If the NE keyword
is in the header, it should be NE = '0 0 0 0'
Reject if any of the HgCd arc lamps are turned on. If the HGCD keyword
is in the header, it should be HGCD = '0 0 0 0'
EXAMPLES:
BUGS:
PROCEDURES CALLED:
REVISION HISTORY:
15-Jun-2001 Written by D. Schlegel, Princeton.
(See pro/spec2d/reject_science.pro)
NAME:
remove2redo
PURPOSE:
Removed specified exposures from the SOS log files and re-reduce them.
CALLING SEQUENCE:
remove2redo, [ mjd=, plate=, expnum=, /not_sos ]
INPUTS:
OPTIONAL INPUTS:
mjd - MJD number; if not set, then select the most recent MJD
in the $SPECTROLOG_DIR directory.
plate - If specified, then search for all sdR files for this plate
that were not successfully reduced. They are assumed to
have been successfully reduced if they have an entry in
HDU #1, 2, or 3 in the SOS log file.
expnum - If specified, then force the re-reduction of this exposure
number(s) even if they have already been successfully reduced.
Do not specify both PLATE and EXPNUM.
not_sos - This keyword can be set to run this proc on a machine
that is not named "sos". This would only be done for
testing purposes, or if Son-of-Spectro has been moved
to another machine.
OUTPUT:
COMMENTS:
The way this procedure works is to actually remove the sdR*.fit files
from /data/spectro. The Son-of-Spectro cron jobs will then re-copy
and re-reduce those files. It does not look for or remove sdR*.fit.gz
files, which SOS currently makes too. If the raw data no longer exists
on sdsshost.apo, then the data will not be re-reduced.
If $SPECTROLOG_DIR is not set, then it is assumed to be
/data/spectro/spectrologs
When using the PLATE keyword, never re-reduce the very last exposure
number on disk. If the last exposure is not for the specified plate,
then we can try re-reducing any exposures for that plate.
EXAMPLES:
BUGS:
Currently, either EXPNUM or PLATE must be specified. Probably nothing
happens if neither is set.
PROCEDURES CALLED:
apo_log2html
djs_filename()
djs_lockfile()
djs_modfits
djs_unlockfile
sdsshead()
INTERNAL SUPPORT ROUTINES:
REVISION HISTORY:
03-April-2001 Written by Scott Burles, FNAL
(See pro/apo2d/remove2redo.pro)
NAME: rline_findpeaks PURPOSE: Given a two dimensional array for Equivalent Width (EW) and weights (EW inverse variance), this function returns a structure containing peak positions, heights, and significance level (SN). Only postive peaks are detected, so transform the array is negative peaks are sought. CALLING SEQUENCE: peak_list = rline_findpeaks(ew, ewinv, npeak=, threshold=, minsep=) INPUTS: ew - Positive equivalent width array ewinv - Associated inverse variance OPTIONAL INPUTS: npeak - Maximum number of peaks to locate (default 20) threshold - Minimum significance level (sigma) to return (default 5.0) minsep - Minimum pixel separation to between peaks (default 2.5) OPTIONAL KEYWORDS: OUTPUTS: peak_list - Array of structures with peak information COMMENTS: EXAMPLES: PROCEDURES CALLED: find_npeaks DATA FILES: REVISION HISTORY: 05-Jan-2001 Written by S. Burles, Fermiland 17-Dec-2001 Commented, updated to work with new find_npeaks.pro
(See pro/spec1d/rline_findpeaks.pro)
NAME:
sdreportmake
PURPOSE:
Generate sdReport files from the raw (idR) FITS files.
CALLING SEQUENCE:
sdreportmake, [ speclog_dir=, mjd=, mjstart=, mjend=, /clobber ]
INPUTS:
OPTIONAL INPUTS:
speclog_dir- Top directory name for output files; default to that
set by the environment variable SPECLOG_DIR.
mjd - Look for raw data files in RAWDATA_DIR/MJD; default to
search all subdirectories. Note that this need not be
integer-valued, but could be for example '51441_test'.
mjstart - Starting MJD.
mjend - Ending MJD.
clobber - If set, then over-write conflicting sdReport files; default to
not over-write files.
OUTPUT:
COMMENTS:
The environment variables ASTROLOG_DIR and RAWDATA_DIR must be set.
Look for the original sdReport files and the raw FITS data files in:
ASTROLOG_DIR/MJD/sdReport-mmmmm.par
RAWDATA_DIR/MJD/sdR-cs-eeeeeeee.fit
where c=color, s=spectrograph number, eeeeeeee=exposure number.
At present, only the header keyword pairs are retained from the
original sdReport files.
The output sdReport files created are:
SPECLOG_DIR/MJD/sdReport-mmmmm.par
where SPECLOG_DIR is specified either by the environment variable
by that name, or by a keyword to this procedure.
EXAMPLES:
Generate the sdReport files for the night of data from MJD=51441,
and output to the directory '/u/schlegel/test'
> sdreportmake, mjd=51441, speclog_dir='/u/schlegel/test'
BUGS:
This routine spawns the Unix command 'mkdir'.
The use of CONCAT_DIR may not be valid for non-Unix OS's.
PROCEDURES CALLED:
concat_dir()
fileandpath()
get_mjd_dir()
splog
sdsshead()
spplan_findrawdata
sxpar()
yanny_read
yanny_write
REVISION HISTORY:
30-Apr-2001 Written by David Schlegel, Princeton.
(See pro/spec2d/sdreportmake.pro)
NAME: sdsshead PURPOSE: Read in header from raw SDSS file. CALLING SEQUENCE: hdr = sdsshead(infile, [ indir= ] ) INPUTS: infile - Raw SDSS file name OPTIONAL KEYWORDS: indir - Input directory for INFILE do_lock - Keyword passed to SDSSPROC OUTPUTS: hdr - Processed FITS header COMMENTS: BUGS: PROCEDURES CALLED: sdssproc REVISION HISTORY: 27-May-2000 Written by D. Schlegel, Princeton
(See pro/spec2d/sdsshead.pro)
NAME:
sdssproc
PURPOSE:
Read in raw SDSS files, and process with opConfig, opECalib, opBC par files.
CALLING SEQUENCE:
sdssproc, infile, [image, invvar, indir=, $
outfile=, varfile=, nsatrow=, fbadpix=, $
hdr=hdr, configfile=, ecalibfile=, bcfile=, $
/applybias, /applypixflat, /silent, /do_lock, minflat=, maxflat=, $
spectrographid=, color=, camname= ]
INPUTS:
infile - Raw SDSS file name
OPTIONAL KEYWORDS:
indir - Input directory for INFILE
outfile - Calibrated 2d frame, after processing
varfile - Inverse variance frame after processing
nsatrow - Number of saturated rows, assuming that a row is saturated
if at least 20 of its pixels are above saturation level
fbadpix - Fraction of bad pixels, not including bad columns
configfile - Default to "opConfig*par", selecting the file with the
appropriate MJD.
ecalibfile - Default to "opECalib*par", selecting the file with the
appropriate MJD.
bcfile - Default to "opBC*par", selecting the file with the
appropriate MJD.
applybias - Apply 2-D bias image.
applypixflat- Apply 2-D pixel-to-pixel flat (after subtracting bias).
silent - If set, then don't output any text.
do_lock - If set, then lock the "sdHdrFix-$MJD.par" file
using DJS_LOCKFILE().
minflat - Minimum values allowed for pixflat; pixels with the
flat out of range are masked; default to 0.
maxflat - Maximum values allowed for pixflat; pixels with the
flat out of range are masked; default to 1e10.
OUTPUTS:
OPTIONAL OUTPUTS:
image - Processed 2d image
invvar - Associated inverse variance
hdr - Processed FITS header
spectrographid - Return spectrograph ID (1 or 2)
color - Return spectrograph color ('red' or 'blue')
camname - Return camera name: 'b1', 'r1', 'b2', or 'r2'
COMMENTS:
Only the header is read from the image if IMAGE, INVVAR, OUTFILE and
VARFILE are all not set.
Required header keywords: EXPTIME.
The returned image is in electrons, not ADU.
The signal-to-noise is limited to never exceed 100, by adding 1.e-4
times the flux squared to the variance term.
Change the CAMERAS keyword to the camera as specified by the file name.
Rename 'target' to 'science', and 'calibration' to 'arc' in the
header keyword FLAVOR.
Determine the exposure number from the file name itself.
BUGS:
The open-shutter correction SMEARIMG will include smeared data from
any cosmic rays, which is wrong. At the minimum, I could interpolate
over A/D saturations (in ADMASK) before constructing SMEARIMG.
PROCEDURES CALLED:
djs_filepath()
djs_iterstat
fileandpath()
findopfile()
fits_purge_nans
fits_wait()
headfits()
idlspec2d_version()
idlutils_version()
lookforgzip()
rdss_fits()
sphdrfix
splog
sxaddpar
sxpar()
writefits
yanny_free
yanny_read
INTERNAL SUPPORT ROUTINES:
make_badcolumn_mask()
DATA FILES:
$IDLSPEC2D_DIR/examples/opConfig*par
$IDLSPEC2D_DIR/examples/opECalib*par
$IDLSPEC2D_DIR/examples/opBC*par
$SPECFLAT_DIR/biases/pixbias*.fits
$SPECFLAT_DIR/flats/pixflat*.fits
REVISION HISTORY:
13-May-1999 Written by Scott Burles & David Schlegel, Apache Point.
08-Sep-1999 Modified to read Yanny param files instead of FITS
versions of the same (DJS).
01-Dec-1999 Added version stamping (DJS).
07-Dec-1999 Mask neighbors of pixels that saturated the A/D converter.
Identify blead trails and mask from that row up (DJS).
10-Dec-1999 Test if the shutter was open during readout, and try
to correct the light for that (DJS).
04-Feb-2000 Declare that the shutter was open if it is a >640 sec
exposure taken before MJD=51570 (DJS).
26-Jul-2000 Added fix for "dropped pixel" problem for data on or after
MJD=51688 (23 May 2000). Should disable this code for later
MJD's once this problem is fixed in the electronics.
26-Jul-2000 Added fix for more severe "shifted row" electronics problem
for data taken on MJD=51578 to 51580 (3 to 5 Feb 2000).
26-Aug-2000 Horrible kludge for this night MJD=51779 (22/23 Aug 2000).
Add a noise term of 100 ADU to the left amplifier of r2.
That amplifier had random bits being set incorrectly,
in particular the 32 bit and 256 bit.
04-Nov-2000 Measure the bias values using DJS_ITERSTAT instead of MEDIAN,
since the median is always only an integer value.
31-Jan-2001 Determine the exposure number from the file name itself,
since the counting got off by one on MJD=51882.
(See pro/spec2d/sdssproc.pro)
NAME:
sdss_spec_block
PURPOSE:
take a set of sdss spectra and output as a big block
CALLING SEQUENCE:
sdss_spec_block
INPUTS:
plate - [N] list of plates
fiberid - [N] list of fibers
mjd - [N] list of mjds
OPTIONAL INPUTS:
avloglam - [nl] wavelength grid
vdisp - try to get everything to this velocity dispersion (in km/s)
OPTIONAL KEYWORDS:
deextinct - apply corrections for galactic extinction
OUTPUTS:
block_flux - [nl, N] list of fluxes (as output by readspec)
block_ivar - [nl, N] list of inverse variances
block_lamba - [nl] output wavelengths (angstroms)
DEPENDENCIES:
idlutils
idlspec2d
BUGS:
Input and output wavelength grids MUST be logarithmically spaced.
ivar is unchanged when vdisp is used
revision history wrong
COMMENTS:
Units are in 10^{-17} ergs/cm^2/s/A
Bolometric flux is kept constant in deredshifting step
(ie. lambda -> lambda/(1+z), flux -> flux*(1+z), ivar ->
ivar/(1+z)^2)
REVISION HISTORY:
2001-11-17 written - Hogg (NYU)
(See pro/science/sdss_spec_block.pro)
NAME:
select_arc
PURPOSE:
Select best arc from an arc structure produced with SPCALIB.
CALLING SEQUENCE:
bestarc = select_arc ( arcstruct )
INPUTS:
arcstruct - Structure array with extracted arc calibration information
OPTIONAL KEYWORDS:
OUTPUTS:
bestarc - Structure with extracted arc calibration information
for that arc selected from ARCSTRUCT
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
BUGS:
PROCEDURES CALLED:
djsig()
REVISION HISTORY:
25-Jan-2000 Written by D. Schlegel, Princeton
(See pro/spec2d/select_arc.pro)
NAME:
select_flat
PURPOSE:
Select best flat from a flat-field structure produced with SPCALIB.
CALLING SEQUENCE:
bestflat = select_flat( flatstruct, tai )
INPUTS:
flatstruct - Structure array with extracted flat calibration information
tai - Time of observation for object frame (from header card)
OPTIONAL KEYWORDS:
OUTPUTS:
bestflat - Structure array with extracted flat calibration information
for best flat selected for the time specified by TAI.
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
BUGS:
PROCEDURES CALLED:
REVISION HISTORY:
25-Jan-2000 Written by D. Schlegel, Princeton
(See pro/spec2d/select_flat.pro)
NAME:
skyline_dispersion
PURPOSE:
Measure and apply broadening to dispersion solution from an arc traceset
to agree with widths of sky lines, which may be broader due to flexure.
CALLING SEQUENCE:
skydispset = skyline_dispersion(flux, fluxivar, xcen, iskies, dispset)
INPUTS:
flux - Object extracted flux [NPIX,NTRACE]
fluxivar - Corresponding inverse variance [NPIX,NTRACE]
xcen - xpeaks of sky lines [NTRACE,NLINES]
iskies - Fiber indices corresponding to good sky fibers;
default to using all fibers if this is not set.
dispset - Original arcline solution for resolution vs. pixel
(typically measured in native pixels)
OPTIONAL KEYWORDS:
OUTPUTS:
skydispset - Modified version of DISPSET with dispersions broadened
to agree with the sky line widths.
OPTIONAL OUTPUTS:
COMMENTS:
The pixel dispersion can be broadened, but never made smaller.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
djs_iterstat
extract_image
splog
traceset2xy
xy2traceset
REVISION HISTORY:
20-Feb-2002 Written by S. Burles, MIT (Adapted from fitdispersion)
(See pro/spec2d/skyline_dispersion.pro)
NAME:
skymask
PURPOSE:
Mask regions in spectra where sky-subtraction errors are expected to
dominate.
CALLING SEQUENCE:
newivar = skymask(objivar, andmask, [ormask, ngrow= ])
INPUTS:
objivar - Inverse variance array [NPIX,NOBJ]
andmask - Mask from spectro-2D outputs, usually the AND-mask [NPIX,NOBJ]
OPTIONAL INPUTS:
ormask - Optional OR-mask [NPIX,NOBJ]; if specified, then also mask
wherever the REDMONSTER bit is set in this mask.
ngrow - Numbers of pixels neighboring masked pixels to reject along
each spectrum; default to 2.
OUTPUTS:
newivar - Modified OBJIVAR, where masked pixels are set to zero
[NPIX,NOBJ]
COMMENTS:
Grow the mask by 2 pixels in each direction for each spectrum.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
pixelmask_bits()
REVISION HISTORY:
12-Oct-2000 Written by D. Schlegel, Princeton
(See pro/spec1d/skymask.pro)
NAME:
skysubtract
PURPOSE:
Sky-subtract an image and modify the variance
CALLING SEQUENCE:
skystruct = skysubtract(objflux, objivar, plugsort, wset, objsub, objsubivar, $
[ iskies= , fibermask=, nord=, upper=, lower=, maxiter=, pixelmask=, $
dispset=, /novariance, relchi2set=, npoly=, tai=, newmask=, sset= ])
INPUTS:
objflux - Image flux [NPIX,NFIBER]
objivar - Inverse variance for OBJFLUX [NPIX,NFIBER]
plugsort - Plugmap structure trimmed to one element per fiber [NFIBER]
wset - Structure with traceset of wavelength solution
OPTIONAL KEYWORDS:
fibermask - Fiber status bits, set nonzero for bad status [NFIBER]
pixelmask - Mask of 0 for good pixels [NPIX,NFIBER]
thresh - Treshold in relative chi^2 for identifying BADSKYCHI in;
the pixel mask. Default to 4.0, and pass this value to
the REDMONSTER function.
dispset - Dispersion trace-set; if present, then solve for the
super-sky vector using a variable PSF described by this
structure.
novariance - Set keyword to prevent variance correction for sky residuals
relchi2set- Structure containing information of chi^2 fitting
npoly - Polynomial order of 2d fit.
tai - TAI of plate exposure, if supplied a linear airmass correction
is applied
nbkpt - Number of bkpts to use for full sky spectrum fit.
This gives us the freedom to use less points for the blue side.
PARAMETERS FOR SLATEC_SPLINEFIT (for supersky fit):
nord - Order of B-spline; default set in BSPLINE_ITERFIT()
upper - Low rejection sigma; default to 10
lower - High rejection sigma; default to 10
maxiter - Maximum number of iterations for reject loop; default to 5
OUTPUTS:
skystruct - structure containing sorted sky wavelengths,flux,fluxivar
+ bkpts and coeffs from fitting
objsub - Image (OBJFLUX) after sky-subtraction
objsubivar - Inverse variance (OBJIVAR) after sky-subtraction
OPTIONAL OUTPUTS:
iskies - Indices of good sky fibers
newmask - Modified version of PIXELMASK,
sset - B-spline structure for supersky.
COMMENTS:
Construct a "supersky" spectrum by spline-fitting the (good) sky fibers,
resampling this at every wavelength in the extracted image, then
subtracting. We then measure the variance of the sky-subtracted sky
fibers in terms of chi^2. Wherever chi^2 > 1, we increase the variance
of all fibers such that chi^2=1 in the sky fibers.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
bspline_iterfit()
bspline_valu()
gauss_kernel()
pixelmask_bits()
redmonster
splog
tai2airmass()
traceset2xy
REVISION HISTORY:
16-Sep-1999 Written by S. Burles, APO
30-Dec-1999 Modified by D. Schlegel, Princeton
4-Oct-2000 Changed to bspline_iterfit
26-Jul-2001 Implemented Higher-order fits, if dispset is set it fits
against fiber number (I know this doesn't make sense)
Also upped the tolerance on rejection by 5 times!
Too many pixels were masked for high order fit!
(See pro/spec2d/skysubtract.pro)
NAME:
slithistory
PURPOSE:
Plot the history of spectro slit-head positions based upon plSlitpos files.
CALLING SEQUENCE:
slithistory, [ mjdrange= ]
INPUTS:
OPTIONAL INPUTS:
mjdrange - 2-element vector of plotting range in MJD; default to
using all MJDs.
OUTPUT:
COMMENTS:
A single PostScript file is created "Slithistory-$MJDSTART-$MJDEND.ps",
with one page per cartridge. The fiber bundle spacing is plotted
in units of the fiber-mapper stepper motor steps.
EXAMPLES:
Make plots of history of slit-head positions for all time:
IDL> slithistory
Make plots of history of slit-head positions between MJD 52000 and MJD 52020:
IDL> setenv, 'ASTROLOG_DIR=/scr/spectro1/spectro/scan'
IDL> slithistory, mjdrange=[52000,52020]
BUGS:
PROCEDURES CALLED:
dfpsclose
dfpsplot
fileandpath()
yanhy_free
yanny_par()
yanny_read
REVISION HISTORY:
19-Nov-2002 Written by David Schlegel, Princeton.
(See pro/apo2d/slithistory.pro)
NAME:
smeartimes
PURPOSE:
List the TAI timestamps of 'smear' exposures in a log file.
CALLING SEQUENCE:
smeartimes
INPUTS:
OPTIONAL INPUTS:
OUTPUT:
OPTIONAL OUTPUTS:
COMMENTS:
All raw spectro files (sdR files) have their headers read and
their start and end time stamps computed. The purpose of this
is to get an exact list of times and determine from the TPM logs
whether the telescope moved in the way that it was supposed to
during these 'smear' exposures.
The file names and their timestamps are written to the following files.
timestamps-all.log
timestamps-smear.log
EXAMPLES:
BUGS:
PROCEDURES CALLED:
sdssproc
splog
struct_print
REVISION HISTORY:
10-Dec-2002 Written by David Schlegel, Princeton (not checked in then)
(See pro/plan/smeartimes.pro)
NAME:
smear_compare
PURPOSE:
Ratio calibrated smear and science spectra and fit with a 3rd order
polynomial.
CALLING SEQUENCE:
smearset = smear_compare(smearname, sciloglam, sciflux, sciivar, $
best_exp_str, plate_str, mjd_str, [camnames=, combinedir=, $
tsobjname=, nord=nord, adderr=, noplot=])
INPUTS:
smearname - list of smear exposure names [nsmear * nexp]
sciloglam - wavelength (log10 (A)) of calibrated science image [npix]
sciflux - flux of fully calibrated science image [npix,nfiber]
sciivar - inverse variance of calibrated science image [npix,nfiber]
best_exp_str - string containing the exposure ID of the best science image.
The fluxcalib vector from this image takes the place of the
PCA average vector for the smear.
plate_str - plate id -- used to reconstruct standard star FITS filename
mjd_str - MJD -- used to reconstruct standard star FITS filename
OUTPUT:
A structure containing the median smear and science S/N and the
Legendere coeff of the smear/sci flux ratio for each fiber is returned
KEYWORDS:
camnames - defaults to ['b1', 'b2', 'r1', 'r2']
combinedir - optional output directory
tsobjname - full path name of tsobjfile
nord - order of spline fit when combining exposures (defaults to 3)
adderr - additional error to add to formal error
noplot - toggle some of the plotting
COMMENTS:
The smear images are calibrated in a manner nearly identical to the
calibration of the science images. The smear and science image are
coarsely binned with locally deviant points rejected. The ratio
(smear/sci) is fit with a 3rd order Legendre polynomial. The structure
which is returned contains the Legendre coeff as well as the median S/N
of the binned smear and science frames. The smear/sci ratio is probably
meaningless for object with a S/N < 3 in the science image or < 1 in the
smear.
BUGS:
The smear/science flux ratio is only meaningful for high S/N point
sources!!!!
EXAMPLES:
To turn the coeff back into vectors do:
smear_hdu = mrdfits('spPlate-0503-51999.fits', 8)
smearset = {func: 'legendre', xmin: alog10(3800.0), xmax: alog10(9200.0), $
coeff: dblarr(3,640)}
smearset.coeff = smear_hdu.legendre_coeff
readspec, 503, mjd=51999, wave=wave
traceset2xy, smearset, alog10(wave), sratio
ok = where(smear_hdu.smear_sn gt 1 and smear_hdu.sci_sn gt 3)
plot, wave[*,ok], sratio[*,ok], psym=3
PROCEDURES CALLED:
bspline_valu
combine1fiber
divideflat
djs_filepath
djs_icolor
djs_oplot
djs_plot
legend
sphoto_calib
splog
spmedian_rebin
spread_frames
traceset2xy
xy2traceset
INTERNAL SUPPORT ROUTINES:
REVISION HISTORY:
12-Aug-2003 Created by C. Tremonti, Steward Observatory
(See pro/fluxfix/smear_compare.pro)
NAME:
smooth_halo
PURPOSE:
Given a model image of the CCD, smooth and return a halo image
CALLING SEQUENCE:
smooth = smooth_halo ( image, wset )
INPUTS:
image - Image to smooth, this should be something like ymodel
form extract_image
west - Wavelength solution
OPTIONAL KEYWORDS:
OUTPUTS:
smooth - Smoothed halo image, same size as image
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
BUGS:
Only does a 1d halo correction, does not spread the halo scattering
in the dispersion correction.
Parameters for halo term are hardwired and only qualitatively tested
on a few frames.
PROCEDURES CALLED:
traceset2xy
REVISION HISTORY:
29-Sep-2000 Written by S. Burles, FNAL
(See pro/spec2d/smooth_halo.pro)
NAME:
smooth_halo
PURPOSE:
Given a model image of the CCD, smooth and return a halo image
CALLING SEQUENCE:
smooth = smooth_halo2d ( image, wset, [kernel_size= ] )
INPUTS:
image - Image to smooth, this should be something like ymodel
form extract_image
wset - Wavelength solution
OPTIONAL KEYWORDS:
kernel_size - size of box relative to r0, default = 3.
a value of 5 or higher may be safer.
OUTPUTS:
smooth - Smoothed halo image, same size as image
OPTIONAL OUTPUTS:
COMMENTS:
2d version with surface brightness function given by J Gunn
EXAMPLES:
BUGS:
PROCEDURES CALLED:
traceset2xy
REVISION HISTORY:
29-Sep-2000 Original Written by S. Burles, FNAL
3-Feb-2005 Finally attempted 2-d convolution, not too slow...
(See pro/spec2d/smooth_halo2d.pro)
NAME:
smooth_superflat
PURPOSE:
Take the superflat fit and target wavelengths and filter superflat
to be sure to remove spurious features
CALLING SEQUENCE:
smooth_fit = smooth_superflat( superflatset, airset )
INPUTS:
superflatset - Superflat bsplineset returned from "superflat"
airset - Wavelength solution (preferably shifted to match skylines)
OPTIONAL KEYWORDS:
OUTPUTS:
smooth_fit - Filtered superflat fit smoothed over about 4 pixels
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
BUGS:
PROCEDURES CALLED:
bspline_iterfit()
bspline_valu()
djs_oplot
djs_plot
traceset2xy
REVISION HISTORY:
27-Jul-2001 Written by S. Burles, FNAL
(See pro/spec2d/smooth_superflat.pro)
NAME:
solvefilter
PURPOSE:
Solve for the 2.5-m imaging filter curves by using the spectra.
CALLING SEQUENCE:
solvefilter, [ filttype=, filternum=, plate=, mjd=, $
starerr=, qsoerr=, wavemin=, wavemax=, magrej=, sncut=, maxiter=, $
fluxpath=, value=, fixed= ]
INPUTS:
OPTIONAL INPUTS:
filttype - Type of functional form for the filter curve. Options are:
'sdss': Modified SDSS filter curve (default). 3 params.
'tanh': Function with tanh() shape at edges. 5 params.
filternum - Filter number, 1=g, 2=r, 3=i; default to 3.
plate - Plate number(s); if not specified, then select all DR1 plates
with number > 431.
mjd - MJD for each PLATE.
starerr - Fractional error to add in quadrature to photometric errors
for stars; default to 0.05; if <=0, then do not use stars.
qsoerr - Fractional error to add in quadrature to photometric errors
for QSOs; default to 0.15; if <=0, then do not use QSOs.
wavemin - Minimum wavelength for spectra during computation;
default to 3800 Ang.
wavemax - Maximum wavelength for spectra during computation;
default to 9300 Ang.
magrej - Reject any objects where the raw photo vs. spectro magnitude
difference is more than MAGREJ from the median difference
for that plate. This will reject wild outliers, which are
often objects where there is a bright blend but the PHOTO
flux is only for a fainter child. Default value is 0.5 mag.
Or, QSOs that have varied.
sncut - Minimum SN_MEDIAN (median S/N per pixel) for spectroscopic
objects used in sample; default to 2.0
maxiter - Maximum number of iterations in call to MPFIT(); default to 200
fluxpath - Path name for spPlate files used for reading the spectra.
The spZ files are still read from $SPECTRO_DATA/$PLATE
regardless of this keyword.
value - Initial guess values for the fit parameters. The default
values are chosen to closely match the Gunn Jun-2001 curves.
fixed - A vector of elements set to 0 for each parameter to be fit,
and 1 for each parameter value to fix. Default to fitting
all parameters.
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
For FILTTYPE='tanh', the following function response(loglam) is fit:
m = (a[4] - 1) / (a[1] - a[0])
b = 1 - m * a[0]
Filter = tahn((loglam - a[0])*a[2]) + 1)
* tahn((a[1] - loglam)*a[3]) + 1)
* (m * loglam + b)
There are a total of five a[] parameters above.
The default initial-guess values for g-band are:
a = [alog10(3950), alog10(5325), 100, 140, 2.0]
The default initial-guess values for r-band are:
a = [alog10(5580), alog10(6750), 130, 160, 1.2]
The default initial-guess values for i-band are:
a = [alog10(6915), alog10(8210), 150, 220, 0.55]
For FILTTYPE='sdss', we fit a modified version of the Gunn Jun-2001
filter curves. The wavelength scale is remapped with a shift and
rescaling, which has the effect of moving the filter edges. The
filter shape is also multiplied by a function that is linear in
log-wavelength, which has the effect of changing the broad-band
slope of the filter. Given a filter curve Gunnfilt(loglam), it is
re-mapped as follows:
slopeterm = (loglam - 3.5)^theta[2]
Filter(loglam) = Gunnfilt((loglam + a[1]) * a[0]) * slopeterm
The default initial-guess values for the three a[] parameters are always:
a = [0, 1.0, 0.01]
The effect of a positive a[2] makes the filter slope more upwards
with wavelength, and a negative a[2] makes it slope more downwards.
Iteratively solve for the SDSS 2.5-m filter curves, using one of
the several possible parameterizations as specified by FILTTYPE.
For each possible filter curve, we regress the spectroscopic magnitude
vs. the photometric magnitude. In order to not be sensitive to
photometric calibration errors, each group of objects (same RUN, RERUN,
CAMCOL, PLATE, SPECTROGRAPHID) is allowed to have a floating zero-point
offset. These offsets are plotted as MAGOFFSET in one of the final plots.
We only use spectroscopically-confirmed stars and QSOs, not any galaxies.
Anything targetted as a galaxy is rejected. Any blended objects are
rejected. Anything with the following bits set is rejected:
OBJECT2_SATUR_CENTER, OBJECT2_INTERP_CENTER, OBJECT2_PSF_FLUX_INTERP.
These last cuts remove stars with CRs in the core on the i-band images
that were targetted as QSOs -- this was actually due to a bug in PHOTO
that called stars CRs when the seeing was too good, then the incorrect
CR-removal made the i-band 2 mags fainter, and these things were targetted
as QSOs.
All calculations are done in vacuum wavelengths, but then converted
to air wavelengths at the end.
EXAMPLES:
Solve for the i-band filter using Tremonti's re-reductions of the spectra:
IDL> solvefilter, filternum=3, fluxpath='/scr/wire50/cat/recalib/kurucz'
BUGS:
I should average together more telluric spectra for better S/N.
I should use the extinction coeff for each imaging night.
Do Christy's flux-calibrations improve things?
Do any objects argue for light leaks?
Should we more heavily weight the QSOs?
DATA FILES:
$IDLSPEC2D_DIR/etc/sdss_jun2001_$FILTER_atm.dat
$SPECTRO_DATA/0432/spFrame-r2-00007466.fits* (for telluric-correction)
$SPECTRO_DATA/$PLATE/spPlate-$PLATE-$MJD.fits
$SPECTRO_DATA/$PLATE/spZbest-$PLATE-$MJD.fits
$SPECTRO_DATA/plates/tsObj*-$PLATE.fit
PROCEDURES CALLED:
dfpsclose
dfpsplot
djs_int2bin()
djs_maskinterp()
djs_oplot
djs_plot
djs_xyouts
headfits()
idlspec2d_version()
mpfit()
mrdfits()
readcol
readspec
sdss_run2mu() (in photoop product)
skymask()
splog
tai2airmass()
traceset2xy
wavevector()
INTERNAL SUPPORT ROUTINES:
solvefiltshape()
solvefiltfn()
REVISION HISTORY:
05-Nov-2002 Written by David Schlegel, Princeton.
(See pro/spec1d/solvefilter.pro)
NAME:
sortplugmap
PURPOSE:
Cull and order the plugmap entries to those that match the object fibers
CALLING SEQUENCE:
plugsort = sortplugmap(plugmap, [ spectrographid, fibermask=, nfibers= ])
INPUTS:
plugmap - The full plug map structure read in from plPlugMapM
OPTIONAL KEYWORDS:
spectrographid - The spectrograph number, either 1 or 2;
if not set (or 0), then return all object fibers
fibermask - Byte array with bits set for unknown fibers
nfibers - Number of fibers to locate; default 320 if SPECTROGRAPHID
is set, or to 640 otherwise.
OUTPUTS:
plugsort - Culled plugmap structure matching plugged fibers
OPTIONAL OUTPUTS:
fibermask - Modified.
COMMENTS:
EXAMPLES:
PROCEDURES CALLED:
fibermask_bits()
REVISION HISTORY:
19-Oct-1999 Written by S. Burles, Chicago
(See pro/spec2d/sortplugmap.pro)
NAME: spadd_guiderinfo PURPOSE: Add seeing and RMS offset header cards by parsing guiderMon-$MJD.par CALLING SEQUENCE: spadd_guiderinfo, hdr INPUTS: hdr - FITS header OPTIONAL INPUTS: OUTPUTS: hdr - FITS header (modified) COMMENTS: This routine recalls the beginning and ending exposure time-stamps and collects all seeing and guider offsets available from the speclog file: guiderMon-mmmmm.par (where mmmmm is MJD). It reports the 20,50,80% seeing and RMS guiding deviations (closely resembles -1,0,+1 sigma for normal distributions). The following keywords are added: RMSOFF20, RMSOFF50, RMSOFF80, SEEING20, SEEING50, SEEING80. All quantities are quoted in arcseconds. Results of 0.0 mean entries do not exist or are ill-defined. EXAMPLES: filename = 'sdR-b2-00003976.fit' hdr = headfits(filename) spadd_guiderinfo, hdr BUGS: PROCEDURES CALLED: concat_dir() fileandpath() get_tai splog sxaddpar sxpar() yanny_free yanny_read INTERNAL SUPPORT ROUTINES DATA FILES: $SPECLOG_DIR/$MJD/guiderMon-$MJD.par REVISION HISTORY: 28-Jan-2002 Written by S. Burles, MIT
(See pro/spec2d/spadd_guiderinfo.pro)
NAME: spallflat PURPOSE: Calling script for SPFLATTEN that generates pixel flats as specified in a plan file. CALLING SEQUENCE: spallflat, planfile=planfile INPUTS: OPTIONAL INPUTS: planfile - Name of output plan file; default to 'spPlanFlat.par' OUTPUT: COMMENTS: EXAMPLES: BUGS: PROCEDURES CALLED: spflatten yanny_par() yanny_read INTERNAL SUPPORT ROUTINES: REVISION HISTORY: 02-Nov-1999 Written by David Schlegel, Princeton.
(See pro/spec2d/spallflat.pro)
NAME:
spbiasave
PURPOSE:
Average together a set (or all!) 2D pixel biases.
CALLING SEQUENCE:
spbiasave, [ mjd=, mjstart=, mjend=, mjout=, indir=, outdir=, docam= ]
INPUTS:
OPTIONAL INPUTS:
mjd - Valid MJD's for input pixel biases.
mjstart - Valid starting MJD for input pixel biases.
mjend - Valid ending MJD for input pixel biases.
mjout - MJD for name of output average pixel bias; default to 0,
resulting in file names like 'pixbiasave-00000-b1.fits'.
indir - Input directory; default to current directory.
outdir - Output directory; default to same as INDIR.
docam - Camera names; default to all cameras: ['b1', 'b2', 'r1', 'r2']
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
Some sigma-clipping is done before combining each pixel, clipping
at 2-sigma if more than 7 frames, and a lower sigma for fewer frames.
The output file has two HDU's, the first being the average bias,
the second being the standard deviation at each pixel.
--> Comment this out for the time being!!???
EXAMPLES:
BUGS:
PROCEDURES CALLED:
djs_filepath()
djs_iterstat
fileandpath()
headfits()
mrdfits()
splog
sxaddpar
sxpar()
writefits
REVISION HISTORY:
26-Feb-2002 Written by D. Schlegel, Princeton
(See pro/spec2d/spbiasave.pro)
NAME:
spbiasgen
PURPOSE:
Routine to generate mean biases for a night.
CALLING SEQUENCE:
spbiasgen, [ mjd=, expnum=, expstart=, expend=, timesep=, $
indir=, outdir=, docam=, sigrej=, maxiter= ]
INPUTS:
OPTIONAL INPUTS:
mjd - If INDIR not set, then look for files in $RAWDATA_DIR/MJD.
expnum - If set, then use these exposure numbers
expstart - If set, then only use exposure numbers >= EXPSTART
expend - If set, then only use exposure numbers >= EXPEND
timesep - Discard any bias that isn't within TIMESEP after another bias;
default to 300 sec. The time is obtained from TAI-BEG in the
FITS header. Note that this always discards the first bias in
any sequence.
indir - Look for input files in this directory; default to current
directory if neither MJD or INDIR are set.
outdir - Output directory; default to same as INDIR.
docam - Camera names; default to all cameras: ['b1', 'b2', 'r1', 'r2']
sigrej - Sigma rejection level; default to 1, 1, 1.1, 1.3, 1.6 or 1.9
for 1,2,3,4,5 or 6 flats. For more then 6 flats, default
to 2.0.
maxiter - Number of rejection iterations; default to 3.
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
This routine looks for biases in a given night that are logged as such.
Discard the first bias in any sequence, and generate a mean bias from
all the others for each camera. There must be at least 3 frames.
A sigma-clipped mean is computed for each pixel.
Trigger a failure if there are more than 25 biases for a given camera,
since that is probably too many to load into memory.
Four FITS files are produced, one for each camera:
pixbias-MJD-CAMERA.fits
where MJD is the 5-digit modified Julian date, and CAMERA
is 'b1', 'b2', 'r1', and 'r2'.
The header contains the number of files used in each camera (NEXP),
and an identifier for each of those files (EXPID*). Those identifiers
contain the camera name, MJD, and exposure number, all dash-separated.
EXAMPLES:
The following nights probably contain a bias sequence:
51686 51781 51809 51852 51893 51950 51978 52010 52038 52069
52245 52276 52305 52333 52363 52392 52423 52454 52514 52551
52573 52602 52633 52655 52689 52718 52747 (<- should declare some bad!)
52808 52868 52899 52956 52983 53014 53044 53073 53100 53132
53162 53220 53257 ...???
53610 53633
(Those are the nights with a pixel flat sequence.) There are other
nights with many biases that may be useful, but may have been done
for other testing purposes:
52084 52085 52121 52229 52294 52550 52572 52601 52629
52657 52660 52661 52717 52807 52863 52864 52865 52926
Generate one of these sets of biases with:
spbiasgen, mjd=51893, expstart=7607, expend=7616, outdir='.'
BUGS:
PROCEDURES CALLED:
djs_avsigclip()
djs_filepath()
fileandpath()
get_tai
sdsshead()
sdssproc
splog
sxaddpar
sxpar()
writefits
INTERNAL SUPPORT ROUTINES:
spbiasgen1
REVISION HISTORY:
30-Aug-2001 Written by D. Schlegel, Princeton
(See pro/spec2d/spbiasgen.pro)
NAME:
spcalib
PURPOSE:
Extract calibration frames.
CALLING SEQUENCE:
spcalib, flatname, arcname, fibermask=, $
lampfile=, indir=, timesep=, ecalibfile=, plottitle=, $
minflat=, maxflat=, arcinfoname=, flatinfoname=, $
arcstruct=, flatstruct=]
INPUTS:
flatname - Name(s) of flat-field SDSS image(s)
arcname - Name(s) of arc SDSS image(s)
OPTIONAL KEYWORDS:
fibermask - Fiber status bits, set nonzero for bad status [NFIBER].
Note this is not modified, but modified copies appear
in the returned structures ARCSTRUCT and FLATSTRUCT.
lampfile - Name of file describing arc lamp lines, which would
over-ride the default file read by FITARCIMAGE.
indir - Input directory for FLATNAME, ARCNAME, OBJNAME;
default to '.'
timesep - Maximum time separation between flats and arcs to pair them;
set to zero to disable this test; default to 7200 sec.
ecalibfile - opECalib file to pass to SDSSPROC
plottitle - Prefix for titles in QA plots.
minflat - Parameter for SDSSPROC for pixel flats; default to 0.8
maxflat - Parameter for SDSSPROC for pixel flats; default to 1.2
arcinfoname- File name (with path) to output arc extraction and fitting
information
flatinfoname-File name (with path) to output flat field extraction and
fitting information
OUTPUTS:
arcstruct - Structure array with extracted arc calibration information
flatstruct - Structure array with extracted flat calibration information
OPTIONAL OUTPUTS:
COMMENTS:
Always pair arcs to the nearest good flat, and flats to the nearest good arc
(nearest in time, as defined by the TAI-BEG keyword in the FITS headers).
Also store SUPERFLATSET from fiberflat, since we need this to remove
small scale features present in all spectra
EXAMPLES:
BUGS:
PROCEDURES CALLED:
extract_image
fiberflat()
fitarcimage
fitarcimage_old
fitdispersion
fitflatwidth()
get_tai
reject_arc()
reject_flat()
sdssproc
shift_trace()
smooth_halo2d()
splog
trace320crude()
traceset2xy
xy2traceset
INTERNAL SUPPORT ROUTINES:
create_arcstruct()
create_flatstruct()
REVISION HISTORY:
24-Jan-2000 Written by D. Schlegel, Princeton
27-Nov-2000 Changed to proftype 3, added minflat, maxflat keywords
8-Jan-2001 And now back to proftype 1, more robust against bad columns
26-Jan-2001 And now let's check both 1&3, and use the better fit
(See pro/spec2d/spcalib.pro)
NAME:
spcoadd_fluxed_frames
PURPOSE:
Combine reduced frames with the same plugmap and spectrophotometrically
calibrate the output
CALLING SEQUENCE:
spcoadd_fluxed_frames, spframes, outputname, fcalibprefix=, [mjd=, $
binsz=, zeropoint=, nord=, wavemin=, window=, adderr=, docams=, $
plotsnfile=, combinedir=, tsobjname=, smearname=, best_exposure=]
INPUTS:
spframes - Names of files to combine (written by SPREDUCE)
outputname - Output file name of the form spPlate-pppp-mmmmm.fits
where pppp=plateid, mmmmm=MJD.
REQUIRED KEYWORDS:
fcalibprefix - Prefix for flux-calibration files.
OPTIONAL KEYWORDS:
mjd - The MJD to put in the output header
binsz - Bin size (in log-10 wavelength) in output spectra;
default to 1d-4, which corresponds to 69.02977415 km/s.
zeropoint - Log10(lambda) zero-point of the output spectra;
the output wavelength bins are chosen such that
one bin falls exactly on this value;
default to 3.5D, which corresponds to 3162.27766 Ang.
nord - Order for spline fit; default to 3 (cubic spline).
wavemin - Log-10 wavelength of first pixel in output spectra;
default to the nearest bin to the smallest wavelength
of the input spectra.
window - Window size for apodizing the errors of the spectrum
from each individual frame; default to 100 pixels
apodization on each end of the spectrum.
adderr - Additional error to add to the formal errors, as a
fraction of the flux.
combinedir - Optional output directory
docams - Cameras to combine; default to ['b1', 'b2', 'r1', 'r2']
plotsnfile - File which will contain diagnostics of the final S/N
and spectrophotometric quality
tsobjname - Name of tsObj file. Fibermags used in setting spectrophoto
zeropoints -- if tsObj not available fibermags are
taken from the plugmap
smearname - Names of frames containing data observed in "smear" mode.
Polynomials describing the ratio of the calibrated smear
and science image are written the the 8th HDU.
best_exposure - Exposure ID of the exposure which all other exposures
should be matched to. (string). If not set the "best"
exposure is determined from the S/N and a measure of the
spectrophotometric quality
noxytweak - Allow correction for residual spectrophotometry errors
as a funtion of plate xy position to be turned off
OUTPUTS:
A fully calibrated "spPlate" file is produced. The HDU's are as follows
HDU #0: flux [npix, nfiber]
HDU #1: inverse variance [npix, nfiber]
HDU #2: and mask [npix, nfiber]
HDU #3: or mask [npix, nfiber]
HDU #4: dispersion [npix, nfiber]
HDU #5: plugmap - structure [nfiber]
HDU #6: S/N in g, r, i [3, nfiber]
HDU #7: synthetic g, r, i mag [3, nfiber]
HDU #8: smear coeffs -- structure [nfiber]
OPTIONAL OUTPUTS:
Diagnostic plots in "spDiagcomb-" and "spSN2d-" files
COMMENTS:
This routine can combine data from a single plug maps.
All input files must have the same number of pixels per spectrum,
i.e. 2048 wavelength samplings, although those wavelengths can
be different. The spectrophotometry is now tied to Kurucz models.
Two new structure tags are added to the plugmap "tsobj_mag" and "tsobjid"
to track the tsobj info used in the reductions.
EXAMPLES:
BUGS:
Should only apodize starting with the first/last good pixel of a spectrum.
Probably will not work without data for all 4 cameras
Mask bits should be looked at more carefully
PROCEDURES CALLED:
atmdisp_cor
bspline_valu
combine1fiber
divideflat
djs_diff_angle()
djs_filepath()
fibermask_bits
frame_flux_calib
frame_flux_tweak
mkhdr
modfits
mrdfits()
mwrfits
pixelmask_bits()
platesn
smear_compare
spdata2model_ratio
sphoto_calib
splog
sxaddpar
sxpar()
traceset2xy
writefits
INTERNAL SUPPORT PROCEDURES:
add_iraf_keywords
qgoodfiber
REVISION HISTORY:
12-Aug-2003 modified from "spcoadd_frames" by C. Tremonti, Steward Obs.
02-Jan-2000 spcoadd_frames written by D. Schlegel
(See pro/fluxfix/spcoadd_fluxed_frames.pro)
NAME:
spcoadd_frames
PURPOSE:
Combine several reduced frames of the same objects
CALLING SEQUENCE:
spcoadd_frames, spframes, outputname, $
fcalibprefix=, [ mjd=, binsz=, zeropoint=, nord=, wavemin=, $
bkptbin=, window=, maxsep=, adderr=, plotsnfile=, combinedir= ]
INPUTS:
spframes - Name(s) of files to combine (written by SPREDUCE)
outputname - Output file name
REQUIRED KEYWORDS:
fcalibprefix - Prefix for flux-calibration files.
OPTIONAL KEYWORDS:
mjd - The MJD to put in the output header
binsz - Bin size (in log-10 wavelength) in output spectra;
default to 1d-4, which corresponds to 69.02977415 km/s.
zeropoint - Log10(lambda) zero-point of the output spectra;
the output wavelength bins are chosen such that
one bin falls exactly on this value;
default to 3.5D, which corresponds to 3162.27766 Ang.
nord - Order for spline fit; default to 3 (cubic spline).
wavemin - Log-10 wavelength of first pixel in output spectra;
default to the nearest bin to the smallest wavelength
of the input spectra.
bkptbin - ???
window - Window size for apodizing the errors of the spectrum
from each individual frame;
default to 100 pixels apodization on each end of the
spectra.
maxsep - ???
adderr - Additional error to add to the formal errors, as a
fraction of the flux.
combinedir - Optional output directory
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
This routine can combine data from multiple (different) plug maps.
Objects are matched based upon their positions agreeing to 2 arc sec.
All input files must have the same number of pixels per spectrum,
i.e. 2048 wavelength samplings, although those wavelengths can
be different.
The input files (FILENAMES) have their pixelmasks modified by this routine.
Flux-correction files are also read in, where they are assumed to
have the name spFluxcorr-EEEEEEEE-S.fits, where EEEEEEEE is the exposure
number and S is the spectrograph ID (1 or 2).
EXAMPLES:
BUGS:
Should only apodize starting with the first/last good pixel of a spectrum.
PROCEDURES CALLED:
combine1fiber
correct_dlam
divideflat
djs_diff_angle()
fiber_rollcall
idlspec2d_version()
mkhdr
modfits
mrdfits()
pixelmask_bits()
platesn
splog
sxaddpar
sxdelpar
sxpar()
traceset2xy
writefits
INTERNAL SUPPORT PROCEDURES:
makelabel()
REVISION HISTORY:
02-Jan-2000 Written by D. Schlegel; modified from COMBINE2DOUT
(See pro/spec2d/spcoadd_frames.pro)
NAME:
spcoadd_v5
PURPOSE:
Combine several reduced frames of the same objects
CALLING SEQUENCE:
spcoadd_v5, spframes, outputname, $
[ mjd=, binsz=, zeropoint=, nord=, wavemin=, $
bkptbin=, window=, maxsep=, adderr=, plotsnfile=, $
combinedir=, bestexpnum= ]
INPUTS:
spframes - Name(s) of spFrame files (written by SPREDUCE)
outputname - Output file name
OPTIONAL KEYWORDS:
mjd - The MJD to put in the output header
binsz - Bin size (in log-10 wavelength) in output spectra;
default to 1d-4, which corresponds to 69.02977415 km/s.
zeropoint - Log10(lambda) zero-point of the output spectra;
the output wavelength bins are chosen such that
one bin falls exactly on this value;
default to 3.5D, which corresponds to 3162.27766 Ang.
nord - Order for spline fit; default to 3 (cubic spline).
wavemin - Log-10 wavelength of first pixel in output spectra;
default to the nearest bin to the smallest wavelength
of the input spectra.
bkptbin - Parameter for COMBINE1FIBER
window - Window size for apodizing the errors of the spectrum
from each individual frame;
default to 100 pixels apodization on each end of the
spectra.
maxsep - Parameter for COMBINE1FIBER
adderr - Additional error to add to the formal errors, as a
fraction of the flux.
combinedir - Optional output directory
bestexpnum - Exposure number for best exposure, to which all other
exposures are tied; this is only used in this procedure
for logging in the FITS header
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
All input files must have the same number of pixels per spectrum,
i.e. 2048 wavelength samplings, although those wavelengths can
be different.
Flux-correction files are also read in, where they are assumed to
have the name spFluxcorr-EEEEEEEE-S.fits, where EEEEEEEE is the exposure
number and S is the spectrograph ID (1 or 2).
EXAMPLES:
BUGS:
This routine used to combine data from multiple (different) plug maps.
Objects are matched based upon their positions agreeing to 2 arc sec.
This is *not* true any longer, especially when applying the
flux-distortion solutions.
PROCEDURES CALLED:
combine1fiber
correct_dlam
divideflat
djs_diff_angle()
fcalib_default()
fiber_rollcall
flux_distortion()
idlspec2d_version()
mkhdr
mrdfits()
mwrfits
pixelmask_bits()
platesn
splog
spframe_read
sxaddpar
sxdelpar
sxpar()
traceset2xy
INTERNAL SUPPORT PROCEDURES:
makelabel()
add_iraf_keywords
REVISION HISTORY:
02-Jan-2000 Written by D. Schlegel; modified from COMBINE2DOUT
(See pro/spec2d/spcoadd_v5.pro)
NAME:
spcombine
PURPOSE:
Calling script for SPCOADD_FRAMES.
CALLING SEQUENCE:
spcombine, [ planfile, docams=, adderr=, /xdisplay, minsn2=, /smearinclude ]
INPUTS:
OPTIONAL INPUTS:
planfile - Name(s) of output plan file; default to reducing all
plan files matching 'spPlancomb*.par'
docams - Cameras to combine; default to ['b1', 'b2', 'r1', 'r2']
adderr - Additional error to add to the formal errors, as a
fraction of the flux; default to 0.03 (3 per cent).
xdisplay - Send plots to X display rather than to plot file
minsn2 - Minimum S/N^2 to include science frame in coadd (default 0.2)
smearinclude- If set, then include 'smear' flavor exposures as well
as 'science' flavor.
OUTPUT:
COMMENTS:
EXAMPLES:
BUGS:
This routine spawns the Unix command 'mkdir'.
PROCEDURES CALLED:
cpbackup
idlspec2d_version()
idlutils_version()
spcoadd_frames
spflux
splog
yanny_free
yanny_par()
yanny_read
INTERNAL SUPPORT ROUTINES:
REVISION HISTORY:
06-Jul-2000 Written by David Schlegel, Princeton.
(See pro/spec2d/spcombine.pro)
NAME:
spcombine_v5
PURPOSE:
Calling script for SPCOADD_FRAMES.
CALLING SEQUENCE:
spcombine_v5, [ planfile, docams=, adderr=, /xdisplay, minsn2= ]
INPUTS:
OPTIONAL INPUTS:
planfile - Name(s) of output plan file; default to reducing all
plan files matching 'spPlancomb*.par'
docams - Cameras to combine; default to ['b1', 'b2', 'r1', 'r2']
adderr - Additional error to add to the formal errors, as a
fraction of the flux; default to 0.03 (3 per cent).
xdisplay - Send plots to X display rather than to plot file
minsn2 - Minimum S/N^2 to include science frame in coadd (default 0.2)
OUTPUT:
COMMENTS:
EXAMPLES:
BUGS:
We currently hard-wire the rejection of all smears, all exposures
with any CCDs with (S/N)^2 < 1, and any with (S/N)^2 less than 20% of
the best exposure.
PROCEDURES CALLED:
cpbackup
dfpsclose
dfpsplot
headfits
idlspec2d_version()
idlutils_version()
spcoadd_frames
spflux_v5
spfluxcorr_v5
splog
sxpar()
yanny_free
yanny_par()
yanny_read
INTERNAL SUPPORT ROUTINES:
REVISION HISTORY:
06-Jul-2000 Written by David Schlegel, Princeton.
(See pro/spec2d/spcombine_v5.pro)
NAME:
spdata2model_ratio
PURPOSE:
Construct flux correction vectors by ratioing the observed spectra of
standard stars to Kurucz models of the appropriate spectral type and
smoothing the result.
CALLING SEQUENCE:
corvector = spdata2model_ratio(loglam, stdflux, stdivar, stdmask,
stdinfo, corvivar=, cormed=, /norm)
INPUTS:
loglam -- wavelength array in log10(Angstroms) [npix]
stdflux -- array of standard star fluxes [npix, nstd]
stdivar -- inverse variance of standard star fluxes [npix, nstd]
stdmask -- ormask of standard star spectra [npix, nstd]
(used to mask sky residuals)
stdinfo -- structure containing information about which Kurucz model
is to be used with each standard star [nstd]. (This is the
output of "stype_standard".)
OPTIONAL INPUT:
norm -- normalize the vectors before returning them (between
5700 - 6300 A -- avoiding the last 200 pixels before the
dichroic)
OUTPUT:
Vectors which represent the smoothed ratio of (data/model) for each
standard star. [npix, nstd]
OPTIONAL OUTPUT:
corvivar - inverse variance corresponding to each flux correction vector.
[npix, nstd]
cormed - median of each flux correction vector between 5700 and 6300 A
(but avoiding the 200 pixels nearest the dichroic) [nstd]
COMMENTS:
For each standard star the best fit Kurucz model (as determined by
"stype_standard") is restored, redshifted, and linearly interpolated to
match the wavelength grid of the data. Each model is then reddened
using the SDF reddening at the RA/DEC of the standard star and the
extinction curve used by SFD (O'donnell).
BUGS:
EXAMPLES:
PROCEDURES CALLED:
divideflat
djs_maskinterp
djs_median()
ext_odonnell
filter_thru()
kurucz_restore
linterp
skymask()
INTERNAL SUPPORT ROUTINES:
REVISION HISTORY:
12-Aug-2003 Create by C. Tremonti, Steward Observatory
(See pro/fluxfix/spdata2model_ratio.pro)
NAME:
specdb_create
PURPOSE:
Create spectro database.
CALLING SEQUENCE:
specdb_create, [ topdir, astrolog= ]
INPUTS:
OPTIONAL INPUTS:
topdir - Search for reduced data files in TOPDIR/MJD/*.
This should be an absolute file path, and we default to
'/home/data/2d_test'.
astrolog - Search for plug-map files in PLUGDIR/MJD/*.
If not specified, then look for these files in the same
place as the reduced data.
OUTPUT:
COMMENTS:
Look for the input files in:
TOPDIR/MJD/2d/spSpec2d-b1-*.fits - pppp=plate
ASTROLOG/MJD/plPlugMapM-pppp-mmmmm-aa.par - Plug map files, aa=mapper
EXAMPLES:
BUGS:
PROCEDURES CALLED:
headfits()
mrdfits()
yanny_read
INTERNAL SUPPORT ROUTINES:
spsummary_create()
REVISION HISTORY:
27-Mar-2000 Written by David Schlegel, Princeton.
(See pro/specdb/specdb_create.pro)
NAME:
speclinefit
PURPOSE:
Line-fitting calling script for entire plate(s)
CALLING SEQUENCE:
speclinefit, [ platefile, fiberid=, $
hdr=, objflux=, objivar=, $
zhdr=, zans=, synflux=, dispflux=, $
outfile=, zline=, yfit=, /doplot, /debug ]
INPUTS:
OPTIONAL INPUTS:
platefile - Plate file(s) from spectro-2D; default to all files
matching 'spPlate*.fits' if neither PLATEFILE nor OBJFLUX
are set.
If specified, then all inputs are read from this file
and its corresponding spZbest file. The following inputs
are ignored: HDR,OBJFLUX,OBJIVAR,ZHDR,ZANS,SYNFLUX,DISPFLUX.
If set, then an output FITS file and a log file are created,
as is a PostScript plot file if /DOPLOT is set.
fiberid - If specified, then only reduce these fiber numbers;
this must be a vector with unique values between 1 and
the number of rows in the plate file (typically 640).
This keyword must be set to only those fibers that exist
in the spZbest file if FIBERID was specified when
running SPREDUCE1D.
hdr - Header from plate file. The fields COEFF0,COEFF1 are
used for the wavelength mapping.
objflux - Object spectra [NPIX,NOBJ]
objivar - Object inverse variance [NPIX,NOBJ]
zhdr - Optional header for output file.
zans - Output structure from SPREDUCE1D. The following fields
are used in this procedure: PLATE,MJD,FIBERID,CLASS,Z.
synflux - Best-fit synthetic spectra; used for STAR background terms.
dispflux - Best-fit dispersion spectra; used for GALAXY background terms.
outfile - Name of output file (the name is generated from PLATEFILE
if that is set).
doplot - If set, then generate plots. Send plots to a PostScript
file if PLATEFILE is set and /DEBUG is not set.
debug - If set, then send plots to the X display and wait for
a keystroke after each plot; setting /DEBUG forces /DOPLOT.
OUTPUTS:
OPTIONAL OUTPUTS:
zline - Output structure with line fits [NLINE,NOBJ].
Entries are blank where nothing was measured.
yfit - Best-fit background terms + line fits [NPIX,NOBJ]
COMMENTS:
If PLATEFILE is set, then names of other input/output files are derived
from that name. For example, if PLATEFILE='spPlate-0306-51690.fits', then
ZBESTFILE = 'spZbest-0306-51690.fits' (input file)
ZLINEFILE = 'spZline-0306-51690.fits' (input file)
LOGFILE = 'spDiagLine-0306-51690.log' (output file)
PLOTFILE = 'spDiagLine-0306-51690.ps' (output file)
An output file is written only if PLATEFILE or OUTFILE are set.
The first background term is simply the best-fit dispersion template
for galaxies, nothing for QSOs, or the synthetic spectrum for other
types of objects.
At any wavelengths where this background model does not exist (at the
line center), then fit another term that is a linear term
with a width of 0.030 in log-wavelength (300 pix) for QSOs, or a
linear term with a width of 0.005 (50 pix) for other types of objects.
The initial guess for the dispersion is 2000 km/sec for QSO's
(ZGUESS=0.0030), and 105 kms/sec for all other objects (ZGUESS=0.00015).
EXAMPLES:
BUGS:
DATA FILES:
$IDLSPEC2D_DIR/etc/emlines.par
PROCEDURES CALLED:
cpbackup
create_linestruct()
dfpsclose
dfpsplot
djs_filepath()
fileandpath()
headfits()
linebackfit()
mrdfits()
mwrfits
poly_array()
splog
skymask()
sxaddpar
sxpar()
REVISION HISTORY:
12-Feb-2002 Written by D. Schlegel, Princeton
(See pro/spec1d/speclinefit.pro)
NAME:
spec_param_str
PURPOSE:
Build structure SPEC_PARAM for parameters derived from analysis of
galaxy spectra.
CALLING SEQUENCE:
str= spec_param_str(N)
INPUTS:
tsObjfile - tsObj file name
ver1Ddir - 1D directory name (including version number)
OPTIONAL INPUTS:
KEYWORDS
OUTPUTS:
str - array of structures of type "SPEC_PARAM" with N elements
COMMENTS:
BUGS:
heliocentric correction will have to be removed when the 2D bug is fixed
REVISION HISTORY:
2000-Sep-07 written by Mariangela Bernardi
(See pro/science/spec_param_str.pro)
NAME:
spflatave
PURPOSE:
Average together a set (or all!) 2D pixel flats.
CALLING SEQUENCE:
spflatave, [ mjd=, mjstart=, mjend=, mjout=, indir=, outdir=, docam= ]
INPUTS:
OPTIONAL INPUTS:
mjd - Valid MJD's for input pixel flats.
mjstart - Valid starting MJD for input pixel flats.
mjend - Valid ending MJD for input pixel flats.
mjout - MJD for name of output average pixel flat; default to 0,
resulting in file names like 'pixflatave-00000-b1.fits'.
indir - Input directory; default to current directory.
outdir - Output directory; default to same as INDIR.
docam - Camera names; default to all cameras: ['b1', 'b2', 'r1', 'r2']
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
Some sigma-clipping is done before combining each pixel, clipping
at 2-sigma if more than 7 frames, and a lower sigma for fewer frames.
The output file has two HDU's, the first being the average flat,
the second being the standard deviation at each pixel.
--> Comment this out for the time being!!???
EXAMPLES:
BUGS:
PROCEDURES CALLED:
djs_filepath()
djs_iterstat
fileandpath()
headfits()
mrdfits()
splog
sxaddpar
sxpar()
writefits
REVISION HISTORY:
17-Jul-2001 Written by D. Schlegel, Princeton
(See pro/spec2d/spflatave.pro)
NAME:
spflatgen
PURPOSE:
Wrapper for SPFLATTEN2 for generating pixel-to-pixel flat-fields.
CALLING SEQUENCE:
spflatgen, [ mjd=, expnum=, expstart=, expend=, $
indir=, outdir=, docam= ]
INPUTS:
OPTIONAL INPUTS:
mjd - If INDIR not set, then look for files in $RAWDATA_DIR/MJD.
expnum - If set, then use these exposure numbers
expstart - If set, then only use exposure numbers >= EXPSTART
expend - If set, then only use exposure numbers >= EXPEND
indir - Look for input files in this directory; default to current
directory if neither MJD or INDIR are set.
outdir - Output directory; default to same as INDIR.
docam - Camera names; default to all cameras: ['b1', 'b2', 'r1', 'r2']
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
This routine looks for flats and arcs in a given night that are logged
(according to the headers) to be spectroscopic pixel flats. We expect
at least 7 flats in a sequence plus one or more arcs. If this is not
true for a given camera, then no pixel flats are generated for that camera.
Trigger a failure if there are more than 25 biases for a given camera,
since that is probably too many to load into memory.
Four FITS files are produced, one for each camera:
pixflat-MJD-CAMERA.fits
where MJD is the 5-digit modified Julian date, and CAMERA
is 'b1', 'b2', 'r1', and 'r2'.
The header contains the number of files used in each camera (NEXP),
and an identifier for each of those files (EXPID*). Those identifiers
contain the camera name, MJD, flat exposure number, and arc exposure
number, all dash-separated.
EXAMPLES:
The following nights look like they contain a flat sequence:
51686 51781 51809 51852 51893 51950 51978 52010 52038 52069
52161 62193 52216 52245 52276 52304 52333 52363 52392 52423
52454 52514 52551 52573 52602 52633 52655 52689 52719 52747
52777 52808 52868 52899 52956 52983 53014 53044 53073 53100
53132 53162 53220 53257 ...???
53610 53633
53649 (15 dithers)
53651 (15 dithers)
Generate one of these sets of flats with:
spflatgen, mjd=51781, outdir='.'
The initial set of pixel flats were generated using six of the
flats taken on MJD=51441 from three different plates: exposure
numbers 1351,1352,1362,1363,1372,1373 with exp #1350 as the
fiducial flat and #1347 as the arc.
BUGS:
PROCEDURES CALLED:
djs_filepath()
sdsshead()
spflatten2
splog
sxpar()
REVISION HISTORY:
06-Jul-2001 Written by D. Schlegel, Princeton
(See pro/spec2d/spflatgen.pro)
NAME:
spflatten
PURPOSE:
Create pixel-to-pixel flat-field from a stack of SDSS spectral flats.
CALLING SEQUENCE:
spflatten, flatname, [ pixflat, sigrej=, maxiter=, $
outfile=, indir=, outdir=, tmpdir=, $
bkspace=, nord=, lower=, upper= ]
INPUTS:
flatname - Name(s) of raw SDSS flat-field image(s).
Note that many flats from many nights can be combined.
OPTIONAL INPUTS:
sigrej - Sigma rejection level; default to 1, 1, 1.1, 1.3, 1.6 or 1.9
for 1,2,3,4,5 or 6 flats. For more then 6 flats, default
to 2.0.
maxiter - Number of rejection iterations; default to 2.
outfile - Write the image PIXFLAT to this file.
indir - Input directory for FLATNAME; default to './'
outdir - Output directory for OUTFILE; default to './'
tmpdir - Directory for temporary files; default to same as OUTDIR
PARAMETERS FOR SLATEC_SPLINEFIT:
bkspace
nord
lower
upper
OUTPUTS:
OPTIONAL OUTPUTS:
pixflat - Image containing all the information about pixel-to-pixel
variations. Illumination variations are removed.
COMMENTS:
This program writes 2*nflat temporary files to disk to save internal memory.
But it still creates an two arrays (FLATARR (float) and OUTMASK (byte))
that is as large as all of the input flats.
Thus, if you are using ten 16 MB flat images,
that array will be 10*(16+4)=200 MB (in addition to a few other images).
EXAMPLES:
BUGS:
Not sure what to do if exactly 2 frames are passed.
PROCEDURES CALLED:
djs_avsigclip()
extract_image
readfits()
slatec_bvalu()
slatec_splinefit()
sdssproc
writefits
REVISION HISTORY:
13-Oct-1999 Written by D. Schlegel, APO
(See pro/spec2d/spflatten.pro)
NAME:
spflatten2
PURPOSE:
Create pixel-to-pixel flat-field from a stack of SDSS spectral flats.
CALLING SEQUENCE:
spflatten2, flatname, arcname, allflats, [ pixflat, sigrej=, maxiter=, $
oldflat=, outfile=, indir=, outdir=, tmpdir=, $
pixspace=, nord=, lower=, upper=, mincounts=, /nodelete ]
INPUTS:
flatname - Name of flat image for tracing arc
arcname - Name of arc image
allflats - Name(s) of raw SDSS flat-field image(s).
Note that many flats from many nights can be combined.
OPTIONAL INPUTS:
sigrej - Sigma rejection level; default to 1, 1, 1.1, 1.3, 1.6 or 1.9
for 1,2,3,4,5 or 6 flats. For more then 6 flats, default
to 2.0.
maxiter - Number of rejection iterations; default to 2.
oldflat - Name of old flat-field from which to select pixels to mask;
if not set, then read the masks in this source distribution.
outfile - Write the image PIXFLAT to this file.
indir - Input directory for FLATNAME; default to current directory
outdir - Output directory for OUTFILE; default to current directory
tmpdir - Directory for temporary files; default to current directory
pixspace - Approximate spacing in pixels for break points in the
spline fits to individual fibers; default to 50 pixels.
Note that this spacing need be small enough to fit out
the flux variations of multiple fibers crossing a single
column, but it need not fit out the actual flat-field
variations.
mincounts - The summed model image must have a minimum of this many counts
at each pixel, or the output flat is set to zero for that
pixel; default to 100 counts.
nodelete - If set, then do not delete temporary files.
PARAMETERS FOR SLATEC_SPLINEFIT:
nord - Default to 4
lower - Default to 2
upper - Default to 2
OUTPUTS:
OPTIONAL OUTPUTS:
pixflat - Image containing all the information about pixel-to-pixel
variations. Illumination variations are removed.
COMMENTS:
This program writes 2*nflat temporary files to disk to save internal memory.
But it still creates an two arrays (FLATARR (float) and OUTMASK (byte))
that is as large as all of the input flats.
Thus, if you are using ten 16 MB flat images,
that array will be 10*(16+4)=200 MB (in addition to a few other images).
The header contains the number of files used in each camera (NEXP),
and an identifier for each of those files (EXPID*). Those identifiers
contain the camera name, MJD, flat exposure number, and arc exposure
number, all dash-separated.
EXAMPLES:
BUGS:
Not sure what to do if exactly 2 frames are passed.
Pass UPPER and LOWER.
Look for bad fibers or outlier fibers to exclude from superflat.
Right now, we can get bad spline fits across the large hole in the
b1 flat-field if the break points fall too close to the edges of
that hole. Try to keep more data points between the last break point
and the beginning of the hole, or do a linear interpolation across
the hole.
PROCEDURES CALLED:
bspline_iterfit()
bspline_valu()
calcscatimage()
djs_avsigclip()
djs_filepath()
extract_image
fileandpath()
genflatmask()
readfits()
repstr()
rmfile
sdssproc
sxaddpar
sxpar()
superflat()
trace320crude()
traceset2xy
writefits
xy2traceset
REVISION HISTORY:
13-Oct-1999 Written by D. Schlegel, APO
(See pro/spec2d/spflatten2.pro)
NAME:
spfluxcorr_v5
PURPOSE:
Compute flux-correction vectors for each CCD+exposure
CALLING SEQUENCE:
spfluxcorr_v5, objname, [ adderr=, combinedir=, ] bestexpnum=
INPUTS:
objname - File names (including path) for spFrame files, all from
either spectro-1 or spectro-2, but not both!
bestexpnum - Exposure number for best exposure, to which all other
exposures are tied.
OPTIONAL INPUTS:
adderr - Additional error to add to the formal errors, as a
fraction of the flux; default to 0.03 (3 per cent).
combinedir - Directory for output files
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
BUGS:
DATA FILES:
PROCEDURES CALLED:
djs_filepath()
djs_reject()
fcalib_default()
mrdfits()
mwrfits
solve_poly_ratio
splog
soplot
splot
INTERNAL SUPPORT ROUTINES:
fcorr_goodvector()
REVISION HISTORY:
05-Feb-2004 Written by D. Schlegel, Princeton
(See pro/spec2d/spfluxcorr_v5.pro)
NAME:
spflux_read_kurucz
PURPOSE:
Read the Kurucz models at the specified log-lambda and resolution
CALLING SEQUENCE:
spflux_read_kurucz
modelflux = spflux_read_kurucz( loglam, dispimg, [ iselect=, $
kindx_return= ] )
INPUTS:
loglam - Log10 wavelengths [NPIX]
dispimg - Dispersion image, in units of pixels [NPIX]
OPTIONAL INPUTS:
iselect - If set, then only return these model numbers; default to
returning all models
OUTPUTS:
modelflux - Model fluxes [NPIX,NMODEL]
OPTIONAL OUTPUTS:
kindx_return- Structure with model parameters for each model
COMMENTS:
Note that this function allocates a ridiculous amount of memory
for caching the oversampled spectra at many dispersions in GRIDFLUX.
EXAMPLES:
BUGS:
DATA FILES:
$IDLSPEC2D_DIR/templates/kurucz_stds_raw_v5.fits
PROCEDURES CALLED:
mrdfits()
rebin_spectrum()
splog
sxpar()
REVISION HISTORY:
05-Feb-2004 Written by D. Schlegel, Princeton
(See pro/spec2d/spflux_read_kurucz.pro)
NAME:
spflux_v5
PURPOSE:
Compute flux-calibration vectors for each CCD+exposure from std stars
CALLING SEQUENCE:
spflux_v5, objname, [ adderr=, combinedir= ]
INPUTS:
objname - File names (including path) for spFrame files, all from
either spectro-1 or spectro-2, but not both!
OPTIONAL INPUTS:
adderr - Additional error to add to the formal errors, as a
fraction of the flux; default to 0.03 (3 per cent)
combinedir - Directory for output files
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
One output file is written for every input file OBJNAME,
prefixed with spFluxcalib. It containts the following:
HDU #0: Calibration image
HDU #1: Trace-set used to construct the former
HDU #2: Structure with info on each standard star
EXAMPLES:
BUGS:
DATA FILES:
PROCEDURES CALLED:
airtovac
bspline_bkpts()
bspline_iterfit()
bspline_valu()
combine1fiber
computechi2()
correct_dlam
djs_filepath()
djs_maskinterp()
djs_median()
djs_oplot
djs_plot
djs_xyouts
euler
ext_odonnell
fileandpath()
filter_thru()
find_nminima()
mrdfits()
mwrfits
pixelmask_bits()
rebin_spectrum()
spframe_read
skymask()
spflux_read_kurucz()
splog
tai2airmass()
wavevector()
INTERNAL SUPPORT ROUTINES:
spflux_masklines()
spflux_medianfilt()
spflux_bestmodel()
spflux_goodfiber()
spflux_bspline()
spflux_mratio_flatten()
spflux_plotcalib
sxaddpar
sxpar()
REVISION HISTORY:
05-Feb-2004 Written by D. Schlegel, Princeton
(See pro/spec2d/spflux_v5.pro)
NAME:
spframe_read
PURPOSE:
Read data from either an spFrame or spCFrame file.
CALLING SEQUENCE:
spframe_read, filename, [ indx, objflux=, objivar=, mask=, $
wset=, loglam=, dispset=, dispimg=, plugmap=, skyflux=, hdr=, adderr= ]
INPUTS:
filename - Input file name
OPTIONAL INPUTS:
indx - Optional 0-indexed row numbers; default to all
adderr - Additional error to add to the formal errors, as a
fraction of the flux; default to none
OUTPUTS:
OPTIONAL OUTPUTS:
objflux - Object flux
objivar - Object inverse variance (units of 1/OBJFLUX^2)
mask - Pixel bit mask
wset - Trace-set for wavelength solution
loglam - Wavelength image (vacuum log-10 Ang)
dispset - Trace-set for dispersion solution
dispimg - Dispersion image (per native pixel)
skyflux - Sky flux (same units as OBJFLUX)
hdr - FITS header for HDU#0
COMMENTS:
The spFrame and spCFrame files contain nearly identical HDUs,
except for HDU #3 and #4 which are trace-sets in spFrame, and
more easily-interpreted 2-dimensional images in spCFrame:
spFrame spCFrame
HDU #0: Flux Flux
HDU #1: Invvar Invvar
HDU #2: mask mask
HDU #3: wset loglam
HDU #4: dispset dispimg
HDU #5: plugmap plugmap
HDU #6: sky sky
HDU #7: flatfit
HDU #8: telluric (deprecated)
EXAMPLES:
BUGS:
PROCEDURES CALLED:
fileandpath()
headfits()
lookforgzip()
mrdfits()
traceset2xy
traceset_trim()
REVISION HISTORY:
05-Feb-2004 Written by D. Schlegel, Princeton
(See pro/spec2d/spframe_read.pro)
NAME:
spgain
PURPOSE:
Measure the gain + read noise for SDSS spectroscopic images
CALLING SEQUENCE:
spgain, flatfile1, flatfile2, [ biasfile1, biasfile2, indir=, $
xskip=, yskip=, /simulate, gain=, rnoise=]
INPUTS:
flatfile1 - File name for flat #1
flatfile2 - File name for flat #2
biasfile1 - File name for bias #1
biasfile2 - File name for bias #2
OPTIONAL KEYWORDS:
indir - Input directory for all files
xskip - Number of columns to ignore at beginning and end of each
amplifier; default to 50
yskip - Number of rows to ignore at beginning and end of each
amplifier; default to 5
simulate - If set, then replace the images with simulated images with
a gain of 1.3 e-/ADU and read noise of 3.5 ADU.
OUTPUTS:
gain - Gain in electrons/ADU for each amplifier (array)
rnoise - Read noise in electrons for each amplifier (array)
COMMENTS:
EXAMPLES:
Compute the read nosie and gain using the bias frames and flats
taken for this very purpose on MJD 53114 (18/19 April 2004).
For the b1 CCD:
IDL> spgain, 'sdR-r2-00026145.fit.gz', 'sdR-r2-00026146.fit.gz', $
'sdR-r2-00026147.fit.gz', 'sdR-r2-00026148.fit.gz'
BUGS:
PROCEDURES CALLED:
djs_iterstat
sdssproc
REVISION HISTORY:
21-Nov-1999 Written by D. Schlegel, Princeton.
(See pro/spec2d/spgain.pro)
NAME:
sphdrfix
PURPOSE:
Fix header cards in raw SDSS spectroscopic data.
CALLING SEQUENCE:
sphdrfix, filename, hdr, [ /do_lock ]
INPUTS:
filename - Name of raw FITS file
hdr - FITS header
OPTIONAL INPUTS:
do_lock - If set, then lock the "sdHdrFix-$MJD.par" file
using DJS_LOCKFILE().
OUTPUTS:
hdr - FITS header (modified)
COMMENTS:
This routine implements "hand edits" of the raw FITS headers for
SDSS spectroscopic images. The list of edits to make can be stored
in two possible Yanny parameter file, the static "opHdrFix.par" file
in the IDLSPEC2D product, and in the "sdHdrFix-$MJD.par" file for
the relevant night.
This proc only works in IDL version 5.3 and later, because it
uses STRMATCH().
EXAMPLES:
filename = 'sdR-b2-00003976.fit'
hdr = headfits(filename)
sphdrfix, filename, hdr
BUGS:
This will fail if the MJD needs hand-editing in the sdHdrFix file,
since we need the MJD to find the sdHdrFix file in the first place!
PROCEDURES CALLED:
djs_lockfile()
djs_unlockfile
fileandpath()
splog
sxaddpar
yanny_free
yanny_read
INTERNAL SUPPORT ROUTINES
sphdrfix1
DATA FILES:
$IDLSPEC2D_DIR/examples/opHdrFix.par
$SPECLOG_DIR/$MJD/sdHdrFix-$MJD.par
REVISION HISTORY:
29-Dec-2009 Written by D. Schlegel, Princeton
(See pro/spec2d/sphdrfix.pro)
NAME:
sphoto_calib
PURPOSE:
Derive spectrophotometric calibration for a group of exposures from
one camera + spectrograph
CALLING SEQUENCE:
sphoto_calib, wave, flux, invvar, mask, plugtag, fcalfile, $
stdstarfile, [/stype, input_calibset=, /noplot]
INPUTS:
wave - wavelength array in log10(ang) [npix, nstd*nexp]
flux - flux array of standard stars [npix, nstd*nexp]
invvar - inverse variance of standard stars [npix, nstd*nexp]
mask - pixel masks of standard stars [npix, nstd*nexp]
plugtag - structure containing plugmap info + exposure identification
fcalfile - vector of names for flux calibration FITS files [nexp]
Traditionally spFluxcalib-cc-eeeeeeee.fits where cc is the
camera id (b1,b2,r1,r2) and eeeeeeee is the exposure number
stdstarfile - name of FITS file containing standard star info -- if
"stype" is set, this is created. Traditionally the names
are spStd-pppp-mmmmm-s.fits where pppp=plateid,
mmmmmm=MJD, and s = spectrograph ID [1/2]
OPTIONAL INPUT:
stype - if set spectral type the standard stars (for this to
work the frames must be blue!!)
input_calibset - use this as the average flux correction (instead of
using PCA to determine the average) This is typically
done done for the smear exposures since their S/N is low.
noplot - toggle plotting of flux correction residuals -- the
PCA average is always shown
OUTPUT:
The bspline coefficients of the average flux calibration vectors
of each exposure are written out as FITS files (using the names in
fcalfile). If "stype" is set, info about the standard stars (Teff,
[Fe/H], velocity, etc) is saved as a binary FITS structure in the
file given by "stdstarfile".
OPTIONAL OUTPUT:
COMMENTS:
Frames from the blue camera should be processed first, because the
spectral typing requires blue wavelengths.
BUGS:
The PCA code is run (and plots are made) even if the output is not used.
EXAMPLES:
PROCEDURES CALLED:
bspline_iterfit
bspline_valu
combine1fiber
djs_maskinterp
djs_median
frame_flux_calib
mrdfits
pca_flux_standard
rectify
skymask
stype_standard
splog
INTERNAL SUPPORT ROUTINES:
REVISION HISTORY:
12-Aug-2003 Created by C. Tremonti, Steward Observatory
(See pro/fluxfix/sphoto_calib.pro)
NAME:
spmedian_rebin
PURPOSE:
Coarsely rebin the data using medians to reject outliers
CALLING SEQUENCE:
medflux = spmedian_rebin(loglam, flux, ivar, color, mask=, sigrej=, $
outwave=, sn=, quality=)
INPUTS:
loglam - wavelength array in log10(Angstroms) [npix, nfiber]
flux - flux array [npix, nfiber]
ivar - inverse variance [npix, nfiber]
color - choices are 'r' (data from red camera) 'b' (data from blue camera)
or 'full' (data from both cameras combined -- for use with smears)
OPTIONAL KEYWORDS:
sigrej - threshold for masking of data (scalar)
OUTPUTS:
A rebinned version of the input flux spectrum is returned. [nnewpix, nfiber]
OPTIONAL OUTPUTS:
mask - The approximate inverse variance of the output spectrum (set
to zero for bad pix). [nnewpix, nfiber]
outwave - output wavelength scale in log10(Angstroms) [nnewpix]
sn - median S/N prior to rebinning [nfiber]
quality - flag set to zero for good data, one if bad trace/arc/flat, etc
[nfiber]
COMMENTS:
Used when division of low S/N spectra is necessary. See "frame_flux_tweak"
and "smear_compare".
EXAMPLES:
plot, 10.0^loglam[*,0], flux[*,0]
medflux = spmedian_rebin(loglam, flux, ivar, 'full', outwave=outwave)
oplot, 10.0^outwave, medflux[*,0]
BUGS:
PROCEDURES CALLED:
djs_iterstat()
djs_median()
fibermaks_bits()
REVISION HISTORY:
12-Aug-2003 Split into stand-alone function by C. Tremonti
17-Oct-2000 Formerly part of fluxcorr_new -- written by S. Burles
(See pro/fluxfix/spmedian_rebin.pro)
NAME:
spplan1d
PURPOSE:
Decide if any of these MJD's are within the bounds specified by
MJD,MJSTART,MJEND.
CALLING SEQUENCE:
qmjd = mjd_match(mjdlist, [mjd=, mjstart=, mjend=])
INPUTS:
mjdlist - One MJD or an array of MJD's.
OPTIONAL INPUTS:
mjd - Match against these specific MJD's.
mjstart - Starting MJD.
mjend - Ending MJD.
OUTPUT:
qmjd - Set to 1 if any of the MJD's in MJDLIST are within
the bounds specified by MJD,MJSTART,MJEND.
Otherwise, set to 0.
COMMENTS:
EXAMPLES:
BUGS:
PROCEDURES CALLED:
REVISION HISTORY:
22-Aug-2001 Written by David Schlegel, Princeton.
(See pro/spec2d/mjd_match.pro)
NAME:
spplan1d
PURPOSE:
Create plan file(s) for combining Spectro-2D outputs into one plate.
CALLING SEQUENCE:
spplan1d, [ topindir=, topoutdir=, mjd=, mjstart=, mjend=, $
platenum=, platestart=, plateend=, /clobber ]
INPUTS:
OPTIONAL INPUTS:
topindir - Top directory name for 2D outputs; default to ''
topoutdir - Top directory name for 2D outputs; default to the
same as TOPINDIR.
mjd - Use data from these MJD's.
mjstart - Starting MJD.
mjend - Ending MJD.
platenum - Look for input data files in TOPINDIR/PLATENUM; default to
search all subdirectories. Note that this need not be
integer-valued, but could be for example '0306_test'.
platestart - Starting plate number.
plateend - Ending plate number.
clobber - If set, then over-write conflicting plan files; default to
not over-write files.
OUTPUT:
COMMENTS:
EXAMPLES:
BUGS:
This routine spawns the Unix command 'mkdir'.
The use of CONCAT_DIR may not be valid for non-Unix OS's.
PROCEDURES CALLED:
concat_dir()
fileandpath()
get_mjd_dir()
idlspec2d_version()
idlutils_version()
mjd_match()
splog
sdsshead()
sxpar()
yanny_free
yanny_par()
yanny_read
yanny_write
REVISION HISTORY:
04-Jul-2000 Written by David Schlegel, Princeton.
(See pro/spec2d/spplan1d.pro)
NAME:
spplan2d
PURPOSE:
Create plan file(s) for running the Spectro-2D pipeline.
CALLING SEQUENCE:
spplan2d, [ topoutdir=, mjd=, mjstart=, mjend=, minexp=, $
/clobber ]
INPUTS:
OPTIONAL INPUTS:
topoutdir - Top directory name for output files; default to ''.
mjd - Look for raw data files in RAWDATA_DIR/MJD; default to
search all subdirectories. Note that this need not be
integer-valued, but could be for example '51441_test'.
mjstart - Starting MJD.
mjend - Ending MJD.
minexp - Minimum exposure time for science frames; default to 1 sec.
clobber - If set, then over-write conflicting plan files; default to
not over-write files.
OUTPUT:
COMMENTS:
The environment variables SPECLOG_DIR and RAWDATA_DIR must be set.
Look for the raw FITS data files in:
RAWDATA_DIR/MJD/sdR-cs-eeeeeeee.fit
where c=color, s=spectrograph number, eeeeeeee=exposure number.
The output 2D plan files created are:
TOPOUTDIR/PLATE/spPlan2d-pppp-mmmmm.par
where pppp=plate number, mmmmm=MJD.
For the earliest data (before MJD=51455), then NAME keyword in the FITS
files did not properly describe the plug-map name. In those cases,
look for the actual plug-map files in SPECLOG_DIR/MJD.
Exclude all files where the QUALITY header keyword is not 'excellent'.
EXAMPLES:
Create the plan file(s) for reducing the data for MJD=51441, with that
top level directory set to '/u/schlegel/2d_test'
> spplan2d, '/u/schlegel/2d_test', mjd=51441
BUGS:
This routine spawns the Unix command 'mkdir'.
The use of CONCAT_DIR may not be valid for non-Unix OS's.
PROCEDURES CALLED:
concat_dir()
fileandpath()
get_mjd_dir()
idlspec2d_version()
idlutils_version()
splog
sdsshead()
spplan_findrawdata
spplan_create_spexp
sxpar()
yanny_write
REVISION HISTORY:
02-Nov-1999 Written by David Schlegel, Princeton.
(See pro/spec2d/spplan2d.pro)
NAME:
spread_frames
PURPOSE:
Read in multiple frame files produced by spectro2d and pass back arrays
of the various quantities.
CALLING SEQUENCE:
spread_frames, spframes, [window=, binsz =, adderr=, camnames=, $
tsobjname=, flux=, ivar=, loglam=, dispersion=, pixelmask=, plugmap=, $
plugtag=, camerasvec=, filenum=, expid=, sn2=, hdrarr=, merged_hdr=]
INPUTS:
spframes -
OPTIONAL INPUT KEYWORDS:
window - window size for apodizing the errors of the spectrum from each
individual frame -- default to 100 pixels on each end of the
spectrum
binsz - bin size (in log10(ang) of the output spectra; default to
1d-4 which is 69 km/s
adderr - additional error to add to the formal errors as a fraction
of the flux
camnames - camera names to combine -- default to ['b1', 'b2', 'r1', 'r2']
tsobjname - full path name to tsobjfile if one is available. It is
assumed that the target info is in HDU#1 and the latest
photo re-run is in HDU#2
OUTPUT:
OPTIONAL OUTPUT:
flux - flux array from all frames [npix, nfiber*nfames]
ivar - inverse variance array from all frames [npix, nfiber*nframes]
loglam - wavelength array (log10(Ang)) [npix, nfiber*nframes]
dispersion - instrumental resolution array [npix, nfiber*nfrmes]
pixelmask - mask array [npix, nfiber*nframes]
plugmap - array of structures containing plugmap [nfiber*nframes]
plugtag - like plugmap but with newer tsObj info if available and with
exposure ID info included (useful for bookkeeping)
camerasvec - vector of camera IDs (b1,b2,r1,r2) [nframes]
filenum - file number of frame (used in bookkeeping) [nfiber*nframes]
expid - exposure ID number [nframes]
sn2 - signal-to-noise squared of each frame [nframes]
hdrarr - array of pointers to header files from each frame [nframes]
merged_hdr - header to be used for combined frames (some quantities
keywords contain averages of the keywords in the frames)
COMMENTS:
BUGS:
EXAMPLES:
PROCEDURES CALLED:
correct_dlam
djs_diff_angle
mrdfits
pixelmask_bits()
splog
sxaddpar
sxcombinepar
sxdelpar
traceset2xy
idlspec2d_version
INTERNAL SUPPORT ROUTINES:
makelabel()
REVISION HISTORY:
12-Aug-2003 Made into a stand-alone routine by C. Tremonti, Steward Obs.
02-Jan-2000 Written as part of "spcoadd_frames" by D. Schlegel, Princeton
(See pro/fluxfix/spread_frames.pro)
NAME:
spreduce
PURPOSE:
Extract, wavelength-calibrate, and flatten SDSS spectral frame(s).
CALLING SEQUENCE:
spreduce, flatname, arcname, objname, $
plugfile=, lampfile=, indir=, plugdir=, outdir=, $
ecalibfile=, plottitle=, summarystruct=, /do_telluric
INPUTS:
flatname - Name(s) of flat-field SDSS image(s)
arcname - Name(s) of arc SDSS image(s)
objname - Name(s) of object SDSS image(s)
REQUIRED KEYWORDS:
plugfile - Name of plugmap file (Yanny parameter file)
OPTIONAL KEYWORDS:
lampfile - Name of file describing arc lamp lines;
default to the file 'lamphgcdne.dat' in $IDLSPEC2D_DIR/etc.
indir - Input directory for FLATNAME, ARCNAME, OBJNAME;
default to '.'
plugdir - Input directory for PLUGFILE; default to '.'
outdir - Directory for output files; default to '.'
ecalibfile - opECalib.par file for SDSSPROC
plottitle - Prefix for titles in QA plots.
summarystruct - Good intentions ???
do_telluric- Passed to EXTRACT_OBJECT
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
BUGS:
Should test that arcs and flats are valid images with CHECKFLAVOR.
PROCEDURES CALLED:
extract_object
fibermask_bits()
get_tai
qaplot_arcline
qaplot_fflat
readplugmap()
reject_science()
select_arc()
select_flat()
sortplugmap
sdssproc
spcalib
splog
sxaddpar
sxpar()
DATA FILES:
$IDLSPEC2D_DIR/etc/skylines.dat
REVISION HISTORY:
12-Oct-1999 Written by D. Schlegel & S. Burles, APO
(See pro/spec2d/spreduce.pro)
NAME:
spreduce1d
PURPOSE:
1-D reduction of spectra from 1 plate
CALLING SEQUENCE:
spreduce1d, [ platefile, fiberid=, /doplot, /debug ]
INPUTS:
OPTIONAL INPUTS:
platefile - Plate file(s) from spectro-2D; default to all files
matching 'spPlate*.fits'
fiberid - If specified, then only reduce these fiber numbers;
this must be a vector with unique values between 1 and
the number of rows in the plate file (typically 640).
doplot - If set, then generate plots. Send plots to a PostScript
file spDiagDebug1d-$PLATE-$MJD.ps unless /DEBUG is set.
debug - If set, then send plots to the X display and wait for
a keystroke after each plot; setting /DEBUG forces /DOPLOT.
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
Names of output files are derived from PLATEFILE.
For example, if PLATEFILE='spPlate-0306-51690.fits', then
ZALLFILE = 'spZall-0306-51690.fits'
ZBESTFILE = 'spZbest-0306-51690.fits'
EXAMPLES:
BUGS:
DATA FILES:
$IDLSPEC2D_DIR/templates/TEMPLATEFILES
PROCEDURES CALLED:
cpbackup
dfpsclose
dfpsplot
djs_filepath()
elodie_best()
fileandpath()
filter_thru()
mrdfits()
mwrfits
qaplot_fcalibvec
splog
skymask()
speclinefit
star_dvelocity()
struct_addtags()
sxaddpar
sxdelpar
sxpar()
synthspec()
vdispfit
zfind()
zrefind()
REVISION HISTORY:
28-Jun-2000 Written by D. Schlegel, Princeton
(See pro/spec1d/spreduce1d.pro)
NAME:
spreduce2d
PURPOSE:
Calling script for SPREDUCE that reduces a night of data according
to a plan file.
CALLING SEQUENCE:
spreduce2d, [ planfile, docams=, /do_telluric, /xdisplay ]
INPUTS:
OPTIONAL INPUTS:
planfile - Name(s) of output plan file; default to reducing all
plan files matching 'spPlan2d*.par'
docams - Cameras to reduce; default to ['b1', 'b2', 'r1', 'r2']
do_telluric- Passed to EXTRACT_OBJECT
xdisplay - Send plots to X display rather than to plot file
OUTPUT:
COMMENTS:
The following environment variables must be set:
RAWDATA_DIR
SPECLOG_DIR
SPECFLAT_DIR
Look for raw FITS data files in RAWDATA_DIR/MJD.
Look for plug map files in SPECLOG_DIR/MJD.
Look for spectroscopic flat files in SPECFLAT_DIR.
EXAMPLES:
BUGS:
This routine spawns the Unix command 'mkdir'.
PROCEDURES CALLED:
cpbackup
idlspec2d_version()
idlutils_version()
splog
spreduce
yanny_free
yanny_par()
yanny_read
INTERNAL SUPPORT ROUTINES:
REVISION HISTORY:
02-Nov-1999 Written by David Schlegel, Princeton.
(See pro/spec2d/spreduce2d.pro)
NAME:
sshiftvec
PURPOSE:
Shift vector or image (line-at-a-time) using a damped sinc function.
CALLING SEQUENCE:
simage = sshiftvec( fimage, shift, [ sincrad=sincrad, dampfac=dampfac, $
eps=eps ] )
INPUTS:
fimage - Input vector (1D) or image (2D)
shift - Distance to shift
OPTIONAL KEYWORDS:
sincrad - Half-width of sinc convolution kernal; default to 10 pixels
dampfac - Damping factor for gaussian; default to 3.25
eps - Smallest fractional shift allowed; default to 1.0e-5
OUTPUTS:
simage - Shifted image
OPTIONAL OUTPUTS:
COMMENTS:
This routine is based upon the IDL routine SSHIFT from Marc Buie,
which in turn is based upon the Zodiac routine shiftc/sshift.
EXAMPLES:
PROCEDURES CALLED:
Dynamic link to sshiftvec.c
REVISION HISTORY:
14-Apr-1999 Written by David Schlegel, Princeton.
(See pro/spec2d/sshiftvec.pro)
NAME:
star_dvelocity
PURPOSE:
Solve for velocity shifts between multiple exposures.
CALLING SEQUENCE:
res = star_dvelocity(plate, mjd=, [ vmin=, vmax=, fiberid=, path= ] )
INPUTS:
plate - Plate number
mjd - MJD for this plate
OPTIONAL INPUTS:
vmin - Minimum velocity to consider; default to -700.
vmax - Maxmimum velocity to consider; default to 700.
fiberid - If set, then only fit for the objects specified by
these 1-indexed fiber IDs. Set to 0 to not
fit any objects (but return empty 640-element output
structures); default to fitting all.
path - Override all path information with this directory name
(for reading the spCFrame files)
OUTPUTS:
res - Output structure with result for each object [NOBJECT].
The structure contains the following
best-fit Elodie spectrum:
VELOCITY_TIME[10] - Timestamp for each exposure
VELOCITY[10] - Velocity for each exposure [km/s]
VELOCITY_ERR[10] - Error in velocity
OPTIONAL OUTPUTS:
COMMENTS:
Velocities are computed relative to the first exposure. Each exposure
is compared to every other exposure, with no assumption about the kind
of object. The object need not be a star.
EXAMPLES:
Fit the velocity shifts for the white dwarf star in SDSS publication #535:
IDL> res=star_dvelocity(518,mjd=52282,fiberid=285)
BUGS:
PROCEDURES CALLED:
INTERNAL SUPPORT ROUTINES:
dvelocity_struct()
dvelocity_fn()
REVISION HISTORY:
09-Jul-2005 Written by D. Schlegel, LBL
(See pro/spec1d/star_dvelocity.pro)
NAME:
stype_standard
PURPOSE:
Spectral type the standard stars and store the result as a structure.
The normalized input spectra are compared to a grid of normalized
Kurucz models produced by the SPECTRUM code (R.0. Gray & C. J. Corbally,
1994, AJ, 107, 742) and convolved to SDSS resolution. Since nearly all
of the interesting spectral features are in the blue, data from the
blue camera only can be used.
CALLING SEQUENCE:
std = stype_standard(loglam, nflux, ninvvar, plugmap, outfile=, $
nonsdss=, smoothpix=)
INPUTS:
loglam - Wavelength array of input spectra in log10(Angstroms) [npix]
nflux - Array of normalized standard star spectra [npix, nstar]
ninvvar - Inverse variance of standard star spectra [npix,nstar]
plugmap - Plugmap corresponding to the input standard stars [nstar]
OUTPUT:
A structure containing best fit model name, Teff, g, [Fe/H] and
magnitudes is returned. Diagnostic plots are also produced. Each
spectophoto standard is shown with the (normalized) best fit spectrum
plotted over top in red.
KEYWORDS:
outfile - Name of output FITS file. It must be of the from
?????-pppp-mmmm-s.fits where, pppp is the plateid,
mmmmm is the mjd and s is the spectrograph ID.
e.g. spStd-0519-52283-1.fits
nonsdss - Set to 1 for use with data which is not from the SDSS --
the plugmap is not used in this case, and no reddening
is applied.
smoothpix - number of pixels to smooth Kurucz models by -- for use with
data of lower resolution than the SDSS
COMMENTS:
A file containing the Kurucz model data is required. It is called
"kurucz_stds_*.fit" and it should reside in IDLSPEC2D_DIR/etc. See
"kurucz_restore.pro" for a description of this file.
The SFD dust maps are needed to estimate the foreground extinction
to add to the models. To acomodate this a new environment variable
"DUST_DIR" is required.
BUGS:
Spectral typing is slightly sensitive to the method of normalization
EXAMPLES:
PROCEDURES CALLED:
djs_icolor()
djs_median()
djs_oplot
djs_plot
dust_getval()
ext_odonnell()
filter_thru()
glactc()
kurucz_restore
mwrfits
splog
zcompute()
INTERNAL SUPPORT ROUTINES
kurucz_match()
REVISION HISTORY:
28-Sep-2002 Written by C. Tremonti
12-Aug-2003 Modified by C. Tremonti for use with Spectro2d
(See pro/fluxfix/stype_standard.pro)
NAME:
superflat
PURPOSE:
Create a "superflat" from an extracted flat-field image
CALLING SEQUENCE:
sset = superflat(flux, fluxivar, wset, fullbkpt, coeff, $
[ fibermask=, minval=, medval=, title=, $
x2=, nord=, npoly=, upper=, lower= ])
INPUTS:
flux - Array of extracted flux from a flat-field image [Nrow,Ntrace]
fluxivar - Inverse variance map for FLUX.
wset - Wavelength solution
OPTIONAL KEYWORDS:
fibermask - Fiber status bits, set nonzero for bad status [NFIBER]
minval - Minimum value to use in fits to flat-field vectors;
default to 0.
title - TITLE of plot; if not set, then do not make this plot.
OPTIONAL PARAMETERS FOR BSPLINE_ITERFIT:
x2 - Orthogonal dependent variable for B-spline fit;
this will typically be the X position on the CCD.
nord - Order of b-splines; default of 4 for cubic
npoly - Order of X2 polynomial fit; default to 0 for none
lower -
upper -
OUTPUTS:
sset - Output structure describing spline fit to superflat.
OPTIONAL OUTPUTS:
medval - Median value of each fiber [NFIBER]
fibermask - (Modified)
COMMENTS:
EXAMPLES:
BUGS:
PROCEDURES CALLED:
djs_maskinterp()
djs_mean()
djs_oplot
djs_plot
bspline_valu()
bspline_iterfit()
traceset2xy
REVISION HISTORY:
02-Jan-2000 Excised code from SPFLATTEN2 (DJS).
(See pro/spec2d/superflat.pro)
NAME:
synthspec
PURPOSE:
Construct synthetic spectrum from eigen-templates.
CALLING SEQUENCE:
synflux = synthspec(zans, [ loglam=, hdr=, eigendir= ])
INPUTS:
zans - Structure(s) with redshift-fit information (from SPREDUCE1D).
OPTIONAL KEYWORDS:
loglam - Log-10 wavelengths at which to synthesize the spectrum;
this can either be a single vector if all spectra have
the same wavelength mapping, or an array of [NPIX,NOBJ].
hdr - If specified, then use this header to construct LOGLAM.
Either LOGLAM or HDR must be specified.
eigendir - Directory for EIGENFILE; default to $IDLSPEC2D/templates.
OUTPUTS:
synflux - Synthetic spectra
COMMENTS:
The sub-pixel shifts are applied with the COMBINE1FIBER procedure.
EXAMPLES:
BUGS:
DATA FILES:
$IDLSPEC2D_DIR/etc/TEMPLATEFILES
PROCEDURES CALLED:
combine1fiber
concat_dir()
poly_array()
readfits()
sxpar()
REVISION HISTORY:
20-Aug-2000 Written by D. Schlegel, Princeton
(See pro/spec1d/synthspec.pro)
NAME:
telluric_corr
PURPOSE:
Use SPECTROPHOTO and REDDEN_STD's to fit telluric features.
CALLING SEQUENCE:
telluric_factor = telluric_corr(flux, fluxivar, wset, plugsort, $
fibermask=, tellbands=, ncoeff=, pixspace=, /dospline, $
nord=, upper=, lower=, plottitle=
INPUTS:
flux - Sky-subtracted extracted spectra [NX,NTRACE]
fluxivar - Inverse variance for FLUX [NX,NTRACE]
wset - Wavelength coefficients as a trace set
plugsort - Plugmap entries
OPTIONAL KEYWORDS:
fibermask - Fiber status bits, set nonzero for bad status [NFIBER]
tellbands - Structure array defining the telluric bands and the
wavelengths used to fit the continuum. If not set,
then default values are used. See the code for the
definition of this structure.
ncoeff - Number of coefficients used in constructing continuum;
default to 4.
pixspace - Approximate spacing in pixels for break points in the
spline fits to individual fibers; default to 10 pixels.
dospline - If this keyword is set, then fit the continuum
to splines (using PIXSPACE) rather than to a Legendre
polynomial (using NCOEFF).
plottitle - Title for QA plot; if not set, then do not plot.
PARAMETERS FOR SLATEC_SPLINEFIT:
nord
upper
lower
OUTPUTS:
telluric_factor - Telluric correction for each pixel in flux array;
set to 1 where there is no correction.
OPTIONAL OUTPUTS:
COMMENTS:
Objects that are SPECTROPHOTO_STD or REDDEN_STD (as listed in the plugmap
structure) are selected for constructing the telluric-correction factor.
EXAMPLES:
BUGS:
Other fainter telluric bands at [7178,7212], [8130,8206].
PROCEDURES CALLED:
djs_oplot
djs_plot
djs_reject()
fibermask_bits()
func_fit()
bspline_valu()
bspline_iterfit()
splog
traceset2xy
REVISION HISTORY:
19-Oct-1999 Written by S. Burles, Chicago
15-Aug-2000 Major modifications by D. Schlegel to fit all telluric
bands with one spline, and to do this fit on the spectra
before flux-correction.
(See pro/spec2d/telluric_corr.pro)
NAME:
throughput_calib
PURPOSE:
Calculate spectroscopic throughput with fluxcalib files
CALLING SEQUENCE:
throughput = throughput_calib(file, loglam, $
primary=primary, exposure=exposure, pixelsize=pixelsize
INPUTS:
file - full name of fluxcalib fits file
loglam - optional, alog10 wavelengths.
throughput is set to zero outside of the wavelength range
of both bspline set and the wavemin,wavemax header cards
OPTIONAL KEYWORDS:
primary - effective primary aperature in cm^2 (default 40000)
exposure - effective exposure time of calibration exposure
pixelsize - physical CCD pixel size (guess alog10 1.0e-4)
this could also be passed as a keyword in the header
OUTPUTS:
throughput - percent throughput at each loglam position
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
loglam = 3.57 + findgen(400)/1000.
cd,getenv('SPECTRO_DATA')
allfiles = findfile('0*/*calib*fits', count=nf)
throughput = fltarr(400, nf)
for i=0,nf-1 do throughput[*,i] = throughput_calib(allfiles[i],loglam)
PROCEDURES CALLED:
REVISION HISTORY:
26-Jun-2001 Scott Burles (Paris)
(See pro/spec2d/throughput_calib.pro)
NAME:
trace320cen
PURPOSE:
Find the 320 fiber positions for the central row of an image.
CALLING SEQUENCE:
xfiber = trace320cen( fimage, [mthresh=, ystart=, nmed=, xgood= ] )
INPUTS:
fimage - Image
OPTIONAL INPUTS:
mthresh - Threshold for peak-finding in convolved row; default to 0.5
times the dispersion (found with djs_iterstat).
ystart - Y position in image to search for initial X centers; default
to the central row
nmed - Number of rows to median filter around YSTART; default to 21
OUTPUTS:
xfiber - Vector of 320 X centers
OPTIONAL OUTPUTS:
xgood - Set to 1 for fibers that were actually found, 0 otherwise
COMMENTS:
EXAMPLES:
PROCEDURES CALLED:
djs_iterstat
REVISION HISTORY:
13-Sep-1999 Written by David Schlegel, Princeton.
(See pro/spec2d/trace320cen.pro)
NAME:
trace320crude
PURPOSE:
Calling script to return 320 full traces using TRACE_CRUDE.
CALLING SEQUENCE:
xset = trace320crude( fimage, invvar, [mthresh=, ystart=, nmed=, $
xmask=, yset=, maxerr=, maxshifte=, maxshift0=, xerr=, maxdev=, ngrow=, $
fibermask= ] )
INPUTS:
fimage - Image
OPTIONAL INPUTS FOR TRACE320CEN:
mthresh - Threshold for peak-finding in convolved row; default to 0.5
times the dispersion (found with djs_iterstat).
ystart - Y position in image to search for initial X centers; default
to the central row
nmed - Number of rows to median filter around YSTART; default to 21
OPTIONAL INPUTS FOR TRACE_CRUDE:
invvar - Inverse variance (weight) image
radius - Radius for centroiding; default to 3.0
maxerr - Maximum error in centroid allowed for valid recentering;
default to 0.2
maxshifte - Maximum shift in centroid allowed for valid recentering;
default to 0.1
maxshift0 - Maximum shift in centroid allowed for initial row;
default to 0.5
OPTIONAL INPUTS:
maxdev - Maximum deviation of X in pixels; default to rejecting any
XPOS positions that deviate by more than 1.0 pixels from
a polynomial remapping of the centroids from other rows.
ngrow - For each trace, replace all centroids within NGROW rows
of a bad centroid with the predicted centroid locations.
Default to 5.
fibermask - Fiber status bits, set nonzero for bad status [NFIBER]
OUTPUTS:
xset - X centers for all traces
OPTIONAL OUTPUTS:
yset - Y centers for all traces
xerr - Errors for XSET
xmask - Mask set to 1 for good fiber centers, 0 for bad;
same dimensions as XSET.
fibermask - (Modified.)
COMMENTS:
Without djs_maskinterp, hot columns skew traces
EXAMPLES:
PROCEDURES CALLED:
djs_maskinterp()
fibermask_bits()
trace_crude()
trace_fweight()
trace320cen()
REVISION HISTORY:
13-Sep-1999 Written by David Schlegel, Princeton.
8-Jul-2001 Added djs_maskinterp call
(See pro/spec2d/trace320crude.pro)
NAME:
trace_fix
PURPOSE:
Fix a set of trace centers by replacing traces that converge.
CALLING SEQUENCE:
xnew = trace_fix( xcen, [minsep= , ngrow=, ycen=, xerr=])
INPUTS:
xcen - X centers for all traces [ny,nTrace]
OPTIONAL INPUTS:
minsep - Minimum separation between adjacent traces. Smaller
separations are regarded as bad traces. Default to 5.5.
ngrow - Replace all pixels within MINSEP of its adjacent trace,
plus NGROW of its neighboring pixels. Default to 20.
ycen - Y centers corresponding to XCEN.
xerr - X errors corresponding to XCEN.
OUTPUTS:
xnew - Modified XCEN; traces may be removed or shifted.
ycen - Modified YCEN; columns may be removed.
xerr - Modified XERR; columns may be removed.
COMMENTS:
EXAMPLES:
PROCEDURES CALLED:
INTERNAL PROCEDURES:
remove_column
REVISION HISTORY:
13-Aug-1999 Written by David Schlegel, Princeton.
(See pro/spec2d/trace_fix.pro)
NAME: tweaktrace PURPOSE: Use fitans to tweak trace and sigma This just perturbs the input values of xcen and sigma CALLING SEQUENCE: tweaktrace, x, sigma, centershift, sigmashift, maxshift=maxshift INPUTS: x - the input trace positions sigma - the input sigma widths of profiles centershift - the pixel shift in x sigmashift - the fractional change of sigma OPTIONAL KEYWORDS: maxshift - the absolute allowed shift in x (default = 1.0) OUTPUTS: OPTIONAL OUTPUTS: COMMENTS: EXAMPLES: PROCEDURES CALLED: REVISION HISTORY: 19-Oct-1999 Written by S. Burles, Chicago
(See pro/spec2d/tweaktrace.pro)
NAME:
update_platelist
PURPOSE:
Update the plate list file found in this idlspec2d product.
CALLING SEQUENCE:
update_platelist, [ outfile ]
INPUTS:
outfile - Name of output file; default to 'spPlateList.par' in the
current directory.
OPTIONAL KEYWORDS:
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
The file in $IDLSPEC2D_DIR/etc/spPlateList.par is read, and we
merge in the list of plates returned by the PLATELIST procedure.
Manual comments from the first file are retained.
EXAMPLES:
BUGS:
DATA FILES:
$IDLSPEC2D_DIR/etc/spPlateList.par
PROCEDURES CALLED:
copy_struct_inx
platelist
yanny_read
yanny_write
REVISION HISTORY:
04-Jun-2002 Written by D. Schlegel, Princeton (checked in later)
(See pro/plan/update_platelist.pro)
NAME:
update_plate_release
PURPOSE:
Update the plate list file found in this idlspec2d product
with new data release notes.
CALLING SEQUENCE:
update_plate_release, [ release, rfile, outfile ]
INPUTS:
OPTIONAL INPUTS:
release - Data release name to put into plate list file;
default to 'DR2'
rfile - Yanny param file with PLATEID,MJD,RELEASE columns,
where the release names should appear in the RELEASE entries;
default to "$IDLSPEC2D_DIR/etc/dr2spectro.par",
outfile - Name of output file; default to 'spPlateList.par' in the
current directory.
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
The file in $IDLSPEC2D_DIR/etc/spPlateList.par is read, and we
merge in the list of plates returned by the PLATELIST procedure.
Manual comments from the first file are retained.
EXAMPLES:
BUGS:
DATA FILES:
$IDLSPEC2D_DIR/etc/spPlateList.par
PROCEDURES CALLED:
yanny_readone()
yanny_write
REVISION HISTORY:
04-Feb-2004 Written by D. Schlegel, Princeton
(See pro/plan/update_plate_release.pro)
NAME:
ushift
PURPOSE: (one line)
Shift data using a damped sinc onto slightly non-linear x values
DESCRIPTION:
This function will shift an array of data pointed to by x and
extending for n points. The amount of the shift is given by shift.
The result of the operation is placed at xp. A shift that is within
0.0001 of a whole number is treated to be that of the whole number. If
the shift is by an integral number of pixels then the shift involves
reindexing the data, no interpolation is done. If the shift is some
non-integral amount then the data is resampled using a damped sinc
function.
The sense of the shift is as follows: think of the array plotted on a
fixed scale. A shift of 1 corresponds to shifting the data by one data
point to the right relative to the fixed scale, ie. x[3]=xp[4].
The data will fall off one end or another of the output vector as a
result of the shift. However, this is not as significant as the edge
effect, the convolution is not complete for any data point within 10
points of the edge, so those points cannot be trusted. The missing
points in the convolution are assumed to be equal to the end points.
CATEGORY:
Numerical
CALLING SEQUENCE:
yp = ushift(y, invset, xp)
INPUTS:
y - Input data array to be shifted.
invset - Structure which contains coefficients to map xin to pixels
xin - The x-axis values for the requested yp
OPTIONAL INPUT PARAMETERS:
KEYWORD PARAMETERS:
OUTPUTS:
Return value is the shifted array.
COMMON BLOCKS:
SIDE EFFECTS:
RESTRICTIONS:
The input and output arrays cannot be the same.
PROCEDURE:
MODIFICATION HISTORY:
Adapted from Zodiac routine: shiftc/sshift
Marc W. Buie, Lowell Observatory, 1992 October 2
(See pro/spec2d/ushift.pro)
NAME:
vdispfit
PURPOSE:
Compute velocity dispersions for galaxy spectra.
CALLING SEQUENCE:
vdans = vdispfit(objflux, objivar, [ objloglam, hdr=, zobj=, npoly=, $
eigenfile=, eigendir=, columns=, sigma=, sigerr=, yfit=, $
plottitle=, /doplot, /debug ])
INPUTS:
objflux - Galaxy spectrum (spectra); array of [NPIX,NGALAXY].
objivar - Galaxy inverse variance; array of [NPIX,NGALAXY].
OPTIONAL INPUTS:
objloglam - Log-10 wavelengths; this can be either an NPIX vector
if all the galaxy spectra have the same wavelength mapping,
or an array with the same dimensions as OBJFLUX.
Either OBJLOGLAM or HDR must be specified.
hdr - FITS header from which to read COEFF0, COEFF1 for the
wavelength mapping.
Either OBJLOGLAM or HDR must be specified.
zobj - Redshift for each galaxy; default to 0.
npoly - Number of polynomial terms to append to eigenspectra;
default to 5.
eigenfile - File name for eigenvectors; default to 'spEigenVdisp*.fits'
eigendir - Directory name for EIGENFILE; default to
'$IDLSPEC2D_DIR/templates'
columns - Column numbers of the eigenspectra image to use in the
PCA fit; default to all columns.
plottitle - Title of plot (if /DOPLOT is set).
doplot - If set, then make plots.
debug - If set, then wait for keystroke after plot.
OUTPUTS:
vdans - Output structure [NGALAXY] with the following elements:
vdisp : Velocity dispersion in km/sec.
vdisp_err : Error for VDISP in km/sec.
vdispchi2 : Minimum chi^2
vdispnpix : Number of pixels overlapping the templates
and used in the fits
vdispdof : Degrees of freedom = the number of pixels
overlapping the templates minus the number of
templates minus the number of polynomial terms
minus 1 (the last 1 is for the velocity dispersion)
vdisptheta : Coefficients for each template, where the
first terms are for the stellar templates
followed by those for the polynomial terms
OPTIONAL OUTPUTS:
yfit - Best-fit template (actually, the one with the closest
velocity dispersion to the best-fit sigma); wavelengths
outside of those available with the templates have their
values set to zero [NPIX,NGALAXY]
COMMENTS:
Note that the wavelength spacing in the galaxy and stellar template spectra
must be the same.
We currently mask within +/- 280 km/sec of the following wavelengths
that could have emission lines:
linelist = [3725.94, 3727.24, 3970.072, 4101.73, 4340.46, $
4861.3632, 4958.911, 5006.843, 6300.32, 6548.05, 6562.801, $
6583.45, 6716.44, 6730.82]
The constructed over-sampled and smoothed eigenspectra are stored
in a common block between calls if the eigen-vector file is the same.
EXAMPLES:
BUGS:
DATA FILES:
$IDLSPEC2D_DIR/templates/spEigenVdisp*.fits
PROCEDURES CALLED:
airtovac
combine1fiber
computechi2()
djs_filepath()
find_nminima
mrdfits()
poly_array()
splog
sxpar()
INTERNAL SUPPORT ROUTINES:
create_vdans()
vdisp_gconv()
REVISION HISTORY:
13-Mar-2001 Written by D. Schlegel, Princeton
(See pro/spec1d/vdispfit.pro)
NAME:
veldisp
PURPOSE:
Fit a series of galaxy spectrum with a single stellar template.
For each object, this procedure will first find the best redshift
between object and template. The correlation function is formed
in fitredshift, and the best redshift and width of the correlation
peak is calculated (along with error estimates). Next perform chi2
fitting with fourier_difference and fourier_quotient methods
CALLING SEQUENCE:
veldisp, objflux, objivar, starflux, starivar, result, $
klo_cut=, khi_cut=, maxsig=, sigmastep=, zoffset= ]
INPUTS:
objflux - Array of object spectra [NPIX] or [NPIX,NOBJ]
objivar - Array of object inverse variance [NPIX] or [NPIX,NOBJ]
starflux - Template spectrum [nstarpix]
starivar - Template inverse variance [nstarpix]
OPTIONAL KEYWORDS:
klo_cut - Low frequency cutoff for cross-correlation peak finding;
default to 1/128.
khi_cut - High frequency cutoff for cross-correlation peak finding;
default to 1/3.
maxsig - Maximum velocity dispersion to search for; default to 2 pix
sigmastep - Steps between each test sigma; default to 0.2 pix
zoffset - ???
OUTPUTS:
result - Structure array with outputs
OPTIONAL OUTPUTS:
COMMENTS:
We assume that objflux and star have the same zeropoint
And that all spectra are binned log-linear in wavelength
If there is a zeropoint difference between objects and star
this needs to be included after veldisp has run.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
bandpassfilter()
djs_maskinterp()
djs_mean()
fft_apodize
fitredshift
fourier_difference()
fourier_quotient()
REVISION HISTORY:
25-Mar-2000 Written by S. Burles, FNAL
29-Mar-2000 Modified by D. Finkbeiner & D. Schlegel, APO
25-Jun-2000 Cleaned up and commented by D. Finkbeiner, APO
(See pro/spec1d/veldisp.pro)
NAME: warn_daytime PURPOSE: Print a warning if an excellent-quality exposure taken with the Sun up. CALLING SEQUENCE: warn_daytime, hdr INPUTS: hdr - FITS header from SDSS spectroscopic exposure OPTIONAL KEYWORDS: OUTPUTS: OPTIONAL OUTPUTS: COMMENTS: The only output from this procedure is to print (using SPLOG) a warning message if an "excellent"-quality exposure for a flat, arc, or science was taken with the Sun above the horizon. This should basically never happen -- those should almost always be test data. EXAMPLES: BUGS: PROCEDURES CALLED: djs_diff_angle() get_tai splog sunpos sxpar() zenpos REVISION HISTORY: 28-Apr-2003 Written by D. Schlegel, Princeton
(See pro/spec2d/warn_daytime.pro)
NAME:
writespec
PURPOSE:
Routine for writing Princeton-1D spectro outputs to an ASCII file
CALLING SEQUENCE:
writespec, plate, fiberid, [ mjd=, filename= ]
INPUTS:
plate - Plate number(s)
fiber - Fiber number(s), 1-indexed
OPTIONAL INPUTS:
mjd - MJD number(s); if not set, then select the most recent
data for this plate (largest MJD).
OUTPUTS:
OPTIONAL OUTPUTS:
mjd - If not specified, then this is returned as an array of one
MJD per object.
filename - Output file name; default to spec-pppp-mmmmm-fff.dat,
where pppp=plate number, mmmmm=MJD, fff=fiber ID.
COMMENTS:
The data are read with READSPEC. See the documentation for that
routine to see how to set environment variables that describe where
the data files are.
EXAMPLES:
Write the spectrum of plate 401, fiber #100, to an ASCII file as follows:
IDL> writespec, 401, 100
The default file name will be "spec-0401-51788-100.dat". This can be
changed by setting the FILENAME keyword:
IDL> writespec, 401, 100, filename='junk.dat'
BUGS:
PROCEDURES CALLED:
readspec
sdss_flagname()
INTERNAL SUPPORT ROUTINES:
REVISION HISTORY:
25-Sep-2000 Written by David Schlegel, Princeton.
(See pro/spec1d/writespec.pro)
NAME:
write_uros
PURPOSE:
Generate ASCII files of individual exposures on spectra for Uros Seljak
CALLING SEQUENCE:
write_uros, plate, [ fiber, ] mjd=
INPUTS:
plate - Plate number(s)
REQUIRED KEYWORDS:
mjd - MJD number(s); if not set, then select the most recent
data for this plate (largest MJD).
OPTIONAL INPUTS:
fiber - Fiber number(s), 1-indexed; if not set, or zero, then
read all fibers for each plate. We assume that there
are exactly 640 fibers.
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
The following file is written for each individual (CCD) spectrum
of each object:
spUros-$PLATE-$MJD-$FIBER-$EXPNUM-$CAMERA.fits
In general, there will be (3 exposures) x (2 cameras) = 6 spectra
for each plate+MJD+fiber combination.
Output the following for each individual spectrum of each object:
log-Wave : Log10(wavelength [Ang])
Flux : Flux in units of flat-fielded electrons
InverseVar : Inverse variance for the above
Sky ; Sky
Pixelmask : Pixel mask
Dispers : Wavelength dispersion in the **native** pixel scale
(e.g., relative to the local wavelength spacing)
Calibfac : Flux-calibration vector for this plate+spectrograph
Invercorr : Flux-correction vector for this exposure relative
to the flux-calibrated (smear) exposure
Flatvec : Flat-field vector, relative to a quartz lamp, combined
with the atmospheric telluric correction (in the red)
Rnois : Read noise in electrons (or photons)
The fluxes have already been divided by the fiber-to-fiber flats
(superfit) and the telluric-correction vector (telluricfactor).
Convert the fluxes back to photon number as follows:
Flux_photons = Flux * Flatvec
Sky_photons = Sky * Flatvec
InverseVar_photons = InverseVar / Flatvec^2
The read noise portion (Rnois) is already in units of electrons,
or equivalently photons.
Before combining multiple spectra, we re-normalize as follows:
Flux_ergs = Flux / (Calibfac * Invercorr)
InverseVar = InverseVar * (Calibfac * Invercorr)^2 * Window
where Window is a linear apodization of the first 100 pixels
of each spectrum (the blue/red overlap region, so the red side
of the blue camera, and the blue side of the red camera).
Once the flux has been normalized, it is in units of 10^(-17) erg/cm/s/Ang
EXAMPLES:
BUGS:
DATA FILES:
$SPECTRO_DATA/$PLATE/spFrame-$CAMERA-$EXPNUM.fits*
$SPECTRO_DATA/$PLATE/spFluxcalib-$PLATE-$MJD-$CAMERA.fits
$SPECTRO_DATA/$PLATE/spFluxcorr-$EXPNUM-$SPECID.fits
$SPECTRO_DATA/$PLATE/spPlate-$PLATE-$MJD.fits
PROCEDURES CALLED:
bspline_valu()
mrdfits()
readspec
sxpar()
traceset2xy
yanny_free
yanny_read()
INTERNAL SUPPORT ROUTINES:
write_uros1
REVISION HISTORY:
14-Jun-2002 Written by David Schlegel, Princeton.
This is based upon the code in SPCOADD_FRAMES.
(See pro/spec2d/write_uros.pro)
NAME:
zcompute
PURPOSE:
Compute relative redshift of object(s) vs. eigen-templates.
CALLING SEQUENCE:
zans = zcompute(objflux, objivar, starflux, [starmask, nfind=, $
poffset=, pspace=, pmin=, pmax=, mindof=, width=, minsep=, $
plottitle=, /doplot, /debug, /verbose ]
INPUTS:
objflux - Object fluxes [NPIXOBJ,NOBJ]
objivar - Object inverse variances [NPIXOBJ,NOBJ]
starflux - Eigen-template fluxes [NPIXSTAR,NTEMPLATE]
OPTIONAL INPUTS:
starmask - Eigen-template mask; 0=bad, 1=good [NPIXSTAR]
nfind - Number of solutions to find per object; default to 1.
poffset - Offset between all objects and templates, in pixels.
A value of 10 indicates that STARFLUX begins ten pixels
after OBJFLUX, i.e. OBJFLUX[i+10] = STARFLUX[i] for the
case when the relative redshift should be zero. If the
wavelength coverage of the templates is larger, then the
value of ZOFFSET will always be negative.
[Scalar or vector of size NOBJ]
pspace - The spacing in redshifts to consider; default to 1 [pixels];
[Scalar or vector of size NOBJ]
pmin - The smallest redshift to consider [pixels].
[Scalar or vector of size NOBJ]
pmax - The largest redshift to consider [pixels].
[Scalar or vector of size NOBJ]
mindof - Minimum number of degrees of freedom for a valid fit;
default to 10.
width - Parameter for FIND_NMINIMA(); default to 3 * PSPACE.
minsep - Parameter for FIND_NMINIMA(); default to the same as WIDTH.
plottitle - Title of plot (if /DOPLOT is set).
doplot - If set, then make plots.
debug - If set, then wait for keystroke after plot.
verbose - If set, then log using SPLOG instead of PRINT.
OUTPUTS:
zans - Output structure [NOBJECT,NFIND] with the following elements:
z : The relative redshift.
z_err : Error in the redshift, based upon the local quadratic
fit to the chi^2 minimum.
chi2 : Fit value for the best (minimum) chi^2
dof : Number of degrees of freedom, equal to the number of
pixels in common between the object and templates
minus the number of templates.
theta : Mixing angles [NTEMPLATE]. These are computed at the
nearest integral redshift, e.g. at ROUND(ZOFFSET).
theta_covar : Covariance matrix for THETA
COMMENTS:
Fits are done to chi^2/DOF, not to chi^2.
EXAMPLES:
BUGS:
DATA FILES:
$IDLSPEC2D_DIR/etc/TEMPLATEFILES
PROCEDURES CALLED:
computechi2()
find_nminima()
splog
INTERNAL SUPPORT ROUTINES:
create_zans()
REVISION HISTORY:
10-Jul-2000 Written by D. Schlegel, Princeton
(See pro/spec1d/zcompute.pro)
NAME:
zcompute_qso
PURPOSE:
Compute relative redshift of object(s) vs. eigen-templates.
CALLING SEQUENCE:
zans = zcompute_qso(objflux, objivar, starset, starflux, [starmask, nfind=, $
poffset=, pspace=, pmin=, pmax=, mindof=, width=, minsep=, $
plottitle=, /doplot, /debug, /verbose ]
INPUTS:
objflux - Object fluxes [NPIXOBJ,NOBJ]
objivar - Object inverse variances [NPIXOBJ,NOBJ]
starset - Eigen-template bspline-set [structure]
starflux - Eigen-template fluxes (polynomials are expected) [NPIXSTAR,NTEMPLATE]
OPTIONAL INPUTS:
starmask - Eigen-template mask; 0=bad, 1=good [NPIXSTAR]
nfind - Number of solutions to find per object; default to 1.
poffset - Offset between all objects and templates, in pixels.
A value of 10 indicates that STARFLUX begins ten pixels
after OBJFLUX, i.e. OBJFLUX[i+10] = STARFLUX[i] for the
case when the relative redshift should be zero. If the
wavelength coverage of the templates is larger, then the
value of ZOFFSET will always be negative.
[Scalar or vector of size NOBJ]
pspace - The spacing in redshifts to consider; default to 1 [pixels];
[Scalar or vector of size NOBJ]
pmin - The smallest redshift to consider [pixels].
[Scalar or vector of size NOBJ]
pmax - The largest redshift to consider [pixels].
[Scalar or vector of size NOBJ]
mindof - Minimum number of degrees of freedom for a valid fit;
default to 10.
width - Parameter for FIND_NMINIMA(); default to 3 * PSPACE.
minsep - Parameter for FIND_NMINIMA(); default to the same as WIDTH.
plottitle - Title of plot (if /DOPLOT is set).
doplot - If set, then make plots.
debug - If set, then wait for keystroke after plot.
verbose - If set, then log using SPLOG instead of PRINT.
OUTPUTS:
zans - Output structure [NOBJECT,NFIND] with the following elements:
z : The relative redshift.
z_err : Error in the redshift, based upon the local quadratic
fit to the chi^2 minimum.
chi2 : Fit value for the best (minimum) chi^2
dof : Number of degrees of freedom, equal to the number of
pixels in common between the object and templates
minus the number of templates.
theta : Mixing angles [NTEMPLATE]. These are computed at the
nearest integral redshift, e.g. at ROUND(ZOFFSET).
COMMENTS:
Fits are done to chi^2/DOF, not to chi^2.
EXAMPLES:
BUGS:
DATA FILES:
$IDLSPEC2D_DIR/etc/TEMPLATEFILES
PROCEDURES CALLED:
computechi2()
find_nminima()
splog
INTERNAL SUPPORT ROUTINES:
create_zans()
REVISION HISTORY:
10-Jul-2000 Written by D. Schlegel, Princeton
(See pro/spec1d/zcompute_qso.pro)
NAME:
zfind
PURPOSE:
Find possible redshift matches for a set of spectra using a set of
eigen-templates.
CALLING SEQUENCE:
result = zfind( objflux, objivar, hdr=hdr, $
[ starflux=, starloglam0=, stardloglam=, $
eigenfile=, eigendir=, columns=, npoly=, $
zmin=, zmax=, zguess=, pwidth=, nfind=, width=, _EXTRA= ]
INPUTS:
objflux - Object fluxes [NPIXOBJ,NOBJ]
objivar - Object inverse variances [NPIXOBJ,NOBJ]
REQUIRED KEYWORDS:
hdr - FITS header for objects, used to construct the wavelengths
from the following keywords: COEFF0, COEFF1.
OPTIONAL KEYWORDS:
starflux - Eigenspectra [NPIXSTAR,NSTAR].
starloglam0- Zero-point of log-10(Angstrom) wavelength mapping of STARFLUX.
stardloglam- Wavelength spacing for STARFLUX in log-10(Angstroms)
eigenfile - Input FITS file with an [NPIXSTAR,NSTAR] image with
either templates or eigenspectra. If a wildcard appears
in the file name, then the file that appears last in a sort
is used.
The header keywords COEFF0, COEFF1 are used to specify
the wavelength mapping in log-10 Angstroms.
This must be set if STARFLUX,STARLOGLAM0 are not set.
eigendir - Directory for EIGENFILE; default to $IDLSPEC2D/templates.
columns - Column numbers of the eigenspectra image to use in the
PCA fit; default to all columns.
npoly - Number of polynomial terms to append to eigenspectra;
default to none.
zmin - Minimum redshift to consider; default to no lower bound.
zmax - Maximum redshift to consider; default to no upper bound.
zguess - Initial guess for redshift; search for a solution about
this value. If specified with PWIDTH, then ZMIN and ZMAX
are ignoreed.
pwidth - Search width in pixels about the intial guess redshift ZGUESS.
If specified with ZGUESS, then ZMIN and ZMAX are ignored.
nfind - Keyword for ZCOMPUTE().
width - Keyword for ZCOMPUTE().
_EXTRA - Keywords for ZCOMPUTE(), such as PSPACE, DOPLOT, DEBUG, VERBOSE
OUTPUTS:
result - Structure with redshift-fit information. Structure
elements are left blank if fewer than NFIND peaks are found.
OPTIONAL OUTPUTS:
COMMENTS:
One can specify a search domain for the redshift with ZMIN and ZMAX, or
with ZGUESS and PWIDTH. If none of those parameters are set, then all
possible redshifts that overlap the object and star (template) are tested.
Mask any pixels on the templates where the first template contains zeros.
This is useful, in particular, where the stellar templates have zeros
at the beginning or end of the spectral range due lack of wavelength
coverage.
EXAMPLES:
BUGS:
PROCEDURES CALLED:
concat_dir()
djs_filepath()
fileandpath()
readfits()
splog
sxpar()
zcompute()
INTERNAL SUPPORT ROUTINES:
sp1d_struct()
REVISION HISTORY:
28-Jun-2000 Written by D. Schlegel, Princeton
(See pro/spec1d/zfind.pro)
NAME: zrefind PURPOSE: Re-fit redshifts from a previous call to ZFIND(), but doing a local fit around the previous answers. CALLING SEQUENCE: result = zrefind( objflux, objivar, pwidth=, pspace=, width=, zold= ] INPUTS: objflux - Object fluxes [NPIXOBJ,NOBJ] objivar - Object inverse variances [NPIXOBJ,NOBJ] REQUIRED KEYWORDS: zold - Z structure from an initial call to ZFIND(). OPTIONAL KEYWORDS: pwidth - Search width in pixels about the intial redshift; default to 5 pspace - Keyword for ZCOMPUTE(). width - Keyword for ZCOMPUTE(). OUTPUTS: result - Structure with redshift-fit information, modified from ZOLD. OPTIONAL OUTPUTS: COMMENTS: EXAMPLES: BUGS: PROCEDURES CALLED: zfind() REVISION HISTORY: 17-Aug-2000 Written by D. Schlegel, Princeton
(See pro/spec1d/zrefind.pro)
NAME: ztweak PURPOSE: Tweak redshifts CALLING SEQUENCE: ztweak, platefile INPUTS: platefile - Plate file from spectro-2D OPTIONAL INPUTS: OUTPUTS: OPTIONAL OUTPUTS: COMMENTS: EXAMPLES: BUGS: DATA FILES: $IDLSPEC2D_DIR/etc/TEMPLATEFILES PROCEDURES CALLED: spec_append struct_addtags() sxpar() veldisp REVISION HISTORY: 19-Jul-2000 Written by D. Schlegel, Princeton
(See pro/spec1d/ztweak.pro)
NAME: ztweak2 PURPOSE: Tweak redshifts CALLING SEQUENCE: ztweak, platefile INPUTS: platefile - Plate file from spectro-2D OPTIONAL INPUTS: OUTPUTS: OPTIONAL OUTPUTS: COMMENTS: EXAMPLES: BUGS: DATA FILES: $IDLSPEC2D_DIR/etc/TEMPLATEFILES PROCEDURES CALLED: spec_append struct_addtags() sxpar() veldisp REVISION HISTORY: 19-Jul-2000 Written by D. Schlegel, Princeton
(See pro/spec1d/ztweak2.pro)
NAME:
ztweak_gal
PURPOSE:
Tweak galaxy redshifts
CALLING SEQUENCE:
ztweak_gal, platefile, [subsamp= ]
INPUTS:
platefile - Plate file from spectro-2D
OPTIONAL INPUTS:
subsamp - ???
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
BUGS:
Make sure we use exactly the same object pixels for eadh test z ???
Convovle the emission lines just like the stars - incl. instrumental
response???
DATA FILES:
$IDLSPEC2D_DIR/etc/TEMPLATEFILES
PROCEDURES CALLED:
spec_append
struct_addtags()
sxpar()
veldisp
REVISION HISTORY:
19-Jul-2000 Written by D. Schlegel, Princeton
(See pro/spec1d/ztweak_gal.pro)
NAME:
ztweak_star
PURPOSE:
Find the best-fit Elodie spectrum to a set of spectra.
CALLING SEQUENCE:
ztweak_star, [ filename, zmin=, zmax=, /overwrite ]
INPUTS:
OPTIONAL INPUTS:
filename - Yanny parameter file with at least the entries PLATE,
MJD, FIBERID, and optionally CZ.
Default to "$IDLSPEC2D_DIR/templates/eigeninput_star.par".
zmin - Minimum redshift to consider; default to -0.00333
(-1000 km/sec).
zmax - Minimum redshift to consider; default to +0.00333
(+1000 km/sec).
overwrite - If set, then overwrite the input file with CZ replaced
with the best-fit value.
OUTPUTS:
OPTIONAL OUTPUTS:
COMMENTS:
EXAMPLES:
BUGS:
No attempt is made to precisely match the instrumental dispersion
of the SDSS spectra and the Elodie spectra. The Elodie spectra are
smoothed to an instrumental dispersion of 70 km/sec.
PROCEDURES CALLED:
elodie_best()
readspec
struct_addtags()
yanny_free
yanny_read
REVISION HISTORY:
03-Apr-2002 Written by D. Schlegel, Princeton
(See pro/spec1d/ztweak_star.pro)