IDL Help for XIDL

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: Fri Jun 11 15:03:24 2004.


List of Cloudy/

List of Color/

List of Cosm/

List of DLA/

List of FIT/

List of FUSE/*/

List of GRB/

List of General/

List of IDLA/

List of IMG/General/

List of IMG/Photometry/

List of IMG/Reduction/

List of Keck/HIRES/

List of Keck/LRIS/*/

List of Lick/Kast/*/

List of Obs/

List of SDSS/*/

List of Spec/Analysis/

List of Spec/Arcs/

List of Spec/Display/

List of Spec/Extraction/

List of Spec/Flux/

List of Spec/General/

List of Spec/Lines/

List of Spec/Rectify/

List of Spec/Slits/

List of Spec/Voigt/

List of lcoovi/


Routine Descriptions

ABSLINSTRCT__DEFINE

[Next Routine] [List of Routines]
 NAME:
 abslinstrct__define
   Version 1.1

 PURPOSE:
  Structure for a simple absorption line. 

 CALLING SEQUENCE:
   tmp = {abslinstrct}

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
  Written by JXP

(See Spec/Lines//abslinstrct__define.pro)


AIRMASS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 airmass
   Version 1.1

 PURPOSE:
    Calculate the airmass for an obj with a given DEC at an
  observatory with a given DEC and an offset in RA

 CALLING SEQUENCE:
  airmass = airmass(obs_dec, obj_dec, [hour_angle])

 INPUTS:
  obs_dec -- DEC of the observatory
  obj_dec -- DEC of the object
  [hour_angle]  -- Offset of RA [default: [-2,-1,0,1,2]]

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  APER=   -- Aperture size (boxcar)
  /BOXCAR -- Do boxcar extraction
  /CHK    -- 
  YMODEL= -- 2D solution from extract_image

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
  print, airmass( 20., 45., [-3, -2, -1, 0])

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   Written by E. Gawiser

(See Obs//airmass.pro)


ARCLINSTRCT__DEFINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 arclinstrct__define
    Version 1.1

 PURPOSE:
    Arc line structure

 CALLING SEQUENCE:
   tmp = {arclinstrct}

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   Written by JXP

(See Spec/Arcs//arclinstrct__define.pro)


CLDY_2PHAS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 cldy_2phas   
   Version 1.1

 PURPOSE:
    Finds the best 2-phase solution for a series of ratio
    constraints

 CALLING SEQUENCE:
   
 cldy_2phas, grid, ratio, sig, ion1, ion2, restrct, NHILMT=, FEHLMT=, /UONLY

 INPUTS:
   grid  - CLOUDY grid
   ratio -  Observed ionic ratios
   sig  -  Error on the ratios
   ion1 - Z, i for ion1  (can be an array of Z,i pairs)
   ion2 - Z, i for ion2  (can be an array of Z,i pairs)

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
   NHILMT - 2-element array giving NHI min,max
   FEHLMT - 2-element array giving FeH min,max
   UONLY  - Value of nH to use

 OPTIONAL OUTPUTS:
   retstrct - Returns a structure of the output

 COMMENTS:

 EXAMPLES:
   cldy_2phas, grid, [0.3], [0.1], [14,4], [14,2], soltn


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   08-Aug-2001 Written by JXP

(See Cloudy//cldy_2phas.pro)


CLDY_ALLFN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 cldy_allfn
   Version 1.1

 PURPOSE:
    Plots [X/Fe+], [X/H0] vs. Elem for a range of the grid

 CALLING SEQUENCE:
   
 cldy_allfn, grid, obsi, val, ions

 INPUTS:
   grid  -- CLOUDY grid
   obsi  -- Observed pair of ions
   val   -- Ratio of observed ions
   ions  -- Array of [Z,ion] vectors to plot
   fN_in -- Fraction of the ratio contributed by entirely ionzed gas

 RETURNS:
   

 OUTPUTS:
   Creates a Plot

 OPTIONAL OUTPUTS:

 OPTIONAL KEYWORDS:
   NHI   
   FeH
   nH

 COMMENTS:

 EXAMPLES:
   cldy_allfn, grid, [ [26,3], [26,2] ], -0.5,  [[14,2], [13,2]]

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   04-Dec-2001 Written by JXP

(See Cloudy//cldy_allfn.pro)


CLDY_CALCNCOLL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 cldy_calcncoll
  V1.1

 PURPOSE:
    Parses a standard binary fits file into the CLOUDY struct

 CALLING SEQUENCE:
   
  cldy_calcncoll, temp, ions, colms, NHI=, MTL=

 INPUTS:
   temp -- Temperature of the gas
   ions -- Ions to calculate columns for [[Z,i]]

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  NHI - N(HI) value  [default = 15]
  MTL - Metallicity value  [default = 0. (solar)]
  INFIL - Name of fits file containing Cloudy output of 
      collsional ionization calculation (e.g. cloudy_collisions.fits)

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
 cldy_calcncoll, 1e5, [[14,2], [8,6]], colms, NHI=14.8

 PROCEDURES CALLED:
  prs_cldycoll
  printcol

 REVISION HISTORY:
   04-Feb-2004 Written by JXP

(See Cloudy//cldy_calcncoll.pro)


CLDY_CALCTCOLL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 cldy_calctcoll
  V1.1

 PURPOSE:
    Given a pair of ions and the ratio between those ions, calculate
   the temperature for ag as with temperature T that gives that ratio
 CALLING SEQUENCE:
   
   cldy_calctcoll, ion1, ion2, rtio, tans, INFIL=, /PLOT

 INPUTS:
   ion1 -- [Z,i]
   ion2 -- [Z,i]
   rtio -- Ratio between ion1 and ion2
   tans -- Temperature which gives that ratio

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  OFFS - 'Error' in rtio to determine temperature range [default: 1.]
  PLOT - Create a plot

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
 cldy_calctcoll, [7,5], [8,6], -0.9, tans, /plot

 PROCEDURES CALLED:
  getabnd
  prs_cldycoll

 REVISION HISTORY:
   04-Feb-2004 Written by JXP

(See Cloudy//cldy_calctcoll.pro)


CLDY_CALCU

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 cldy_calcu
   Version 1.0

 PURPOSE:
    Calculate the ionization parameter 'U' for a given redshift
    an dnH value assuming the Haardt & Madau spectrum

 CALLING SEQUENCE:
  cldy_calcu, hm_fil, z, nH, logU, NRM=nrm

 INPUTS:
   hm_fil - Haardt & Madau file of fluxes 
   z - Redshif
   nH - Hydrogen volume density
   [NRM] - Normalization factor for H&M data  [default: 1e-23]

 RETURNS:
   
 OUTPUTS:

 OPTIONAL OUTPUTS:
  logU -- The log of the ionization parameter

 COMMENTS:

 EXAMPLES:
   cldy_calcu, hm_fil, z, nH, logU, NRM=

 PROCEDURES/FUNCTIONS CALLED:
  readcol

 REVISION HISTORY:
   02-Nov-2003 Written by JXP

(See Cloudy//cldy_calcu.pro)


CLDY_CUBA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 cldy_cuba
   Version 1.1

 PURPOSE:
   Creates a Cloudy input file from a CUBA output file given a
    redshift 

 CALLING SEQUENCE:
   
   cldy_cuba, fil, z, outfil, FIXG=fixg

 INPUTS:
   fil  - CUBA output file
   z    - Redshift

 RETURNS:

 OUTPUTS:
   outfil  - Cloudy output file

 OPTIONAL INPUTS:
  /FIXG -- I do not remember what this is for!

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
 cldy_cuba, '/u/xavier/Cloudy/Spec/Data/CUBA/Q1G0/bkgthick.out',
 0.35, '/u/xavier/Cloudy/Spec/Output/q1g0_z035.spec'


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   06-Nov-2003 Written by JXP

(See Cloudy//cldy_cuba.pro)


CLDY_PLT2PHS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 cldy_plt2phs
   Version 1.1

 PURPOSE:
  Plots a 2 phase solution (one purely neutral) given a Cloudy
  grid and related values.  The user also inputs a pair of ions and
  a ratio between them.
    

 CALLING SEQUENCE:
   
 cldy_plt2phs, grid, NHI, FeH, nH, obsi, val, ions

 INPUTS:
   grid  - CLOUDY grid
   NHI   - N(HI) value
   FeH   - Metallicity of the gas
   nH    - Hydrogen volume density
   obsi  - Observed pair of ions
   val   - Ratio of observed ions
   ions  - Array of [Z,ion] vectors to plot
   [YMNX=] - Y limits of the plot

 RETURNS:
   

 OUTPUTS:
   Creates a Plot

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   cldy_plt2phs, grid, 19.0d, -1.0d, -1.0d, [ [26,3], [26,2] ], -0.5,
   [[14,2], [14,3]]


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   15-Nov-2001 Written by JXP

(See Cloudy//cldy_plt2phs.pro)


CLDY_QCK2

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 cldy_qck2
   Version 1.0

 PURPOSE:
   Calculates a quick 2-phase model given a set of ions
   and the ratio of these ions (and the error in the ratio)
   and finally the two elements in the Cloudy grid which
   are to give the input ratios.

 CALLING SEQUENCE:
   
 cldy_qck2, grid, ratio, sig, ion1, ion2

 INPUTS:
   grid  - CLOUDY grid
   ratio -  Observed ionic ratios (array)
   sig  -  Error on the ratios
   ion1 - Z, i for ion1
   ion2 - Z, i for ion2 
   model - Two element array of the Cloudy grid

 RETURNS:
   

 OUTPUTS:

 OPTIONAL KEYWORDS:
   NHILMT - 2-element array giving NHI min,max
   FEHLMT - 2-element array giving FeH min,max

 OPTIONAL OUTPUTS:
  CHISQ - chisq

 COMMENTS:

 EXAMPLES:
   cldy_qck2, grid, [0.4], [0.1], [ 14,3 ], [14,2], model


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   13-Nov-2001 Written by JXP

(See Cloudy//cldy_qck2.pro)


CLDY_UPLOT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 cldy_uplot
   Version 1.0

 PURPOSE:
    Creates a 'Uplot' for given NHI, FeH, nH values after inputting
   a Cloudy grid and a set of ions.

 CALLING SEQUENCE:
   
 cldy_uplot, grid, NHI, FeH, nH, ions

 INPUTS:
   grid - Cloudy grid
   NHI  - HI column densities [Can be an array of values]
   FeH  - Metallicity of the gas [must match grid value]
   nH   - Volume density of the gas [must match grid value]
   ions  - Array of [Z,ion] vectors
   YMNX= - Y values of the plot
   INFIL= - Ps file to create (instead of plotting to screen)

 RETURNS:
   
 OUTPUTS:
   Creates a Plot

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   cldy_Uplot, grid, 19.0d, -1.0d, -1.0d, [[14,2], [14,3]]


 PROCEDURES/FUNCTIONS CALLED:
 getcolor
 xcolors
 getabnd

 REVISION HISTORY:
   15-Nov-2001 Written by JXP

(See Cloudy//cldy_uplot.pro)


COSM_COMMON

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 cosm_common

 PURPOSE:
    Routine to set initialize and set values in the Cosmology common
    block named 'cosmolgy_cmmn'
      or VICE VERSA

 CALLING SEQUENCE:
   
   cosm_common

 INPUTS:
   H0 =   Hubbles constant in km/s/Mpc
   Omegavac = Lambda value   [Default: 0.7]
   OmegaDM = Omega for Dark Matter  [Default: 0.3]

 RETURNS:

 OUTPUTS:
   
 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES CALLED:

 REVISION HISTORY:
   22-Nov-2003 Written by JXP

(See Cosm//cosm_common.pro)


COSM_DIST

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 cosm_dist

 PURPOSE:
  Calculate the cosmological distance (Mpc) given a 
     cosmology and redshift   

 CALLING SEQUENCE:
    dist = cosm_dist(z)

 INPUTS:
   z -  Redshift
   [cosomlogy] -  By default the cosmology is set prior to 
     calling this using cosm_common.  You can have this done by
     keying 

 RETURNS:
   dist  -- Distance in Mpc

 OUTPUTS:

 OPTIONAL KEYWORDS:
  H0=    -- Hubble constant (km/s/Mpc)
  /INIT  -- Initializes the cosmology to the default values

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   
   dist = cosm_dist(2., /INIT)

 PROCEDURES CALLED:
   x_constants
   cosm_common
   cosm_intdist
   qromb

 REVISION HISTORY:
   22-Nov-2003 Written by JXP

(See Cosm//cosm_dist.pro)


COSM_HUBBLE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 cosm_hubble

 PURPOSE:
   Calculates Hubbles constant at arbitrary redshift

 CALLING SEQUENCE:
   

 INPUTS:
   z  -- Redshift

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /INIT  -- Initializes the cosmology to the default values

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   hubb = cosm_hubble(2., /INIT)
   

 PROCEDURES CALLED:
   cosm_common

 REVISION HISTORY:
   22-Nov-2003 Written by JXP

(See Cosm//cosm_hubble.pro)


COSM_XZ

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 cosm_xz

 PURPOSE:
    Calculate the cosmological distance X from z=0 to z=z

 CALLING SEQUENCE:
   

 INPUTS:
   z -- Redshift

 RETURNS:
   x -- Cosmological pathlength

 OUTPUTS:

 OPTIONAL KEYWORDS:
   H0 -- Hubbles constant (km/s/Mpc)
   OM -- Omega Dark Matter
   OV -- Lambda

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   

 PROCEDURES CALLED:
  cosm_common
  cosm_intxz
  qromb

 REVISION HISTORY:
   11-March-2004 Written by JXP

(See Cosm//cosm_xz.pro)


DBLSOBJSTRCT__DEFINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 dblsobjstrct__define
   Version 1.1

 PURPOSE:
  This routine creates a structure to describe the spectrum for an
  object in a given slit

 CALLING SEQUENCE:
   tmp = {dlbsobjstrct}

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
  Written by JXP

(See Spec/Slits//dblsobjstrct__define.pro)


DISTRUCT__DEFINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 distruct__define
    Version 1.1

 PURPOSE:
    Defines the structure for direct imaging

 CALLING SEQUENCE:
  tmp = {distruct}

 INPUTS:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   ??-2001 Written by JXP

(See IMG/General//distruct__define.pro)


DLA_ANALYSE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 dla_analyse
  V1.1

 PURPOSE:
    Launches a GUI which enables simple plotting and inspection of
     individual DLA
 CALLING SEQUENCE:
   dla_analyse, [list]

 INPUTS:
   [list] -- List of DLA to inspect  
       [default: /u/xavier/DLA/Lists/tot_dla.lst]

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   dla_analyse, '/u/xavier/DLA/Lists/tot_dla.lst'

 PROCEDURES CALLED:

 REVISION HISTORY:
   10-Jun-2002 Written by JXP

(See DLA//dla_analyse.pro)


DLA_EPLOT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 dla_eplot   
   Version 1.1

 PURPOSE:
    Given an abundance file and NHI value, create a abundance
   number plot (logarithmic with H = 12)

 CALLING SEQUENCE:
   
   dla_eplot, fil, NHI, ZMTL=, PSFILE=, XR=, YR=

 INPUTS:
   fil -- Abundance file, [format: Zatm, Ncolm, Nsig, Flag, Instr]
   NHI -- NHI value of the DLA

 RETURNS:

 OUTPUTS:
   If PSFILE is set, will create a ps file instead of 
       plotting to the screen

 OPTIONAL KEYWORDS:
  ZMTL -- Metallicity of the gas (for overplotting Solar pattern)
  XR   -- X range of the plot  [default: min and max of Zatm values]
  YR   -- Y range of the plot  [default: [4., 12] ]

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   dla_eplot, fil, 20.8, ZMTL=-1.2


 PROCEDURES/FUNCTIONS CALLED:
  readcol

 REVISION HISTORY:
   17-Feb-2004 Written by JXP

(See DLA//dla_eplot.pro)


DLA_ESITOSDSS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 dla_esitosdss   
   Version 1.0

 PURPOSE:
    Turn an ESI spectrum into SDSS 'quality' (i.e. resolution)

 CALLING SEQUENCE:
   
   dla_esitosdss, fil, wave, fx, sig

 INPUTS:
   fil  -- ESI fits file  [assumes binning of 1]

 RETURNS:

 OUTPUTS:
   wave -- Wavelength array

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   dla_esitosdss, fil, NHI, Z


 PROCEDURES/FUNCTIONS CALLED:
 REVISION HISTORY:
   09-Dec-2002 Written by JXP

(See DLA//dla_esitosdss.pro)


DLA_FILLMTL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 dla_fillmtl
  V1.1

 PURPOSE:
    Sets the metallicity for a DLA depending on whether there is an
    alpha, Zn, and/or Fe measurement.  [Obsolete!]

 CALLING SEQUENCE:
   
   dla_fillmtl, dla, OFF=off

 INPUTS:
   dla      - IDL DLA structure 

 RETURNS:

 OUTPUTS:
   dla      - IDL structure with TAG 'mtl' updated

 OPTIONAL KEYWORDS:
   OFF - Offset for Fe to metallicity [default: +0.4]

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:


 PROCEDURES CALLED:

 REVISION HISTORY:
   02-Jan-2003 Written by JXP

(See DLA//dla_fillmtl.pro)


DLA_FNDTRAN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 dla_fndtran   
   Version 1.1

 PURPOSE:
    Given a DLA structure, calculates the rest EW of weak, rare
    transitions like OI 1355, BII, etc.

 CALLING SEQUENCE:
   dla_fndtran, dla, [fil], OUTFIL=, LMT=

 INPUTS:
   dla --  IDL DLA structure
   [fil] -- List of weak line transitions [default:
            '/u/xavier/DLA/Abund/weak_lin.dat']

 RETURNS:

 OUTPUTS:
   OUTFIL= -- Writes the values to OUTFIL [default: 'fort.23']

 OPTIONAL KEYWORDS:
   LMT= -- Minimum EW to print the transition [default: 0.5 mA]

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   dla_fndtran, dla, outfil='weak_lin.dat'

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   09-Dec-2002 Written by JXP

(See DLA//dla_fndtran.pro)


DLA_GUESSEW

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 dla_guessew   
   Version 1.1

 PURPOSE:
    Calcualtes the EW limits for a series of input transitions for a
    DLA with given NHI and metallicity Z.

 CALLING SEQUENCE:
   dla_guessew, fil, NHI, Z, NPIX=, SNR=, NSIG=, DWV=

 INPUTS:
  fil -- File with list of wavlengths
  NHI -- N(HI) value of the DLA (logarithmic)
  Z   -- Metallcitiy  (logarithmic)

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  NPIX=  -- Number of pixels making up the feature [default: 4]
  NSIG=  -- Number of sigma significant [default: 3.]
  SNR=   -- Signal-to-noise per pixel [default: 10.]
  DWV=   -- Width of pixel in Angstromgs [default: 0.1 Ang]

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_guessew, fil, NHI, Z


 PROCEDURES/FUNCTIONS CALLED:
 REVISION HISTORY:
   14-Nov-2002 Written by JXP

(See DLA//dla_guessew.pro)


DLA_INDX

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 dla_indx
  V1.0

 PURPOSE:
    Returns the index for a DLA given the name and z (if necessary)
     Defaults to the first entry if multiple.  This is a simple and
     rather uninteresting program.

 CALLING SEQUENCE:
   
   idx = dla_indx(struct, name, [z]) 

 INPUTS:
   struct - dla structure
   name - Name of the quasar (string; need not be complete)
   [z] - redshift (optional)

 RETURNS:
   index

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   idx = dla_indx(sdla, 'Q0000')


 PROCEDURES CALLED:

 REVISION HISTORY:
   24-Nov-2001 Written by JXP

(See DLA//dla_indx.pro)


DLA_SDSSRICH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 dla_sdssrich   
   Version 1.0

 PURPOSE:
    Inputs a list of absorption lines, and the quasar emission
  redshift and then prints all probably DLA (quality > 0.7)

 CALLING SEQUENCE:
   
   dla_sdssrich, zem, obslin

 INPUTS:
  zem -- Emission redshift of the quasar
  obslin -- List of observed lines

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
 
 GRAN= -- List of metal-line transitions to key on

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   dla_sdssrich


 PROCEDURES/FUNCTIONS CALLED:
 REVISION HISTORY:
   09-Dec-2002 Written by JXP

(See SDSS/DLA//dla_sdssrich.pro)


DLA_SI2STAR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 dla_si2star   
   Version 1.1

 PURPOSE:
    Given a normalized QSO spectrum (fits file) and the redshift of
    the DLA, overplots a SiII* feature at the expected spot based on
    the observed CII* profile.  THe program also plots the 
    CII* profile

 CALLING SEQUENCE:
   
  dla_si2star, fits_fil, zabs, VMNX=, PSFIL=, YMNX=, RTIO=

 INPUTS:
  fits_fil -- FITS file containing the QSO data [Assumes HIRES
              format]
  zabs  -- Absorption redshift

 RETURNS:

 OUTPUTS:
   PSFIL=  -- Writes PS file 

 OPTIONAL KEYWORDS:
  RTIO= -- Ratio of optical depth of SiII* to CII* [deafult: 0.05]
  VMNX= -- Velcoity region to plot [default: -100 to 100 km/s]
  YMNX= -- Ymin, ymax of plot [deafult: 0., 1.]

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   dla_si2star, 'Q1331_f.fits', 1.770


 PROCEDURES/FUNCTIONS CALLED:
 REVISION HISTORY:
   29-May-2003 Written by JXP

(See DLA//dla_si2star.pro)


ECHFSPECSTRCT__DEFINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 echfspecstrct__define
   Version 1.1

 PURPOSE:
  Creates a structure for echelle spectroscopy that will hold the
  wavelength, flux and error arrays.  Also includes the ZANS
  structure which is useful for using SDSS redshift identification.
 

 CALLING SEQUENCE:
   tmp = {echfspecstrct}

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   Written by JXP

(See Spec/Analysis//echfspecstrct__define.pro)


EMISSSTRCT__DEFINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 emissstrct__define
   Version 1.1

 PURPOSE:
  Structure for a simple emission line. 

 CALLING SEQUENCE:
   tmp = {emissstrct}

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
  Written by JXP

(See Spec/Lines//emissstrct__define.pro)


EXTRCTSTRCT__DEFINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 extrctstrct__define
    Version 1.1

 PURPOSE:
  Define the extraction structure

 CALLING SEQUENCE:
   tmp = {extrctstrct}

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
   
 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   Written by JXP

(See Spec/General//extrctstrct__define.pro)


F2DPOLY

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 f2dpoly
   Version 1.1

 PURPOSE:
    Creates basis functions of a 2dpoly for feeding into SVDFIT for
    2D surface fitting. Requires an initial call with m=-1 to set 
    up the common block.  This code even makes my head spin!

 CALLING SEQUENCE:
   
   fpoly = f2dpoly(s, m, XVAL=, YVAL=, FLG=)

 INPUTS:
   s          - scalar or vector identifying the index number
   m          - Total order (nx*ny) of the polynomial (-1 to
                initialize; -2 to deconstruct)

 RETURNS:
   fpoly      - Basis functions

 OUTPUTS:

 OPTIONAL KEYWORDS:
  XVAL=  -- Dummy array used to initialize the common block
  YVAL=  -- Dummy array used to initialize the common block
  FLG=  -- Number of coefficients in the X direction.   
           If FLG=0, then it is assumed that nx=ny=sqrt(m)

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   fpoly = f2dpoly(s, m)


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   31-Jan-2002 Written by JXP

(See FIT//f2dpoly.pro)


FILL_ELMXH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 fill_elmxh   
   Version 1.1

 PURPOSE:
  Given a DLA structure, fills up the X/H info.  Simply reads in the
  info from the .XH files.  This program is not likely to be called
  by any program except parse_dlalst.

 CALLING SEQUENCE:
   
  fill_elmxh, dla

 INPUTS:
  dla  -- IDL DLA structure

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:


 PROCEDURES/FUNCTIONS CALLED:
 REVISION HISTORY:
   29-May-2003 Written by JXP

(See DLA//fill_elmxh.pro)


FILL_ION

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 fill_ion
  V1.1

 PURPOSE:
    Fills up the column densities for all of the ions observed for a
    given DLA.  This program is unlikely to be called by anything
    except parse_dlalst.

 CALLING SEQUENCE:
   
   fill_ion, sDLA

 INPUTS:

 RETURNS:
   sDLA      - IDL DLA structure

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   fill_ion, sdla


 PROCEDURES CALLED:

 REVISION HISTORY:
   12-Nov-2001 Written by JXP

(See DLA//fill_ion.pro)


FIT2DSTRCT__DEFINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 fit2dstrct__define
   Version 1.1

 PURPOSE:
    IDL structure for 2D surface fitting

 CALLING SEQUENCE:
   
   tmp = {fit2dstrct}

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   tmp = {fit2dstrct}


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   31-Jan-2002 Written by JXP

(See FIT//fit2dstrct__define.pro)


FITS2ASC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 fits2asc

 PURPOSE:
    Converts fits spectrum to ASCII.   The wavelength array is 
    read from the header.  Particularly useful for VPFIT

 CALLING SEQUENCE:
   
   fits2asc, file, [error], OUTFIL=

 INPUTS:
   file    - Data Filename [spectrum; data in extension 0]
   [error] - Error filename

 RETURNS:

 OUTPUTS:
   outfil  - ASCII file with wavelength, file, [error] in columns

 OPTIONAL KEYWORDS:
  WVMIN -- Minimum wavelength to print out [default: 0.]
  WVMAX -- Maximum wavelength to print out [default: 1e6]

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   fits2asc, 'Blah.fits'

 PROCEDURES CALLED:
  x_fitswave
  writecol

 REVISION HISTORY:
   27-Aug-2001 Written by JXP

(See General//fits2asc.pro)


FITSTRCT__DEFINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 fitstrct__define
   Version 1.1

 PURPOSE:
    IDL structure for 1D fitting

 CALLING SEQUENCE:
   
   tmp = {fitstrct}

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   tmp = {fitstrct}


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   31-Jan-2002 Written by JXP

(See FIT//fitstrct__define.pro)


FIT_CONVXPTOX

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 fit_convxptox
    Version 1.1

 PURPOSE:
    Convert the fitted coefficients of a POLY fit from the normalized
    values to 'sensible' ones.

 CALLING SEQUENCE:
   newcoeff = fit_convxptox( calib, FFIT=, NRM= )

 INPUTS:
  calib -- FIT structure

 RETURNS:
  newcoeff -- Unnormalized coefficients

 OUTPUTS:

 OPTIONAL KEYWORDS:
  FFIT= -- Coefficients [default: *calib.ffit]
  NRM=  -- Normalization values [default: calib.nrm]

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   02-Aug-2002 Written by JXP

(See FIT//fit_convxptox.pro)


FUSE_CALCION

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 fuse_calcion
  V1.1

 PURPOSE:
   For FUSE observations, calculate ionic column densities for all
   ions in the FUSE structure.  The code allows for limits and does a
   weighted mean for multiple transitions.

 CALLING SEQUENCE:
   fuse_calcion, strct_fil, zabs, ion_fil, NHI=, HAND=

 INPUTS:
   strct_fil -- FITS file for the FUSE structure
   zabs -- Absorption redshift of the system

 RETURNS:

 OUTPUTS:
   ion_fil -- Output ion file

 OPTIONAL KEYWORDS:
  NHI=  -- NHI value and error [required at present!]
  HAND= -- Input file of ionic column densities used to override the
           values that would otherwise be derived by this program.

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   fuse_calcion, strct_fil, zabs, 'PKS0405_z495.ion'

 PROCEDURES CALLED:
  getabnd
  getion

 REVISION HISTORY:
   11-Sep-2003 Written by JXP

(See FUSE/Analysis//fuse_calcion.pro)


FUSE_CALCXH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 fuse_calcxh
  V1.1

 PURPOSE:
    Calculate X/H values for FUSE observations.  It grabs the info
    from the ion_fil and an input XH_fil and then outputs the XH
    values into a XH data file.  The Input file must contain
    ionization information (Cloudy file, U values) to do the final
    calcalculations of X/H.  You need to see an example file to get
    this set correctly.

 CALLING SEQUENCE:
   fuse_calcxh, xhfil

 INPUTS:
  xhfil -- Input file to run the XH calculations and output

 RETURNS:

 OUTPUTS:
  outfil -- Output file of X/H values

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   fuse_calcxh, 'Input/z0495_XH.inp'

 PROCEDURES CALLED:
  fuse_calcxh_parse

 REVISION HISTORY:
   21-Nov-2003 Written by JXP

(See FUSE/Analysis//fuse_calcxh.pro)


FUSE_COG

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 fuse_cog
  V1.1

 PURPOSE:
    Given a list of DLA base files, fill up the structure ;
 CALLING SEQUENCE:
   
  fuse_cog, strct_fil, cog_fil, [Nlmt, blmt], /CHICHK, PLTONLY=
    NSTP=, BSTP=, PSFILE=, OUTFIL=, /EXACT, ZLBL=

 INPUTS:
  strct_fil -- FITS file for the FUSE structure
  cog_fil -- COG input file (lists redshift and transitions to use)
  [Nlmt] -- Range of column densities to explore (2 element array)
  [blmt] -- Range of Doppler parameters to explore (2 element array)

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /CHICHK -- Plot Chi^2 image
  PLTONLY --  4-element array of N,b values and error for a plot
  NSTP -- Number of steps to search N space [default: 100L]
  BSTP -- Number of steps to search b space [default: 100L]
  /EXACT -- Calculate EW exactly (Spline is generally good enough)
  ZLBL= -- Label for Plot giving redshift of the absorber (string)

 OPTIONAL OUTPUTS:
   OUTFIL -- File with best fit values and error
   PSFILE -- File for postscript plot

 COMMENTS:

 EXAMPLES:
  fuse_cog, '/u/xavier/FUSE/data/PKS0405-12/Analysis/pks0405_abslin.fits', $
    '/u/xavier/FUSE/data/PKS0405-12/Analysis/COG/Input/pks0405_z0918.cog', $
    PSFIL='Figures/z0918_cog.ps', PLTONLY=[14.52, 38.2, 0.04, 1.8]

 PROCEDURES CALLED:

 REVISION HISTORY:
   11-Sep-2003 Written by JXP

(See FUSE/Analysis//fuse_cog.pro)


FUSE_FNDNEVIII

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 fuse_fndneviii
    Version 1.1

 PURPOSE:
   GUI which plots the metal line systems including NeVIII

 CALLING SEQUENCE:
   
   fuse_fndneviii, yin, lyalist, VMNX=, INFLG=, VMNX=, XSIZE=,
   YSIZE=, SVSTATE=, INIZ=

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
   VMNX   -- Velocity range for plotting transitions
   INFLG  -- Flag for type of spectrum file (see x_readspec)
   XSIZE  -- Size of gui x-pixels [default: 80% of screen] 
   YSIZE  -- Size of gui y-pixels [default: 80% of screen]
   INIZ   -- Initial redshift to start search at [default: 0.]

 OPTIONAL OUTPUTS:
  SVSTATE  -- Save the state to return to search later

 COMMENTS:

 EXAMPLES:
   fuse_fndneviii, 'file.fits', inflg=4, SVSTATE='save_neviii.idl'


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   29-Oct-2002 Written by JXP

(See FUSE/Analysis//fuse_fndneviii.pro)


FUSE_FNDOVI

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 fuse_fndovi
    Version 1.1

 PURPOSE:
   GUI which plots the spectra in two strips corresponding to the
   doublet of OVI.  User can indicate the regions where OVI
   could be detected (visually).

 CALLING SEQUENCE:
   
   fuse_fndovi, datfil, XSIZE=, YSIZE=, /STIS, OUTFIL=, GZFIL=

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  XSIZE  -- Size of gui x-pixels [default: 80% of screen] 
  YSIZE  -- Size of gui y-pixels [default: 80% of screen]
  /STIS  -- STIS data file (as opposed to FUSE)
  GZFIL  -- File containing saved regions

 OPTIONAL OUTPUTS:
  SVSTATE  -- Save the state to return to search later
  OUTFIL   -- File to contain saved regions 
              [default: 'find_ovi.fits']

 COMMENTS:

 EXAMPLES:
   fuse_fndovi, 'PKS0405.fits'

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   09-Feb-2004 Written by JXP

(See FUSE/Analysis//fuse_fndovi.pro)


FUSE_GZNEVIII

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 fuse_gzneviii
    Version 1.1

 PURPOSE:
   GUI which plots the spectra in two strips corresponding to the
   doublet of OVI.  User can indicate the regions where OVI
   could be detected (visually).

 CALLING SEQUENCE:
   
   fuse_gzneviii, datfil, XSIZE=, YSIZE=, OUTFIL=, GZFIL=

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  XSIZE  -- Size of gui x-pixels [default: 80% of screen] 
  YSIZE  -- Size of gui y-pixels [default: 80% of screen]
  GZFIL  -- File containing saved regions

 OPTIONAL OUTPUTS:
  SVSTATE  -- Save the state to return to search later
  OUTFIL   -- File to contain saved regions 
              [default: 'find_neviii.fits']

 COMMENTS:

 EXAMPLES:
   fuse_gzneviii, x, maskid, expsr


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   05-Oct-2003 Written by JXP

(See FUSE/Analysis//fuse_gzneviii.pro)


FUSE_H2LIN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 fuse_h2lin
  (V1.1)

 PURPOSE:
    Sets up a line list of Molecular Hydrogen

 CALLING SEQUENCE:
   
   h2strct = fuse_h2lin([file]) 

 INPUTS:
   [file] - H2 line list [default: $XIDL_DIR/FUSE/H2/h2sort.dat]

 RETURNS:
   h2strct - Structure of molecular hydrogen

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   h2strct = fuse_h2lin()

 PROCEDURES CALLED:

 REVISION HISTORY:
   09-Feb-2004 Written by JXP

(See FUSE/H2//fuse_h2lin.pro)


FUSE_TWOCOG

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 fuse_twocog
  V1.1

 PURPOSE:
    Perform a COG analysis allowing for two components.  This program
    is best used to plot (use PLTONLY) the results of 
    a two component analysis, not
    to fit for the 2 components.
 CALLING SEQUENCE:
   
  fuse_twocog, strct_fil, cog_fil, N1lmt, b1lmt, N2lmt, b2lmt, delv
   /CHICHK, PLTONLY=, ZLBL=,  NSTP=, BSTP=, PSFILE=, OUTFIL=, /EXACT

   lowzovi_prsdat, stucture, filename

 INPUTS:
  strct_fil -- FITS file for the FUSE structure
  cog_fil -- COG input file (lists redshift and transitions to use)
  [N1lmt] -- Range of column densities to explore (2 element array)
  [b1lmt] -- Range of Doppler parameters to explore (2 element array)
  [N2lmt] -- Range of column densities to explore (2 element array)
  [b2lmt] -- Range of Doppler parameters to explore (2 element array)
  [delv]  -- Separation of the 2 components (km/s)

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /CHICHK -- Plot Chi^2 image
  PLTONLY --  4-element array of N,b values and error for a plot
  NSTP -- Number of steps to search N space [default: 5L]
  BSTP -- Number of steps to search b space [default: 5L]
  ZLBL= -- Label for Plot giving redshift of the absorber (string)

 OPTIONAL OUTPUTS:
  OUTFIL -- File with best fit values and error
  PSFILE -- File for postscript plot

 COMMENTS:

 EXAMPLES:
   fuse_calccolm, struct, fil_instr


 PROCEDURES CALLED:

 REVISION HISTORY:
   15-Sep-2003 Written by JXP

(See FUSE/Analysis//fuse_twocog.pro)


FUSE_VELPLT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 fuse_velplt
  V1.1

 PURPOSE:
    Velcoity plot of FUSE transitions for a given absorption 
    system
 CALLING SEQUENCE:
   
   fuse_velplt, strct_fil, instr_list, vel_fil, NTOT=, CSIZE=,
   LSIZE=, PSFILE=, XTINT=

 INPUTS:

 RETURNS:
  strct_fil -- FITS file for the FUSE abs lin structure
  instr_list -- List of instrument files
  vel_fil -- Input file for velocity plot

 OUTPUTS:

 OPTIONAL KEYWORDS:
  NTOT -- Number of plots per page [default: 16]
  LSIZE -- Label size [default: 1.8]
  CSIZE -- Numbering character size [default: 1.8]
  XTINT -- xtick interval

 OPTIONAL OUTPUTS:
  PSFILE -- Postscript filename

 COMMENTS:

 EXAMPLES:
   fuse_calcewn, struct, fil_instr


 PROCEDURES CALLED:

 REVISION HISTORY:
   12-Sep-2003 Written by JXP

(See FUSE/Analysis//fuse_velplt.pro)


GETABND

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 getabnd

 PURPOSE:
    Given the name or Z, get abnd and or Z.  Reads the file
    abnd.dat in $XIDL_DIR/General

 CALLING SEQUENCE:
   
   getabnd, name, Z, abnd, flag=

 INPUTS:
   name (Z)    - Element name

 RETURNS:
   Z       - Atomic number
   abnd    - Meteoritic Abundance
   [name]  - Element name [returned if flag = 1]

 OUTPUTS:

 OPTIONAL KEYWORDS:
   flag    - 0=Name input, 1=Z input

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES: ;   getabnd, 'C', Z, abnd
   getabnd, elm, 14, abnd, flag=1


 PROCEDURES CALLED:

 REVISION HISTORY:
   31-May-2001 Written by JXP

(See General//getabnd.pro)


GETCOLOR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GETCOLOR

 PURPOSE:
       The original purpose of this function was to enable the
       user to specify one of the 16 colors supported by the
       McIDAS color map by name. Over time, however, the function
       has become a general purpose function for handling and
       supporting drawing colors in a device-independent way.
       In particular, I have been looking for ways to write color
       handling code that will work transparently on both 8-bit and
       24-bit machines. On 24-bit machines, the code should work the
       same where color decomposition is turned on or off. The program
       now supports 88 colors.

 AUTHOR:
       FANNING SOFTWARE CONSULTING:
       David Fanning, Ph.D.
       1645 Sheely Drive
       Fort Collins, CO 80526 USA
       Phone: 970-221-0438
       E-mail: davidf@dfanning.com
       Coyote's Guide to IDL Programming: http://www.dfanning.com

 CATEGORY:
       Graphics, Color Specification.

 CALLING SEQUENCE:
       result = GETCOLOR(color, index)

 OPTIONAL INPUT PARAMETERS:
       COLOR: A string with the "name" of the color. Valid names are:
           black
           magenta
           cyan
           yellow
           green
           red
           blue
           navy
           pink
           aqua
           orchid
           sky
           beige
           charcoal
           gray
           white

           The color YELLOW is returned if the color name can't be resolved.
           Case is unimportant.

           If the function is called with just this single input parameter,
           the return value is either a 1-by-3 array containing the RGB values of
           that particular color, or a 24-bit integer that can be "decomposed" into
           that particular color, depending upon the state of the TRUE keyword and
           upon whether color decomposition is turned on or off. The state of color
           decomposition can ONLY be determined if the program is being run in
           IDL 5.2 or higher.

       INDEX: The color table index where the specified color should be loaded.
           If this parameter is passed, then the return value of the function is the
           index number and not the color triple. (If color decomposition is turned
           on AND the user specifies an index parameter, the color is loaded in the
           color table at the proper index, but a 24-bit value is returned to the
           user in IDL 5.2 and higher. This assumes the INDEXED keyword is NOT set.)

       If no positional parameter is present, then the return value is either a 16-by-3
       byte array containing the RGB values of all 16 colors or it is a 16-element
       long integer array containing color values that can be decomposed into colors.
       The 16-by-3 array is appropriate for loading color tables with the TVLCT command:

           Device, Decomposed=0
           colors = GetColor()
           TVLCT, colors, 100


 INPUT KEYWORD PARAMETERS:

       NAMES: If this keyword is set, the return value of the function is
              a 88-element string array containing the names of the colors.
              These names would be appropriate, for example, in building
              a list widget with the names of the colors. If the NAMES
              keyword is set, the COLOR and INDEX parameters are ignored.

                 listID = Widget_List(baseID, Value=GetColor(/Names), YSize=16)

       INDEXED:  If this keyword is set, the return value is always an index
              into the color table. In the absence of a color table INDEX
              parameter, the color is loaded at !P.COLOR < (!D.Table_Size-1).

       LOAD:  If this keyword is set, all 88 colors are automatically loaded
              starting at the color index specified by the START keyword.
              Note that setting this keyword means that the return value of the
              function will be a structure, with each field of the structure
              corresponding to a color name. The value of each field will be
              an index number (set by the START keyword) corresponding to the
              associated color, or a 24-bit long integer value that creates the
              color on a true-color device. What you have as the field values is
              determined by the TRUE keyword or whether color decomposition is on
              or off in the absense of the TRUE keyword. It will either be a 1-by-3
              byte array or a long integer value.

       START: The starting color index number if the LOAD keyword is set. This keyword
              value is ignored unless the LOAD keyword is also set. The keyword is also
              ignored if the TRUE keyword is set or if color decomposition in on in
              IDL 5.2 and higher. The default value for the START keyword is
              !D.TABLE_SIZE - 89.

       TRUE:  If this keyword is set, the specified color triple is returned
              as a 24-bit integer equivalent. The lowest 8 bits correspond to
              the red value; the middle 8 bits to the green value; and the
              highest 8 bits correspond to the blue value. In IDL 5.2 and higher,
              if color decomposition is turned on, it is as though this keyword
              were set.

 COMMON BLOCKS:
       None.

 SIDE EFFECTS:
       None.

 RESTRICTIONS:
       The TRUE keyword causes the START keyword to be ignored.
       The NAMES keyword causes the COLOR, INDEX, START, and TRUE parameters to be ignored.
       The COLOR parameter is ignored if the LOAD keyword is used.
       On systems where it is possible to tell the state of color decomposition
       (i.e., IDL 5.2 and higher), a 24-bit value (or values) is automatically
       returned if color decomposition is ON.

 EXAMPLE:
       To load a yellow color in color index 100 and plot in yellow, type:

          yellow = GETCOLOR('yellow', 100)
          PLOT, data, COLOR=yellow

       or,

          PLOT, data, COLOR=GETCOLOR('yellow', 100)

       To do the same thing on a 24-bit color system with decomposed color on, type:

          PLOT, data, COLOR=GETCOLOR('yellow', /TRUE)

       or in IDL 5.2 and higher,

          DEVICE, Decomposed=1
          PLOT, data, COLOR=GETCOLOR('yellow')

       To load all 88 colors into the current color table, starting at
       color index 100, type:

          TVLCT, GETCOLOR(), 100

       To add the color names to a list widget:

           listID = Widget_List(baseID, Value=GetColor(/Names), YSize=16)

       To load all 88 colors and have the color indices returned in a structure:

           DEVICE, Decomposed=0
           colors = GetColor(/Load, Start=1)
           HELP, colors, /Structure
           PLOT, data, COLOR=colors.yellow

       To get the direct color values as 24-bit integers in color structure fields:

           DEVICE, Decomposed=1
           colors = GetColor(/Load)
           PLOT, data, COLOR=colors.yellow

       Note that the START keyword value is ignored if on a 24-bit device,
       so it is possible to write completely device-independent code by
       writing code like this:

           colors = GetColor(/Load)
           PLOT, data, Color=colors.yellow

 MODIFICATION HISTORY:
       Written by: David Fanning, 10 February 96.
       Fixed a bug in which N_ELEMENTS was spelled wrong. 7 Dec 96. DWF
       Added the McIDAS colors to the program. 24 Feb 99. DWF
       Added the INDEX parameter to the program 8 Mar 99. DWF
       Added the NAMES keyword at insistence of Martin Schultz. 10 Mar 99. DWF
       Reorderd the colors so black is first and white is last. 7 June 99. DWF
       Added automatic recognition of DECOMPOSED=1 state. 7 June 99. DWF
       Added LOAD AND START keywords. 7 June 99. DWF.
       Replaced GOLD with CHARCOAL color. 28 Oct 99. DWF.
       Added INDEXED keyword to force indexed color mode. 28 Oct 99. DWF.
       Fixed problem of "aqua" and "pink" being mixed up. 18 Mar 00. DWF.
       Changed ON_ERROR from 1 to 2, and improved error handling. 2 Aug 00. DWF.
       Increased the known colors from 16 to 88. 19 October 2000. DWF.
       Fixed typos in which "thisColor" was written as "theColor". 10 AUG 2001. DWF.

(See Color//getcolor.pro)


GETFNAM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 getfnam
  Version 1.1

 PURPOSE:
    Given an atomic wavelength, return the fvalue and name of the
    transition.  Wavelength needs to be within 0.03Ang of the 
    desired transition.  By default, the file $XIDL_DIR/Spec/Lines/
    Lists/qal.lst is read.

 CALLING SEQUENCE:
   
   getfnam, wave, fval, [nam], FIL=fil

 INPUTS:
   wave       - ionic transition

 RETURNS:

 OUTPUTS:
   f          - oscillator strength

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:
   nam        - Name of transition (string)

 COMMENTS:

 EXAMPLES:
   getfnam, 1215.6701, fval, name

 PROCEDURES CALLED:

 REVISION HISTORY:
   31-May-2001 Written by JXP

(See General//getfnam.pro)


GETION

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 getion
  Version 1.1

 PURPOSE:
  Given an atomic wavelength, return the ionic value
    (e.g. 1, 2, 3).  Uses getfnam to grab the transition name.  

 CALLING SEQUENCE:
   
   getion, ion, [elm], Z=z

 INPUTS:
   wave       - ionic transition

 RETURNS:
   ion        - Ion value (e.g. 1,2,3)

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:
   elm        - Name of element 

 COMMENTS:

 EXAMPLES:
   getion, 1215.6701, ion, nm 

 PROCEDURES CALLED:
  getfnam

 REVISION HISTORY:
   11-Sep-2003 Written by JXP

(See General//getion.pro)


GRB_FXLUM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
  grb_fxlum
   Version 1.1

 PURPOSE:
    Calculates GRB flux as a function of time given the flux at
    one point in time.  The solution is based on the paper by
    Sari, Piran, & Narayan 1998.

 CALLING SEQUENCE:
   
   grb_fxlum, fini, tini, freq, RAD=, FLUX=, LUM=, Z=, $
              tEarth=,  TEXP=, TSTART=, NSTP=

 INPUTS:
     fini -- Flux measured at tini in muJy
     tini -- Time at Earth when fini was measured (seconds)
     freq -- Frequency of the radiation
 RETURNS:
   flux= -- Array of flux values computed as function of time

 OUTPUTS:

 OPTIONAL KEYWORDS:
    /RAD   -- Radiative expansion [Default: adiabatic]
    z=     -- Redshift [default: 1.]
  tstart=  -- Starting time of observation [default: 3600.]
  tend=    -- Starting time of observation [default: 7200.]
  nstp=    -- Number of time steps [default: 1000L]

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   grb_fxlum, 1., 7200., 1e15

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   29-Oct-2003 Written by JXP (based on Sari, Piran, Narayan 1998)

(See GRB//grb_fxlum.pro)


H2LINSTRCT__DEFINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 h2linstrct__define
  (V1.1)

 PURPOSE:
    Molecular hydrogen structure

 CALLING SEQUENCE:
   
   tmp = {h2linstrct}

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES CALLED:

 REVISION HISTORY:
   09-Feb-2004 Written by JXP

(See FUSE/H2//h2linstrct__define.pro)


HIRES_CUT_35

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 hires_cut_35
    Version 1.1

 PURPOSE:
    Zero out the first 35 points of a HIRES spectrum.  I cant
  even recall why I do it.

 CALLING SEQUENCE:
   hires_cut_35, fil

 INPUTS:
   fil -- Name of HIRES file to edit

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   ??  Written by JXP

(See Keck/HIRES//hires_cut_35.pro)


HIRES_UPD_NAM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 hires_upd_nam
    Version 1.1

 PURPOSE:
   Set the FILENAME, SIGFILE, and CONTFILE header key cards

 CALLING SEQUENCE:
   hires_upd_nam, fil, filnm, signm, contnm

 INPUTS:
   fil -- Name of HIRES file to edit

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   ??  Written by JXP

(See Keck/HIRES//hires_upd_nam.pro)


HIRES_WAV

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 hires_wav

 PURPOSE:
   Create a line list appropriate for the HIRES emulator 
 provided the redshift.

 CALLING SEQUENCE:
  hires_wav, z, fil, /LLS   

 INPUTS:
   z  -- Redshift
  fil -- Output fil

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
   /LLS  -- Create a line list for LLS

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   hires_wav, 2.2, 'q0440-221_wav.dat'

 PROCEDURES CALLED:

 REVISION HISTORY:
   17-Nov-2003 Written by JXP

(See Keck/HIRES//hires_wav.pro)


KASTSTRCT__DEFINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 kaststrct__define   
     Version 1.1

 PURPOSE:
   Kast IDL structure

 CALLING SEQUENCE:
  tmp = {kaststrct}

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   01-Mar-2003 Written by JXP

(See Lick/Kast/General//kaststrct__define.pro)


KAST_AR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 kast_ar   
     Version 1.1

 PURPOSE:
   Reads the Kast IDL structure from fits file into memory.  The
  program grabs the first file in the directory with kast_*fits

 CALLING SEQUENCE:
   
  kast = kast_ar(file)

 INPUTS:
    [file] - Filename (default: first file in list ./kast_*fits*)

 RETURNS:
    kast -  Kast IDL structure

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   kast = kast_ar()


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   01-Mar-2003 Written by JXP

(See Lick/Kast/General//kast_ar.pro)


KAST_CALIBSTD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 kast_calibstd   
   Version 1.1

 PURPOSE:
    Takes the kast structure and an index for the standard to
  create a sensitivity function.

 CALLING SEQUENCE:
  kast_calibstd, kast, indx, outfil, HSTFIL=

 INPUTS:
   kast  -- Kast IDL structure
   indx  -- Index of standard star

 RETURNS:

 OUTPUTS:
   outfil -- Name of sensitivity function

 OPTIONAL KEYWORDS:
   HSTFIL= --  HST spectrophotometric file

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   kast_calibstd, kast, 0, 1, 0


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   03-Mar-2003 Written by JXP

(See Lick/Kast/Calibs//kast_calibstd.pro)


KAST_COMBSPEC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 kast_combspec
    Version 1.1

 PURPOSE:
   Coadd kast spectra using x_combspec

 CALLING SEQUENCE:
   kast_combspec, kast, setup, side, obj_id, [exp_id]

 INPUTS:
   kast  --  Kast IDL structure
  setup  --  Setup value
   side  --  Specific camera [blue (1) vs. red (2)]
 obj_id  --  Object value
  [exp_id]  --  Exposure indices

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /CHK  -- Show the final combined spectrum

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   kast_combspec, kast, 0, 1, 2

 PROCEDURES/FUNCTIONS CALLED:
  x_combspec
  kast_wrspec

 REVISION HISTORY:
   28-August-2003 Written by GEP

(See Lick/Kast/Extract//kast_combspec.pro)


KAST_CRAYS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 kast_crays
   Version 1.1

 PURPOSE:
   Detect cosmic rays, set affected pixels to have var = -1

 CALLING SEQUENCE:
   kast_crays, kast, setup, side, obj_id, [exp_id], CHK=chk

 INPUTS:
   kast  --  Kast IDL structure
  setup  --  Setup value
   side  --  Specific camera [blue (1) vs. red (2)]
 obj_id  --  Object value
  [exp_id]  --  Exposure indices
 
 OUTPUTS:

 OPTIONAL KEYWORDS:
  /CHK  -- Print out info on CRays

 COMMENTS:

 EXAMPLES:
    kast_crays, kast, 0, 1, 2, /chk

 PROCEDURES/FUCTIONS CALLED:

 REVISION HISTORY:
   01-September-2003 Written by GEP

(See Lick/Kast/Extract//kast_crays.pro)


KAST_EDITSTRCT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 kast_editstrct   
   Version 1.1

 PURPOSE:
    Launches a gui to edit the Kast IDL structure

 CALLING SEQUENCE:
   kast_editstrct, kast

 INPUTS:
  kast  --  Kast IDL structure

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   kast_editstrct, kast

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   01-Mar-2003 Written by JXP

(See Lick/Kast/General//kast_editstrct.pro)


KAST_EXTRACT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 kast_extract   
   Version 1.1

 PURPOSE:
    Extract a 1D spectrum from a Kast 2D image.

 CALLING SEQUENCE:
  kast_extract, kast, setup, side, obj_id, [exp], $
                 APER=, SKYNORD=, /STD, YMODEL=, /BOXCAR

 INPUTS:
   kast  --  Kast IDL structure
  setup  --  Setup value
   side  --  Specific camera [blue (1) vs. red (2)]
 obj_id  --  Object value
  [exp]  --  Exposure indices

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /BOXCAR -- Extract with a boxcar [default: optimal]
  APER= -- Aperture (for boxcar primarily)

 OPTIONAL OUTPUTS:
  YMODEL=  -- Image fit created in optimal extraction

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   01-Mar-2003 Written by JXP

(See Lick/Kast/Extract//kast_extract.pro)


KAST_FLUX

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 kast_flux   
   Version 1.1

 PURPOSE:
    Flux a set of Kast spectra given a sensitivity file.

 CALLING SEQUENCE:
  kast_flux, kast, setup, side, obj_id, [exp], /STD, SENSFIL=

 INPUTS:
   kast -- Kast IDL structure
  setup -- Setup value 
   side -- Side of Kast (blue=1, red=2)
 obj_id -- Object ID value
  [exp] -- Exposure indices

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
   /STD  -- Flux a standard
 SENSFIL -- Name of sensitivity file

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   kast_flux, kast, 0, 1, 0


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   03-Mar-2003 Written by JXP

(See Lick/Kast/Calibs//kast_flux.pro)


KAST_FNDOBJ

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 kast_fndobj   
     Version 1.0

 PURPOSE:
    Find object on the image and then trace using x_trace.
  The code can look automatically or the user can look interactively.

 CALLING SEQUENCE:
 kast_fndobj, kast, setup, side, obj_id, [exp], $
                /CHK, /NOCLOBBER, SCICLM=, /STD, /AUTO, SCIROW=
 
 INPUTS:
   kast  --  Kast IDL structure
  setup  --  Setup value
   side  --  Specific camera [blue (1) vs. red (2)]
 obj_id  --  Object value
  [exp]  --  Exposure indices

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  SCICLM     -- Column to look for object in
  SCIROW     -- Approximate row expected for the object
  /AUTO      -- Look for the object automatically
  /NOCLOBBER -- Do not overwrite the object structure
  /STD       -- Standard star
  /CHK       -- Plot the image and the trace

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   kast_fndobj, kast 


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   01-Mar-2003 Written by JXP

(See Lick/Kast/Extract//kast_fndobj.pro)


KAST_MKARC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 kast_mkarc   
     Version 1.0

 PURPOSE:
    Process arc files (flatten, combine)

 CALLING SEQUENCE:
  kast_mkarc, kast, setup, /CLOBBER

 INPUTS:
   kast  --  Kast IDL structure
  setup  --  Setup value

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
 /CLOBBER -- Clobber any previous processed image

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   kast_mkarc, kast


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   27-Aug-2002 Written by JXP

(See Lick/Kast/Calibs//kast_mkarc.pro)


KAST_MKFLAT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 kast_mkflat   
     Version 1.1

 PURPOSE:
    Process flat file

 CALLING SEQUENCE:
   
  kast_mkflat, kast, slit

 INPUTS:
   kast  --  Kast IDL structure
  setup  --  Setup value

 RETURNS:

 OUTPUTS:
  One normalized flat per slit width

 OPTIONAL KEYWORDS:
 /CLOBBER -- Clobber any previous processed image

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   kast_mkflat, kast, 1L


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   01-Mar-2003 Written by JXP

(See Lick/Kast/Calibs//kast_mkflat.pro)


KAST_PLTOBJ

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 kast_pltobj
    Version 1.1

 PURPOSE:
   Calls x_pltobj after gathering the relevant data

 CALLING SEQUENCE:
  kast_pltobj, kast, [setup, side, obj_id, obj_nm], EXPSR=, XSIZE=, $
                 YSIZE=, /FLUX, /FSPEC, XMAX=, /NOIMG, /NOWV, /COMB

 INPUTS:
   kast  --  Kast IDL structure
  [setup]  --  Setup value
   [side]  --  Specific camera [blue (1) vs. red (2)]
 [obj_id]  --  Object value

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /NOIMG  -- Do not display 2D image of spectrum
  /COMB   -- Show the combined 1D spectra
  EXPSR   -- Index of spectrum
  /FLUX   -- Show the fluxed spectra
  XMAX    -- Max height of spectrum [default: 7e-17]

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   kast_pltobj, kast, /noimg

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   30-Jul-2002 Written by JXP
   ??  Major revisions by GEP

(See Lick/Kast/Spec//kast_pltobj.pro)


KAST_PROC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 kast_proc   
     Version 1.1

 PURPOSE:
    Process an image (flatten) and create variance array.  The
  routine also turns the DN into electrons by scaling by the gain.
      WARNING! Assumes 1 flat for all images

 CALLING SEQUENCE:
  kast_proc, kast, setup, obj_id, side, INDEX=, /CLOBBER

 INPUTS:
   kast  - Kast IDL structure
  setup  --  Setup value
   side  --  Specific camera [blue (1) vs. red (2)]
 obj_id  --  Object value

 RETURNS:

 OUTPUTS:
  Processed file (Final/f_###.ccd)

 OPTIONAL KEYWORDS:
   INDEX  - Indices of objects to process
   FLAT   - Flat file
 /CLOBBER - Overwrite processed image if it exists

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   kast_proc, kast 


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   18-Jul-2002 Written by JXP

(See Lick/Kast/General//kast_proc.pro)


KAST_QCKREDUX

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 kast_qckredux   
   Version 1.1

 PURPOSE:
   Perform a quick and dirty (and rather accurate) reduction of a
  Kast spectrum.  Very useful at the telescope.

 CALLING SEQUENCE:
  kast_qckredux, img, flat, spec, sig, ARC=, OVR=, $
                  CLINE=, APER=, SKYFUNC=, SKYNORD=, SKYREG=, 
                  /DISPLAY, /NOREJ, TRACE=, /NOSKY=, STRCT=, RN=, GAIN=, 
                  VAR=, CRUDE=, TINTER=, /SILENT,
                  WAVE=, /OPTIMAL, /AINTER, OBJLIN=, /DEBUG, /APINTER, 
                  YMODEL=, SIGMA=, /CHK=

 INPUTS:
   img  -- Image to extract from (raw fits file)
  flat  -- Name of flat file (fits)

 RETURNS:
  spec  -- 1D spectrum
   sig  -- Error of 1D spectrum

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /CRUDE   -- Use the routine trace_crude to trace [recommended]
  CLINE=   -- Row to use to identify object  [default: half way on image]
  APER=    -- Aperture for boxcar extraction  (output or input)
  TRACE=   -- Trace of the object (output or input)
  /CHKTRC  -- Check the trace by eye
  /DISPLAY -- Display the sky subtracted image with xatv
  /NOREJ   -- Turn off rejection in sky subtraction (not recommended)
  /AINTER  -- Interactively fiddle with the Arc peakup
  OBJLIN=  -- Row near the object trace [default: center of image]
  /OPTIMAL -- Perform optimal extraction
  YMODEL   -- 2D model of the image created by extract_image
  RN=      -- Readnoise of the image [default: 3.29]
  ARC=     -- Arc image (fits file)
  /DEBUG   -- Debug the program (this one often 'breaks')
  SIGMA=   -- Approximate sigma of the Gaussian profile (for Optimal)

 OPTIONAL OUTPUTS:
  WAVE=    -- Wavelength array (requires Arc image)

 COMMENTS:

 EXAMPLES:
   kast_qckredux, 'b109.ccd', spec, sig, WAVE=wave, ARC='b102.ccd',
                  FLAT='b100.ccd', /OPTIMAL, /NOSKY 


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   01-Mar-2003 Written by JXP

(See Lick/Kast/Extract//kast_qckredux.pro)


KAST_SPECSETUP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 kast_specsetup   
     Version 1.1

 PURPOSE:
    Examines the Kast IDL structure, checks for appropriate
  Flats and Arcs and then outputs a summary ASCII file.

 CALLING SEQUENCE:
  kast_specsetup, kast, OUTFIL=

 INPUTS:
   kast --  Kast IDL structure

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  OUTFIL=  -- Name of ASCII file (default: kast_specsumm.txt')

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   kast_specsetup, kast

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   01-Mar-2003 Written by JXP

(See Lick/Kast/General//kast_specsetup.pro)


KAST_STRCT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 kast_strct   
     Version 1.1

 PURPOSE:
    Creates and outputs a structure for a series of Kast frames.
    This structure organizes the data for the night and is used 
    to run most of the programs in the Kast package    

 CALLING SEQUENCE:
  kast_strct, struct, LIST=, /NOMKDIR, OUTFIL=, /NOEDIT

 INPUTS:

 RETURNS:

 OUTPUTS:
  struct  -- Kast IDL structure

 OPTIONAL KEYWORDS:
   LIST=     - Image list:  e.g.  'gd_files.lst'
               [Default is 'Raw/kast*.fits']
   /NOMKDIR   - Do not make default directories
   /NOEDIT    - Do not edit the hand
   OUTFIL=    - Name of fits output file [default: 'kaststrct.fits']
   

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   kast_strct, nght1_strct, /MKDIR


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   01-Mar-2003 Written by JXP

(See Lick/Kast/General//kast_strct.pro)


KAST_WAVESOL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 kast_wavesol   
   Version 1.1

 PURPOSE:
  Create a wavelength solution for a specific object using 
     an archived solution.  The wavelength array in the object
     structure and writes that structure out.

 CALLING SEQUENCE:
 kast_wavesol, kast, setup, side, obj_id, [exp], /STD,
  /SILENT, /AINTER, /AUTO, CALIB=, CALIBFIL=, NFIN=

 INPUTS:
   kast  --  Kast IDL structure
  setup  --  Setup value
   side  --  Specific camera [blue (1) vs. red (2)]
 obj_id  --  Object value
  [exp]  --  Exposure indices

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /AUTO    -- Automatically fit the arc
  NFIN=    -- Requires nfin lines to start the fit [default: 5]
  /SILENT
  /AINTER  -- Peak up on the arc cross-correlation interactively

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   01-Mar-2003 Written by JXP

(See Lick/Kast/Calibs//kast_wavesol.pro)


KAST_WRSPEC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 kast_wrspec
    Version 1.0

 PURPOSE:
    Writes kastspectrct to a FITS file

 CALLING SEQUENCE:
   kast_wrspec, kastspecstrct, outfil, /READ

 INPUTS:
   kastspecstrct     - Kast Combined Spectrum structure

 RETURNS:

 OUTPUTS:
   outfil            - FITS file for the structure

 OPTIONAL KEYWORDS:
   /READ   -- Reverse the operation (read from the FITS file)

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   kast_wrspec, kastspecstrct, outfil

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   03-Aug-2003 Written by GEP

(See Lick/Kast/Extract//kast_wrspec.pro)


KAST_WRSTRCT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 kast_wrstrct   
    Version 1.0

 PURPOSE:
    Write the kast structure to a FITS file and write an ASCII summary

 CALLING SEQUENCE:
   
  kast_wrstrct, kast, /ANONLY, OUTFIL=, FITS=

 INPUTS:
   kast   - An ESI structure

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
   ANONLY - Only print files with flg_anly NE 0   

 OPTIONAL OUTPUTS:
   OUTFIL= - Output file (default: kast.list)
   FITS=   - Name of fits output file

 COMMENTS:

 EXAMPLES:
   kast_wrstrct, kast, FITS='kast_13oct02.fits'


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   01-Mar-2003 Written by JXP

(See Lick/Kast/General//kast_wrstrct.pro)


LCO_GUIDESTR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 lco_guidestr
   Version 1.1

 PURPOSE:
    Inputting a photometry structure, parse out a set of stars
  useful for guide stars for WFCCD masks.

 CALLING SEQUENCE:
   lco_guidestr, phot, mmin, mmax

 INPUTS:
   phot -- Photometry structure
   mmin -- Min mag for guide star
   mmax -- Max mag for guide star

 RETURNS:

 OUTPUTS:
   'Masks/guidestr.dat' -- Guide star output file

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   ?? Written by JXP

(See lcoovi//lco_guidestr.pro)


LCO_PHOT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 lco_phot
   Version 1.1

 PURPOSE:
    Turns the photometry output (B,R filters) into a structure

 CALLING SEQUENCE:
   lco_phot, phot_fil, phot_str

 INPUTS:
   phot_fil -- Photometry ASCII file

 RETURNS:
   phot_str -- Photometry structure

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   ?? Written by JXP

(See lcoovi//lco_phot.pro)


LCO_TARGETS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 lco_targets
   Version 1.1

 PURPOSE:
    Turns a Sextractor output file into an IDL structure

 CALLING SEQUENCE:
   lco_targets, name, galstr

 INPUTS:
   name -- Name of Sextractor file

 RETURNS:
   galstr -- IDL galaxy structure

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   ?? Written by JXP

(See lcoovi//lco_targets.pro)


LLISTSTRCT__DEFINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 lliststrct__define
   Version 1.1

 PURPOSE:
  Structure for the line lists

 CALLING SEQUENCE:
   tmp = {lliststrct}

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
  Written by JXP

(See Spec/Lines//lliststrct__define.pro)


LNDLTSTR__DEFINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 lndltstr__define
   Version 1.1

 PURPOSE:
   Structure to handle Landolt star data

 CALLING SEQUENCE:
  tmp = {lndltstr}

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   07-Aug-2001 Written by JXP

(See IMG/Photometry//lndltstr__define.pro)


LRIS_CALIBSTD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 lris_calibstd   
   Version 1.1

 PURPOSE:
    CURRENTLY UNDER CONSTRUCTION

 CALLING SEQUENCE:
   
   spec = x_apall(ydat, [head])

 INPUTS:
   ydat       - Values 
   [head]     - Header

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
   wave       - wavelength array
   DISPLAY    - Display the sky subtracted image with xatv
   OVR        - String array for ov region:  '[2050:2100, *]'
   ERROR      - Variance array

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   kast_calibstd, kast, 0, 1, 0


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   03-Mar-2003 Written by JXP

(See Keck/LRIS/Flux//lris_calibstd.pro)


LRIS_FLUX

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 lris_flux   
   Version 1.1

 PURPOSE:
    Flux an LRIS spectrum given a sensitivity function (archived)

 CALLING SEQUENCE:
   flux = lris_flux(wave, spec, flux_fil, SIG=, FSIG=)

 INPUTS:
   wave  -- Wavelength array
   spec  -- LRIS spectrum
  flux_fil -- Sensitivity function

 RETURNS:
   flux  -- Fluxed LRIS spectrum

 OUTPUTS:

 OPTIONAL KEYWORDS:
  EXP=  -- Exposure time [default: 1.]
  SIG=  -- Error array to flux as well

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   kast_calibstd, kast, 0, 1, 0


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   29-Aug-2003 Written by JXP

(See Keck/LRIS/Flux//lris_flux.pro)


LWDFSPECSTRCT__DEFINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 lwdfspecstrct__define
   Version 1.1

 PURPOSE:
  Creates a structure for Low dispersion spectroscopy that will hold the
  wavelength, flux and error arrays.  Also includes the ZANS
  structure which is useful for using SDSS redshift identification.
 

 CALLING SEQUENCE:
   tmp = {lwdfspecstrct}

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:
  Currently a maximum of 5000 pixels

 EXAMPLES:


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   Written by JXP

(See Spec/Analysis//lwdfspecstrct__define.pro)


MSLITSTRCT__DEFINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 mslitstrct__define
   Version 1.1

 PURPOSE:
  This structure is used to save info about a slit in a mask.  In
  particular, one saves the edges of the slit.

 CALLING SEQUENCE:
   tmp = {mslitstrct}

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
  Written by JXP

(See Spec/Slits//mslitstrct__define.pro)


OBSERVABLE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 observable
   Version 1.1

 PURPOSE:
    Calculate the airmass for an obj with a given DEC at an
  observatory with a given DEC and an offset in RA

 CALLING SEQUENCE:
  observable, month, obs_dec, obj_ra, obj_dec, PAR=par, $
               POS=pos, L1=l1, L2=l2, KECK=keck, VLT=vlt

 INPUTS:
  month   -- 
  obs_dec -- DEC of the observatory
  obj_ra  -- RA of the object
  obj_dec -- DEC of the object

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /KECK  -- Calculate for Keck
  /VLT   -- Calculate for VLT

 OPTIONAL OUTPUTS:

 COMMENTS:
written by E. Gawiser, last modified 05jul03
anyone can use this code, please notify gawiser@astro.yale.edu regarding
any errors found!    
WARNING:  POS=0 is equivalent to not setting it, so use e.g. 0.001  
WARNING:  "middle of the night" is not local midnight but is much more useful 
in Chile it's about 00:40 in winter, 01:40 in summer with daylight savings!
dec in degrees, RA in hours
month is from 1.00 to 12.99, use decimals for days.  e.g automnal equinox
is roughly 9.67.  (No accounting for 28/30/31 days)
NOTE:  To get Keck Nasmyth platform limits, use /keck.  
/par will output the amplitude of atmospheric dispersion from L1 to L2
along the parallactic angle (default is 3000,10000A) and if POS is set it 
will output the component perpendicular to a slit at position angle POS

EXAMPLE FOR IMAGING:  
observable, 1.7, -30., 3.5, -27. 
models observing the CDF-S (03 30 -27) on January 21 from CTIO 
The program outputs the RA overhead, length of night, and airmass values.

EXAMPLE FOR SPECTROSCOPY:  
observable, 10.3, 20., 3.5, -27., /par, /keck, l1=3500, l2=6000, pos=0.01
models observing the CDF-S (03 30 -27) on October 9 from Keck with 
slit(s) at position angle = 0.01
The program outputs the Nasmyth platform limits, RA overhead, 
length of night, airmass, parallactic angle, total amplitude of ADR from 
3500 to 6000A, and amplitude of that ADR perpendicular to POS=0.01 
for this field.  
you can call /vlt instead of /keck to use atmospheric conditions at 
Paranal (about 50% more ADR) instead of Mauna Kea.  Calling neither uses 
atmospheric conditions at La Silla which cause a bit more ADR than Paranal.  
Note that parallactic angle is 
defined as angle towards zenith i.e. from blue to red light of the object,
with North=0, East=90, etc. This has been tested versus the skycalc code 
and works fine anywhere on the sky (doesn't mean much once the object is 
below the horizon however ;) ).  

(See Obs//observable.pro)


PARSE_DLALST

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 parse_dlalst
  V1.2

 PURPOSE:
    Given a list of DLA base files, fill up the DLA structure.  THis
    program also defines the DLA structure {sDLA}.

 CALLING SEQUENCE:
   
   parse_DLAlst, dla, [list]

 INPUTS:
  [list] -- List of DLA base files.  [default:
            '/u/xavier/DLA/Lists/tot_dla.lst']

 RETURNS:

 OUTPUTS:
  dla  -- IDL DLA structure

 OPTIONAL KEYWORDS:
  /ION - Input ionic column densities
  /NOELM - Supress inputting Elemental [X/H] values

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   parse_dlalst, dla, '/u/xavier/DLA/Lists/tot_dla.lst'


 PROCEDURES CALLED:

 REVISION HISTORY:
   31-May-2001 Written by JXP
   02-Jan-2003 Added metallicity structure

(See DLA//parse_dlalst.pro)


PARSE_PHOT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
  parse_phot
   Version 1.1

 PURPOSE:
    Reads in the BRI ASCII file from DLA photometery to an IDL
    structure.  Not too useful for the common folk.

 CALLING SEQUENCE:
   
   parse_phot, file, nobj, supstrc, FLAG=

 INPUTS:

 RETURNS:


 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
 
 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   

(See IDLA//parse_phot.pro)


PARSE_SDSS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 parse_sdss   
   Version 1.1

 PURPOSE:
    Given an SDSS spectrum, return flux, wavelength, etc.

 CALLING SEQUENCE:
 parse_sdss, fil, flux, wave, conti, SIG=, IVAR=, ZQSO=, $
                  NPIX=, HEAD=, CFIL=, CDIR=

 INPUTS:
  fil -- Name of SDSS file

 RETURNS:
  flux -- Spectral flux array
  wave -- Wavelength array
  conti -- Continuum array  (requires CFIL)

 OUTPUTS:

 OPTIONAL KEYWORDS:
  CFIL= -- Name of continuum file
  CDIR= -- Name of directory to continuum files

 OPTIONAL OUTPUTS:
  SIG=  -- Sigma array
  IVAR= -- Inverse variance array
  ZQSO= -- Redshift of the quasar (or galaxy)
  NPIX= -- Number of pixels in the spectrum
  HEAD= -- Full header of the SDSS spectrum

 COMMENTS:

 EXAMPLES:
   parse_sdss, fil


 PROCEDURES/FUNCTIONS CALLED:
 REVISION HISTORY:
   05-Sep-2003 Written by JXP

(See SDSS/General//parse_sdss.pro)


PCA_QSOTILT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 pca_qsotilt   
   Version 1.0

 PURPOSE:
  Attempt to fit in logarithmic flux a low order polynomial to
   match the CIV region (range)
   coeffs contains the [npoly,nspec] coefficients based on rlam

   This fit is done in logarithmic flux vs. logarithmic wavelength

 CALLING SEQUENCE:
 pca_qsotilt, rlam, flux, invvar, xmed, ymed, tilt, tiltivar, $
                coeff, npoly=, range=, answer=, FLG_TILT=

 INPUTS:
  rlam -- Observed Wavelength array (logarithmic)
  flux -- Flux of quasar
  invvar -- Inverse variance array
  xmed -- Rest frame wavelength array [logarithmic; rlam / (1+zem) ]
  ymed -- 0th channel of the PCA fit  (pca[*,0])


 RETURNS:
  tilt --  Normalized fit to QSO (tilt taken out)
  tiltivar -- Inverse variance of the fit
  coeff -- Coefficients of the fit to the tilt

 OUTPUTS:

 OPTIONAL KEYWORDS:
  npoly=  -- Number of coefficients in POLY fit to tilt
  range=  -- Rest-wavelength range to fit [default: 1270--2000]

 OPTIONAL OUTPUTS:
  ANSWER= -- Tilted fit
  FLG_TILT -- Flag describing the success of the fit (0=bad, 1=good)

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   09-Sep-2003 Written by JXP (based on qso_tilt by SB)

(See SDSS/PCA//pca_qsotilt.pro)


PRINTCOL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 printcol
   Version 1.1

 PURPOSE:
    Prints a series of arrays to the screen in column format.
   The program will print as many entries as found in v1.

 CALLING SEQUENCE:
   
   printcol, v1, v2, [v3-v8], FORMAT=''

 INPUTS:
   v1       - Vector 1
   v2       - Vector 2
   [v3-v8]  - Additional vectors.

 RETURNS:

 OUTPUTS:
   Prints v1, v2 to screen

 OPTIONAL KEYWORDS:
   FORMAT -  FORTRAN formatting

 OPTIONAL OUTPUTS:

 COMMENTS:
   The program keys off the number of elements in v1

 EXAMPLES:
   printcol, array1, array2

 PROCEDURES CALLED:

 REVISION HISTORY:
   17-June-2001 Written by JXP

(See General//printcol.pro)


PRS_CLDYCOLL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 prs_cldycoll
  V1.1

 PURPOSE:
    Parses a standard binary fits file into the CLOUDY struct
   for collisional ionization.  The default file was created by
   J.C. Howk using Cloudy

 CALLING SEQUENCE:
   
   prs_cldycoll, stucture, [filename]

 INPUTS:
  [filename]  - Input fits file  
        [default: $XIDL_DIR/Cloudy/cloud_collisons.fits]

 RETURNS:
   structure      - IDL structure strctcldy

 OUTPUTS:

 OPTIONAL KEYWORDS:
  ION - Input ionic column densities
  NOELM - Supress inputting Elemental values

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   parse_dlalst, struct, '/home/xavier/DLA/Lists/tot_dla.lst'


 PROCEDURES CALLED:
  xmrdfits

 REVISION HISTORY:
   03-Nov-2003 Written by JXP

(See Cloudy//prs_cldycoll.pro)


PRS_CLDYGRID

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 prs_cldygrid
  V1.1

 PURPOSE:
    Parses a standard binary fits file into the CLOUDY struct
    for Photoionized models
 CALLING SEQUENCE:
   
   prs_cldygrid, stucture, filename

 INPUTS:
   filename   - Cloudy File
   ROOT=  - Path to Cloudy files [default: /u/xavier/Cloudy/Grid/Output]

 RETURNS:
   structure  - IDL structure strctcldy containing the Cloudy info

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   prs_cldygrid, struct, 'HM01A.fits'


 PROCEDURES CALLED:
  xmrdfits

 REVISION HISTORY:
   31-May-2001 Written by JXP

(See Cloudy//prs_cldygrid.pro)


PS_OPEN

[Previous Routine] [Next Routine] [List of Routines]
 Name:

   PS_Open

 Purpose:

   Set the plotting device to be PostScript, 
   and save the current plotting device (that can thus be restored).
   Use in conjunction with ps_close.

 Calling sequence:

   PS_Open

 Example:
   
   IDL> ps_open,file='test.ps',/por
   IDL> plot,findgen(10)
   IDL> ps_close,/nop

 Keywords:

   PORTRAIT - Normally, PS_Open defines the plotting area as landscape. If
     this keyword is set, the plotting area will be portrait.

   FILENAME = <string> - Normally, PS_Open uses '/tmp/idl-$USER.ps' (on
     Sparx) for the PostScript file, but the keyword FILENAME can be used
     to override that value.  ($USER is retrieved with a getenv('USER')).

   SQUARE - if set, defines the plotting area to be square.  to also get
     a square data window, use the position keyword when making the plot.

   FONT - set !P.font to value of FONT

   ENCAPSULATED - produces an encapsulated PostScript plot.
   
   BPP = <n> - Set the number of bits per pixel; default value is 8,
     valid values are 8, 4, OR 2. A higher no produces a better
     resolution but also a bigger PostScript file.

   COLOR - produces a color PostScript plot.

   LEDGER - selects ledger format (17x11; usefull mostly for color printer)

   XSIZE - the x size in inches of the plotting region

   YSIZE - the y size in inches of the plotting region

   MAXS -- Maximize the plot on a standard 8.5 x 11 page (JXP)


 See also:
    PS_Close

 History:
   23-Aug-93: added bpp=[2,4,8] option, with 8 bpp as default
   24-Aug-93: added support for /color, 
              and reduced the page size for QMS color printer
   16-Sep-93: added color flag to common block (see also PS_Close)
    9-Apr-94: added file name to info message
   11-Apr-94: added LEDGER support (see also PS_Close)
   28-Apr-94: added SQUARE, and fixed color portrait offset
    5-May-94: got /SQUARE to actually work
   25-Jun-94: added xsize and ysize keywords

(See General//ps_open.pro)


QALCHARSTRCT__DEFINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 qalcharstrct__define
   Version 1.1

 PURPOSE:
  Defines the QAL structure for SDSS
 
 CALLING SEQUENCE:
 tmp = {qalcharstrct}

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   30-Sep-2002 Written by JXP

(See SDSS/General//qalcharstrct__define.pro)


SDSS_CHKBAL[1]

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 sdss_chkbal
    Version 1.1

 PURPOSE:
  used to select the QSOs that have already been checked 
  for BALs (in 'oldqalfil') and update their values (in 'newqalfil').  
  The 'matchfil' is then fed to sdss_chkbal and those 
  QSOs are skipped.
 
 CALLING SEQUENCE:
  sdss_balupdate, oldqalfil, newqalfil, matchfil, SDSSPATH=sdsspath

 INPUTS:
  oldqalfil  -- Name of FITS file containing the previous QAL structure
  newqalfil  -- Name of FITS file containing the current QAL structure
  
 RETURNS:

 OUTPUTS:
  newqalfil --  With the 'flg_bal' info modified accordingly
  matchfil  --  Name of FITS file containing array of 'newqsofil'
                indices that matched

 OPTIONAL KEYWORDS:
  SDSSPATH --  maybe already set in .cshrc file, but just in case- a
               path to the data

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   sdss_balupdate, 'DR1_QSO/sdss_DR1_QAL.fits', $
      'DR2_QSO/sdss_DR2_QAL.fits', 'DR2_QSO/matched.fits'

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   07-Jun-2004 Written by SHF

(See SDSS/General//sdss_balupdate.pro)


SDSS_CHKBAL[2]

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 sdss_chkbal
    Version 1.1

 PURPOSE:
   GUI used to check for (and designate) BAL quasars from SDSS

 CALLING SEQUENCE:
   sdss_chkbal, qalfil, IQSO=, XSIZE=, YSIZE=, /RECHK

 INPUTS:
  qalfil  -- Name of FITS file containing the QAL structure

 RETURNS:

 OUTPUTS:
  qalfil --  With the BAL info modified accordingly

 OPTIONAL KEYWORDS:
   IQSO  -- Number of the first QSO to start with [default: 0L]
  /RECHK -- Only plot thos QSOs identified as BAL previously
   MATCHFIL -- to skip QSOs that have already been checked 
               (see sdss_balupdate.pro)

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   sdss_chkbal, 'DR2_QSO/sdss_DR2_QAL.fits', MATCHFIL='DR2_QSO/matched.fits'

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   05-Feb-2004 Written by JXP
   07-Jun-2004 Revised by SHF

(See SDSS/General//sdss_chkbal.pro)


SDSS_CHKDLA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 sdss_chkdla
    Version 1.1

 PURPOSE:
   Launches a GUI that is used to check the DLA candidates 
  (and metal-line systems) identified by the automated algorithm

 CALLING SEQUENCE:
 sdss_chkdla, qalfil, dlafil, con_dir, IQSO=, /FNEW, XSIZE=, YSIZE=

 INPUTS:
 qalfil  -- FITS file containing the QAL structure
 dlafil  -- FITS file containing the SDSS DLA structure (may be new) 
 con_dir -- Path to the directory containting the continuum files

 RETURNS:

 OUTPUTS:
 dlafil -- FITS file containing the SDSS DLA structure

 OPTIONAL KEYWORDS:
  /FNEW -- Start with first quasar that hasnt been checked
  OBJNM= --
  XSIZE -- Size of gui in screen x-pixels [default: screen-200]
  YSIZE -- Size of gui in screen y-pixels [default: screen-200]

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   sdss_chkdla, x, maskid, expsr


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   05-Oct-2003 Written by JXP

(See SDSS/DLA//sdss_chkdla.pro)


SDSS_CHKLLS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 sdss_chklls
    Version 1.1

 PURPOSE:
   GUI used to check the LLS candidates identified automatically. 
  Currently this is just a visual tool.  Nothing sensible is saved.

 CALLING SEQUENCE:
 sdss_chklls, qalfil, dlafil, con_dir, IQSO=iqso, FNEW=fnew, $
             XSIZE=xsize, L_YSIZE=i_ysize, M_YSIZE=s_ysize, $
             YSIZE=ysize

 INPUTS:
 qalfil  -- FITS file containing the QAL structure
 dlafil  -- FITS file containing the SDSS DLA structure (may be new) 
 con_dir -- Path to the directory containting the continuum files

 RETURNS:

 OUTPUTS:
 dlafil -- FITS file containing the SDSS DLA structure

 OPTIONAL KEYWORDS:
  /FNEW -- Start with first quasar that hasnt been checked
  OBJNM= --
  XSIZE -- Size of gui in screen x-pixels [default: screen-200]
  YSIZE -- Size of gui in screen y-pixels [default: screen-200]

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   sdss_chklls, 

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   05-Oct-2003 Written by JXP

(See SDSS/General//sdss_chklls.pro)


SDSS_CHKMGII

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 sdss_chkmgii
    Version 1.0

 PURPOSE:
   Visually check SDSS Mg II absorption

 CALLING SEQUENCE:
   
   sdss_chkmgii, x, maskid, expsr, XSIZE=, YSIZE=

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
   XSIZE      - Size of gui in screen x-pixels (default = 1000)
   YSIZE      - Size of gui in screen y-pixels (default = 600)

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   sdss_chkmgii, x, maskid, expsr


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   19-Dec-2003 Written by GEP/SHF

(See SDSS/MgII//sdss_chkmgii.pro)


SDSS_COMPARE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 sdss_compare
    Version 1.1

 PURPOSE:
  Given the structure containing DLA info, combine the values to
 create a final quality value.
   
 CALLING SEQUENCE:
   sdss_compare, strct, FSTRCT=

 INPUTS:
  strct -- QALstrct with the relevant info

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:
  FSTRCT=  -- Struct containing the combined values [required?]

 COMMENTS:

 EXAMPLES:
   sdss_chkbal, 'sdss_DR1_QAL.fits'

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   2003 Written by SHF

(See SDSS/General//sdss_compare.pro)


SDSS_COMPTST

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 sdss_comptst
    Version 1.1

 PURPOSE:
  Monte-carlo routine to check the completeness of our automoated
  algorithm
   
 CALLING SEQUENCE:
   sdss_comptst, fil, outfil, NTRIAL=, /CHK, /DEBUG

 INPUTS:
  fil -- SDSS spectrum (without a DLA present)

 RETURNS:

 OUTPUTS:
  outfil -- FITS file with the qalstrct

 OPTIONAL KEYWORDS:
  NTRIAL=  -- Number of simulations to run [default: 1000L]
  /CHK  -- Plot the spectrum
  /DEBUG -- 

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   sdss_comptst, '/data5/SDSS/DR1_QSO/spectro/1d/0463/0463-51312-122.fit',
    'monte_snr10.fits', NTRIAL=10000L

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   2003 Written by SHF

(See SDSS/General//sdss_comptst.pro)


SDSS_DLA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 sdss_dla
    Version 1.1

 PURPOSE:
  Main routine to search for DLA in SDSS spectra (or ESI).  This
  is the key driver of the N(HI) search for DLA.
   
 CALLING SEQUENCE:
  sdss_dla, n2=, ESI=, SDSS=, WIN_REST=, /PFLUX, /SMOOTH, /NORM, 
     SIGV=, STRCT=, ZEM=

 INPUTS:

 RETURNS:

 OUTPUTS:
  STRCT=  -- QAL structure created by this program

 OPTIONAL KEYWORDS:
  n2= -- Sigma value above which a pix is bad in the DLA profile [default: 5]
  SIGV= -- Sigma value to add to flux of all pixels
  SDSS= -- Name of SDSS file to examine
  /PFLUX  -- Plot the spectrum
  /SMOOTH -- Smooth the spectrum by 5 pixels
  /NORM   -- The flux is normalized
  WIN_REST -- Width of DLA window (angstroms)  [default: 6]

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   sdss_comptst, '/data5/SDSS/DR1_QSO/spectro/1d/0463/0463-51312-122.fit',
    'monte_snr10.fits', NTRIAL=10000L

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   2003 Written by SHF

(See SDSS/DLA//sdss_dla.pro)


SDSS_DLADX

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 sdss_dladx
  Version 1.1

 PURPOSE:
    Calculate the cosmological path length dX for a given
  cosmology for the sample of quasars searched for DLA in the SDSS.
  For now, the code defaults to point at all the DR1 values.

 CALLING SEQUENCE:
   dX = sdss_dladx(zmin, zmax, GZFIL=, XZFIL=)

 INPUTS:
   zmin -- Min redshift of the bin
   zmax -- Max redshift of the bin

 RETURNS:
   dX  -- The cosmological pathlength 

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /UNIQ -- 

 OPTIONAL OUTPUTS:

 COMMENTS:
   The program keys off the number of elements in v1

 EXAMPLES:
   writecol, 'arrays.dat', array1, array2


 PROCEDURES CALLED:

 REVISION HISTORY:
   15-March-2004 Written by JXP

(See SDSS/DLA//sdss_dladx.pro)


SDSS_DLA_2

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 sdss_dla_2
    Version 1.1

 PURPOSE:
  Main routine to search for DLA in SDSS spectra (or ESI).  This
  version is used primarily with the Monte-Carlo simulations.
   
 CALLING SEQUENCE:
  sdss_dla_2, flux, wave, sig, i, zabs, n1=, n2=, ESI=, $
               SDSS=, WIN_REST=, /PFLUX, /SMOOTH, /NORM, SIGV=, $
               STRCT=, ZEM=

 INPUTS:
  flux -- QSO flux array
  wave -- QSO wavelength array
  sig  -- QSO error array
  i    -- INDEX of QALstrct

 RETURNS:

 OUTPUTS:
  outfil -- FITS file with the qalstrct

 OPTIONAL KEYWORDS:
  n1= -- Sigma value below which a pix is good [default: code determines]
  n2= -- Sigma value above which a pix is bad in the DLA profile [default: 5]
  SIGV= -- Sigma value to add to flux of all pixels
  SDSS= -- Name of SDSS file to examine
  /PFLUX  -- Plot the spectrum
  WIN_REST -- Width of DLA window (angstroms)

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   sdss_comptst, '/data5/SDSS/DR1_QSO/spectro/1d/0463/0463-51312-122.fit',
    'monte_snr10.fits', NTRIAL=10000L

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   2003 Written by SHF

(See SDSS/DLA//sdss_dla_2.pro)


SDSS_DR1_GOZ

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 sdss_dr1_goz

 PURPOSE:
    Turns RA, DEC in XX:XX:XX.X -DD:DD:DD.D format to decimal deg
      or VICE VERSA

 CALLING SEQUENCE:
   
   x_radec, ra, dec, rad, decd, /ARCS, /FLIP

 INPUTS:
   ra, dec    - RA and DEC in in RR:RR:RR.R -DD:DD:DD.D format 
                 Colons are required as separators
   rad, decd  - RA and DEC in decimal degrees (double)

 RETURNS:

 OUTPUTS:
   ra, dec    - RA and DEC in in RR:RR:RR.R -DD:DD:DD.D format 
                 Colons are required as separators
   rad, decd  - RA and DEC in decimal degrees (double)

 OPTIONAL KEYWORDS:
   ARCS - Outputs in arcseconds
   FLIP - Gives RA and DEC from decimal RA,DEC

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_radec, '21:12:23.1', '-13:13:22.2', rad, decd

 PROCEDURES CALLED:

 REVISION HISTORY:
   27-Feb-2004 Written by SHF

(See SDSS/DLA//sdss_dr1_goz.pro)


SDSS_EWMGII

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 sdss_ewmgii
  Version 1.1

 PURPOSE:
  Measures the EW of the MgII lines (rest values) in the SDSS

 CALLING SEQUENCE:
  sdss_ewmgii, wave, flux, sig, strct, ZABS=

 INPUTS:
  wave  -- Wavelength array
  flux  -- Flux array (normalized)
  sig   -- Sigma array

 RETURNS:
  strct -- MgII structure with MgII EW filled up

 OUTPUTS:

 OPTIONAL KEYWORDS:
  ZABS=  -- Absorption redshift (required)

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES CALLED:

 REVISION HISTORY:
   27-Feb-2004 Written by JXP

(See SDSS/MgII//sdss_ewmgii.pro)


SDSS_FINCHK

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 sdss_finchk
    Version 1.1

 PURPOSE:
   GUI used to make a final check of metal-strong candidates

 CALLING SEQUENCE:
  sdss_finchk, dlafil, con_dir, MAG=mag, XSIZE=, YSIZE=, 
                 OUTFIL=outfil, RA=ra

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  MAG=  -- Largest magnitude to include in the check
  RA=   -- 2-element array giving constraint on RA

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   sdss_finchk, 'dla_dr1.fits', 'ABSLIN/'


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   05-Oct-2003 Written by JXP

(See SDSS/DLA//sdss_finchk.pro)


SDSS_FIX_REP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 sdss_fix_rep
    Version 1.1

 PURPOSE:
   Remove repeat entries from the 'checked' file of QAL.  Defaulted
  to deal with DR2 using dr2_bd.list

 CALLING SEQUENCE:
  sdss_fix_rep, fil=, bdlst=, new=new

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  FIL= -- File name of file including duplicates
  BDLST= -- List of indices which are to be removed
  NEW=   -- Name of new DR2_chkd file [default: 'DR2_chkd.fits']

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   Apr-2004 Written by SHF

(See SDSS/General//sdss_fix_rep.pro)


SDSS_METALS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 sdss_metals
    Version 1.1

 PURPOSE:
   Identify metal-line systems given a set of absorption lines

 CALLING SEQUENCE:
  sdss_metals, abswave, zem, WAVE=, FLUX=, QSTRCT=

 INPUTS:
  abswave -- Absorption line array
  zem     -- Emission redshift of the QSO

 RETURNS:

 OUTPUTS:
  QSTRCT= -- Structure containing the key output of this routine

 OPTIONAL KEYWORDS:
  WAVE= -- Wavelength array for plotting (not required)
  FLUX= -- Flux array for plutting (not required)
  

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   Apr-2004 Written by SHF

(See SDSS/General//sdss_metals.pro)


SDSS_MGIISEARCH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 sdss_mgiisearch   
    Version 1.0

 PURPOSE:
    Given an array of strings, return an array of unique values +
    number

 CALLING SEQUENCE:
   
 uniq = x_chkfil(strings, COUNT=count)

 INPUTS:
   strings - Array of strings

 RETURNS:
   uniq  - Array of unique members

 OUTPUTS:

 OPTIONAL KEYWORDS:
   sort - Sort the output

 OPTIONAL OUTPUTS:
  COUNT - number of unique strings

 COMMENTS:

 EXAMPLES:
   flg = x_chkfil( lbls, count=count)

lines_strct, '/data4/SDSS/DR1_QSO/dr1_fit.lst', 'sdss_DR1_QAL.fits',
  SDSSSUM='/data4/SDSS/DR1_QSO/summ_z04_R195.fit'

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   07-May-2002 Written by JXP

(See SDSS/MgII//sdss_mgiisearch.pro)


SDSS_OBJINF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 sdss_objinf   
    Version 1.1

 PURPOSE:
  Routine to quickly parse the SDSS database.    

 CALLING SEQUENCE:
 sdss_objinf, names, SUMMF=, /PLOT, DATDIR=, $
                FILNM=, CHKDF=, PATH=, ZEM=,$
                RMAG=, RA=, DEC=, /SILENT, /NMRAD

 INPUTS:
   names -- List of filenames or 2-element array giving plate and fiber

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  SUMMF=  -- Summary file [default: 'sdss2_qsoi205.fits']
  PATH=   -- Path to SDSS data [default: 'SDSSPATH'+'/DR2_QSO']
  DATDIR= -- Data directory [default: 'spectro/1d_23']
  /NMRAD  -- Input is ['RA:::', 'DED:::']

 OPTIONAL OUTPUTS:
  FILNM=  -- File name of the data
  RA=     -- RA of the QSO
  DEC=    -- DEC of the QSO

 COMMENTS:

 EXAMPLES:
  sdss_objinf, '0571-52286-276', /plot
  sdss_objinf, [463, 95], filnm=filnm
  sdss_objinf, ['12:00:21.3', '+32:22:12'], /nmrad

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   20-Nov-2003 Written by JXP

(See SDSS/General//sdss_objinf.pro)


SDSS_QSOLIN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 sdss_qsolin   
   Version 1.0

 PURPOSE:
    Fits a continuum to spectroscopic data interactively

 CALLING SEQUENCE:
   
   dla_sdssrich, fil

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   parse_sdss, fil
       sdss_qsolin, 'dr1_fit.lst', OUTDIR='ABSLIN/', /noplt

 PROCEDURES/FUNCTIONS CALLED:
 REVISION HISTORY:
   09-Sep-2003 Written by JXP

(See SDSS/General//sdss_qsolin.pro)


SDSS_REPEATS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 sdss_repeats   
    Version 1.1

 PURPOSE:
  Identify repeats in the checked file (default: DR2)

 CALLING SEQUENCE:
 sdss_repeats, fil

 INPUTS:
   fil  -- Name of checked file

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   Written by SHF

(See SDSS/General//sdss_repeats.pro)


SDSS_SEARCH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 sdss_search
    Version 1.1

 PURPOSE:
    Main program which drives the search for LLS, DLA and metal-line systems

 CALLING SEQUENCE:
  sdss_search, filename, outfil, ESIF=, SDSSSUM=, ZMIN=, $
                RMAX=, SDSSPATH=

 INPUTS:
  filename -- ASCII file listing all SDSS quasars

 RETURNS:

 OUTPUTS:
  outfil   -- Name of QAL file

 OPTIONAL KEYWORDS:
  ZMIN=  -- Minimum redshift to search
  RMAX=  -- Maximum magnitude to include [default: 21.]

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   flg = x_chkfil( lbls, count=count)

lines_strct, '/data4/SDSS/DR1_QSO/dr1_fit.lst', 'sdss_DR1_QAL.fits',
  SDSSSUM='/data4/SDSS/DR1_QSO/summ_z04_R195.fit'

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   07-May-2002 Written by JXP

(See SDSS/DLA//sdss_search.pro)


SDSS_WAVE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 sdss_wave
    Version 1.1

 PURPOSE:
    Create a wavelength array for SDSS data out (for practice only!)

 CALLING SEQUENCE:
  sdss_wave, wave, pxiels=, iwave=

 INPUTS:

 RETURNS:
  wave -- Wavelength array

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   Written by SHF

(See SDSS/General//sdss_wave.pro)


SPECOBJSTRCT__DEFINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 specobjstrct__define
   Version 1.1

 PURPOSE:
  This routine creates a structure to describe the spectrum for an
  object in a given slit

 CALLING SEQUENCE:
   tmp = {specobjstrct}

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
  Written by JXP

(See Spec/Slits//specobjstrct__define.pro)


STDSTRUCT__DEFINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 stdstruct__define
   Version 1.1

 PURPOSE:
   Structure to handle observations of Standard stars

 CALLING SEQUENCE:
  tmp = {stdstruct}

 INPUTS:

 RETURNS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   07-Aug-2001 Written by JXP

(See IMG/Photometry//stdstruct__define.pro)


STRCTCLDY__DEFINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 strctcldy__define
  V1.1

 PURPOSE:
    Named IDL Structure for Cloudy output
 CALLING SEQUENCE:
   
   tmp = {strctcldy}

 REVISION HISTORY:
   31-May-2001 Written by JXP

(See Cloudy//strctcldy__define.pro)


TRACESTRCT__DEFINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 tracestrct__define
   Version 1.1

 PURPOSE:
  This routine defines the trace structure
  Not in use

 CALLING SEQUENCE:
   tmp = {tracestrct}

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
  Written by JXP

(See Spec/Rectify//tracestrct__define.pro)


VELPLTSTRCT__DEFINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 velpltstrct__define
   Version 1.1

 PURPOSE:
  Structure that is useful for velocity plots

 CALLING SEQUENCE:
   tmp = {velpltstrct}

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
  Written by JXP

(See Spec/Lines//velpltstrct__define.pro)


VOIGTQ

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 voigtq
    Version 1.0

 PURPOSE:
    Creates a quick Voigt profile using code written by SB.
   Not recommended for usage

 CALLING SEQUENCE:
   
 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   07-Feb-2002 Written by JXP

(See Spec/Voigt//voigtq.pro)


VOIGTWAL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
   voigtwal

 PURPOSE:
   Calculate a single voigt profile, given wavelength, absorber, and
    an array of lines.  I recommend x_voigt

 CALLING SEQUENCE:
   tau = voigtwal(wave,abs,lines)

 INPUTS:
   wave       - Array of wavelengths to realize voigt profile
   abs        - single absorber
   lines      - line(s) structure to compute voigt profile, if mutliple,
                   the entire list will be looped through.

 OUTPUTS:
   tau        - Optical depth at each wavelength

 OPTIONAL OUTPUTS:

 COMMENTS:

  Line is a structure with:

 ** Structure <81a5f94>, 4 tags, length=24, refs=3:
    ION             STRING    'H I'
    WAVE            DOUBLE           1215.6701
    F               FLOAT          0.416400
    GAMMA           FLOAT       6.26500e+08

  Abs must have at least :

** Structure ABS, 10 tags, length=44:
   N               FLOAT           15.0000   	log 10 Column density
   B               FLOAT           5.00000     velocity dispersion (km/s)
   Z               FLOAT           2.00000	redshift

 EXAMPLES:

 BUGS:

 PROCEDURES CALLED:

 REVISION HISTORY:
   25-May-2000  Created by S. Burles, FNAL/IAP

(See Spec/Voigt//voigtwal.pro)


WRITECOL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 writecol
  Version 1.1

 PURPOSE:
    Prints a series of arrays to a file in ASCII format

 CALLING SEQUENCE:
   
   writecol, filename, v1, v2, FMT=''

 INPUTS:
   file     - Name of the ASCII file
   v1       - Vector 1
   v2       - Vector 2
   [v3-v19]       - Vectors 3-14

 RETURNS:

 OUTPUTS:
   Prints v1, v2 to screen

 OPTIONAL KEYWORDS:
   FMT -  FORTRAN formatting
   FILNUM - File number (as opposed to file)

 OPTIONAL OUTPUTS:

 COMMENTS:
   The program keys off the number of elements in v1

 EXAMPLES:
   writecol, 'arrays.dat', array1, array2


 PROCEDURES CALLED:

 REVISION HISTORY:
   17-June-2001 Written by JXP

(See General//writecol.pro)


WRITE_DIMGSTR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 write_dimgstr   
    Version 1.1

 PURPOSE:
    Write a dimg_struct (direct image) to an ASCII file and/or FITS file

 CALLING SEQUENCE:
   
  write_dimgstr, struct, ANONLY=anonly, OUTFIL=outfil, FITS=fits

 INPUTS:
   struct        - A dimg_struct

 RETURNS:

 OUTPUTS:
   OUTFIL  - Output file for ASCII [default is image.list]

 OPTIONAL KEYWORDS:
   /ANONLY - Only print files with flg_anly NE 0   
   FITS=   - Fits file output for the structure

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   write_dimgstr, nght1_strct

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   18-July-2001 Written by JXP
   29-Dec-2001 Added fits option

(See IMG/General//write_dimgstr.pro)


X1DFIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x1dfit   
   Version 1.3

 PURPOSE:
    GUI for fitting a function to a set of x,y data.  This
    program does far too much!  Warning:  This was one of my first
    GUIs.  It works pretty well, but is a bit old.

 CALLING SEQUENCE:
   
   fit = x1dfit([xdat],ydat,func=,nord=, /inter, xsize=, ysize=)

 INPUTS:
   xdat       - Values along one dimension [optional]
   ydat       - Values along the other

 RETURNS:
   fit        - Values at each xdat

 OUTPUTS:

 OPTIONAL KEYWORDS:
   func       - String for Fitting function (POLY, LEGEND, BSPLINE,
                GAUSS, CHEBY)
   nord       - Order of the fit
   /inter      - Interactive fitting
   xsize      - Draw window xsize (pixels)
   ysize      - Draw window ysize (pixels)
   sig        - Errors in the points
   reg        - Regions of data to fit
   LSIG       - Lower SIGMA
   HSIG       - High SIGMA
   /REJ        - Turn rejection on
   DELPTS     - Array of user-deleted points
   MSK        - Array of 0,1 values [0=do not include]

 OPTIONAL OUTPUTS:
   bset       - Bspline info
   rms        - RMS of the fit (only valid for fits with rejection)

 COMMENTS:

 EXAMPLES:
   fit = x1dfit(x, y, 'POLY', nord=5, /inter)


 PROCEDURES/FUNCTIONS CALLED:
  POLY_FIT
  POLY
  SVDFIT
  SVLEG
  BSPLINE
  GAUSS
  XGETX_PLT
  XGETY_PLT
  XGETXPIX_PLT
  XGETYPIX_PLT
  GETCOLOR (coyote package)

 REVISION HISTORY:
   22-June-2001 Written by JXP
   28-June-2001 Added LEGENDRE fits (JXP)
   23-Nov-2001 Added BSPLIN (SB), GAUSS, REJECTION (JXP)
   31-Jan-2002 Added CHEBYSHEV

(See FIT//x1dfit.pro)


XCOMBINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xcombine   
   Version 1.2  

 PURPOSE:
    Combines a set of images with a variety of options.

 CALLING SEQUENCE:
   
   xcombine, img, comb, [header], FCOMB=, GAIN=, RN=, MASKS=, SCALE=,
     STATSEC=, MMEM=, SIGHI=, SIGLO=, MXITER=, OUTNM=, /SILENT, 
     WEIGHT=, IMGINDX=

 INPUTS:
   img -- Array of image names

 RETURNS:

 OUTPUTS:
   comb -- Combined image

 OPTIONAL KEYWORDS:
   fcomb -- Binary keyword describing combine method 
          0,1 = Median, Avg
          2 = SIG Rej
          4 = Masks
          8 = Weight
   mmem -- Maximum memory to use at any one time [default: Approx 200Mb]
   outnm -- File to write combined fits image
   gain -- Gain (required for SIGMEDCLIP)
   rn -- ReadNoise (required for SIGMEDCLIP)
   scale -- scale:  Could be array of floats, 'MED', 'AVG', or
            Keyword
   statsec -- Section to perform stats on (for scale)
   imgindx -- Index number of image [default: 0L]
   siglo  -- Lower sigma for rejection [default: 3.]
   sighi  -- Upper sigma for rejection [default: 3.]
   

 OPTIONAL OUTPUTS:
   header -- Header of one of the files

 COMMENTS:

 EXAMPLES:
   xcombine, all_img, comb_img


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   18-Jul-2001 Written by JXP
   28-Jul-2001 Added masks, sigma clipping
   29-Jul-2001 Added scaling, median routines
   07-Jan-2002 Fixed memory leak

(See IMG/Reduction//xcombine.pro)


XCPS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xcps
    Version 1.1

 PURPOSE:
    Close the ps file and reset to x windows

 CALLING SEQUENCE:
   
 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   17-Nov-2001 Written by JXP

(See General//xcps.pro)


XDIMG_AR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xdimg_ar   
     Version 1.1

 PURPOSE:
   Reads in the first file in the directory with 'xdimg*fits'

 CALLING SEQUENCE:
  xdimg = xdimg_ar()

 INPUTS:

 RETURNS:
    xdimg -  WFCCD structure

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   xdimg = xdimg_ar()


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   13-Nov-2001 Written by JXP

(See IMG/General//xdimg_ar.pro)


XDIMG_BIAS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xdimg_bias   
    Version 1.1

 PURPOSE:
    Creates Bias frame given direct image structure (which must
   contain a number of bias files!)

 CALLING SEQUENCE:
   
   xdimg_bias, struct, /SVOV, OUTFIL=

 INPUTS:
   struct -- dimg_strct defining the images of interest

 RETURNS:

 OUTPUTS:
   OUTFIL - Name of Bias file [default is 'Bias/Bias.fits']

 OPTIONAL KEYWORDS:
   SVOV - Save ov files (default is to delete them)

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   xdimg_bias, nght1_strct


 PROCEDURES/FUNCTIONS CALLED:
  XDIMG_OVER
  XCOMBINE
  MWRFITS
  XDIMG_DELOV

 REVISION HISTORY:
   26-July-2001 Written by JXP

(See IMG/Reduction//xdimg_bias.pro)


XDIMG_DELOV

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xdimg_delov
     Version 1.1

 PURPOSE:
   Delete a set of OV images

 CALLING SEQUENCE:
  xdimg_delov, strct, delimg

 INPUTS:
   strct  -- Direct image structure
   delimg -- Indices of direct images

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   13-Nov-2001 Written by JXP

(See IMG/General//xdimg_delov.pro)


XDIMG_DFLAT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xdimg_dflat   
  Version 1.1

 PURPOSE:
    Creates dome flats given the direct image structure (assuming
  there are dome flats in the structure)

 CALLING SEQUENCE:
   
   xdimg_dflat, struct, /SVOV, OUTROOT=, /ALLOUT

 INPUTS:
   struct -- dimg_strct defining the images of interest

 RETURNS:

 OUTPUTS:
   flats - fits files in the dir Flats; 1 per filter

 OPTIONAL KEYWORDS:
   /SVOV   - save ov files
   OUTROOT - Root name of Dome flats (default is 'Flats/DFlat')
   /ALLOUT - Output unnormalized frame too

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   xdimg_dflat, nght1_strct


 PROCEDURES/FUNCTIONS CALLED:
  XDIMG_OVER
  XCOMBINE
  MWRFITS
  XDIMG_DELOV
  X_FILTERS

 REVISION HISTORY:
   18-July-2001 Written by JXP
   24-Apr-2002 Allow for non-linearity

(See IMG/Reduction//xdimg_dflat.pro)


XDIMG_NONLINEAR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xdimg_nonlinear   
  Version 1.0

 PURPOSE:
    Performs non-linear correction on a ccd image.  Only setup
   for SITe3 at this point.

 CALLING SEQUENCE:
   newimg = xdimg_nonlinear(img, ccd)

 INPUTS:
    img  -  image
    ccd  -  (SITe3)

 RETURNS:
    newimg - Corrected image

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   newimg = xdimg_nonlinear(img, 'SITe3')


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   24-Apr-2002 Written by JXP

(See IMG/Reduction//xdimg_nonlinear.pro)


XDIMG_OBJMSK

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xdimg_objmsk   
   Version 1.0

 PURPOSE:
    Builds a sky mask for each input image using xmkmask, an 
      IDL gui built for this procedure.

 CALLING SEQUENCE:
   xdimg_skymask, struct, objimg, XSIZE=, YSIZE=, IMSK=

 INPUTS:
   struct -- dimg_strct defining the images of interest
   objimg   -- integer array defining the images to mask

 RETURNS:

 OUTPUTS:
   skymasks --  Builds sky masks and puts them into 'Masks/Sky/'

 OPTIONAL KEYWORDS:
   XSIZE, YSIZE -- Size of GUI

 OPTIONAL OUTPUTS:
  IMSK -- Image of mask

 COMMENTS:

 EXAMPLES:
   xdimg_objmsk, nght1_strct, objimg


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   14-Oct-2002 Written by JXP

(See IMG/Reduction//xdimg_objmsk.pro)


XDIMG_OVER

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xdimg_over   
        Version 1.1

 PURPOSE:
    Overscan subtracts a list of images of a structure.  Calls
  routine xoverscan extensively.

 CALLING SEQUENCE:
   
   xdimg_over, struct, imgs, ORDR=, /ERASE, /INTER, /NOSV

 INPUTS:
   struct -- dimg_strct defining the images of interest
   imgs   -- integer array defining the images to process

 RETURNS:

 OUTPUTS:
   ovimg - fits files in the dir OV

 OPTIONAL KEYWORDS:
   /erase - Erase pre-existing ov files
   /inter - Interactive OV fitting (uses x1dfit)
   /nosv  -- Dont save the OV image!
   ORDR=  -- Order to fit the overscan

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   xdimg_over, nght1_strct, ovimg


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   22-July-2001 Written by JXP

(See IMG/Reduction//xdimg_over.pro)


XDIMG_PHOTCAL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xdimg_photcal   
   Version 1.1

 PURPOSE:
    Drives the program x_intphotcal which allows the user to 
      interactively create photometric solutions.

 CALLING SEQUENCE:
   
   xdimg_photcal, struct, LNDTFIL=, SETAM=, XSIZE=, YSIZE=, MIN_NOBS=
     MIN_MOBS=, SETAM=, OUTROOT=, MAGROOT=, /NCLR

 INPUTS:
   struct -- dimg_strct defining the images of interest.  This
             program focuses on the STD frames only.

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  LNDTFIL  = Filename of landolt fits file [default:
        $XIDL_DIR/IMG/Photometry/Lists/nlandolt.fits ]
  SETAM    = AM terms (one per filter: UBVRI)
  MIN_MOBS = Minimum number of nights observed by Landolt (default=2)
  MIN_NOBS = Minimum number of observations by Landolt (default=4)
  XSIZE=   - Size of gui in screen x-pixels (default = 1000)
  YSIZE=   - Size of gui in screen y-pixels (default = 600)
  OUTROOT  - Root name of Twilight flats (default is 'Photo/soln_')

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   xdimg_photcal, dimg


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   07-Aug-2001 Written by JXP

(See IMG/Photometry//xdimg_photcal.pro)


XDIMG_PROC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xdimg_proc   
    Version 1.1

 PURPOSE:
    Processes a set of images  (OV, TRIM, FLAT)

 CALLING SEQUENCE:
   
   xdimg_proc, struct, img, flat, OUTPTH=, /INTER, /DELOV, /NOGAIN
     /SILENT, MSK=

 INPUTS:
   struct -- dimg_strct defining the images of interest
   img    -- intarr of images to process
   flatnm -- Flat root to use (e.g. 'Flats/SkyFltN')

 RETURNS:

 OUTPUTS:
   Processed image (e.g. Final/f_ccd001.fits)

 OPTIONAL KEYWORDS:
  OUTPTH  =  Output directory (default = 'Final/')
  /INTER  =  Interactive OV fitting
  /DELOV  =  Delete ov files when through
  MSK     =  Default name for mask file
  /NOGAIN =  Do not apply the gain

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   xdimg_proc, dimg, STDS, 'Flats/SkyFltN'


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   03-Aug-2001 Written by JXP
   03-Jan-2002 Dealt with Gain

(See IMG/Reduction//xdimg_proc.pro)


XDIMG_SKYFLT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xdimg_skyflt   
   Version 1.1

 PURPOSE:
    Creates Super-sky flat given the image list structure.  
    The routine first OV subtracts each image as necessary.
    It then calls xdimg_skymask create masks for each of the images.
    It then calls xcombine which: (1) scales each image 
    by the median calculated for the OV image (2) does a median
    combine with 3sigma/2.5sigma (low/high) clipping.

 CALLING SEQUENCE:
   
   xdimg_skyflt, struct, MMEM=, /NOMSK, /INTER

 INPUTS:
   struct -- dimg_strct defining the images of interest

 RETURNS:

 OUTPUTS:
   skyflt - fits files; 1 per filter

 OPTIONAL KEYWORDS:
  MMEM - Max memory to use with this routine (default = 200M)
  NOMSK - Don't create new masks
  OUTROOT - Root name of Sky flats (default is 'Flats/SkyFlt')
  INTER - Interactive OV subtraction

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   xdimg_skyflt, nght1_strct


 PROCEDURES/FUNCTIONS CALLED:
  XDIMG_OVER
  XCOMBINE
  MWRFITS
  XDIMG_DELOV
  X_FILTERS
  XDIMG_SKYMASK

 REVISION HISTORY:
   26-July-2001 Written by JXP
   24-Apr-2002 Added nonlinearity correction

(See IMG/Reduction//xdimg_skyflt.pro)


XDIMG_SKYMSK

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xdimg_skymsk   
   Version 1.1

 PURPOSE:
    Builds a sky mask for each input image using xmkmask, an 
      IDL gui built for this procedure.

 CALLING SEQUENCE:
   
   xdimg_skymask, struct, objimg, /ERASE, /DOOV, XSIZE=, YSIZE=

 INPUTS:
   struct -- dimg_strct defining the images of interest
   objimg   -- integer array defining the images to mask

 RETURNS:

 OUTPUTS:
   skymasks --  Builds sky masks and puts them into 'Masks/Sky/'

 OPTIONAL KEYWORDS:
   erase - Erase pre-existing sky masks first
   doov - Make OV files as necessary

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   xdimg_skymsk, nght1_strct, objimg


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   26-July-2001 Written by JXP

(See IMG/Reduction//xdimg_skymsk.pro)


XDIMG_STARID

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xdimg_starid   
   Version 1.1

 PURPOSE:
    Helps identify standard stars in a field by driving the program
     x_starid which is an interactive, GUI program.

 CALLING SEQUENCE:
   
   xdimg_starid, struct, LST_PATH=, INDX=

 INPUTS:
   struct -- dimg_strct defining the images of interest.  This
             program focuses on the STD frames only.

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
   LST_PATH   - Path name for Lists (default: Take x_starid default)
   OUT_PATH   - Output name for id files (default: 'Photo/')

 OPTIONAL OUTPUTS:
   INDX -- Subset of indices for standards to fit

 COMMENTS:

 EXAMPLES:
   xdimg_starid, strct

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   07-Aug-2001 Written by JXP
   08-Jan-2002 Added paths (JXP)
   14-Oct-2002 Added indx (JXP)

(See IMG/Photometry//xdimg_starid.pro)


XDIMG_STDMAG

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xdimg_stdmag   
   Version 1.1

 PURPOSE:
    Does aperture photometry on the objects in the std_* lists.
   Drives the program x_aper

 CALLING SEQUENCE:
   xdimg_stdmag, struct, SKYR=, STRROOT=, OUTROOT=

 INPUTS:
   struct -- dimg_strct defining the images of interest.  This
             program focuses on the STD frames only.

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  SKYR =  2 float array describing sky annulus in arcsec
            (default=15,30)
  STRROOT=  Path for standard stars [default: 'Photo/std_']
  OUTROOT=  Path for output of magnitudes [default: 'Photo/mag_']

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   xdimg_stdmag, dimg


 PROCEDURES/FUNCTIONS CALLED:
  X_APER
  X_CCDINF

 REVISION HISTORY:
   07-Aug-2001 Written by JXP

(See IMG/Photometry//xdimg_stdmag.pro)


XDIMG_STRCT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xdimg_strct   
     Version 1.2

 PURPOSE:
    Creates and outputs a structure for a series of direct images.
  This is a key routine in organizing a night of imaging data.

 CALLING SEQUENCE:
   
  xdimg_strct, struct, ccd, tel, LIST=, /MKDIR, /NOFILE

 INPUTS:
   CCD        - CCD/INSTRUMENT;  Options: Tek5, LRISR, SITe1, SITe3
   tel        - Telescope; Options: (Keck, LCO-40, LCO-100)

 RETURNS:

 OUTPUTS:
   struct     -  Creates an IDL structure for direct images 
               +  an ASCII file summarizing the structure
               +  a FITS file saving the IDL structure

 OPTIONAL KEYWORDS:
   LIST       - Image list [default is Raw/*.fits]
   /NOFILE     - Do not create the ASCII file
   /MKDIR      - Create a set of directories which facilitate the rest
                    of the reduction process (e.g. Flats/ Bias/
                    Photo/)

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   xdimg_strct, nght1_strct, 'Tek5', /MKDIR

 PROCEDURES/FUNCTIONS CALLED:
   MRDFITS
   SXPAR
   X_SETJDATE
   MWRFITS
   WRITE_DIMGSTR

 REVISION HISTORY:
   18-July-2001 Written by JXP
   22-Aug-2001  Allows for LRISR
   24-Dec-2001  LRISR modifications

(See IMG/General//xdimg_strct.pro)


XDIMG_TWIFLT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xdimg_twiflt   
  Version 1.1

 PURPOSE:
    Creates twilight flats given the image list structure (assuming
     twilight flats were taken!)

 CALLING SEQUENCE:
   
   xdimg_twiflt, struct, /SVOV, OUTROOT=

 INPUTS:
   struct -- 'distruct' defining the images of interest

 RETURNS:

 OUTPUTS:
   twiflats - fits files; 1 per filter

 OPTIONAL KEYWORDS:
   SVOV - Save ov files
   OUTROOT - Root name of Twilight flats (default is 'Flats/TwiFlat')

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   xdimg_twiflt, nght1_strct


 PROCEDURES/FUNCTIONS CALLED:
  XDIMG_OVER
  XCOMBINE
  MWRFITS
  XDIMG_DELOV
  X_FILTERS

 REVISION HISTORY:
   26-July-2001 Written by JXP
   24-Apr-2002 Added nonlinearity correction

(See IMG/Reduction//xdimg_twiflt.pro)


XDIMG_UPDSTR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xdimg_updstr   
   Version 1.1

 PURPOSE:
    Looks around for OV and other images and resets the appropriate
   flags.

 CALLING SEQUENCE:
  xdimg_updstr, strct, /REDOMED

 INPUTS:
   strct -- Direct Image strcure DISTRUCT

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   xdimg_updstr, struct


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   07-Aug-2001 Written by JXP

(See IMG/General//xdimg_updstr.pro)


XGETX_PLT[1]

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xgetx_plt
    Version 1.1

 PURPOSE:
  Returns the x-value corresponding to the x-pixel on a GUI.
   Requires pos, xymnx or the appropriate Structure.

 CALLING SEQUENCE:
  xval = xgetx_plt(xtmp, pos, xymnx, size, /STRCT)
   
 INPUTS:
  xtmp -- x-pixel value
  pos  -- Fraction of plot window covered by plot (2 element array)
  xymnx -- x-y limits of plot window (4 element array: x0,y0,x1,y1)

 RETURNS:
   xval -- 

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /STRCT -- xtmp contains a structure with the relevant tags

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   uniq = x_uniqstr( lbls, count=count)


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   17-Nov-2001 Written by JXP

(See General//xgetx_plt.pro)


XGETX_PLT[2]

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xgetx_plt
    Version 1.1

 PURPOSE:
  Returns the x-pixel value corresponding to the x-value.
   Requires pos, xymnx or the appropriate Structure.

 CALLING SEQUENCE:
  xpix = xgetx_plt(xtmp, pos, xymnx, size, /STRCT)
   
 INPUTS:
  xtmp -- x-pixel value
  pos  -- Fraction of plot window covered by plot (2 element array)
  xymnx -- x-y limits of plot window (4 element array: x0,y0,x1,y1)

 RETURNS:
   xpix -- 

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /STRCT -- xtmp contains a structure with the relevant tags

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   17-Nov-2001 Written by JXP

(See General//xgetxpix_plt.pro)


XGETX_PLT[2]

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xgetx_plt
    Version 1.1

 PURPOSE:
  Returns the y-value corresponding to the y-pixel on a GUI.
   Requires pos, xymnx or the appropriate Structure.

 CALLING SEQUENCE:
  yval = xgety_plt(ytmp, pos, xymnx, size, /STRCT)
   
 INPUTS:
  ytmp -- y-pixel value
  pos  -- Fraction of plot window covered by plot (2 element array)
  xymnx -- x-y limits of plot window (4 element array: x0,y0,x1,y1)

 RETURNS:
   yval -- 

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /STRCT -- ytmp contains a structure with the relevant tags

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   uniq = x_uniqstr( lbls, count=count)


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   17-Nov-2001 Written by JXP

(See General//xgety_plt.pro)


XGETY_PLT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xgety_plt
    Version 1.1

 PURPOSE:
  Returns the y-pixel corresponding to the y-value on a GUI.
   Requires pos, xymnx or the appropriate Structure.

 CALLING SEQUENCE:
  yval = xgety_plt(ytmp, pos, xymnx, size, /STRCT)
   
 INPUTS:
  ytmp -- y-pixel value
  pos  -- Fraction of plot window covered by plot (2 element array)
  xymnx -- x-y limits of plot window (4 element array: x0,y0,x1,y1)

 RETURNS:
   yval -- 

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /STRCT -- ytmp contains a structure with the relevant tags

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   uniq = x_uniqstr( lbls, count=count)


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   17-Nov-2001 Written by JXP

(See General//xgetypix_plt.pro)


XHEADFITS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xheadfits
   Version 1.1

 PURPOSE:
    Uses headfits to read the header of a fits file.  The only
   advantage of xheadfits is that the file can be compressed and
   yet the filename may be named without the gz extension.

 CALLING SEQUENCE:
   head = xheadfits(fil, _EXTRA)

 INPUTS:
   fil -- FITS Filename

 RETURNS:
   head -- Header

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   head = xheadfits('spec.fits')

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   17-Sep-2002 Written by JXP

(See General//xheadfits.pro)


XMKMASK

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xmkmask   
   Version 1.1

 PURPOSE:
    Allows the user to interactively choose pixels to mask in an
    image.  The resulting images are saved as gzipped fits images.

 CALLING SEQUENCE:
   
   xmkmask, img, IMSK=, OUTDIR=, XSIZE=, YSIZE=, /SKYMSK

 INPUTS:
   img        - Image(s) for Masking

 RETURNS:

 OUTPUTS:
   mask       -  Creates a fits table of pixel values to mask

 OPTIONAL KEYWORDS:
   outdir     - Output directory: Default = './Masks/'
   IMSK       - Initial mask to include; Convenient for dealing with
                  bad columns and the like in the CCD
   XSIZE      - Size of gui in screen x-pixels (default = 700)
   YSIZE      - Size of gui in screen y-pixels (default = 700)
   SKYMSK     - Create sky mask (default into Masks/Sky/)

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   xmkmask,'OV/ccd001.fits'


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   11-July-2001 Written by JXP

(See IMG/Reduction//xmkmask.pro)


XMRDFITS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xmrdfits
   Version 1.1

 PURPOSE:
    Uses mrdfits to read the header of a fits file.  The only
   advantage of xheadfits is that the file can be compressed and
   yet the filename may be named without the gz extension.

 CALLING SEQUENCE:
   
   dat = xmrdfits(fil, [extension, header], _EXTRA)

 INPUTS:
   fil -- FITS Filename
   [extension] -- Extension of the data array

 RETURNS:
   dat  - Data array

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:
  header -- Header of the FITS extension

 COMMENTS:

 EXAMPLES:
   dat = xmrdfits('spec.fits')

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   17-Sep-2002 Written by JXP

(See General//xmrdfits.pro)


XOFFSET

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xoffset
   Version 1.1

 PURPOSE:
    Calculates integer offsets between a series of images.  The
  program uses Sextractor to find objects in the image and then
  uses a brute force algorithm to find the integer offset.

 CALLING SEQUENCE:
   
   xoffset, imglist, INSTR=

 INPUTS:
   imglist    - List of images

 RETURNS:

 OUTPUTS:
   offsets    -  ASCII file with offsets

 OPTIONAL KEYWORDS:
   INSTR      - Instrument keyword
   

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   xoffset, 'offR.list', INSTR='SITe3'


 PROCEDURES CALLED:

 REVISION HISTORY:
   26-Apr-2001 Written by JXP

(See IMG/Reduction//xoffset.pro)


XOVERSCAN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xoverscan
   Version 1.2

 PURPOSE:
    Subtracts an overscan region from an image

 CALLING SEQUENCE:
   
   xoverscan, img, ccd, [medov], OVSEC=, OVROOT=, /INTER, /ERASE
    OVIMG=, /NOFITS, /SILENT, /MEDONLY, /COMPRESS, TRIMSEC=

 INPUTS:
   img        - Raw fits file
   ccd        - CCD name (Tek5, SITe1, LRISR, LRISb, GEN, WFTek5,
                SITe3)

 RETURNS:

 OUTPUTS:
   nwimg      - Writes overscan subtracted image to OV directory
                  with an ov_ prefix (default)

 OPTIONAL KEYWORDS:
   func       - String defining function to fit with (POLY is
                default)
   ordr       - Order of the function
   ovsec      - String defining overscan section
   ovroot     - String for OV root ('OV/' is the default)
   erase      - Erase pre-existing ov files
   NOFITS     - Suppress output to fits file
   MEDONLY    - Useful in updating distruct
   /COMPRESS  - Spawn gzip on the output image
   TRIMSEC    - Image region to trim to
   

 OPTIONAL OUTPUTS:
   medov      - Median of each OV image
   OVIMG      - Float array of OV image

 COMMENTS:

 EXAMPLES:
   xoverscan, 'ccd001.fits', 'Tek5'


 PROCEDURES CALLED:
  xregtovec
  djs_median
  x1dfit

 REVISION HISTORY:
   20-June-2001 Written by JXP
   05-Dec-2001  Added OVIMG option

(See IMG/Reduction//xoverscan.pro)


XPIX_CIRC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xpix_circ
   Version 1.1

 PURPOSE:
  Finds all pixels within a circle on an image.

 CALLING SEQUENCE:
   pval = xpix_circ(x0, y0, radius, /NOZERO, MAXX=, MAXY=, COUNT=)

 INPUTS:
   x0 -- Circle x position
   y0 -- Circle y position
   radius -- Radius of the circle

 RETURNS:
  pval -- pixels in the circle:  array[2,npt]

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /NOZERO -- Disallow value of 0 (minimum is 1 instead)

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   17-Sep-2002 Written by JXP

(See General//xpix_circ.pro)


XPIX_LINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xpix_line
   Version 1.1

 PURPOSE:
  Finds all pixels within a ray (or line) of specified width.

 CALLING SEQUENCE:
   pval = xpix_line(x0, y0, x1, y1, wid, xmax, ymax, /NOZERO, COUNT=)

 INPUTS:
   x0 -- x position of one point on the ray
   y0 -- y position of one point on the ray
   x1 -- x position of one point on the ray
   y1 -- y position of one point on the ray
   wid -- Width of the line

 RETURNS:
  pval -- pixels in the circle:  array[2,npt]

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /NOZERO -- Disallow value of 0 (minimum is 1 instead)
  COUNT=  -- Number of the pixels in the ray

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   17-Sep-2002 Written by JXP

(See General//xpix_line.pro)


XREGTOVEC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xregtovec
   Version 1.1

 PURPOSE:
    Converts a string region into a vector for an image

 CALLING SEQUENCE:
   
   vect = xregtovec(sreg, size)

 INPUTS:
   string     - String defining the region (e.g. '[1:10,*]')
   size       - Size of the image

 RETURNS:
   vect       - Integer vector defining the region in sreg

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   area = xregtovec('[1:10,*]',size(img))

 PROCEDURES CALLED:

 REVISION HISTORY:
   21-June-2001 Written by JXP

(See IMG/Reduction//xregtovec.pro)


XSP1DSTRCT__DEFINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 xsp1dstrct__define
    Version 1.0

 PURPOSE:
  This routine defines the structure for individual object spectra

 CALLING SEQUENCE:
   tmp = {xsp1dstrct}

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   02-Aug-2002 Written by JXP

(See Spec/Analysis//xsp1dstrct__define.pro)


XSPLINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	XSPLINE 
    -- Copied version of the RSI program

 PURPOSE:
	This function performs cubic spline interpolation.

 CATEGORY:
	Interpolation - E1.

 CALLING SEQUENCE:
	Result = SPLINE(X, Y, T [, Sigma])

 INPUTS:
	X:	The abcissa vector. Values MUST be monotonically increasing.

	Y:	The vector of ordinate values corresponding to X.

	T:	The vector of abcissae values for which the ordinate is 
		desired. The values of T MUST be monotonically increasing.

 OPTIONAL INPUT PARAMETERS:
	Sigma:	The amount of "tension" that is applied to the curve. The 
		default value is 1.0. If sigma is close to 0, (e.g., .01),
		then effectively there is a cubic spline fit. If sigma
		is large, (e.g., greater than 10), then the fit will be like
		a polynomial interpolation.

 OUTPUTS:
	SPLINE returns a vector of interpolated ordinates.
	Result(i) = value of the function at T(i).

 RESTRICTIONS:
	Abcissa values must be monotonically increasing.

 EXAMPLE:
	The commands below show a typical use of SPLINE:

		X = [2.,3.,4.]  	;X values of original function
		Y = (X-3)^2     	;Make a quadratic
		T = FINDGEN(20)/10.+2 	;Values for interpolated points.
					;twenty values from 2 to 3.9.
		Z = SPLINE(X,Y,T) 	;Do the interpolation.



 MODIFICATION HISTORY:
	Author:	Walter W. Jones, Naval Research Laboratory, Sept 26, 1976.
	Reviewer: Sidney Prahl, Texas Instruments.
	Adapted for IDL: DMS, Research Systems, March, 1983.

(See General//xspline.pro)


X_ADDIMG

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_addimg
   Version 1.1

 PURPOSE:
    Combines a set of images.  I think this routine is entirely
  superseded by xcombine.

 CALLING SEQUENCE:
   
   x_addimg, img, comb, var, SCALE=, WEIGHT=, IMGINDX=, VARINDX=

 INPUTS:

 RETURNS:

 OUTPUTS:
   comb -- Combined image

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_addimg, all_img, comb_img


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   10-Dec-2002 Written by JXP

(See IMG/Reduction//x_addimg.pro)


X_ADDNOISE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_addnoise
   Version 1.1

 PURPOSE:
  Simply bins data up in integer pixels    

 CALLING SEQUENCE:
   
   newf = x_addnoise(fx, snr, SEED=)

 INPUTS:
   fx       - Flux array
   snr      - Signal-to-noise per pixel of the data

 RETURNS:
   newfx    - Flux array with noise

 OUTPUTS:

 OPTIONAL KEYWORDS:
  SEED=  -- Seed for random number generator [Default: -1322]

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   newfx = x_addnoise(fx, 15.)

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   04-Nov-2002 Written by JXP

(See Spec/Analysis//x_addnoise.pro)


X_ADDTWOFLATS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_addtwoflats
   Version 1.1

 PURPOSE:
    Combines two flats, rejecting Cosmic Rays.  This routine is
   used extensively in the WFCCD routines.

 CALLING SEQUENCE:
   
   flat = x_addtwoflats, img1, img2, VAR=, GAIN=, RN=

 INPUTS:
   img1       - OV subtracted img1 (data or fits)
   img2       - OV subtracted img2 (data or fits)

 RETURNS:

 OUTPUTS:
   flat      - Combined flat with CR rejected

 OPTIONAL KEYWORDS:
  GAIN       - gain
  RN         - Read noise (for the VAR output only)

 OPTIONAL OUTPUTS:
   VAR       - Variance image

 COMMENTS:

 EXAMPLES:
   flat = x_addtwoflats(img1, img2)


 PROCEDURES CALLED:

 REVISION HISTORY:
   17-Jan-2002 Written by JXP

(See IMG/Reduction//x_addtwoflats.pro)


X_ALLVELO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_allvelo

 PURPOSE:
  Create an array of velocity arrays for a string of transitions

 CALLING SEQUENCE:
   all_velo = x_allvelo(wave, zabs, wrest, vmnx, ALL_PMNX=, NPIX=)

 INPUTS:
  wave  -- Wavelength array
  zabs  -- Redshift of absorption system
  wrest -- Array of rest wavelengths
  vmnx  -- 2-element array of velocities

 RETURNS:
  all_velo  -- Velocity array (one per rest wavelength)

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:
  ALL_PMNX=  -- pixmin and pixmax array

 COMMENTS:

 EXAMPLES:
   all_velo = x_allvelo(wave, zabs, wrest, vmnx, ALL_PMNX=)

 PROCEDURES CALLED:

 REVISION HISTORY:
   24-Oct-2002 Written by JXP

(See Spec/General//x_allvelo.pro)


X_ALLVOIGT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
   x_allvoigt
  Version 1.1

 PURPOSE:
   Calculate a single voigt profile, given wavelength, absorber, and
    an array of lines.  Warning:  This program is not exact!

 CALLING SEQUENCE:
   tau = x_allvoigt(wave,lines, SIGMA=, MNDV=)

 INPUTS:
   wave       - Array of wavelengths to realize voigt profile
   lines      - Line(s) structure to compute voigt profile, if mutliple,
                   the entire list will be looped through.
  RETURNS:
   tau        - Optical depth at each wavelength

 OPTIONAL INPUTS:
   SIGMA=     - Resolution of instrument in pixels
   MNDV=      - Range in velocity to calculate Voigt over [defalut:
                1000 km/s]

 OUTPUTS:

 OPTIONAL OUTPUTS:

 COMMENTS:

  Line is a structure with:

 ** Structure <81a5f94>, 4 tags, length=24, refs=3:
    ION             STRING    'H I'
    WAVE            DOUBLE           1215.6701
    F               FLOAT          0.416400
    GAMMA           FLOAT       6.26500e+08

  Abs must have at least :

** Structure ABS, 10 tags, length=44:
   N               FLOAT           15.0000   	log 10 Column density
   B               FLOAT           5.00000     velocity dispersion (km/s)
   Z               FLOAT           2.00000	redshift

 EXAMPLES:

 BUGS: ;
 PROCEDURES CALLED:

 REVISION HISTORY:
   25-May-2000  Created by S. Burles, FNAL/IAP
                Modified by JXP

(See Spec/Voigt//x_allvoigt.pro)


X_AODM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_aodm
   Version 1.1

 PURPOSE:
    Calculates an AODM column density given a wavelength, flux, and
   error array AND the restwave of the transition.  The routine will
   sum over the entire flux array so pass a sub-array in general.

 CALLING SEQUENCE:
   
   x_aodm, wave, fx, sig, rwave, colm, sig

 INPUTS:
   wave - Wavelength array
   fx - Data
   sig - Error array
   rwave - Rest wavelength

 RETURNS:

 OUTPUTS:
   colm  - Column density
   [sig_colm]  - Error

 OPTIONAL KEYWORDS:
   LOG - Return log answers

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_aodm, wav[203:209], dat[203:209], sig[203:309], 1808.0126d, clm

 PROCEDURES CALLED:

 REVISION HISTORY:
   19-Dec-2001 Written by JXP

(See General//x_aodm.pro)


X_APALL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_apall   
   Version 1.1

 PURPOSE:
    Performs an aperture extraction on a 2D image.  Much like IRAFs
    apall routine.

 CALLING SEQUENCE:
  spec = x_apall( img, OVR=, CLINE=, APER=, $
                 SKYFUNC=, SKYNORD=, SKYREG=, $
                 /DISPLAY, /NOREJ, TRACE=, /NOOV, $
                 /NOSKY=, STRCT=, RN=, GAIN=, VAR=, $
                 /CRUDE, TINTER=, ERROR=, /SILENT )

 INPUTS:
   img -- 2D spectrum

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /DISPLAY - Display the sky subtracted image with xatv
  OVR=     - String array for ov region:  '[2050:2100, *]'
  VAR=     - Variance image
  RN=      - Read noise [default: 5.]
  GAIN=    - Gain [default: 1.]
  /CRUDE   - Use trace_crude to trace the object
  /TINTER  - Fit the trace interactively
  /NOSKY   - Do not sky subtract
  SKYFUNC= - Function to use to fit the sky [default: POLY]
  SKYNORD= - Order for sky fit [default: 1]
  SKYREG=  - Region to fit the sky
  /NOREJ   - Do not do rejection when fitting the sky
  CLINE=   - Line to identify object in [default: sz[0]/2]
  APER=    - Aperture to extract [default: determine interactively]
  /NOOV    - Do not perform OV subtraction

 OPTIONAL OUTPUTS:
   ERROR=   - Sigma array (or is it variance?)
   STRCT=   - Structure defining the various extraction parameters.
              Useful for performing wavelength subtraction
   TRACE=   - Output trace

 COMMENTS:

 EXAMPLES:
   spec = x_apall('spec.fits', STRCT=strct)


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   19-Nov-2001 Written by JXP
   05-Dec-2001 Modularized most of the routine

(See Spec/Extraction//x_apall.pro)


X_APER

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
      X_APER
 PURPOSE:
      Compute concentric aperture photometry (adapted from DAOPHOT) 
    I have adopted this from the Goddard routines
 EXPLANATION:
     APER can compute photometry in several user-specified aperture radii.  
     A separate sky value is computed for each source using specified inner 
     and outer sky radii.   

 CALLING SEQUENCE:
     APER, image, xc, yc, [ mags, errap, sky, skyerr, phpadu, apr, skyrad, 
                       badpix, /EXACT, /FLUX, PRINT = , /SILENT, SETSKYVAL = ]
 INPUTS:
     IMAGE -  input image array
     XC     - vector of x coordinates. 
     YC     - vector of y coordinates

 OPTIONAL INPUTS:
     PHPADU - Photons per Analog Digital Units, numeric scalar.  Converts
               the data numbers in IMAGE to photon units.  (APER assumes
               Poisson statistics.)  
     APR    - Vector of up to 12 REAL photometry aperture radii.
     SKYRAD - Two element vector giving the inner and outer radii
               to be used for the sky annulus
     BADPIX - Two element vector giving the minimum and maximum value
               of a good pix (Default [-32765,32767]).    If BADPIX[0] is
               equal to BADPIX[1] then it is assumed that there are no bad
               pixels.

 OPTIONAL KEYWORD INPUTS:
     /EXACT -  By default, APER counts subpixels, but uses a polygon 
             approximation for the intersection of a circular aperture with
             a square pixel (and normalize the total area of the sum of the
             pixels to exactly match the circular area).   If the /EXACT 
             keyword, then the intersection of the circular aperture with a
             square pixel is computed exactly.    The /EXACT keyword is much
             slower and is only needed when small (~2 pixels) apertures are
             used with very undersampled data.    
     /FLUX - By default, APER uses a magnitude system where a magnitude of
               25 corresponds to 1 flux unit.   If set, then APER will keep
              results in flux units instead of magnitudes.
     PRINT - if set and non-zero then APER will also write its results to
               a file aper.prt.   One can specify the output file name by
               setting PRINT = 'filename'.
     /SILENT -  If supplied and non-zero then no output is displayed to the
               terminal.
     SETSKYVAL - Use this keyword to force the sky to a specified value 
               rather than have APER compute a sky value.    SETSKYVAL 
               can either be a scalar specifying the sky value to use for 
               all sources, or a 3 element vector specifying the sky value, 
               the sigma of the sky value, and the number of elements used 
               to compute a sky value.   The 3 element form of SETSKYVAL
               is needed for accurate error budgeting.

 OUTPUTS:
     MAGS   -  NAPER by NSTAR array giving the magnitude for each star in
               each aperture.  (NAPER is the number of apertures, and NSTAR
               is the number of stars).   A flux of 1 digital unit is assigned
               a zero point magnitude of 25.
     ERRAP  -  NAPER by NSTAR array giving error in magnitude
               for each star.  If a magnitude could not be deter-
               mined then ERRAP = 9.99.
     SKY  -    NSTAR element vector giving sky value for each star
     SKYERR -  NSTAR element vector giving error in sky values

 PROCEDURES USED:
       DATATYPE(), GETOPT, MMM, PIXWT(), STRN(), STRNUMBER()
 NOTES:
       Reasons that a valid magnitude cannot be computed include the following:
      (1) Star position is too close (within 0.5 pixels) to edge of the frame
      (2) Less than 20 valid pixels available for computing sky
      (3) Modal value of sky could not be computed by the procedure MMM
      (4) *Any* pixel within the aperture radius is a "bad" pixel

       APER was modified in June 2000 in two ways: (1) the /EXACT keyword was
       added (2) the approximation of the intersection of a circular aperture
       with square pixels was improved (i.e. when /EXACT is not used) 
 REVISON HISTORY:
       Adapted to IDL from DAOPHOT June, 1989   B. Pfarr, STX
       Adapted for IDL Version 2,               J. Isensee, July, 1990
       Code, documentation spiffed up           W. Landsman   August 1991
       TEXTOUT may be a string                  W. Landsman September 1995
       FLUX keyword added                       J. E. Hollis, February, 1996
       SETSKYVAL keyword, increase maxsky       W. Landsman, May 1997
       Work for more than 32767 stars           W. Landsman, August 1997
       Converted to IDL V5.0                    W. Landsman   September 1997
       Don't abort for insufficient sky pixels  W. Landsman  May 2000
       Added /EXACT keyword                     W. Landsman  June 2000 
       Allow SETSKYVAL = 0                      W. Landsman  December 2000 
       Set BADPIX[0] = BADPIX[1] to ignore bad pixels W. L.  January 2001     
       Fix chk_badpixel problem introduced Jan 01 C. Ishida/W.L. February 2001 

(See IMG/Photometry//x_aper.pro)


X_ARCIMAGE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_arcimage   
    Version 1.0

 PURPOSE:
    Creates an arcimage given a tracestructure

 CALLING SEQUENCE:
   
   arcimg = x_arcimage( trcstrct, arcfit, sz_img )

 INPUTS:
   trcstrct - Trace structure (contains all of the info on the
              position and value of various arc lines)
   arcfit   - Template fit structure ; Includes fit instructions
   sz_img   - Size of output image
   [lines]  - Line list strurcture (Usually defined)

 RETURNS:
   arcimg

 OUTPUTS:

 OPTIONAL KEYWORDS:
  YSTRT  - Row defining the arcfit [default = middle]
  LINELIST  - Arc line list (in lieu of lines)
  NSIG  - Sig of RMS from the fit that line must match

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   arcimg = x_arcimage( trcstrct, arcfit, imgsz)

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   18-Feb-2002 Written by JXP

(See Spec/Arcs//x_arcimage.pro)


X_ARCLIST

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_arclist   
    Version 1.1

 PURPOSE:
    Reads a line list into an arclin strutcture

 CALLING SEQUENCE:
   x_arclist, linelist, lines, /GDONLY

 INPUTS:
   linelist  - Name of line list (formatted: D, I, A)

 RETURNS:
   arclinstr   -  Arc line structure

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /GDONLY -- Restrict the line list to those where flg_qual NE 0

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_arclist, linelist, lines

 PROCEDURES/FUNCTIONS CALLED:
  arclinstrct__define
  readcol

 REVISION HISTORY:
   14-Feb-2002 Written by JXP

(See Spec/Arcs//x_arclist.pro)


X_ARCPEAKUP

[Previous Routine] [Next Routine] [List of Routines]
 NAME: 
 x_arcpeakup   
    Version 1.1

 PURPOSE:
    Finds the fit iteratively to a set of lines given the Arc
    spectrum and a line list

 CALLING SEQUENCE:
   x_arcpeakup, spec, lines, FFIT=, WV=, NFRST=, NFIN=, /INTER, SIG=

 INPUTS:
   spec       - Input arc spectrum
   lines      - Arc line list structure

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  NFRST= -- Order of fit for the first try [default: 3L]
  NFIN=  -- Order of fit for the final fit
  MXOFF= -- Maximum pixel offset between a line and its expected
            position
  SIG=   -- Lower and upper sigma values for fitting

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_arcpeakup, spec, lines, guessfit


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   26-Aug-2002 Written by JXP

(See Spec/Arcs//x_arcpeakup.pro)


X_AUTOID

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_autoid   
    Version 1.0

 PURPOSE:
    Traces a series of arc lines

 CALLING SEQUENCE:
   
   x_autoid, img, [extrct], instr=, IDLIST=, GUESS=, LINELIST=,
                       TOLER=

 INPUTS:
   img       - Input arc image or spectrum
   [extrct]    - Slit edges (default to image edges)

 RETURNS:

 OUTPUTS:
   FITSTR -  Fit structure;  Set values prior to passing for 

 OPTIONAL KEYWORDS:
   CPROG  -  Run the monte-carlo in the c program (advised)

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_autoid, img, instr='WFCCDB'


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   12-Feb-2002 Written by JXP

(See Spec/Arcs//x_autoid.pro)


X_AVSIGCLIP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
   x_avsigclip

 PURPOSE:
   Average multiple images with sigma-rejection.  This routine
   makes extensive use of Schlegels avsigclip routine.

 CALLING SEQUENCE:
   result = x_avsigclip( array, [ dimension, siglo=, sighi=, maxiter=, $
    inmask=, outmask= ] )

 INPUTS:
   array      - N-dimensional array

 OPTIONAL INPUTS:
   dimension  - The dimension over which to collapse the data.  If ommitted,
                assume that the last dimension is the one to collapse.
   siglo     - Low Sigma for rejection; default to 3.0.
   sighi     - High Sigma for rejection; default to 3.0.
   maxiter    - Maximum number of sigma rejection iterations.  One iteration
                does no sigma rejection; default to 10 iterations.
   inmask     - Input mask, setting =0 for good elements

 OUTPUTS:
   result     - The output array.
   outmask    - Output mask, setting =0 for good elements, =1 for bad.
                Any pixels masked in INMASK are also masked in OUTMASK.

 OPTIONAL OUTPUTS:

 COMMENTS:
   The DIMENSION input is analogous to that used by the IDL built-in
   function TOTAL.

 EXAMPLES:
   Create a data cube of 10 random-valued 100x200 images.  At each pixel in
   the image, compute the average of the 10 values, but rejecting 3-sigma
   outliers:
   > array = randomu(123,100,200,10)
   > ave = x_avsigclip(array, siglo=3., sighi=4.)


   If all points are masked in any given vector or array, a mean and
   dispersion are computed for all the points.  Is this the behaviour we want?
   If you want to replace those values with zeros instead, look at OUTMASK:
   > array = randomu(123,100,200)
   > inmask = bytarr(100,200)
   > inmask[*,8] = 1 ; mask all of row #8
   > ave = x_avsigclip(array, 1, inmask=inmask, outmask=outmask)
   > ibad = where( total(1-outmask, 1) EQ 0)
   > if (ibad[0] NE -1) then ave[ibad] = 0 ; zero-out bad rows

 BUGS:

 PROCEDURES CALLED:
   Dynamic link to arravsigclip.c

 REVISION HISTORY:
   07-Jul-1999  Written by David Schlegel, Princeton.
   28-Jul-2001  Revised by JXP (Added lo/hi sigrej)

(See IMG/Reduction//x_avsigclip.pro)


X_BSPLNSKY

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_bsplnsky   
    Version 1.1

 PURPOSE:
    Given the slitstr and slit#, subtract the sky and return 
         the result using a bspline technique

 CALLING SEQUENCE:
   x_bsplnsky, slit_fil, slit, obj_fil, [flux, wave], VAR=, $
               SUBIMG=, PIX=, DATFIL=, ALL_RMS=, SKYIMG=, /CHK, WVMNX=

 INPUTS:
   slit_fil   - File containing the slit structure
   slit       - Slit to sky subtract
   obj_fil    - File containing the object structure
  [flux]      - Flux image
  [wave]      - Wavelength image

 RETURNS:

 OUTPUTS:
   Updates slitstr for original positions

 OPTIONAL KEYWORDS:
  DATFIL=  -- FITS File containing FLUX, WAVE images
  WVMNX=   -- Limit sky subtraction to specific wavelength range
              [default [3900., 11000.] ]

 OPTIONAL OUTPUTS:
  ALL_RMS=  -- Total RMS of the fit
  PIX=      -- Array of pixel values 

 COMMENTS:

 EXAMPLES:
   x_skysubslit, slitstr, map


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   10-Sep-2002 Written by JXP

(See Spec/Extraction//x_bsplnsky.pro)


X_CALC2DFIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_calc2dfit   
   Version 1.1

 PURPOSE:
    Calculates a 2d fit-function at a set of xy pairs.  
    Restrcited to a 2D polynomial for now.

 CALLING SEQUENCE:
   
   fit = x_calc2dfit(xyval, func, ffit, nx, ny, NRM=, FITSTR=)

 INPUTS:
   xyval      - 2D array [npix, 2] of the x,y values
   [func]     - String for Fitting function (POLY)
   [ffit]     - Output from the fitting stuff
   [nx]       - order of the 2d surface in x
   [ny]       - order of the 2d surface in y

 RETURNS:
   fit        - Values at each xyval [1D array]

 OUTPUTS:

 OPTIONAL KEYWORDS:
  FITSTR= -- IDL structure for 2D fitting (recommended)

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   fit = x_calc2dfit(xy, 'POLY', ffit, 3, 3)


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   31-Jan-2002 Written by JXP

(See FIT//x_calc2dfit.pro)


X_CALCCOG

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_calccog
   Version 1.1

 PURPOSE:
  Perform a COG solution given a list of flambda values, EW
  measurements and the errors in those measurements.  The user inputs
  an array of column densities to search over and the code finds the
  minimum in chi^2 and returns the value.

  This code is currently only used to calculate the best b value for
  the lines for the given N values.  See fuse_cog for a better COG
  routine.  [JXP: 5/25/04]
   

 CALLING SEQUENCE:
   x_calccog, ew_red, sig_ew, flambda, Nval, blmt, FNDB=
   BANS=, /EXACT

 INPUTS:
   ew_red  -- Reduced ew array
   sigew   -- Error in ew 
   flambda  -- f lambda (assumes A not cm)
   Nval    -- List of Nval to consider
   blmt    --  Limits for b value search (assumes km/s)

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /EXACT  -- Calculate the COG exactly  (otherwise use lookup table)
  /FNDB   -- Find the b-value (only option now)

 OPTIONAL OUTPUTS:
  BANS=  -- The b value which minimizes chi^2

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:
  x_calccog_initcomm
  x_calccog_cog
  x_calccog_ftau

 REVISION HISTORY:
   05-Mar-2002 Written by JXP

(See Spec/Analysis//x_calccog.pro)


X_CALCEW

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_calcew   
   Version 1.1

 PURPOSE:
    Calculates the EW given a wavelength and flux array and limits to
    integrate over.  Can also calculate the error in the EW as well
    as the reduced values.

 CALLING SEQUENCE:
   ew = x_calcew(wav, fx, lmts, [sig, sigew], /REDUCED, FPIX=)

 INPUTS:
   wav      - Wavelength 
   fx       - Flux (presumed normalized)
   lmts     - Limits of integration (wavelength unless /FPIX is set)
   [sig]    - Error in fx

 RETURNS:
   ew   - Equivalent width

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:
   sigew  - Error in ew

 COMMENTS:
  The flux array should be normalized to unity 

 EXAMPLES:
   ew = x_calcew( fx, sig, [50, 100], ERR=sigew, /FPIX) 

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   05-Mar-2002 Written by JXP

(See Spec/Analysis//x_calcew.pro)


X_CALCFIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_calcfit   
   Version 1.2

 PURPOSE:
    Calculates a fit-function at a set of x points

 CALLING SEQUENCE:
   
   fit = x_calcfit(xval,func,ffit, NORD=)

 INPUTS:
   xval       - Value(s) along one dimension
   [func]       - String for Fitting function (POLY, LEGEND, BSPLIN,
                GAUSS)
   [ffit]       - Output from the fitting stuff

 RETURNS:
   fit        - Values at each xval

 OUTPUTS:

 OPTIONAL KEYWORDS:
   nord       - Required for LEGEND
   FITSTR     - Fit structure (OVERRIDES input values of func, ffit)

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   fit = x_calcfit(x, 'POLY', 5)


 PROCEDURES/FUNCTIONS CALLED:
  POLY_FIT
  POLY
  SVDFIT
  SVLEG
  BSPLIN
  GAUSS

 REVISION HISTORY:
   20-Nov-2001 Written by JXP
   31-Jan-2002 Added NRM, CHEBY func, FITSTR

(See FIT//x_calcfit.pro)


X_CALCLSTAR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_calclstar
  Version 1.1

 PURPOSE:
  Calculate apparent magnitude for Lstar at a given 
      redshift for a given cosmology and Hubbles constant.

 CALLING SEQUENCE:
   lstar = x_calclstar( z, H0=, AMIN=, /SILENT, OM=, OV=)

 INPUTS:
    z -- Redshift

 RETURNS:
    lstar -- Apparent magnitude for Lstar

 OUTPUTS:

 OPTIONAL KEYWORDS:
   lstr0 -- Assumed value of Lstar at z=0  [default: -20.1]
   H0 -- Hubbles constant (km/s/Mpc)
   OM -- Omega Dark Matter
   OV -- Lambda
   /SILENT -- No printing to the screen
   

 OPTIONAL OUTPUTS:
  AMIN -- Mpc per arcmin at z

 COMMENTS:

 EXAMPLES:
   lstar = x_calclstar(2., H0=75., AMIN=amin)

 PROCEDURES CALLED:

 REVISION HISTORY:
   22-Nov-2003 Written by JXP

(See Cosm//x_calclstar.pro)


X_CALCTB

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_calctb   
   Version 1.1

 PURPOSE:
    Launches a cw_field and grabs input from the user

 CALLING SEQUENCE:
   
   x_calctb, b, T, /LOGT, MA=

 INPUTS:
  b -- Doppler parameter (km/s)

 RETURNS:

 OUTPUTS:
  T -- Temperature (K)

 OPTIONAL KEYWORDS:
  /LOGT -- Return logarithmic temperature
  MA -- Mass of nucleus [1 for Hydrogen]

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
  x_calctb, 25., T, /LOGT


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   20-Dec-2001 Written by JXP

(See General//x_calctb.pro)


X_CALIBSTD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_calibstd   
   Version 1.1

 PURPOSE:
    

 CALLING SEQUENCE:
  x_calibstd, wave, flux, outfil, HSTFIL=, /CHKFIT, 
               EXP=, BSPLIN=, SWV=, SFX=, 
               GDWV=, BSET=, YFIT=, SENS=, EVERYN=

 INPUTS:
  wave -- Wavelength array of standard star
  flux -- Flux array of standard star

 RETURNS:

 OUTPUTS:
  outfil -- FITS file to write sensitivity function 

 OPTIONAL KEYWORDS:
  EXP= -- Exposure time [default: 1.]
  HSTFIL= -- HST calibration file
  /CHKFIT -- Plot the fit to the sensitivity function
  EVERYN= -- Spacing of b-spline breakpoints in pixel space [default: 5]

 OPTIONAL OUTPUTS:
  SWV=  -- Wavelength array of calibration data
  SFX=  -- Flux array of calibration data
  SENS= -- Sensitivity function

 COMMENTS:

 EXAMPLES:
   x_calibstd, kast, 0, 1, 0


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   29-Aug-2003 Written by JXP

(See Spec/Flux//x_calibstd.pro)


X_CCDINF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_ccdinf   
   Version 1.0

 PURPOSE:
    Returns arcpix and orientation of ccd+tel combination.  This
   routine saves all of that key info in one spot, although it 
   is primarily used only for direct imaging.

 CALLING SEQUENCE:
   x_ccdinf, ccd, tel, arcpix, [orient], SAT=

 INPUTS:
   ccd   -  Name of CCD ('SITe1', 'LRISR', 'WFTek5')
   tel   -  Name of Telescope ('LCO-40', 'Keck', 'LCO-100')

 RETURNS:
   arcpix --  Arcsec per pixel

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:
   orient - Orientation of the CCD:
;                   -2 = SITe1 on LCO-40  (E up, N left)
  SAT=   -- Saturation limit of the CCD

 COMMENTS:

 EXAMPLES:
   x_ccdinf, 'SITe1', 'LCO-40', arcpix, SAT=sat


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   07-Aug-2001 Written by JXP

(See IMG/General//x_ccdinf.pro)


X_CENTERPK

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_centerpk   
    Version 1.1

 PURPOSE:
    Finds the center of a peak

 CALLING SEQUENCE:
   center = x_centerpk(xdat, ydat, [fracpk], VAR=, FUNC=, NORD=, HSIG=, LSIG=,
   IPX=, MINVAL=, FFIT=, /INTER)

 INPUTS:
   xdat       - x Values 
   ydat       - y Values 
   [fracpk]     - Fraction of peak relative to the minimum 
                      (default=1/3 max + min)

 RETURNS:
   center     - center of the peak

 OUTPUTS:
   ffit - Fit parameters

 OPTIONAL KEYWORDS:
   func - Function 
   VAR  - variance in ydat
   nord - order number
   HSIG - upper sigma
   LSIG - lower sigma
   IPX  - Allows user to give best guess
   INTER - Interative fit

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   center = x_centerpk(xdat, ydat, /inter)


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   23-Nov-2001 Written by JXP

(See Spec/General//x_centerpk.pro)


X_CENTSPLN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_centspln   
   Version 1.1

 PURPOSE:
  Given a 'peak', this routine will find the center of that peak in a
  non-parameteric manner.  The routine first spliens the peak.  It
  then steps in from both sides
  until it hits FRACPK of the peak value of the line.  Finally, the
  centroid is the midpoint of these two spots.

 CALLING SEQUENCE:
   
   xcen = x_centspln(xval, yval, [fracpk])

 INPUTS:
   xval       - x values of the peak
   yval       - y values of the peak
   [FRACPK]   - Fraction of the peak for centroiding [default=0.3333]

 RETURNS:
   xcen      - Center

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /SILENT -- Turn off warnings
  /FORCE  -- Calculate a centroid even if the edges are non-sensical

 OPTIONAL OUTPUTS:
  EDGES=  -- Values of the spots on the peak corresponding to FRACPK

 COMMENTS:

 EXAMPLES:
   xcen = x_centspln(data)


 PROCEDURES/FUNCTIONS CALLED:
 x_fndspln
 x_golden

 REVISION HISTORY:
   07-Feb-2002 Written by JXP

(See FIT//x_centspln.pro)


X_CHGBW

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_chgbw
   Version 1.1

 PURPOSE:
   Sets colors to black and white 

 CALLING SEQUENCE:
   
   x_chgbw

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_chgbw

 PROCEDURES CALLED:
 getcolor

 REVISION HISTORY:
   19-Dec-2001 Written by JXP

(See General//x_chgbw.pro)


X_CHKFIL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_chkfil   
    Version 1.1

 PURPOSE:
    Check for a file and return the number of entries matching

 CALLING SEQUENCE:
   
 flag = x_chkfil(fil, COUNT=, /SILENT)

 INPUTS:
   fil - Filename 

 RETURNS:
   flag  - 0: No file; 1: One file; 2: More than one

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:
  COUNT - number of unique strings

 COMMENTS:

 EXAMPLES:
   flg = x_chkfil('junk.dat', count=cnt, /SILENT)

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   07-May-2002 Written by JXP

(See General//x_chkfil.pro)


X_COMBSPEC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_combspec
    Version 1.1

 PURPOSE:
   Combines multiple exposures of the same slit

 CALLING SEQUENCE:
  x_combspec, flux, var, fflux, fvar, NRMFLUX=, WAVE=, NSIG=,
               SCALE=, SNR=

 INPUTS:
   flux -- 2D flux array
   var  -- 2D variance array

 RETURNS:
  fflux -- Combined flux array
  fvar  -- Combined variance array

 OUTPUTS:

 OPTIONAL KEYWORDS:
  NRMFLUX  -  Array of 2 elements (wave min,max) to normalize flux
  WAVE=    -- Wavelength array for normalizing
  WVMNX=   -- Wavelength region for normalizing
  NSIG=    -- Number of sigma to reject on
  SCALE=   -- Scale the flux arrays by this array
  SNR=     -- Signal-to-noise ratios to weight by

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_combspec, flux, var, fflux, fvar

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   28-May-2002 Written by JXP
   03-Sep-2002 Added SCALE keyword + weighted means for 2 exposures

(See Spec/Extraction//x_combspec.pro)


X_CONSTANTS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_constants   
    Version 1.1

 PURPOSE:
    Return a structure of the usual constants. 

 CALLING SEQUENCE:
   
 cstr = x_constants(/KSG)

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /KSG -- Return mks units

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   cstr = x_constants()

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   07-May-2002 Written by JXP

(See General//x_constants.pro)


X_CONTINUUM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_continuum   
   Version 1.1

 PURPOSE:
    GUI used to fit the continuum of a spectrum (usually quasars).
    The user can dictate a SPLINE or perform a minimum chi^2 fit to
    regions with rejection.

 CALLING SEQUENCE:
   x_continuum, flux_fil, error_fil, FITSTR=, CONTI=, LSIG=, XSIZE=, YSIZE=,
   INFLG=, OUTFIL=, /SPLINE, INISPL=

 INPUTS:
   flux_fil   - Values along one dimension [optional]
   error_fil  - Values along the other

 RETURNS:

 OUTPUTS:
  OUTFIL=  -- Name of FITS file to save continuum

 OPTIONAL KEYWORDS:
   CONTI=  -- Name of FITS file containing previously saved
                continuum
   INFLG   -- 0 = yin, ysin as data arrays (fits allowed and
                expected)
                1 = One fits file (flux, sig)
                2 = One fits file (flux, sig, wave)
                3 = FUSE format
                5 = SDSS file
   XSIZE=  -- Window size in pixels
   YSIZE=  -- Window size in pixels
   LSIG=   -- Value for sigma rejection on low side [default: 2.5]
   INISPL= -- IDL file containing a saved SPLINE for the continuum
   FITSTR  -- Fit structure

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_continuum, 'Q0000.fits', OUTFIL='Q0000_c.fits', /SPLINE


 PROCEDURES/FUNCTIONS CALLED:
  POLY_FIT
  POLY
  SVDFIT
  SVLEG
  BSPLINE
  GAUSS
  XGETX_PLT
  XGETY_PLT
  XGETXPIX_PLT
  XGETYPIX_PLT
  GETCOLOR (coyote package)

; REVISION HISTORY:
   26-Feb-2002 Written by JXP

(See Spec/Analysis//x_continuum.pro)


X_EDITSPEC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_editspec   
   Version 1.1

 PURPOSE:
    Allows user to reset values of a spectrum to reject bad regions
    using a simple GUI

 CALLING SEQUENCE:
   
   x_editspec, wv, fx, var, [title], XSIZE=, YSIZE=, ISPEC=, 
               /BLOCK, NEWVAR=, FLG=, NEWFLG=

 INPUTS
   wv  -- Wavelength array  (expected to be a 2D array [npix, nspec])
   fx  -- Flux array (expected to be a 2D array [npix, nspec])
  var  -- Variance array (expected to be a 2D array [npix, nspec])
  [title] -- List of object ID numbers

 RETURNS:

 OUTPUTS:
  NEWVAR=  -- Updated variance array which has bad pixels (regions) masked
  NEWFLG=  -- Flag used to specify whether to analyse the spectrum

 OPTIONAL KEYWORDS:
   xsize   - Draw window xsize (pixels)
   ysize   - Draw window ysize (pixels)
  /BLOCK   - Block the window

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_editspec 


 PROCEDURES/FUNCTIONS CALLED:
  XGETX_PLT
  XGETY_PLT
  XGETXPIX_PLT
  XGETYPIX_PLT

 REVISION HISTORY:
   03-May-2002 Written by JXP

(See Spec/Analysis//x_editspec.pro)


X_EXTOBJBOX

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_extobjbox   
    Version 1.0

 PURPOSE:
    Given the flux and wave images and the starting position of the
       object to extract (x,y),  do a boxcar extraction

 CALLING SEQUENCE:
   
   x_extobjbox, slitstr, map

 INPUTS:
   sub_fil      - Sky subtracted image file
   slit_fil     - Slit file
   obj_fil      - Object structure file
   [fin_fil]    - Flux,sig,wave file

 RETURNS:

 OUTPUTS:
   Updates slitstr for original positions

 OPTIONAL KEYWORDS:
   WVMNX - Endpoints for extraction (default: [3200., 11000.])
   COLLMNX - Endpoints for collapsing the spectrum prior to extraction
              (default: [3400., 8000.])
   REDBLUE - Spectrum runs from red to blue
   SKYSUB  - Data has been sky subtracted (helps with aperture)

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_extobjbox, slitstr, map


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   01-Apr-2002 Written by JXP

(See Spec/Extraction//x_extobjbox.pro)


X_EXTRACT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_extract   
   Version 1.1

 PURPOSE:
    Extracts a 1D spectrum from a 2D image given an aperture.  This
  routine is really superseded by x_extobjbox

 CALLING SEQUENCE:
   spec = x_extract(img, aper, trace, [error, sky], CAPER=, GAIN=,
                    RN=, /OPTIMAL)

 INPUTS:
   img       - 2D Image
   aper      - Aperture to extract
   trace     - Trace of the spectrum
   [sky]     - Optional input required for error output

 RETURNS:
   spec      - 1D Spectrum

 OUTPUTS:

 OPTIONAL KEYWORDS:
   CAPER      - Line chosen for aperture: Require with TRACE
   GAIN       - CCD gain
   RN       - Read noise

 OPTIONAL OUTPUTS:
   var      - Error array

 COMMENTS:

 EXAMPLES:
   spec = x_extract(img, aper)


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   05-Dec-2001 Written by JXP

(See Spec/Extraction//x_extract.pro)


X_FFTTRACE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_ffttrace   
    Version 1.1

 PURPOSE:
    Traces the y-distortion of a flat using FFTs.  It is unlikely
    this program works well.  I highly recommend tracing the
    'sawtooth' image of a flat instead.

 CALLING SEQUENCE:
   x_ffttrace, img

 INPUTS:
   img    - Input image (flat)

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_ffttrace, img, map


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   29-Jan-2002 Written by JXP

(See Spec/Rectify//x_ffttrace.pro)


X_FILTERS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_filters   
    Version 1.1

 PURPOSE:
    Grabs out a list of unique filters from a full string
  array list of filters.

 CALLING SEQUENCE:
   
 x_filters, allfilt, filter, [nfilt], NOSORT=nosort

 INPUTS:
   allfilt - List of all images

 RETURNS:
   filter - Filter list

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /NOSORT -- Dont bother sorting the unique filter list

 OPTIONAL OUTPUTS:
  nfilt - Number of unique filters

 COMMENTS:

 EXAMPLES:
   x_filters, img, filter, nfilt


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   27-July-2001 Written by JXP
   08-Aug-2001 Revised to sort

(See IMG/General//x_filters.pro)


X_FINDGAUSS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_findgauss   
   Version 1.0

 PURPOSE:
    Finds Gaussian absorption features in a spectrum (should be
    normalized).  The routine uses find_npeaks to find the features
    and then tunes up on then with zfitmax.

 CALLING SEQUENCE:
  x_findgauss, y, [invvar], xarr=, sigma=, xpeak=, ypeak=, xsn=, sn=, 
  width=, nfind=, minsep=
 
 INPUTS:
  y  -- Flux
  [invvar] -- Inverse variance

 RETURNS:

 OUTPUTS:
  xpeak -- x values of the peaks
  ypeak -- y height of the peak

 OPTIONAL KEYWORDS:
  SIGMA= -- Width of Gaussian (pixels)  [default: 1.]
  WIDTH= -- FWHM of the feature [default: 2.5*sigam]
  MINSEP= -- Minimum separation between lines [default: 4.1*sigma]
  NFIND=  -- Number of peaks to find with find_nepaks [default: 50]
  XARR=  -- x array (e.g. wavelength)

 OPTIONAL OUTPUTS:
  xsn -- x values of peaks from find_npeaks
   sn -- y values of the peaks from find_npeaks

 COMMENTS:

 EXAMPLES:


 PROCEDURES/FUNCTIONS CALLED:
 find_npeaks
 gauss_kernel
 zfitmax

 REVISION HISTORY:
   24-Sep-2003 Written by SB
   2003  Grabbed by JXP and slightly modified

(See Spec/Analysis//x_findgauss.pro)


X_FIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_fit   
   Version 1.2

 PURPOSE:
    Fits a function to a set of x,y data

 CALLING SEQUENCE:
   
   fit = x_fit(xdat,ydat,func,nord,sig=,reg=) 

 INPUTS:
   xdat       - Values along one dimension
   ydat       - Values along the other

 RETURNS:
   fit        - Values of the fit at each xdat value

 OUTPUTS:

 OPTIONAL KEYWORDS:
   sig        - Errors in the yval points
   IVAR       - Inverse variance of the ydat values
   func       - String for Fitting function (POLY, LEGEND, BSPLIN,
                GAUSS)
   nord       - Order of the fit
   reg        - Regions of data to fit
   msk        - Mask  (0 = Do NOT include)
   guess      - First guess for GAUSS routine
   FITSTR=    - 1D Fit structure used to set many of the above
                parameters (recommended)

 OPTIONAL OUTPUTS:
   ffit     - Functional form
   NRM      - Normalization numbers for xdat :: dblarr(2)
   RMS      - RMS of the fit

 COMMENTS:

 EXAMPLES:
   fit = x_fit(x, y, 'POLY', nord=5)


 PROCEDURES/FUNCTIONS CALLED:
  POLY_FIT
  POLY
  SVDFIT
  SVLEG
  FUNC_FIT

; REVISION HISTORY:
   20-Nov-2001 Written by JXP
   31-Jan-2002 Revised significantly.  Added fit structure, CHEBY
   27-Feb-2002 Added ivar option, am using func_fit for legendre

(See FIT//x_fit.pro)


X_FIT2DSURF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_fit2dsurf
   Version 1.1

 PURPOSE:
    Fits a 2d surface to a set of x,y data with errors (optional).
    It is recommended to set the FIT parameters with the structure
    FITSTR. 

 CALLING SEQUENCE:
   
   fit = x_fit2dsurf(xy, z,[sig], nx=, ny=, MSK=, FITSTR=, REJPT=,
   NRM=, /NONRM, /SVDFT, LSIG=, HSIG=, NITER=, MAXREJ=, FUNC= )

 INPUTS:
   xy         - 2d array of xy pairs: [N,2]
   z          - Values at each xy pair
   [sig]      - Variance in each data point

 RETURNS:
   fit        - Values at each xdat

 OUTPUTS:

 OPTIONAL KEYWORDS:
   msk        - Mask  (0 = Do NOT include)
   func       - 2d function ('POLY')
   nx         - Order in x
   ny         - Order in y
   NONRM      - Don't normalize data before fitting
   MINPT      - Minimum number of points to keep in fit
   LSIG,HSIG  - Lower and upper sigma rejection
   /SVDFT     - Use the IDL routine SVDFT for the fitting.   
                Otherwise use CHOLDC (recommended for speed)

 OPTIONAL OUTPUTS:
   ffit     - Functional form
   NRM      - [2,2] array of Normalization coefficients
   REJPT    - Points rejected in the fit

 COMMENTS:

 EXAMPLES:
   fit = x_fit2dsurf(xy,z, sig)


 PROCEDURES/FUNCTIONS CALLED:
  f2dpoly
  CHOLDC
  SVDFT
  x_calc2dfit

; REVISION HISTORY:
   31-Jan-2002 Written by JXP
   02-Feb-2002 Added rejection

(See FIT//x_fit2dsurf.pro)


X_FIT2DTRACE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_fit2dtrace   
    Version 1.1

 PURPOSE:
    Fits the traced y-distortion of a flat in 2D given a set of
    traces for at various spots in the image.

 CALLING SEQUENCE:
   
   map = x_fit2dtrace( trcstr, FITSTR=, RES=, NX=, NY=, /SILENT )

 INPUTS:
   trcstr   - Trace structure

 RETURNS:
   map - Map of the y-distortion

 OUTPUTS:

 OPTIONAL KEYWORDS:
  nx -  Number of orders along x axis [default: 4L]
  ny -  Number of orders along y axis [default: 4L]

 OPTIONAL OUTPUTS:
   FITSTR  - 2D fitting function structure of the trace
   RES   - Residual image of the fit

 COMMENTS:
   Need to watch for memory issues with 2d surfaces

 EXAMPLES:
   map = x_fit2dtrace( trcstr )


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   07-Feb-2002 Written by JXP

(See Spec/Rectify//x_fit2dtrace.pro)


X_FITDLA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_fitdla   
   Version 1.11

 PURPOSE:
    GUI used to fit DLA profiles interactively.  The user determines
    the continuum at the same time.

 CALLING SEQUENCE:
  x_fitdla, flux_fil, [err_fil], XSIZE=, YSIZE=, TITLE=, 
               WAVE=, /BLOCK, FWHM=, INIFIT=, INFLG=

 INPUTS:
   flux_fil   - FITS file (or array) containing flux
   [err_fil]  - FITS error array

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
   xsize      - Draw window xsize (pixels)
   ysize      - Draw window ysize (pixels)
   wave       - wavelength array 
   FWHM=      - Resoltuion (FWHM in pixels)  [default: 2]
   INFLG=     - Usual flag for reading the FITS file (see x_readspec)
   INIFIT=    - IDL file containing a saved version of the fit

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_fitdla, 'spec.fits'


 PROCEDURES/FUNCTIONS CALLED:
  XGETX_PLT
  XGETY_PLT
  XGETXPIX_PLT
  XGETYPIX_PLT

 REVISION HISTORY:
   17-Oct-2002 Written by JXP

(See Spec/Voigt//x_fitdla.pro)


X_FITLINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_fitline   
   Version 1.1

 PURPOSE:
    Routine used with absorption line fit GUIs

 CALLING SEQUENCE:
   x_fitline, state, eventch, /FLG_PLT

 INPUTS:
  state - Structure describing the GUI and program
  eventch -- Character input by the user

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:
  XGETX_PLT
  XGETY_PLT
  XGETXPIX_PLT
  XGETYPIX_PLT

 REVISION HISTORY:
   17-Oct-2002 Written by JXP

(See Spec/Voigt//x_fitline.pro)


X_FITREJ

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_fitrej
   Version 1.2

 PURPOSE:
    Fits a function to a set of x,y data with rejection!

 CALLING SEQUENCE:
   
   fit =
   x_fitrej(xdat,ydat,func=,nord=,sig=,reg=,
            lsigma=,hsigma=,maxrej=,niter=,minpt=)

 INPUTS:
   xdat       - Values along one dimension
   ydat       - Values along the other
   [func]     - String for Fitting function (POLY, LEGEND, BSPLIN)
   [nord]     - Order of the fit

 RETURNS:
   fit        - Values at each xdat

 OUTPUTS:

 OPTIONAL KEYWORDS:
   sig        - Errors in the points
   IVAR=      - Inverse variance in the points
   reg        - Regions of data to fit
   lsigma     - Lower sigma threshold
   hsigma     - Upper sigma threshold
   maxrej     - Maximum points to reject per iteration
   niter      - Number of iterations for rejection
   minpt      - Minimum # of points
   FITSTR     - Fit structure :: OVERIDES ALL OTHER INPUT VALUES!
   MSK        - Mask for input data (1 = good)

 OPTIONAL OUTPUTS:
   rms        - RMS of the fit
   REJPT      - Rejected points
   GDPT       - Good (unrejected) points
   NRM      - Normalization numbers for xdat :: dblarr(2)

 COMMENTS:

 EXAMPLES:
   fit = x_fitrej(x, y, FITSTR=fitstr)


 PROCEDURES/FUNCTIONS CALLED:
  POLY_FIT
  POLY
  SVDFIT
  SVLEG
  DJS_REJECT

 REVISION HISTORY:
   20-Nov-2001 Written by JXP
   31-Jan-2002 Revised significantly.  Added fit structure, CHEBY

(See FIT//x_fitrej.pro)


X_FITSTRTOFITS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_fitstrtofits
   Version 1.1

 PURPOSE:
    Writes a fitstr as a binary fits file (or reads one in)

 CALLING SEQUENCE:
   x_fitstrtofits, fit_str, fits_fil, /REVERSE

 INPUTS:
    fit_str   - Fit structure
    fits_fil  - Fitsfile

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
   /REVERSE  -- Default is to write the file.  If /REVERSE is set
                then the FITS file is read into a FIT structure

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_fitstrtofits, fit_str, fits_fil


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   15-Apr-2002 Written by JXP

(See FIT//x_fitstrtofits.pro)


X_FITSWAVE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_fitswave
   V1.1

 PURPOSE:
    Returns the wavelength array after passed a header.  Only 
   allows CTYPE='LINEAR' and 'DC-FLAG' must be set to 0 or 1.
   [Obsolete:  Use x_setwave instead]

 CALLING SEQUENCE:
   
   wave = x_fitswave(head)

 INPUTS:
   head    - Header

 RETURNS:
   wave  - Double array of wavelength values

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   wave = x_fitswave(head)


 PROCEDURES CALLED:

 REVISION HISTORY:
   13-Sep-2001 Written by JXP

(See General//x_fitswave.pro)


X_FLUXCALIB

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_fluxcalib   
    Version 1.1

 PURPOSE:
    Given a spectrum and a flux calib solution, calibrate

 CALLING SEQUENCE:
   fx_fnu = x_fluxcalib(wv, fx, fitstr, [var, newvar], /FLAMBDA, DLMB=, TRUCONV=)

 INPUTS:
   wv   - Wavelength array
   fx   - Stellar flux  (e- per pixel)
   fitstr - Calibration fitting function (assumes alog10 for flux)
   [var]  - Variance array

 RETURNS:
   fx_fnu - Flux in fnu (or flambda)

 OUTPUTS:

 OPTIONAL KEYWORDS:
   /FLAMBDA - Return flambda instead of fnu
   DLMB -- Delta lambda (or km/s if negative) of wavelength array
   
 OPTIONAL OUTPUTS:
   newsig -- Fluxed variance array

 COMMENTS:

 EXAMPLES:
   fx_fnu = x_fluxcalib(wv, fx, fitstr)


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   15-Apr-2002 Written by JXP

(See Spec/Flux//x_fluxcalib.pro)


X_FMIDX

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_fmidx
    Version 1.1

 PURPOSE:
    Converts frame number to index -- Useful for ccd###

 CALLING SEQUENCE:
   
 indx = x_fmidx(struct, frameno)

 INPUTS:
   frameno - Frameno [array] of the CCD image

 RETURNS:
   indx -- Index of the frame

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   idx = x_fmidx(n1, 203)


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   14-Nov-2001 Written by JXP

(See IMG/General//x_fmidx.pro)


X_FNDCHRT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_fndchrt   
    Version 1.1

 PURPOSE:
    Given an array of Obj name, RA, and DEC create a set of postscript
  finding charts using Barlows showfits routine. 

 CALLING SEQUENCE:
  x_fndchrt, targlist, OUTDIR=, IMSIZE=, SURVEY=

 INPUTS:
  targlist  -- ASCII file containing  (QSO,  RA,  DEC)

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
   imsize - Arcmin of image (default is 5')

 OPTIONAL OUTPUTS:
  OUTDIR=  -- Name of output directory

 COMMENTS:

 EXAMPLES:
   x_fndchrt, 'targets.list'

 PROCEDURES/FUNCTIONS CALLED:
  showfits
  querydss

 REVISION HISTORY:
   21-Nov-2003 Written by JXP

(See Obs//x_fndchrt.pro)


X_FNDFITVAL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_fndfitval   
   Version 1.1

 PURPOSE:
    Solves for x in y = f(x) given a fitted function f(x) and y

 CALLING SEQUENCE:
   
   xsolv = x_fndfitval(val, fitstr, xval,[fit], NITER=, IPX=,
      TOLER=, NEG=, FITSTR=)

 INPUTS:
   val        - Value to match
   fitstr     - FIT structure
   xval       - Values where fit was pre-evaluated
   [fit]      - Values of the fit at xval (calculated if not input)

 RETURNS:
   xsolv      - x position where the fit = val

 OUTPUTS:

 OPTIONAL KEYWORDS:
   NORD       - Required for LEGEND
   TOLER      - Tolerance for match (default: 10^-4)
   IPIX       - Starting pixel in xval
   NEG        - Proceed in the negative direction
   NITER      - Max number of iterations

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   xsolv = x_fndfitval(0.2, fitstr, xval)


 PROCEDURES/FUNCTIONS CALLED:
  POLY_FIT
  POLY
  SVDFIT
  SVLEG
  BSPLIN
  GAUSS

; REVISION HISTORY:
   23-Nov-2001 Written by JXP
   13-Feb-2002 Requires fit structure

(See FIT//x_fndfitval.pro)


X_FNDFLUX

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_fndflux   
    Version 1.1

 PURPOSE:
    Given a specphoto spectrum and a star name, returns
      fluxing function.  
    I recommend x_calibstd

 CALLING SEQUENCE:
   x_fndflux, wv, fx, star, fitstr

 INPUTS:
   wv   - Wavelength array
   fx   - Stellar flux
   star - Specphot standard ('LTT7379')
   fitstr - Fit of the star

 RETURNS:

 OUTPUTS:
   fitstr    - Fit structure

 OPTIONAL KEYWORDS:
   INTER - Interactive
   
 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_fndflux, wv, fx, star, fitstr


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   15-Apr-2002 Written by JXP

(See Spec/Flux//x_fndflux.pro)


X_FNDOBJ

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_fndobj   
    Version 1.1

 PURPOSE:
    Finds a set of obj in a spectrum.  I think this is a precursor
  to x_fndpeaks.  I doubt this routine is worth using.

 CALLING SEQUENCE:
  x_fndobj, spec, center, NSIG=, /SILENT, /FORCE, $
             PKWDTH=, EDGES=, NORDB=, NEDG=, AFUNC=, PEAK=, /NOSMOOTH

 INPUTS:
   spec       - Input spectrum (1D)

 RETURNS:

 OUTPUTS:
   center     - Array of peak centers

 OPTIONAL KEYWORDS:
  PKWDTH      - Width of peak to center on (pixels)

 OPTIONAL OUTPUTS:
   peak       - Integer values of centeroids

 COMMENTS:

 EXAMPLES:
   x_fndobj, spec, center


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   14-Feb-2002 Written by JXP

(See Spec/Extraction//x_fndobj.pro)


X_FNDPEAKS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_fndpeaks   
    Version 1.1

 PURPOSE:
    Finds a set of peaks in a spectrum.  Generally used with arc line
    spectra, but valueable in many other areas.

 CALLING SEQUENCE:
   x_fndpeaks, spec, center, NSIG=, PEAK=, /ALL, /SILENT, $
               PKWDTH=, /THIN, /NORECENT, /FORCE, $
               FRACPK=, EDGES=, NORDB=, NEDG=, AFUNC=,$
               MSK=, AUTOFIT=, ICLSE=

 INPUTS:
   spec       - Input spectrum (1D)

 RETURNS:
   center     - Array of peak centers

 OUTPUTS:

 OPTIONAL KEYWORDS:
  PKWDTH   - Width of peak to center on (pixels) [default: 3L]
  NORDB    - Order for b-spline fit to the continuum of the
                spectrum [default: 31L]
  NSIG=    - Number of sigma signifcance for the peak [default: 5.]
  NEDG=    - Number of pixels peak must be from the edge of the
             spectrum [default: 5L]
  AFUNC=   - Name of function to fit to continuum [default: 'BSPLIN']
  MSK=     - Mask of good peaks
  ICLSE=   - Minimum separation between peaks [default: 4L]
  /ALL     - Pass back all peaks, not just the good ones
  /THIN    - Allow peaks to be 3 pixel thin [default: 5 pixel]
  /FORCE   - Force centering in x_centspln
  /NORECNT - Do not bother to try to recenter the peaks
  FRACPK=  - Fraction of peak to calculate centroid [default: 0.33]

 OPTIONAL OUTPUTS:
   PEAK=   - Integer values of centeroids of the peaks
  EDGES=   - Positions of the edges of each peak (usually 0.33 of

 COMMENTS:

 EXAMPLES:
   x_fndpeaks, spec, center


 PROCEDURES/FUNCTIONS CALLED:
 x_centspln

 REVISION HISTORY:
   14-Feb-2002 Written by JXP

(See Spec/Arcs//x_fndpeaks.pro)


X_FNDREG

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_fndreg
   Version 1.1

 PURPOSE:
    Finds data points within a number of regions.  
    [This is a rather difficult routine to use]

 CALLING SEQUENCE:
   
   pts = x_fndreg(xdat, reg)

 INPUTS:
   xdat - Data
   reg  - Regions:   fltarr(N,2)

 RETURNS:
   pts  - Points in the regions

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:
   NPNT -  Number of points within the regions
 COMMENTS:

 EXAMPLES:
   pts = x_fndreg( findgen(1000), [15., 25.])

 PROCEDURES CALLED:

 REVISION HISTORY:
   21-Nov-2001 Written by JXP

(See General//x_fndreg.pro)


X_FNDSLITOBJ

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_fndslitobj   
    Version 1.0

 PURPOSE:
    Given the slitstr and the map, find slit positions in the
    original image and create object structure

 CALLING SEQUENCE:
   
   x_fndslitobj, img, wvimg, slitstr

 INPUTS:
   img         - Flux image
   slitstr     - Slit structure

 RETURNS:

 OUTPUTS:
   Updates slitstr for original positions

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_fndslitobj, slitstr, map


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   14-Feb-2002 Written by JXP

(See Spec/Slits//x_fndslitobj.pro)


X_FNDSPLN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_fndspln
   Version 1.0

 PURPOSE:
    Solves for x in y = f(x) given a splined function f(x) and y

 CALLING SEQUENCE:
   
   xsolv = x_fndsplin(sx,sy,val,[splin] IPX=, TOLER=, /NEG=)

 INPUTS:
   sx         - Values where spline was pre-evaluated
   sy         - Values of the spline at sx
   val        - Value to match
   [splin]    - Spline (calculated if necessary)

 RETURNS:
   xsolv      - x position where the fit = val

 OUTPUTS:

 OPTIONAL KEYWORDS:
   TOLER      - Tolerance for match (default: 10^-4)
   IPIX       - Starting pixel in sx
   /NEG       - Proceed in the negative direction from IPIX
   /SILENT    - Turn off warning messages
   NITER      - Max number of iterations [default: 50L]

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   xsolv = x_fndspln(sx, sy, val)


 PROCEDURES/FUNCTIONS CALLED:
  SPLIN

 REVISION HISTORY:
   02-Feb-2002 Written by JXP

(See FIT//x_fndspln.pro)


X_FWEIGHT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
   x_fweight
    Version 1.1

 PURPOSE:
   Recenter a x using flux-weighted algorithm.

 CALLING SEQUENCE:
   xnew = x_fweight( fimage, xcen, ycen, [radius=radius, xerr=xerr, 
    invvar=invvar] )

 INPUTS:
   fimage     - Image
   xcen       - Initial guesses for X centers
   ycen       - Y positions corresponding to "xcen" (expected as integers)

 OPTIONAL KEYWORDS:
   radius     - Radius for centroiding; default to 3.0
   invvar     - Inverse variance of image used only in computing errors XERR.
                If not set, then INVVAR=1 is used.

 OUTPUTS:
   xnew       - New X centers

 OPTIONAL OUTPUTS:
   xerr       - Formal errors for XNEW; set equal to 999.0 if there are any
                masked pixels in a centroiding region (e.g., if INVVAR=0)

 COMMENTS:

 EXAMPLES:

 PROCEDURES CALLED:
   Dynamic link to x_fweight.c

 REVISION HISTORY:
   24-Mar-1999  Written by David Schlegel, Princeton.
   14-Aug-1999  Revised to loop

(See Spec/Arcs//x_fweight.pro)


X_GETMONTH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_getmonth  

 PURPOSE:
    Converts a number into a month

 CALLING SEQUENCE:
   
   month = x_setmonth(ival)

 INPUTS:
   ival    -  Long value of the month 

 RETURNS:
   month    -  String

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   month = x_getmonth(10)


 PROCEDURES CALLED:

 REVISION HISTORY:
   04-Jan-2002 Written by JXP

(See General//x_getmonth.pro)


X_GETOBJNM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_getobjnm
    Version 1.1

 PURPOSE:
  Get the index of the object name OR return the list of obj_nm.j 
  This is a pretty specific routine.  If obj_nm is not specified the
  routine launches a GUI to have the user choose.

 CALLING SEQUENCE:
   indx = x_getobjnm(objstr, [obj_nm], LST=)

 INPUTS:
  objstr  -- Object structure
  [obj_nm] -- Name of object for which the index is desired

 RETURNS:
   indx -  Index of the object name OR list of obj_nm

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /LST - Return the list instead of the index

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
  indx = x_getobjnm(objstr)
  list = x_getobjnm(objstr, /LST)


 PROCEDURES/FUNCTIONS CALLED:
 x_guilist

 REVISION HISTORY:
   30-Jul-2002 Written by JXP

(See Spec/Analysis//x_getobjnm.pro)


X_GETXPMNX

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_getxpmnx

 PURPOSE:
  Create an array of velocity arrays for a string of transitions

 CALLING SEQUENCE:
   pxmnx = x_getxpmnx(state)

 INPUTS:
  state -- Structure with TAGS wave, xymnx

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   pxmnx = x_getxpmnx(state)

 PROCEDURES CALLED:

 REVISION HISTORY:
   24-Oct-2002 Written by JXP

(See Spec/General//x_getxpmnx.pro)


X_GOLDEN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_golden
   Version 1.1

 PURPOSE:
    Uses the NR routine 'golden' to find the x-value where
    the function has a minimum

 CALLING SEQUENCE:
   
   min = x_golden(func,a,b,c TOL=)

 INPUTS:
   func - String name of the IDL function
   a,c  - Values bracketing the minimum
   b    - Best guess at minimum

 RETURNS:
   min - x-value of function minimum

 OUTPUTS:

 OPTIONAL KEYWORDS:
   TOL - Fractional Tolerance

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   num = x_golden('func', 0.0, 1.0)

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   25-Jan-2002 Written by JXP

(See General//x_golden.pro)


X_GUILIST

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_guilist   
   Version 1.1

 PURPOSE:
    Launches a cw_field, waits for the user to make a choice and
    then returns the index and value of the choice.  Routine will
    block any other GUI.

 CALLING SEQUENCE:
   
   value = x_guilist(list, title)

 INPUTS:
   list  - String array
   title - Title

 RETURNS:
   value - String

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   value = x_guilist( ['a', 'b', 'c'], INDX=indx )

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   04-Jan-2002 Written by JXP

(See General//x_guilist.pro)


X_GUINUM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_guinum   
   Version 1.0

 PURPOSE:
    Launches a cw_field and grabs a number from the user

 CALLING SEQUENCE:
   
   num = x_guinum(flg)

 INPUTS:
   flg = Return (0: float, 1: double, 2: Long)

 RETURNS:
   num - Number

 OUTPUTS:

 OPTIONAL KEYWORDS:
  TITLE= -- Title for the GUI [default: 'Num']

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   num = x_guinum( 0 )


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   20-Dec-2001 Written by JXP

(See General//x_guinum.pro)


X_GUISTRING

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_guistring   
   Version 1.0

 PURPOSE:
    Launches a cw_field and grabs a string from the user

 CALLING SEQUENCE:
   value = x_guistring(title)

 INPUTS:
   title - Title

 RETURNS:
   value - String

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   string = x_guistring( 'Enter filename: ')


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   04-Jan-2002 Written by JXP

(See General//x_guistring.pro)


X_HELPWIDG

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_helpwidg   
   Version 1.1

 PURPOSE:
    Creates a widget to display a help list which is simply an 
   array of strings that describe a GUI [or anything].

 CALLING SEQUENCE:
   x_helpwidg, help

 INPUTS:
   help       - String array of help statements

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
   xsize      - Draw window xsize (pixels)
   ysize      - Draw window ysize (pixels)

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_helpwidg, ['Help', 'h: Show this']


 PROCEDURES/FUNCTIONS CALLED:

; REVISION HISTORY:
   28-Nov-2001 Written by JXP

(See General//x_helpwidg.pro)


X_IDENTIFY

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_identify   
   Version 1.1

 PURPOSE:
    GUI used to create a wavelength solution to an arc line
    spectrum.  Similar to IRAFs identify

 CALLING SEQUENCE:
   
  x_identify, spec, calib, XSIZE=, YSIZE=, LINELIST=, $
               DISP=, LINEROOT=, $
               /DEBUG, MSK=, OUTLIN=, /REDBLUE=, WAVE=, FLUX=, INLIN=

 INPUTS:
   spec       - 1D flux spectrum (array)

 RETURNS:
   calib      - FIT Structure describing the wavelength solution

 OUTPUTS:

 OPTIONAL KEYWORDS:
   LINELIST   - Reference list (user can set interactively)
   LINEROOT   - Path to a set of line lists [default:
                /Spec/Arcs/Lists]
   DISP       - Guess at dispersion (A or km/s per pix [pos/neg
                value])
   /FLUX       - Assumes wide slit and therefore wide arc lines
  XSIZE,YSIZE -- Size of GUI in pixels
  /REDBLUE    - Spectrum runs from red to blue (not blue to red)

 OPTIONAL OUTPUTS:
   WAVE= -- Wavelength array for the arc line spectrum
  MSK=  -- ??
  OUTLIN= -- Lines structure which shows the lines used in the fit

 COMMENTS:

 EXAMPLES:
   x_identify, arc, calib


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   08-Dec-2001 Written by JXP
   19-Dec-2001 Added fitting
   01-Feb-2003 Added input

(See Spec/Arcs//x_identify.pro)


X_IMARITH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_imarith   
    Version 1.1

 PURPOSE:
    Performs arithmetic on two fits images (akin to IRAF)

 CALLING SEQUENCE:
   x_imarith, img1, oper, img2, outimg, FITS=

 INPUTS:
   img1 -- Image 1
   img2 -- Image 2
   oper -- String math operation (+,*,/,-)

 RETURNS:

 OUTPUTS:
   fimg -- Output image 

 OPTIONAL KEYWORDS:


 OPTIONAL OUTPUTS:
   FITS - fimg is a fits file (string)

 COMMENTS:

 EXAMPLES:
   x_imarith, 'f1.fits', '+', 'f2.fits', fimg
   x_imarith, 'f1.fits', '+', 'f2.fits', 's12.fits', /FITS


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   03-Aug-2001 Written by JXP
   29-Dec-2001 Modified

(See IMG/General//x_imarith.pro)


X_INTPHOTCAL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_intphotcal   
  Version 1.2

 PURPOSE:
    Allows the user to interactively perform a photometric solution.
   At its fullest, the code will calculate a zeropoint, an airmass
   term and a color term.
   The routine launches a GUI which allows the deletion 
   of specific stars.

 CALLING SEQUENCE:
   x_intphotcal, obs, landolt, outfil, XSIZE=, YSIZE=, /NCLR,
    MIN_NOBS=, MIN_MOBS=, SETAM=

 INPUTS:
   obs - Standard star observations  (stdstruct)
   landolt - Landolt info (lndltstr)

 RETURNS:

 OUTPUTS:
   OUTFIL -- ASCII file summary of the photometric solution.

 OPTIONAL KEYWORDS:
   XSIZE = size of gui
   YSIZE = size of gui
   MIN_NOBS= Min n value for Landolt star
   MIN_MOBS= Min m value for Landolt star
   /NCLR = Solve without color terms
   SETAM = Value taken for AM term 
        (Note: You cannot choose a value of 0. exactly!)

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_intphotcal, obs, landolt, outfil


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   08-Aug-2001 Written by JXP
   07-Jan-2002 Revised by JXP
   14-Oct-2002 Revised by JXP [setup no AM, no CLR terms]

(See IMG/Photometry//x_intphotcal.pro)


X_INVERTARC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_invertarc   
    Version 1.1

 PURPOSE:
    Converts an Arc image in the flat frame to the original
     Uses a C program, is a memory hog

 CALLING SEQUENCE:
   
   newarc = x_invertarc( arcimg, map )

 INPUTS:
   arcimg  - Arc image in the flat frame (data or fits file)
   map     - Map image (data or fits file)

 RETURNS:
   newarc  - Arc image in the Original frame

 OUTPUTS:

 OPTIONAL KEYWORDS:
  YSTRT  - Row defining the arcfit (default = middle)
  LINELIST  - Arc line list
  NSIG  - Sig of RMS from the fit that line must match

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   newarc = x_invertarc( arcimg, map, /DBL)

 PROCEDURES/FUNCTIONS CALLED:
  C code: invert_arc

 REVISION HISTORY:
   18-Feb-2002 Written by JXP

(See Spec/Arcs//x_invertarc.pro)


X_KECKHELIO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
   x_keckhelio
  Version 1.1

 PURPOSE:
   Compute correction term to add to velocities to convert to heliocentric.

 CALLING SEQUENCE:
   vcorr = x_keckhelio( ra, dec, [epoch], jd=, tai=, $
    longitude=, latitude=, altitude= )

 INPUTS:
   ra             - Right ascension [degrees]
   dec            - Declination [degrees]
   [epoch]          - Epoch of observation for RA, DEC; default to 2000.

 RETURNS:
   vcorr          - Velocity correction term, in km/s, to add to measured
                    radial velocity to convert it to the heliocentric frame.
 OPTIONAL KEYWORDS:
   jd             - Decimal Julian date.  Note this should probably be
                    type DOUBLE.
   tai            - Number of seconds since Nov 17 1858; either JD or TAI
                    must be specified.  Note this should probably either
                    be type DOUBLE or LONG64.
   longitude      - Longitude of observatory;
                    default to (360-155.47220) deg for APO
   latitute       - Latitude of observatory; default to 32.780361 deg for APO
   altitude       - Altitude of observatory; default to 4000 m for
                    Keck

 OUTPUTS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 BUGS:

 PROCEDURES CALLED:
   baryvel
   ct2lst

 REVISION HISTORY:
   09-May-2000  Written by S. Burles & D. Schlegel
   30-Aug-2002  Revised by JXP for Keck

(See Spec/General//x_keckhelio.pro)


X_LNDLTCAT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_lndltcat   
   Version 1.1

 PURPOSE:
    Creates a fits file of the Landolt table.  Probably needs
  to be run only once unless a typo is corrected.

 CALLING SEQUENCE:
   x_lndltcat, fil, fitsfil

 INPUTS:
   fil - Name of the landolt file

 RETURNS:

 OUTPUTS:
   fitsfil - Name of fits file to create

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:
  STRCT - Structre of the landolt file

 COMMENTS:

 EXAMPLES:
   x_lndltcat, '/u/xavier/idl/xidl/IMG/Photometry/Lists/nlandolt.dat', 
   'Landolt.fits'


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   08-Aug-2001 Written by JXP

(See IMG/Photometry//x_lndltcat.pro)


X_LNDLTCLR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_lndltclr   
    Version 1.1

 PURPOSE:
    Returns the Landolt color of a star

 CALLING SEQUENCE:
   
   clr = x_lndltclr(color, lndltstr) 

 INPUTS:
   color - String name of the color (e.g. 'BV')
   lndlstr - Structure of the landolt star

 RETURNS:
   clr - Color of the Landolt star

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   clr = x_lndltclr('BR', landolt)

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   08-Aug-2001 Written by JXP

(See IMG/Photometry//x_lndltclr.pro)


X_LNDLTMAG

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_lndltmag   
    Version 1.1

 PURPOSE:
    Returns the Landolt magnitude for a given filter

 CALLING SEQUENCE:
   
 mag = x_lndltmag(filter, lndltstr, SIGMAG=)

 INPUTS:
   filter - String name of the filter
   lndlstr - Structure of the landolt star

 RETURNS:
   mag - magnitude

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:
  SIGMAG = Error in the magnitude

 COMMENTS:

 EXAMPLES:
   mag = x_lndltmag('R', landolt, SIGMAG=sig)


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   08-Aug-2001 Written by JXP

(See IMG/Photometry//x_lndltmag.pro)


X_MAXSPLN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_maxspln   
   Version 1.1

 PURPOSE:
    Finds the maximum in a set of data using a spline.  The program
    simply splines the data and then finds the max.

 CALLING SEQUENCE:
   
   maxsp = x_maxspln( xval, yval, EDGES=, EDGVAL= )

 INPUTS:
   xval       - x pos
   yval       - y pos (values to be maximized)

 RETURNS:
   maxsp      - Maximum of the values

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:
  EDGES   -- x-value Edges of peak corresponding to 0.333
  EDGVAL  -- y-value Edges of peak corresponding to 0.333

 COMMENTS:

 EXAMPLES:
   maxsp = x_maxspln(x, y)

 PROCEDURES/FUNCTIONS CALLED:
  x_golden

 REVISION HISTORY:
   29-Jan-2002 Written by JXP

(See FIT//x_maxspln.pro)


X_MEDSIGCLIP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
   x_medsigclip

 PURPOSE:
   Median multiple images with sigma-rejection.  Akin to avsigclip
   but does median analysis instead of averaging.  This is my favorite
   combine routine.

 CALLING SEQUENCE:
   result = x_medsigclip( array, [ dimension, siglo=, sighi=, maxiter=, $
    inmask=, ] )

 INPUTS:
   array      - N-dimensional array

 OPTIONAL INPUTS:
   dimension  - The dimension over which to collapse the data.  If ommitted,
                assume that the last dimension is the one to collapse.
   siglo     - Low Sigma for rejection; default to 3.0.
   sighi     - High Sigma for rejection; default to 3.0.
   maxiter    - Maximum number of sigma rejection iterations.  One iteration
                does no sigma rejection; default to 10 iterations.
   inmask     - Input mask, setting =0 for good elements
   gain       - Gain; Crucial for calculating sigma; default to 1.0
   rn         -  Readnoise; Crucial for calculating sigma; default to 7.0

 OUTPUTS:
   result     - The output array.
   outmask    - Output mask, setting =0 for good elements, =1 for bad.
                Any pixels masked in INMASK are also masked in OUTMASK.

 OPTIONAL OUTPUTS:

 COMMENTS:
   The DIMENSION input is analogous to that used by the IDL built-in
   function TOTAL.

 EXAMPLES:
   Create a data cube of 10 random-valued 100x200 images.  At each pixel in
   the image, compute the median of the 10 values, but rejecting 3-sigma
   outliers:
   > array = randomu(123,100,200,10)
   > med = x_medsigclip(array, siglo=3., sighi=4.)


   If all points are masked in any given vector or array, a mean and
   dispersion are computed for all the points.  Is this the behaviour we want?
   If you want to replace those values with zeros instead, look at OUTMASK:
   > array = randomu(123,100,200)
   > inmask = bytarr(100,200)
   > inmask[*,8] = 1 ; mask all of row #8
   > ave = x_avsigclip(array, 1, inmask=inmask, outmask=outmask)
   > ibad = where( total(1-outmask, 1) EQ 0)
   > if (ibad[0] NE -1) then ave[ibad] = 0 ; zero-out bad rows

 BUGS:

 PROCEDURES CALLED:
   Dynamic link to arravsigclip.c

 REVISION HISTORY:
   07-Jul-1999  Based on djs_avsigclip; Written by David Schlegel, Princeton.
   28-Jul-2001  Modfied by JXP (Added lo/hi sigrej, does median)

(See IMG/Reduction//x_medsigclip.pro)


X_MKABSLIN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_mkabslin

 PURPOSE:
    Creates a FITS file from the standard line lists.  Not
    particularly useful anymore.

 CALLING SEQUENCE:
   x_mkabslin

 INPUTS:
   wave       - ionic transition

 RETURNS:
   f          - oscillator strength

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:
   nam        - Name of transition

 COMMENTS:

 EXAMPLES:
   x_mkabslin, 1215.6701, fval, name


 PROCEDURES CALLED:

 REVISION HISTORY:
   16-Oct-2002 Written by JXP

(See Spec/Lines//x_mkabslin.pro)


X_MSKLAYOUT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_msklayout   
    Version 1.1

 PURPOSE:
    Allows the user to interactively place slitmasks on a field of
  targets and write out their positions and PA values

 CALLING SEQUENCE:
   x_msklayout, targ, instr

 INPUTS:
   img        - Image(s) for Masking
   instr      - Name of instrument (LRIS, DEIMOS)

 RETURNS:

 OUTPUTS:
   mask       -  Creates a fits table of pixel values to mask

 OPTIONAL KEYWORDS:
  SECTRG  -- 2nd set of targets to plot (in alternate point style)
  ASTAR   -- File containing the positions of Alignment stars
  PVOBJ   -- File of objects previously observed

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_msklayout, img, 'SITe1', 'LCO-40'


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   04-Jan-2004 Written by JXP

(See Obs//x_msklayout.pro)


X_NORMFLAT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_normflat   
    Version 1.0

 PURPOSE:
    Normalizes a multi-slit flat given the slit structure

 CALLING SEQUENCE:
   
   nrmflat = x_normflat( flat, slitstr, [var, nrmvar] )

 INPUTS:
   flat       - Flat image or fits file
   slistr     - Slit structure

 RETURNS:
   nrmflat    - Normalized flat   

 OUTPUTS:

 OPTIONAL KEYWORDS:
  YMED      -  Number of pixel offset from yedg to take median of
  YNRM      -  Number of pixels outside yedg to normalize

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   nrmflat = x_normflat( flat, slitstr )


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   11-Feb-2002 Written by JXP
   15-Feb-2002 Revised to allow normalization of original
   27-Mar-2004 Revised by MRB to not analyze flg_anly==0 slits

(See Spec/Slits//x_normflat.pro)


X_NORMSPEC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_normspec   
    Version 1.0

 PURPOSE:
    Normalizes a multi-slit image given a normalized flat

 CALLING SEQUENCE:
   
   nrmspec = x_normspec( img, flat, [var, nrmvar])

 INPUTS:
   flat       - Flat image or fits file
   slistr     - Slit structure

 RETURNS:
   nrmspec    - Normalized flat   

 OUTPUTS:

 OPTIONAL KEYWORDS:
  YMED      -  Number of pixel offset from yedg to take median of
  YNRM      -  Number of pixels outside yedg to normalize

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   nrmspec = x_normspec( img, flat)


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   20-Feb-2002 Written by JXP

(See Spec/Slits//x_normspec.pro)


X_OBJNUMID

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_objnumid   
    Version 1.1

 PURPOSE:
    Turns an integer into a letter for Obj identification

 CALLING SEQUENCE:
   
   idval = x_objnumid( num )

 INPUTS:
  num - An integer

 RETURNS:
  idval -- A letter (0='a', 1='b', etc.)

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   idval = x_objnumid( 1 )

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   03-Mar-2002 Written by JXP

(See Spec/Slits//x_objnumid.pro)


X_OPLOTCIRC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_oplotcirc

 PURPOSE:
   Overplot a circle on a current plot given center and radius

 CALLING SEQUENCE:
   x_oplotcirc, rad, x0=, y0=, NPT=, _EXTRA=

 INPUTS:
  rad -- Radius of the circle (plot units)

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  x0 -- x-center of the circle [default: 0.]
  y0 -- y-center of the circle [default: 0.]
  NPT -- Number of points to discretize the circle [default: 1000L]

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
  x_oplotcirc, 2., x0=3., y0=4.

 PROCEDURES CALLED:

 REVISION HISTORY:
   22-Nov-2003 Written by JXP

(See General//x_oplotcirc.pro)


X_ORIGSLIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_origslit   
    Version 1.0

 PURPOSE:
    Given the slitstr and the map, find slit positions in the
    original image.  The values are filled into the slit structure.

 CALLING SEQUENCE:
   x_origslit, slitstr, map, /INVERSE

 INPUTS:
   slitstr     - Slit structure
   map         - y-distortion map (fits is ok)

 RETURNS:

 OUTPUTS:
   Updates slitstr for original positions

 OPTIONAL KEYWORDS:
  /INVERSE  -- The map is the inverse!

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_origslit, slitstr, map


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   14-Feb-2002 Written by JXP

(See Spec/Slits//x_origslit.pro)


X_PHOTCAL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_photcal   
   Version 1.1

 PURPOSE:
    Derives a photometric solution for standard stars

 CALLING SEQUENCE:
   
 x_photcal, obs, landolt, ans, sig, MINSIG=, SETAM=, NCORR=, CHISQ=

 INPUTS:
   obs - Standard star observations  (stdstruct)
   landolt - Landolt info (lndltstr)

 RETURNS:
   ans - Fit
   sig - Error on the fit parameters

 OUTPUTS:

 OPTIONAL KEYWORDS:
  MINSIG - Minimum error for obs+landolt        (default = 0.01)
  MAXSIG - Maximum error to include in analysis (default = 0.1)
  SETAM   - Value to assume for the airmass term
  /NOCLR  - No color term (e.g. only one filter solution)
  MIN_NOBS  - Minimum number of n epochs to include (default = 4)
  MIN_MOBS  - Minimum number of m epochs to include (default = 2)

 OPTIONAL OUTPUTS:
  NCORR - Normalized correlation matrix
  CHISQ - Chisq of the calibrated fit

 COMMENTS:

 EXAMPLES:
   x_photcal, obs, landolt, ans, sig

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   08-Aug-2001 Written by JXP

(See IMG/Photometry//x_photcal.pro)


X_PHOTSOL1

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_photsol1   
   Version 1.1

 PURPOSE:
    Performs the linear algebra on a set of obs with 1 free
    parameters, i.e., Airmass fixed and NO color term

 CALLING SEQUENCE:
   
 x_photsol1, mo0, mT, sig, airmass, setam, coeffs, sigma_coeff,
              COLOR=

 INPUTS:
   mo0 -  Observed magnitudes
   mT  -  True magnitudes
   sig - Combined Error 
   airmass - Airmass values
   SETAM - Value to set air mass coefficient to [Assumed positive!]

 RETURNS:
   coeffs - Fit
   sigma_coeffs - Error on the fit

 OUTPUTS:

 OPTIONAL KEYWORDS:
   color   - Color values

 OPTIONAL OUTPUTS:
  CHISQ - chisq

 COMMENTS:

 EXAMPLES:
   x_photsol1, blah

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   09-Aug-2001 Written by JXP

(See IMG/Photometry//x_photsol1.pro)


X_PHOTSOL2

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_photsol2   
   Version 1.1

 PURPOSE:
    Performs the linear algebra on a set of obs with 2 free
    parameters, i.e., either Airmass fixed or NO color term

 CALLING SEQUENCE:
   
 x_photsol2, mo0, mT, sig, airmass, coeffs, sigma_coeff,
              SETAM=, COLOR=, CHISQ=

 INPUTS:
   mo0 -  Observed magnitudes
   mT  -  True magnitudes
   sig - Combined Error 
   airmass - Airmass values

 RETURNS:
   coeffs - Fit
   sigma_coeffs - Error on the fit

 OUTPUTS:

 OPTIONAL KEYWORDS:
   SETAM - Value to set air mass coefficient to [Assumed positive!]
   color   - Color values

 OPTIONAL OUTPUTS:
  CHISQ - chisq

 COMMENTS:

 EXAMPLES:
   x_photsol2, blah


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   08-Aug-2001 Written by JXP

(See IMG/Photometry//x_photsol2.pro)


X_PHOTSOL3

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_photsol3   
   Version 1.1

 PURPOSE:
    Performs the linear algebra on a set of obs.  Fits for three
  free parameters: zero point, airmass term, color term

 CALLING SEQUENCE:
   
 x_photsol3, mo0, mT, sig, airmass, color, coeffs, sigma, 
      CHISQ=, NCORR=

 INPUTS:
   mo0 -  Observed magnitudes
   mT  -  True magnitudes
   sig - Combined Error 
   airmass - Airmass values
   color   - Color values

 RETURNS:
   coeffs - Fit
   sigma_coeffs - Error on the fit

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:
  NCORR - Normalized correlation matrix
  CHISQ - chisq

 COMMENTS:

 EXAMPLES:
   x_photsol3, blah


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   08-Aug-2001 Written by JXP

(See IMG/Photometry//x_photsol3.pro)


X_PIXMINMAX

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_pixminmax
  Version 1.1

 PURPOSE:
  Find pixels in the wavelength array corresponding to the redshift
  and rest wavelength.

 CALLING SEQUENCE:
   
   x_pixminmax, wave, wrest, zabs, [vmin, vmax], PIXMIN=, PIXMAX=, VELO=

 INPUTS:
  wave -- Wavlength array
  wrest -- Rest wavelength of transition
  zabs -- Absorption redshift
  [vmin,vmax] -- Velocity minimum and maximum

 RETURNS:

 OUTPUTS:
  PIXMIN -- Pixel value corresponding to VMIN
  PIXMAX -- Pixel value corresponding to VMAX
  VELO -- Velocity array

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_pixminmax, wave, 1808.0126d, 1.5, -100., 50., PIXMIN=pixmn

 PROCEDURES CALLED:

 REVISION HISTORY:
   10-Jun-2002 Written by JXP

(See General//x_pixminmax.pro)


X_PLTOBJ

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_pltobj
    Version 1.1

 PURPOSE:
   Sophisticated GUI for plotting 1D and 2D spectra together.

 CALLING SEQUENCE:
  x_pltobj, wave, fx, sig, infx, inwv, [imgwv], YSIZE=
             XSIZE=, PMNX=, YSIZE=, OBJNM=, ZIN=, XMAX=, LLIST=

 INPUTS:
 wave -- 1D Wavelength array
 fx   -- 1D flux array
 sig  -- 1D sigma array
 infx -- 2D flux image
 inwv -- 2D wavelength image
 [imgwv] -- 1D wavelength array giving approximate wave of the 2D
            image

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  XSIZE= -- Size of gui in screen x-pixels [default = ssz-300]
  YSIZE= -- Size of gui in screen y-pixels [default = ssz-400]
  PMNX=  -- Plot range of the 1D spectrum
  ZIN=   -- Input redshift for the object
  LLIST= -- Line list to use upon initialization (1: QAL, 2: GAL, 3:
            QSO)
  OBJNM= -- Title for the plot
  XMAX=  -- Maximum x value for the 1D plot

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_pltobj, x, maskid, expsr


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   19-Apr-2002 Written by JXP

(See Spec/Analysis//x_pltobj.pro)


X_PRSPEAKS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_prspeaks   
     Version 1.1

 PURPOSE:
    Plots any array interactively

 CALLING SEQUENCE:
   
   x_prspeaks, [xdat], ydat, XSIZE=, YSIZE=, TITLE=, XTWO=, YTWO=, PSYM_Y2=,
      /BLOCK

 INPUTS:
   [xdat]     - x values (optional)
   ydat       - Values 

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
   xsize      - Draw window xsize (pixels)
   ysize      - Draw window ysize (pixels)
   TITLE
   YTWO
   PSYM_y2
   BLOCK

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_prspeaks, y


 PROCEDURES/FUNCTIONS CALLED:
  XGETX_PLT
  XGETY_PLT
  XGETXPIX_PLT
  XGETYPIX_PLT

 REVISION HISTORY:
   17-Nov-2001 Written by JXP (modified from x1dfit)
   24-Nov-2001 Added ytwo

(See Spec/Arcs//x_prspeaks.pro)


X_PSCLOSE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_psclose
   Version 1.1

 PURPOSE:
    Call ps_close and reset a number of default values.  Point window
   at X-windows.

 CALLING SEQUENCE:
   
 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:
  ps_close
  set_plot

 REVISION HISTORY:
   09-Feb-2004 Written by JXP

(See General//x_psclose.pro)


X_PSOPEN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_psopen
   Version 1.1

 PURPOSE:
  Calls ps_open and sets a number of default plotting values.  

 CALLING SEQUENCE:
   
   x_psopen, fil, /MAXS, /PORTRAIT

 INPUTS:
   img       - Fits file or data

 RETURNS:
   dat       - Data in fits file or the input data

 OUTPUTS:

 OPTIONAL KEYWORDS:
  FSCALE      - Data is float

 OPTIONAL OUTPUTS:
  HEAD        - Header

 COMMENTS:

 EXAMPLES:


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   09-Feb-2004 Written by JXP

(See General//x_psopen.pro)


X_QABND

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_qabnd
   Version 1.1

 PURPOSE:
    Given an abundance file, quickly converts to standard [X/H] notation

 CALLING SEQUENCE:
   
   x_qabnd, fil, [NHI]

 INPUTS:
   fil - Abundance file (extension .XH generally)
   NHI -- NHI value of system

 RETURNS:

 OUTPUTS:
  Prints the [X/H] values to the screen

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_qabnd, 'q0405.XH', NHI=15.4

 PROCEDURES CALLED:
  getabnd

 REVISION HISTORY:
   19-Dec-2001 Written by JXP

(See General//x_qabnd.pro)


X_QCOADD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_qcoadd
    Version 1.1

 PURPOSE:
  Coadd spectra.  I highly recommend x_combspec.

 CALLING SEQUENCE:
   x_qcoadd, wv1, fx1, wv2, fx2, wvt, fxt

 INPUTS:
  wv1  -- First wavelength array
  fx1  -- First flux array
  wv2  -- Second wavelength array
  fx2  -- Second flux array

 RETURNS:
  wvt  -- Combine

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_qskysub, slitstr, map


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   14-Feb-2002 Written by JXP

(See Spec/Extraction//x_qcoadd.pro)


X_QSKYSUB

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_qskysub   
    Version 1.1

 PURPOSE:
  Sky subtract column by column using a POLY fit.

 CALLING SEQUENCE:
  x_qskysub, data_fil, slit_fil, slit, subimg, pix

 INPUTS:
   data_fil    - Name of Image file
   slit_fil    - File for slit structure
   slit        - Slit to sky subtract

 RETURNS:
   subimg  -- Sub area of the img array corresponding to the slit

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:
 NWIMG -- Sky subtracted image

 COMMENTS:

 EXAMPLES:
   x_qskysub, 


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   14-Feb-2002 Written by JXP

(See Spec/Extraction//x_qskysub.pro)


X_RADEC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_radec

 PURPOSE:
    Turns RA, DEC in XX:XX:XX.X -DD:DD:DD.D format to decimal deg
      or VICE VERSA

 CALLING SEQUENCE:
   
   x_radec, ra, dec, rad, decd, /ARCS, /FLIP

 INPUTS:
   ra, dec    - RA and DEC in in RR:RR:RR.R -DD:DD:DD.D format 
                 Colons are required as separators
   rad, decd  - RA and DEC in decimal degrees (double)

 RETURNS:

 OUTPUTS:
   ra, dec    - RA and DEC in in RR:RR:RR.R -DD:DD:DD.D format 
                 Colons are required as separators
   rad, decd  - RA and DEC in decimal degrees (double)

 OPTIONAL KEYWORDS:
   ARCS - Outputs in arcseconds
   /FLIP - Gives RA and DEC from decimal RA,DEC
   /LONG -- Passes back a longer form (string only)

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_radec, '21:12:23.1', '-13:13:22.2', rad, decd

 PROCEDURES CALLED:

 REVISION HISTORY:
   04-Aug-2001 Written by JXP
   20-Nov-2003 Added + sign for /flip

(See General//x_radec.pro)


X_READIMG

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_readimg   
   Version 1.0

 PURPOSE:
    Convert input to data whether it is a fits file or an image array

 CALLING SEQUENCE:
   
   dat = x_readimg(img)

 INPUTS:
   img       - Fits file or data

 RETURNS:
   dat       - Data in fits file or the input data

 OUTPUTS:

 OPTIONAL KEYWORDS:
  FSCALE      - Data is float
  DSCALE      - Data is double

 OPTIONAL OUTPUTS:
  HEAD        - Header

 COMMENTS:

 EXAMPLES:
   dat = x_readimg('spec.fits')


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   07-Dec-2001 Written by JXP

(See General//x_readimg.pro)


X_READSPEC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_readspec
   Version 1.1

 PURPOSE:
    Create a spectrum from a FITS file or a pair of data arrays

 CALLING SEQUENCE:
   dat = x_readspec(spec, dataunit, INFLG=, /FSCALE, HEAD=, /DSCALE, SIG=
     WAV=, NPIX=, FIL_SIG= )

 INPUTS:
   spec       - Fits file or data

 RETURNS:
   dat       - Data in fits file or the input data

 OUTPUTS:

 OPTIONAL KEYWORDS:
  FSCALE      - Data is float
  DSCALE      - Data is float
  INFLG: 0  - Data, sig separate fits files  dat =
              x_readspec(data_fil, FIL_SIG=sig_fil, SIG=sig, WAV=wav)
         1  - Flux and Sig in one fits file
         2  - Flux, sig, wave in one fits file
         3  - FUSE format
         4  - Flux in first argument, sigma in SIG (data arrays)
         5  - SDSS format

 OPTIONAL OUTPUTS:
  HEAD        - Header

 COMMENTS:

 EXAMPLES:
   dat = x_readspec('spec.fits')


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   26-Feb-2002 Written by JXP

(See Spec/General//x_readspec.pro)


X_REBIN2DSPEC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_rebin2dspec
   Version 1.1

 PURPOSE:
    Rebin a single data set to a new wavlength scale
      Simple adding (no weighting by S/N)

 CALLING SEQUENCE:
  x_rebin2dspec, wv, fx, nwwv, nwfx, VAR=, NWVAR=, GDPIX=,
                  /SILENT, /REDBLUE, /CR, /REBINC

 INPUTS:
   wv   -- Wavelength array
   fx   -- Flux array
   newwv -- New wavelength array to rebin to

 RETURNS:

 OUTPUTS:
   newfx -- New flux array

 OPTIONAL KEYWORDS:
  VAR=     -- Data is float
  /REBINC  -- Rebin using a C program
  /REDBLUE -- Data runs from red to blue

 OPTIONAL OUTPUTS:
  NEWVAR=  - New variance array
  /CR      - VAR = -1 flag CR and eliminate the pix

 COMMENTS:

 EXAMPLES:
   x_rebin2dspec, gdpix, orig_wv, orig_fx, newwv, newfx


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   12-Apr-2002 Written by JXP
   24-Aug-2002 Added C program

(See Spec/General//x_rebin2dspec.pro)


X_RECTIFY

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_rectify   
    Version 1.1

 PURPOSE:
    Takes the y-distortion map and rectifies an image

 CALLING SEQUENCE:
   
   rect = x_rectify(img, map, /TRANSP, /SILENT, /DBL, /FIDL)

 INPUTS:
   img       - Input image
   map       - y-distortion map

 RETURNS:
   rect      - Rectified image

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /FIDL  -- Do this using IDL as opposed to a fast C program
  /TRANSP -- Transpose the image first
  /DBL   -- Return the rectified image in double precision

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   rect = x_rectify(flat, map)


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   29-Jan-2002 Written by JXP
   13-Aug-2002 Added transpose option (JXP)

(See Spec/Rectify//x_rectify.pro)


X_REGISTER

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_register   
   Version 1.1

 PURPOSE:
    Given a set of offsets between images, this routine will
   create final images that are registered.

 CALLING SEQUENCE:
   
   x_register, img, offsets, GOODREG=, OUTPTH=

 INPUTS:
   img -- Array of image names (assumes _sig extensions for sig
          files)
   offsets -- Integer offsets between images

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
   goodreg -- Region of each image (4 int array) defining good data
               Formatted (x0,x1,y0,y1)
   OUTPTH  -- Output path for the images

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_regsiter, img, off, GOODREG=good

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   02-Aug-2001 Written by JXP

(See IMG/Reduction//x_register.pro)


X_SETAPER

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_setaper   
       Version 1.1

 PURPOSE:
    Determine an aperture automatically

 CALLING SEQUENCE:
   x_setaper, spec, center, [frac], RADIUS=, /SKYSUB

 INPUTS:
   spec      - Spectrum (fits file ok)
   center    - center of aperture (guess, actual center not essential)
   frac      - Fraction of profile to extract [default: 0.05 off each side]

 RETURNS:
   aperture  - Aperture: float(2) array around center

 OUTPUTS:

 OPTIONAL KEYWORDS:
  RADIUS=  -- Region of object profile to consider
  /SKYSUB  -- Calculate a median sky at outer regions of slit and 
              subtract off

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_setaper, 'spec.fits', 200.


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   01-Apr-2001 Written by JXP
   02-May-2002 Revised sky level

(See Spec/Extraction//x_setaper.pro)


X_SETAPERGUI

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_setapergui   
       Version 1.1

 PURPOSE:
   Sets objects and apertures interactively using a GUI

 CALLING SEQUENCE:
   x_setapergui, img, XSIZE=, YSIZE=, CLINE=, PEAKFRAC=, OBJSTR=

 INPUTS:
   img   - 1D or 2D image

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
   xsize      - Draw window xsize (pixels)
   ysize      - Draw window ysize (pixels)
   CLINE      - Center line for 2D image to 'extract' 1D [default: sz[1]/2]
   PEAKFRAC=  - Fraction of peak 

 OPTIONAL OUTPUTS:
  OBJSTR=  -- Object structure with the aperture filled in.  This will
              include multiple objects if they are identified.

 COMMENTS:

 EXAMPLES:
   x_setapergui, 'spec.fits'

 PROCEDURES/FUNCTIONS CALLED:
  XGETX_PLT
  XGETY_PLT
  XGETXPIX_PLT
  XGETYPIX_PLT
  GETCOLOR (Coyote)
  DJS_MEDIAN

 REVISION HISTORY:
   17-Nov-2001 Written by JXP

(See Spec/Extraction//x_setapergui.pro)


X_SETCLRS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_setclrs

 PURPOSE:
    Creates an array of colors useful for converting index
    numbers into color

 CALLING SEQUENCE:
   
   xcolors = x_setclrs()

 INPUTS:
   [nclr]  - Optional input setting the array size (Default is 12)

 RETURNS:
   xcolors - String Array of colors

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
  xcolors = x_setclrs()

 PROCEDURES CALLED:
   getcolor (Coyote package)

 REVISION HISTORY:
   25-Nov-2001 Written by JXP

(See Color//x_setclrs.pro)


X_SETDDATE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_setddate   
  Version 1.1

 PURPOSE:
    Converts a string date into decimal date 

 CALLING SEQUENCE:
   ddate = x_setddate(date)

 INPUTS:
   date     - String name of the date
      Allowed formats:  DDmmmYY  (e.g. 22Oct99)
                        DD-MM-YY (e.g. 20-12-99)
                        YYYY-MM-DD (e.g. 1999-12-20)

 RETURNS:
   ddate    -  Decimal date

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:
   If Year is < 50, then the year 2000 is presumed

 EXAMPLES:
   ddate = x_setddate('29Oct00')

 PROCEDURES CALLED:

 REVISION HISTORY:
   07-Aug-2001 Written by JXP

(See General//x_setddate.pro)


X_SETFITSTRCT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_setfitstrct   
     Version 1.1

 PURPOSE:
    Initizlies a 1D FIT structure.

 CALLING SEQUENCE:
   
  fitstr = x_setfitstrct(NITER=, MINPT=, MAXREJ=, FUNC=, NORD=,
  HSIG=, lSIG=, FLGREJ=)

 INPUTS:

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  NITER -- Number of iterations for FIT  [default: 1L]
  MINPT -- Number of points to keep in FIT [default: 1L]
  MAXREJ -- Max Number of points to reject [default: 100L]
  FUNC -- Max Number of points to reject [default: 'POLY']
  NORD -- Order of the fit [default: 3L]
  HSIG -- Upper sigma for rejection [default: 3.]
  LSIG -- Lower sigma for rejection [default: 3.]
  /FLGREJ -- Turn on rejection [default: NONE]

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   fitstr= x_setfitstrct(/FLGREJ)

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   17-Jul-2002 Written by JXP

(See FIT//x_setfitstrct.pro)


X_SETJDATE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_setjdate   
  Version 1.1

 PURPOSE:
    Converts a string date into Julian date 

 CALLING SEQUENCE:
   
   jdate = x_setjdate(date, [UTTIME])

 INPUTS:
   date     - String name of the date
      Allowed formats:  DDmmmYY  (e.g. 22Oct99)
                        DD-MM-YY (e.g. 20-12-99)
                        YYYY-MM-DD (e.g. 1999-12-20)
   [UTTIME] -- To create JD with hr, min, sec

 RETURNS:
   jdate    -  Decimal date

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:
   If Year is < 50, then the year 2000 is presumed

 EXAMPLES:
   jdate = x_setjdate('29Oct00')


 PROCEDURES CALLED:

 REVISION HISTORY:
   31-Aug-2002 Written by JXP

(See General//x_setjdate.pro)


X_SETLINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_setline

 PURPOSE:
    Given an atomic wavelength, return the fvalue and name in the
    absorption line structure.

 CALLING SEQUENCE:
   linstr = x_setline(wave, LINFIL=)

 INPUTS:
   wave  - rest wavelength

 RETURNS:
  linstr -  Abslinstrct of the relevant line

 OUTPUTS:

 OPTIONAL KEYWORDS:
  LINFIL=  -- FITS file containing a set of ABSLINSTRCT entries

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   linstr = x_setline( 1215.6701 )

 PROCEDURES CALLED:

 REVISION HISTORY:
   17-Oct-2002 Written by JXP

(See Spec/Lines//x_setline.pro)


X_SETLLST

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_setllst
  Version 1.1

 PURPOSE:
    Returns a line list sturcture gven a file and a flag

 CALLING SEQUENCE:
   
   llist = x_setllst(file, fmt)

 INPUTS:
   file       - Line list filename
   fmt        - Format of line file  
                    0='lin.dat', 1=Gal or QSO line list

 RETURNS:
   llist - Structure of linelists

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   llist = x_setllst('/u/xavier/bin/junk/lin.dat', 0)

 PROCEDURES CALLED:

 REVISION HISTORY:
   17-Sat-2001 Written by JXP

(See Spec/Lines//x_setllst.pro)


X_SETOBJGUI

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       x_setobjgui
   Version 1.1
 
 PURPOSE: 
       Interactive display of slit mask and slit positions and object
       traces to allow verificaiton of the identificaitons and
       traces.  Largely based on ATV

 CATEGORY: 
       Image display.

 CALLING SEQUENCE:
       x_setobjgui img, slitstr, objstr, [,min = min_value] 
           [,max=max_value] 
           [,/linear] [,/log] [,/histeq] [,/block]
           [,/align] [,/stretch] [,header = header]

 REQUIRED INPUTS:
   img  -- FITS file
   slitstr -- Slit structure
   objstr  -- Object sturcture

 OPTIONAL INPUTS:
       array_name: a 2-D data array to display
          OR
       fits_file:  a fits file name, enclosed in single quotes

 KEYWORDS:
       min:        minimum data value to be mapped to the color table
       max:        maximum data value to be mapped to the color table
       linear:     use linear stretch
       log:        use log stretch 
       histeq:     use histogram equalization
       block:      block IDL command line until ATV terminates
       align:      align image with previously displayed image
       stretch:    keep same min and max as previous image
       header:     FITS image header (string array) for use with data array
       
 OUTPUTS:
       None.  
 
 COMMON BLOCKS:
       x_setobjgui_state:  contains variables describing the display state
       x_setobjgui_images: contains the internal copies of the display image
       x_setobjgui_color:  contains colormap vectors
       x_setobjgui_pdata:  contains plot and text annotation information

 RESTRICTIONS:
       Requires IDL version 5.1 or greater.
       Requires Craig Markwardt's cmps_form.pro routine.
       Requires the GSFC IDL astronomy user's library routines.
       Some features may not work under all operating systems.

 SIDE EFFECTS:
       Modifies the color table.

 EXAMPLE:
       To start x_setobjgui running, just enter the command 'x_setobjgui' at the idl
       prompt, either with or without an array name or fits file name 
       as an input.  Only one x_setobjgui window will be created at a time,
       so if one already exists and another image is passed to x_setobjgui
       from the idl command line, the new image will be displayed in 
       the pre-existing x_setobjgui window.

 MODIFICATION HISTORY:
       Written by Aaron J. Barth, with contributions by 
       Douglas Finkbeiner, Michael Liu, David Schlegel, and
       Wesley Colley.  First released 17 December 1998.

       This version is 1.3, last modified 28 November 2000.
       For the most current version, revision history, instructions,
       list of known bugs, and further information, go to:
              http://cfa-www.harvard.edu/~abarth/x_setobjgui/x_setobjgui.html
       Revised by JXP Aug-2001

(See Spec/Slits//x_setobjgui.pro)


X_SETSLITS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
   x_setslits
 PURPOSE:
    Finds slit edges on the 'flattened' flat in the presence of rotation
 CALLING SEQUENCE:
   slackers_setslits, flatimg, slitstr
 INPUTS:
   flat        - Flat image or fits file
   slitstr     - Slit structure
 COMMENTS:
   This piece of code allows for a slight rotation (-2 to 2 deg) of
   the mask, which can cause overlapping slits and other annoying
   things.
 REVISION HISTORY:
  14-Feb-2002 Written by JXPj
   6-Apr-2004 Revised by MRB 

(See Spec/Slits//x_setslits.pro)


X_SETWAVE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
  x_setwave   
   Version 1.1

 PURPOSE:
    Sets a wavelength array given a header

 CALLING SEQUENCE:
   
   wave = x_setwave(head, ntot)

 INPUTS:
   head     - Header
   ntot     - number of pixels

 RETURNS:
   wave     - Wavelength array

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   wave = x_setwave(head, 1000L)


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   17-Nov-2001 Written by JXP 

(See Spec/General//x_setwave.pro)


X_SKYSUB

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_skysub   
   Version 1.1

 PURPOSE:
    Sky subtracts an input image

 CALLING SEQUENCE:
   newimg = x_skysub(img, SKY=, REG=, CREG=, SKYFSTR=,
                       TRACE=, /NOREJ)

 INPUTS:
   img        - OV subtracted image

 RETURNS:
   newimg     - Sky subtracted image

 OUTPUTS:

 OPTIONAL KEYWORDS:
    REG       -  Sky region
    CREG      -  Column used to define sky regions
    TRACE     -  1-D trace to the object
    SKYFSTR   -  Fit strcture for the sky
    /NOREJ    -  Do not reject bad points

 OPTIONAL OUTPUTS:
    sky       - 2-D image of the sky fit

 COMMENTS:

 EXAMPLES:
   fimg = x_skysub(img, REG=skyreg)


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   05-Dec-2001 Written by JXP
   07-Feb-2002 Revised to take fit structure

(See Spec/Extraction//x_skysub.pro)


X_SLCTLINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_slctline   
   Version 1.1

 PURPOSE:
    Launches a GUI and allows the user to select a line.  The code
    then returns the rest wavelength of that line.

 CALLING SEQUENCE:
   line = x_slctline, lines, /ISM, NLIN=, ILIN=, XOFFSET=, YOFFSET=, /GAL,
                    PDMENU=

 INPUTS:
   lines  - Line list structure

 RETURNS:
   line - Wavelength (double)

 OUTPUTS:
  line = unit number of line

 OPTIONAL KEYWORDS:
   /ISM     - ISM style
   /GAL     - Use the Galaxy style
   YOFFSET= - Placement of the GUI [default: 200]
   XOFFSET= - Placement of the GUI [default: 200]
   PDMENU=  - String array formatted for cw_pdmenu
   NLIN=    - Grab only the first NLIN lines (only for non-ISM or
              GAL)

 OPTIONAL OUTPUTS:
   ILIN= - Index of the selected line in the line list structure

 COMMENTS:

 EXAMPLES:
   line = x_slctline( lines )


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   17-Nov-2001 Written by JXP
   29-Nov-2001 Significantly revised
   08-Dec-2001 Allows ism or name+wave

(See Spec/Lines//x_slctline.pro)


X_SLITTOOBJ

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_slittoobj   
    Version 1.0

 PURPOSE:
    Simple program to move some tags from the slit structure into the
    object structure

 CALLING SEQUENCE:
   x_slittoobj, objstr, nobj, slitstr, clm

 INPUTS:
   objstr      - Object sturcture
   nobj        - Index of the object
   slitstr     - Slit structure
   clm         - Column where the object was identified

 RETURNS:

 OUTPUTS:
   Updates slitstr for original positions

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_slittoobj, objstr, nobj, slitstr


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   03-Mar-2002 Written by JXP

(See Spec/Slits//x_slittoobj.pro)


X_SPECBIN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_specbin
   Version 1.1

 PURPOSE:
  Bins up 1D spectra in integer pixels. The routine returns a
  structure of flux and wavelength and variance that has been
  rebinned.

 CALLING SEQUENCE:
   bin = x_specbin(fx, nbin, VAR=, WAV=)

 INPUTS:
   fx       - Flux
   nbin     - Number of pixels to bin on

 RETURNS:
   bin       - Structure of data

 OUTPUTS:

 OPTIONAL KEYWORDS:
  VAR=  -- Input variance array
  WAV=  -- Input wavelength array

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   bin = x_specbin(fx, 3)

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   04-Mar-2002 Written by JXP

(See Spec/Analysis//x_specbin.pro)


X_SPECCOADD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_speccoadd
   Version 1.1

 PURPOSE:
    Routine written to coadd spectra.  I highly recommend using
    x_combspec instead.  The routine here is old and not recently
    tested!

 CALLING SEQUENCE:
   dat = x_speccoadd(spec)

 INPUTS:
   spec       - Fits file or data

 RETURNS:
   dat       - Data in fits file or the input data

 OUTPUTS:

 OPTIONAL KEYWORDS:
  FSCALE      - Data is float
  DSCALE      - Data is float

 OPTIONAL OUTPUTS:
  HEAD        - Header

 COMMENTS:

 EXAMPLES:
   dat = x_speccoadd('spec.fits')


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   27-Feb-2002 Written by JXP

(See Spec/Analysis//x_speccoadd.pro)


X_SPECPAN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
  x_specpan   
   Version 1.1

 PURPOSE:
    Moves about a spectrum to left or right in a GUI.  The
  state structure must have TAGS: xymnx and wave

 CALLING SEQUENCE:
   x_specpan, state, /LEFT, /NOY

 INPUTS:
  state -- GUI state structure with TAGS: xymnx, wave

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /LEFT -- Pan left (default is right)
  /NOY  -- Do not rescale in y  (default is to rescale)

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_specpan, state, /LEFT

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   17-Nov-2001 Written by JXP 

(See Spec/Display//x_specpan.pro)


X_SPECPLOT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_specplot   
   Version 1.1

 PURPOSE:
    GUI for plotting a spectrum and doing quick analysis 

 CALLING SEQUENCE:
   
   x_specplot, flux, [ysin], XSIZE=, YSIZE=, TITLE=, WAVE=, LLIST=,
           /QAL, /GAL, ZIN=, /BLOCK, /NRM, /LLS

 INPUTS:
   flux  - Flux array (or FITS file)
   [ysin]  - Sigma array (or FITS file)

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
   xsize      - Draw window xsize (pixels)
   ysize      - Draw window ysize (pixels)
   wave=      - wavelength array
   INFLG=     - Specifies the type of input files (or arrays)
   /LLS       - Use Lyman limit line list
   /QSO       - Use Quasar line list
   /GAL       - Use galaxy line list
   /QAL       - Use quasar absorption line list

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_specplot, 'spec.fits'


 PROCEDURES/FUNCTIONS CALLED:
  XGETX_PLT
  XGETY_PLT
  XGETXPIX_PLT
  XGETYPIX_PLT

 REVISION HISTORY:
   17-Nov-2001 Written by JXP
   19-Dec-2001 Added Error array, Colm

(See Spec/General//x_specplot.pro)


X_SPECREBIN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_specrebin
   Version 1.1

 PURPOSE:
    Rebin a single data set to a new wavlength scale
      Simple linear interpolation.

 CALLING SEQUENCE:
   x_specrebin, wv, fx, nwwv, nwfx, VAR=, NWVAR=, /SILENT, /REDBLUE

 INPUTS:
   wv -- Original wavelength array
   fx -- Orignal flux array
   newwv -- New (desired) wavelength array

 RETURNS:
   nwfx  -- New flux array

 OUTPUTS:

 OPTIONAL KEYWORDS:
  VAR= -- Original variance array
  /REDBLUE --  Data runs from red to blue (not blue to red)
  /SILENT

 OPTIONAL OUTPUTS:
  NWVAR= -- New variance array

 COMMENTS:

 EXAMPLES:
   x_specrebin, gdpix, orig_wv, orig_fx, newwv, newfx


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   12-Apr-2002 Written by JXP

(See Spec/Analysis//x_specrebin.pro)


X_SPECZOOM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
  x_speczoom   
   Version 1.1

 PURPOSE:
    Zooms in or out on a spectrum in a GUI

 CALLING SEQUENCE:
   x_speczoom, state, flg

 INPUTS:
   state - GUI state structure (needs TAG xymnx)
   flg   - 0-In, 1-Out

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_speczoom, state, flg


 PROCEDURES/FUNCTIONS CALLED:
  xgetx_plt

 REVISION HISTORY:
   17-Nov-2001 Written by JXP 

(See Spec/Display//x_speczoom.pro)


X_SPECZOOMREG

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
  x_speczoomreg
    Version 1.1

 PURPOSE:
    Sets region to zoom in on in a GUI

 CALLING SEQUENCE:
   x_speczoom, state

 INPUTS:
  state  -- GUI state (requires TAGS xymnx tmpxy, flg_zoom)

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_speczoom, state, flg

 PROCEDURES/FUNCTIONS CALLED:
  xgetx_plt

 REVISION HISTORY:
   17-Nov-2001 Written by JXP 

(See Spec/Display//x_speczoomreg.pro)


X_SPLNCOGMAX

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_splncogmax
   Version 1.0

 PURPOSE:
  Create a table of COG values and fit a spline to it.  The routine
  then writes the output to a FITS file for future usage.
   
 CALLING SEQUENCE:
   x_splncogmax, tmax, tval, tabul, NSTP=, OUTFIL=, TMIN=, STRCT=

 INPUTS:
  tmax -- Maximum optical depth to consider

 RETURNS:
  tval -- Array of optical depth values
  tabul -- Array of COG values (reduced EW)

 OUTPUTS:
  STRCT=  -- Structure containing tval, tabul, and the SPLINE
  OUTFIL= -- FITS file where the spline is written (as a structure)

 OPTIONAL KEYWORDS:
  TMIN= -- Minimum optical depth to consider [default: 1e-4]
  NSTP= -- Number of points to evaluate at between TMIN and tmax
           [default: 1000L]

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   15-Sep-2003 Written by JXP

(See Spec/Analysis//x_splncogmax.pro)


X_SPLOT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_splot   
     Version 1.1

 PURPOSE:
    Plots any array interactively

 CALLING SEQUENCE:
   
   x_splot, [xdat], ydat, XSIZE=, YSIZE=, TITLE=, XTWO=, YTWO=, PSYM2=,
      /BLOCK, PSYM1=, YMNX=, XTHR=, YTHR=, PSYM3=

 INPUTS:
   [xdat]     - x values (optional)
   ydat       - Values 

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
   xsize      - Draw window xsize (pixels)
   ysize      - Draw window ysize (pixels)
   TITLE
   YTWO   -- 2nd array to plot [If without XTWO, must have same dimension
              as xdat]
   XTWO   -- 2nd array of x values to plot [requires YTWO]
   PSYM2  -- Plot symbol for array 2 [default: 10]
   YTHR   -- 3nd array to plot [If without XTWO, must have same dimension
              as xdat]
   XTHR   -- 3nd array of x values to plot [requires YTHR]
   PSYM3  -- Plot symbol for array 3 [default: 10]
   /BLOCK

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_splot, y

 PROCEDURES/FUNCTIONS CALLED:
  XGETX_PLT
  XGETY_PLT
  XGETXPIX_PLT
  XGETYPIX_PLT

 REVISION HISTORY:
   17-Nov-2001 Written by JXP (modified from x1dfit)
   24-Nov-2001 Added ytwo

(See General//x_splot.pro)


X_STARID

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_starid   
    Version 1.1

 PURPOSE:
    Allows the user to interactively identify standard stars in a
    field using lists and the like.  This is a rather quick way of
    doing the calibrations.

 CALLING SEQUENCE:
   x_starid, img, date, ccd, tel, LST_PATH=, OBJ=, XSIZE=, YSIZE=

 INPUTS:
   img        - Image(s) for Masking
   date       - EPOCH of the obs (decimal years)
   ccd        - Name of the CCD  (Tek5, SITe1, LRISR, SITe3)
   tel        - Name of telescope

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
   OBJ       - Object names
   XSIZE     - Size of gui in screen x-pixels (default = 800)
   YSIZE     - Size of gui in screen y-pixels (default = 800)
   OUT_PATH  - Output name for id files (default: 'Photo/')
   LST_PATH  - Path name for Lists [default: $XIDL_DIR/IMG/Photometry/Lists/]

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_starid, img, 2004.2, 'SITe1', 'LCO-40'


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   03-Aug-2001 Written by JXP
   04-Jan-2002 Updated and revised by JXP

(See IMG/Photometry//x_starid.pro)


X_STDMAG

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_stdmag   
   Version 1.1

 PURPOSE:
    Does aperture photometry on the objects in the std_* list files

 CALLING SEQUENCE:
   xdimg_stdmag, struct, SKYR=

 INPUTS:
   img   -- Image
  strfil -- Star list file
  outfil -- Output file

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  SKYR =  2 float array describing sky annulus in arcsec
            (default=15,30)
  ARCPIX= Arcseconds per pixel
  SATUR=  Saturation level

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_stdmag, 'Final/f_ccd003.fits', 'Photometry/star.list', 'outfil'

 PROCEDURES/FUNCTIONS CALLED:
  X_APER
  X_CCDINF

 REVISION HISTORY:
   03-Apr-2003 Written by JXP

(See IMG/Photometry//x_stdmag.pro)


X_STSLTGUI

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_stsltgui   
    Version 1.0

 PURPOSE:
    Allows the user to interactively (GUI) identify edges of 
     inidividual slits in the undistorted image

 CALLING SEQUENCE:
   
   x_stsltgui, img, slitstr, XSIZE=, YSIZE=

 INPUTS:
   img        - Undistorted image
   slitstr    - Slit structure

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
   XSIZE      - Size of gui in screen x-pixels (default = 700)
   YSIZE      - Size of gui in screen y-pixels (default = 700)

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_stsltgui, img, slitstr

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   07-Feb-2002 Written by JXP

(See Spec/Slits//x_stsltgui.pro)


X_SUBSKYSLIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_subskyslit   
    Version 1.1

 PURPOSE:
    Given the slitstr and slit#, subtract the sky and return 
         the result

 CALLING SEQUENCE:
  x_subskyslit, slit_fil, slit, obj_fil, flux, wave, VAR=, 
                 SUBIMG=, PIX=, DATFIL=, ALL_RMS=, 
                 SKYIMG=, REJPIX=, /DEBUG=

 INPUTS:
   slit_fil  -- File for slit structure
   slit      -- Index
   obj_fil   -- File for object structure
  [flux]      - Flux image
  [wave]      - Wavelength image

 RETURNS:

 OUTPUTS:
   Updates slitstr for original positions

 OPTIONAL KEYWORDS:
  DATFIL=  -- FITS File containing FLUX, WAVE images
  WVMNX=   -- Limit sky subtraction to specific wavelength range
              [default [3900., 11000.] ]

 OPTIONAL OUTPUTS:
  ALL_RMS=  -- Total RMS of the fit
  PIX=      -- Array of pixel values 

 COMMENTS:

 EXAMPLES:
   x_skysubslit, slitstr, map


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   20-Mar-2002 Written by JXP

(See Spec/Extraction//x_subskyslit.pro)


X_TEMPLARC

[Previous Routine] [Next Routine] [List of Routines]
 NAME: 
 x_templarc   
    Version 1.1

 PURPOSE:
    Given an archived Arc spectrum and solution and a new arc
    spectrum, find the pixel offset and auto-id the arc lines in new
    arc spectrum.  One must turn /FFT on to calculate the shift.

 CALLING SEQUENCE:
   
 x_templarc, spec, lines, guessfit, /FFT, MSK=, MXSHFT=, $
               MOCK_FFT=, SHFT=, ALL_PK=, PKWDTH=, $
               /THIN, FORDR=, PKSIG=, SKIPLIN=, $
               MXOFF=, /LOG

 INPUTS:
   spec       - Input arc image or spectrum
   lines      - Arc line structure
  guessfit    - FIT to archived arc

 RETURNS:

 OUTPUTS:
   lines     - Sets flg_plt to 1 those lines which are ID'd

 OPTIONAL KEYWORDS:
  /FFT    -- Calculate the most likely offset between the archived
             arc and the new one using the FFT procedure
  MOCKFFT -- Archived FFT [default: create one from the line list]
  MXOFF=  -- Maximum offset between ID line and a line in the
             linelist  [default: 3 pixels]
  SHFT=   -- Shift between archived and new arc (Input and/or Output)
  PKSIG=  -- Sigma significant of arc lines (as found by x_fndpeak)
             [default: 7.]
  MSK=    -- Mask of the lines
  MXSHFT= -- Maximum shift between archived and new solution
  /THIN   -- Allow for very narrow arc lines
  /LOG    -- Do the algorithm with logarithmic wavelengths
  FORDR   -- Order for the fit for the continuum of the arc 
  /SKIPLIN -- Do not bother to identify good lines for subsequent
              fitting (algorithm has only calucated the shift)

 OPTIONAL OUTPUTS:
  ALL_PK= --  Pix values of the arc line peaks

 COMMENTS:

 EXAMPLES:
   x_templarc, spec, lines, guessfit, SHFT=shft

 PROCEDURES/FUNCTIONS CALLED:
  x_fndpeaks

 REVISION HISTORY:
   26-Aug-2002 Written by JXP

(See Spec/Arcs//x_templarc.pro)


X_TIFFSET

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_tiffset
   Version 1.1

 PURPOSE:
  Sets (or unsets) plotting variables for nice looking screen plots 
  to then be used in laptop presentations.

 CALLING SEQUENCE:
   
   x_tiffset, /UNSET

 INPUTS:
   
 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /UNSET -- Unset the plotting values

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   02-Jun-2004 Written by JXP

(See General//x_tiffset.pro)


X_TRACE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_trace   
    Version 1.2

 PURPOSE:
    Plots any array interactively

 CALLING SEQUENCE:
   
   fit = x_trace(img, aper, cline, PHSIG=, PLSIG=, TFFIT=,
      NTRC=, PFUNC=, PNORD=, PHSIG=, PLSIG=, NOINTER=, YBUFF=, /PINTER)

 INPUTS:
   img   - 2D spectral image 
   aper  - Aperture defining the object
   cline - Column to begin trace at

 RETURNS:
   FIT    - Trace at each column

 OUTPUTS:

 OPTIONAL KEYWORDS:
   NTRC -  Number of columns to median for the trace
   TFITSTR - Structure for the fitting the trace
   PFUNC- Profile fitting function
   PNORD- Profile fitting order
   PHSIG
   PLSIG
   INTER - Interactive fitting for trace
   
 OPTIONAL OUTPUTS:
   TFFIT -  Output fit info for the trace

 COMMENTS:

 EXAMPLES:
   x_trace, 'spec.fits'


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   19-Nov-2001 Written by JXP
   02-Feb-2002 JXP -- Added trace_crude option via CRUDE

(See Spec/Extraction//x_trace.pro)


X_TRACEARC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_tracearc   
    Version 1.1

 PURPOSE:
    Given an arc image (or a slit from a multi-slit or one order from
    an echelle), arc lines and trace them across the image.  The
    program returns a trace structure which can be used to create a
    wavelength image.

 CALLING SEQUENCE:
   tracestr = x_tracearc( img, [ymnx], YSTRT=, /ROT, GAIN=, RN=, NSIG=, RADIUS=,
   MIN_XERR=, /SILENT, NORD=, VAR= )

 INPUTS:
   img       - Input arc image
   [ymnx]    - Used to define edges of a slit or an order [default: image edges]

 RETURNS:
   tracestr  - Trace structure describing the traces and fits to the
               traces of the arc lines

 OUTPUTS:

 OPTIONAL KEYWORDS:
   VAR=  - Variance image of the Arc
   GAIN= - Set this if you want the program to create the VAR image
   RN=   - Read noise (set this if you want the program to create the
           VAR image)  [default: 6]
   RADIUS=  -  Radius input parameter to trace_crude [default: 1.5]
   NSIG=  - Number of sigma significance for arc linews [default: 5.]
   YSTRT - COLUMN/ROW to start at
   /ROT  - Rotate the iamge by 90deg in those cases where the Arc
           lines run side-to-side (trace_crude requries this)
   MIN_XERR= -- Minimum xerr for fitting  [default: 0.01]
   NORD= - Order for fit to arc line curvature [default: 2L]
   YSTRT= - Offset to account for sub images

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   trcstr = x_tracearc( img )

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   28-Jan-2002 Written by JXP

(See Spec/Arcs//x_tracearc.pro)


X_TRACEFLAT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_traceflat   
    Version 1.1

 PURPOSE:
    Traces the y-distortion of a flat of a number of slits

 CALLING SEQUENCE:
  x_traceflat, img, tracestrct, VAR=, GAIN=, RN=, SAW=, $
                ystrt=, /NOTRANS

 INPUTS:
   img       - Input image

 RETURNS:
 trcstr -- A trace structure describing the curvature of individual
           slits or orders

 OUTPUTS:

 OPTIONAL KEYWORDS:
  YSTRT    -- COLUMN/ROW to start at
  /NOTRANS  -- Do not transpose original image
  VAR=     -- Variance image input
  GAIN,RN= -- Values to create a VAR array

 OPTIONAL OUTPUTS:
  SAW=  -- The sawtooth image

 COMMENTS:

 EXAMPLES:
   x_traceflat, img, map


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   28-Jan-2002 Written by JXP

(See Spec/Rectify//x_traceflat.pro)


X_TRACESLIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_traceslit   
    Version 1.0

 PURPOSE:
    This is a failed attempt at a tracing program.  Do not use!

 CALLING SEQUENCE:
   
   x_traceslit, img, pos, top, bottom
   FFIT=, /INTER)

 INPUTS:
   img       - Input image
   pos       - [x,y] position on the CCD
                      (default=1/3 max + min)

 RETURNS:

 OUTPUTS:
   top - Trace of the top of the slit
   bottom - Trace of the bottom of the slit

 OPTIONAL KEYWORDS:
   GAIN - Gain of the CCD

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_traceslit, img, [252.3, 235.5], top, bottom


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   16-Jan-2002 Written by JXP

(See Spec/Rectify//x_traceslit.pro)


X_TSTOFF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_tstoff
    Version 1.1

 PURPOSE:
    Does a quick check on the offset between a flat 
       and object frame.  Uses FFT correlation

 CALLING SEQUENCE:
   
   x_tstoff, flat_in, obj_in, offset, CLINE=

 INPUTS:
   flat_in       - Flat image (array or string)
   obj_in        - Flat image (array or string)

 RETURNS:
   offset - Vertical pixel offset

 OUTPUTS:

 OPTIONAL KEYWORDS:
   ELINE - End line of data (routine takes 1/3, 1/2, 2/3)

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_tstoff, flat, obj, offset


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   25-Jan-2002 Written by JXP

(See Spec/Rectify//x_tstoff.pro)


X_UNIQSTR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_uniqstr   
    Version 1.1

 PURPOSE:
    Obsolote:  Superseded by UNIQ

 CALLING SEQUENCE:
   
 uniq = x_uniqstr(strings, COUNT=count)

 INPUTS:
   strings - Array of strings

 RETURNS:
   uniq  - Array of unique members

 OUTPUTS:

 OPTIONAL KEYWORDS:
   sort - Sort the output

 OPTIONAL OUTPUTS:
  COUNT - number of unique strings

 COMMENTS:

 EXAMPLES:
   uniq = x_uniqstr( lbls, count=count)


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   17-Nov-2001 Written by JXP

(See General//x_uniqstr.pro)


X_VELPLT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_velplt
    Version 1.1

 PURPOSE:
  GUI used to display velocity profiles for absorption line system.
  The user can control a number of options for the plot, output ps
  files and PG plot input files, etc.

 CALLING SEQUENCE:
 x_velplt, flux_fil, zin, VMNX=vmnx, INFLG=inflg, $
             TITLE=title, NPLT=nplt, NRM=nrm, XSIZE=xsize, YSIZE=ysize, $
             SIG_FIL=, /ESIDLA, SVSTATE=, /LLS

 INPUTS:
  flux_fil -- Input FITS file for the flux (header includes
              wavelength info)
  zin -- Redshift of absorption lines

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  VMNX= -- Velocity range to plot [default [-300, 300]]
  NPLT= -- Number of plots to show [default: 15L]
 TITLE= -- Title to give GUI
  XSIZE      - Size of gui in screen x-pixels [default = 700]
  YSIZE      - Size of gui in screen y-pixels [default = ssz -200]
  /LLS -- Use LLS line list
  /ESIDLA -- Use ESI DLA line list
  SIG_FIL= -- Sigma file
  INFLG=  -- Flag for flux_fil data (see x_readspec)
  SVSTATE= -- Input IDL file that saved the state of the GUI
              previously

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_velplt, wfccd, maskid, expsr


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   29-Oct-2002 Written by JXP

(See Spec/Analysis//x_velplt.pro)


X_VOIGT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
   x_voigt
  Version 1.1

 PURPOSE:
   Calculate a single voigt profile, given wavelength, absorber, and
    an array of lines.  This can be a very expensive routine to run.

 CALLING SEQUENCE:
   tau = x_voigt(wave, lines, FWHM=)

 INPUTS:
   wave       - Array of wavelengths to realize voigt profile
   lines      - line(s) structure to compute voigt profile. If mutliple,
                   the entire list will be looped through.

 OPTIONAL INPUTS:
   FWHM      - Resolution of instrument in PIXELS of input array

 OUTPUTS:
   tau        - Optical depth at each wavelength

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:

 PROCEDURES CALLED:
  x_gsmooth


 REVISION HISTORY:
   25-May-2000  Created by S. Burles, FNAL/IAP
   2003         Modified by JXP to give 'exact' answer

(See Spec/Voigt//x_voigt.pro)


X_WAVECAL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_wavecal   
   Version 1.1

 PURPOSE:
    Wavelength calibrate a given input Arc img (or spectrum).  This
    routine simply extracts the Arc spectrum (if necessary) and then
    calls x_identify

 CALLING SEQUENCE:
  wave = x_wavecal( arc, [extrct], LINELIST=, /DEBUG, $
                   /REDBLUE, DISP=, CALIB=, FLUX=)

 INPUTS:
   img/spec   - 2D image or 1D spectrum
   [extrct]   - Extraction structure (required for an input 2D image)

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
   LINELIST   - Reference list (user can set interactively)
   DISP       - Guess at dispersion (A or km/s per pix [pos/neg
                value])
   /FLUX       - Assumes wide slit and therefore wide arc lines
   /REDBLUE    - Spectrum runs from red to blue (not blue to red)
   /DEBUG

 OPTIONAL OUTPUTS:
   CALIB= - Structure defining the fit

 COMMENTS:

 EXAMPLES:
   wave = x_wavecal(spec)

 PROCEDURES/FUNCTIONS CALLED:
  x_readimg
  x_identify

 REVISION HISTORY:
   07-Dec-2001 Written by JXP

(See Spec/Arcs//x_wavecal.pro)


X_WRECHFSPEC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_wrechfspec
    Version 1.0

 PURPOSE:
    Reads and writes the echfspec structure

 CALLING SEQUENCE:
   x_wrechfspec, echfspec, outfil, /READ

 INPUTS:
   echfspec -- IDL structure
   outfil -- Name of FITS file

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /READ -- Read instead of write the structure

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_wrechfspec, echfspec, 'Extract/2015+657_ech.fits'

 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   03-Sep-2002 Written by JXP

(See Spec/Analysis//x_wrechfspec.pro)


X_WRLWDFSPEC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_wrlwdfspec
    Version 1.0

 PURPOSE:
    Reads and writes the lwdfspec structure

 CALLING SEQUENCE:
   x_wrlwdfspec, lwdfspec, outfil, /READ

 INPUTS:
   lwdfspec -- IDL structure
   outfil -- Name of FITS file

 RETURNS:

 OUTPUTS:

 OPTIONAL KEYWORDS:
  /READ -- Read instead of write the structure

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_wrlwdfspec, lwdfspec, 'Extract/2015+657_lwd.fits'


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   02-Aug-2002 Written by JXP

(See Spec/Analysis//x_wrlwdfspec.pro)


X_YDTORTGUI

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 x_ydtortgui   
    Version 1.1

 PURPOSE:
    Allows the user to interactively examine the trace to slit
     edges used to trace the y-distortion.

 CALLING SEQUENCE:
   
   x_ydtortgui, img, tracestrct, [newmnx], XSIZE=, YSIZE=

 INPUTS:
   img        - Traced Image 
   trace      - x,y positions of traces fltarr(N,M,2)
   flgs       - Flags describing the traces

 RETURNS:

 OUTPUTS:
  newmnx      - The new min and max values

 OPTIONAL KEYWORDS:
   XSIZE      - Size of gui in screen x-pixels (Default = 1000)
   YSIZE      - Size of gui in screen y-pixels (Default = 500)

 OPTIONAL OUTPUTS:

 COMMENTS:

 EXAMPLES:
   x_ydtortgui, img, tracestrct


 PROCEDURES/FUNCTIONS CALLED:

 REVISION HISTORY:
   05-Feb-2002 Written by JXP

(See Spec/Rectify//x_ydtortgui.pro)


X_ZFIND

[Previous Routine] [List of Routines]
 NAME:
   x_zfind

 PURPOSE:
   Find possible redshift matches for a set of spectra using a set of
   eigen-templates.  This is just a version I grabbed and slightly
   modified from the SDSS distribution.  The main modification was to
   allow for more free paramters in fitting the continuum of the
   galaxies due to poor fluxing with the WFCCD.

 CALLING SEQUENCE:
   result = x_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.

 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.

 EXAMPLES:

 BUGS:

 PROCEDURES CALLED:
   concat_dir()
   djs_filepath()
   fileandpath()
   readfits()
   splog
   sxpar()
   zcompute()

 INTERNAL SUPPORT ROUTINES:
   x_sp1d_struct()

 REVISION HISTORY:
   28-Jun-2000  Written by D. Schlegel, Princeton

(See Spec/Analysis//x_zfind.pro)