SDSS Library

This page is a listing of the entire contents of this library for IDL. This listing is the long version. Viewing the much more compact listing may be handier.

[Go Back to Main IDL Libraries Search Page]


Last modified: Thu Dec 21 21:29:04 2000.

List of Routines


Routine Descriptions

ADD_ARRVAL

[Next Routine] [List of Routines]

 NAME:
    ADD_ARRVAL
       
 PURPOSE:
    Add an element to an array "array". If input array is undefined, 
    set it equal to the new value.

 CALLING SEQUENCE:
    add_arrval, newval, array, front=front

 INPUTS: 
    newval: the new value to be added

 KEYWORD PARAMETERS:
    /front: If set then put the new value at the front of the array, else
       put at end.

 SIDE EFFECTS: 
    array is created or augmented.       

 
 PROCEDURE: 
    
	

 REVISION HISTORY:
    14-NOV-2000 Erin Scott Sheldon UofMich
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/add_arrval.pro)


ADD_TAG

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

 NAME:
    ADD_TAG
       
 PURPOSE:
    Add a new tag to the structure. NOTE: if you want to add more
    than one tag at once, use ADD_TAGS

 CALLING SEQUENCE:
    add_tag, oldstruct, tagname, tagtype, newstruct, structyp=structyp

 INPUTS: 
    oldstruct: The original structure (or array of structures)
    tagname: string containing the new tag name
    tagtype: the initial value of the new tag, e.g. fltarr(5)
           or [3,5,6], or 0L, etc.

 KEYWORD PARAMETERS:
   structyp: a string with the name of the new structure.
     if already defined the program will crash.

 OUTPUTS: 
    newstruct: The structure with the new tag it it.

 OPTIONAL OUTPUT
    NONE

 CALLED ROUTINES:
    COMBINE_STRUCTS
 
 PROCEDURE: 
    
	

 REVISION HISTORY:
    25-OCT-2000, Judith Racusin.
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/add_tag.pro)


ADD_TAGS

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

 NAME:
    ADD_TAGS
       
 PURPOSE:
    Add new tags to the structure. Similar to 
    add_tag, but with these major differences:
       --Unlike the program ADD_TAG, ADD_TAGS can add
         multiple new tags.
       --Unlike add_tag, which takes an actual
         value for the new tag, ADD_TAGS takes in string 
         indicators for each new tag, such as 'fltarr(3)', 
         or '10', and uses MRD_STRUCT
       --Because of this, ADD_TAGS cannot add specific values
         for non-scalars.
       --Also because of this, ADD_TAGS cannot add a substructure.
         If you want to add a substructure to a structure, use
         ADD_TAG: add_tag, oldstruct, tagname, substruct, newstruct 

 CALLING SEQUENCE:
    add_tags, oldstruct, tagnames, values, newstruct

 INPUTS: 
    oldstruct: The original structure (or array of structures)
    tagnames: new tag name(s), can be an array
    values: string containing values for tagnames. must be same size
            array as tagnames. Same format as MRD_STRUCT.PRO
 OPTIONAL INPUTS:
    NONE

 KEYWORD PARAMETERS:
    structyp: a string with the name of the new structure.
     if already defined the program will crash.
       
 OUTPUTS: 
    newstruct: The structure with the new tags in it.

 OPTIONAL OUTPUTS:
    NONE

 EXAMPLE: 
    tagnames=['ra', 'dec', 'image', 'name']
    values  =['0d', '0d',  'intarr(1000, 1000)', "'NGC3035'"]
    add_tags, oldstruct, tagnames, values

 CALLED ROUTINES:
    MRD_STRUCT
    DATATYPE
    COMBINE_STRUCTS
 
 PROCEDURE: 
    Use mrd_struct to create a new structure.
	

 REVISION HISTORY:
    25-OCT-2000, Erin Scott Sheldon
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/add_tags.pro)


ANGDIST

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

 NAME: 
    ANGDIST
       
 PURPOSE: 
    calculate angular diameter distance between zmin and zmax
    Currently only works for lambda = 0 universe.
	

 CALLING SEQUENCE: 
    result = angdist(z1, z2, h=h, q0=q0, omegamat=omegamat, $
                     silent=silent, plot=plot, oplot=oplot )
      
 INPUTS:  
    zmax: max redshift 

 OPTIONAL INPUTS:
    zmin:  Zmin is optional, the default is 0.0

 OPTIONAL KEYWORDS: 
    h: hubble parameter in units of H100 default is 1.0
    q0: dacceleration parameter. default is q0=0.5
    omegamat:  If input, uses q0=omegamat/2.

 OUTPUTS: 
    dist in MPC

 REVISION HISTORY: 
    Author: Erin Scott Sheldon 2/24/99
	   
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/angdist.pro)


ANGDIST_LAMBDA

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

 NAME: 
    ANGDIST_LAMBDA
       
 PURPOSE: 
    calculate angular diameter from zmin to zmax in flat lambda universe
    Uses 4th order polynomial approximation 
    see Pen, U., 1999, ApJ Supplement, 20, 49.
    For z between 0.2 and 1.0 the error is about .4% 
    (Exact for omega_matter = 1.0)
	

 CALLING SEQUENCE: 
    result = angdist(zmax, [zmin, h=h, omegamat=omegamat, dlum=dlum, 
                     verbose=verbose])
      
 INPUTS:  
    z: redshift

 OPTIONAL INPUTS: 
    h: hubble parameter       default is 1.0
    omegamat:  omega matter   default is .3

 OPTIONAL OUTPUTS:
    dlum: the luminosity distance.

 OPTIONAL KEYWORDS: 
    /verbose:  print distances.
       
 OUTPUTS: distance in megaparsecs.

 REVISION HISTORY: 
    Author: Erin Scott Sheldon 2/24/99
	
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/angdist_lambda.pro)


APLOT

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

 NAME:
    APLOT
       
 PURPOSE:
    Wrapper for PLOT that forces a user defined aspect ratio.

 CALLING SEQUENCE:
    aplot, aspect, [x,] y, center=center, _extra=extra

 INPUTS: 
    aspect: xsize/ysize
    y: y values

 OPTIONAL INPUTS:
    x: optional x values

 KEYWORD PARAMETERS:
    /center: if set then center up the display.
    _extra:  plotting keywords.
       
 CALLED ROUTINES:
    PLOT
 
 PROCEDURE: 
    
	

 REVISION HISTORY:
    Author:  Erin Scott Sheldon  UofMich 11/17/99  
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/aplot.pro)


APLOTERROR

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

 NAME:
    APLOTERROR
       
 PURPOSE:
    Wrapper for PLOTERR that forces a user defined aspect ratio.

 CALLING SEQUENCE:
    aploterr, aspect, [x,] y, [xerr,] yerr, center=center, _extra=extra

 INPUTS: 
    aspect: xsize/ysize
    y: y values
    yerr: y error values.

 OPTIONAL INPUTS:
    x: optional x values
    xerr: x error values.

 KEYWORD PARAMETERS:
    /center: if set then center up the display.
    _extra:  plotting keywords.
       
 CALLED ROUTINES:
    PLOTERR
 
 PROCEDURE: 
    
	

 REVISION HISTORY:
    Author: Erin Scott Sheldon  UofMich 11/17/99  
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/aploterror.pro)


ARRSCL

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

 NAME:
    ARRSCL
       
 PURPOSE:
    Rescale the range of an array.

 CALLING SEQUENCE:
    result = arrscl(arr, min, max, arrmin=arrmin, arrmax=arrmax)
                 
 INPUTS: 
    arr:  The array.
    min:  new minimum.
    max:  new maximum.

 OPTIONAL INPUTS:
    arrmin:  A number to be used as minimum of array range.
    arrmax:  A number to be used as maximum of array range.

    NOTE:  These are useful if the original array is known to only be a
           sample of possible range.  e.g. 

           if arr=randomu(seed,20) then one might wish to give arrmin=0, 
           arrmax=1

 KEYWORD PARAMETERS:
    None.
       
 OUTPUTS:
    The rescaled array. 

 PROCEDURE: 
    See the code.
	

 REVISION HISTORY:
    Author: Erin Scott Sheldon UofMich 10/18/99  
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/arrscl.pro)


ASTRONOMYIMAGE__DEFINE[10]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       astronomyImage::Size

 PURPOSE:
       This method returns a vector storing the size of the image.

 CALLING SEQUENCE:
       Result = oAstronomyImage->Size()

 OUTPUTS:
       This method returns a two element vector containing the size
       of the current image array. The first element (Result[0])
       contains the 'x' size, and the second element (Result[1]) the
       y size.

 EXAMPLE:
       Result = oAstronomyImage->Size()

 MODIFICATION HISTORY:
       Written by      Eric H. Neilsen, Jr. 1997

(See /host/bluemoon/usr2/idllib/sdss/allpro/astronomyimage__define.pro)


ASTRONOMYIMAGE__DEFINE[11]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       astronomyImage::headerKeywordValue

 PURPOSE:
       This method returns a the value of a keyword in the header

 INPUTS:
       keyword: The name of the keyword whose value to return 

 CALLING SEQUENCE:
       Result = oAstronomyImage->headerKeywordValue('keyword')

 OUTPUTS:
       This method returns the value of the keyword

 EXAMPLE:
       time = oAstronomyImage->headerKeywordValue('EXPTIME')

 MODIFICATION HISTORY:
       Written by      Eric H. Neilsen, Jr. October 16, 2000

(See /host/bluemoon/usr2/idllib/sdss/allpro/astronomyimage__define.pro)


ASTRONOMYIMAGE__DEFINE[12]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       astronomyImage::deleteHeaderKeyword

 PURPOSE:
       This method deletes a line from the header

 INPUTS:
       keyword: the name of the keyword to delete

 CALLING SEQUENCE:
       oAstronomyImage->deleteHeaderKeyword, 'keyword'

 OUTPUTS:
       There is no output

 EXAMPLE:

 MODIFICATION HISTORY:
       Written by      Eric H. Neilsen, Jr. October 16, 2000

(See /host/bluemoon/usr2/idllib/sdss/allpro/astronomyimage__define.pro)


ASTRONOMYIMAGE__DEFINE[13]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       astronomyImage::addHeaderKeyword

 PURPOSE:
       This method adds a line from the header

 INPUTS:
       keyword: The name of the keyword to add
       value:   The value to give the keyword

 CALLING SEQUENCE:
       oAstronomyImage->addHeaderKeyword, 'keyword', value

 OUTPUTS:
       There is no output

 EXAMPLE:

 MODIFICATION HISTORY:
       Written by      Eric H. Neilsen, Jr. October 16, 2000

(See /host/bluemoon/usr2/idllib/sdss/allpro/astronomyimage__define.pro)


ASTRONOMYIMAGE__DEFINE[14]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       astronomyImage::replaceHeaderKeyword

 PURPOSE:
       This method replaces a line from the header

 INPUTS:
       keyword: The name of the keyword to replace
       value:   The value to give the keyword

 CALLING SEQUENCE:
       oAstronomyImage->replaceHeaderKeyword, 'keyword', value

 OUTPUTS:
       There is no output

 EXAMPLE:

 MODIFICATION HISTORY:
       Written by      Eric H. Neilsen, Jr. October 16, 2000

(See /host/bluemoon/usr2/idllib/sdss/allpro/astronomyimage__define.pro)


ASTRONOMYIMAGE__DEFINE[15]

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

 PURPOSE:
       This routine provides the deffinition of the astronomyImage
       object. This object is not intended to be used in practice;
       under most circumstances, one of it children (dataImage or
       maskImage) probably provides more functionality. 

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. 1997 

(See /host/bluemoon/usr2/idllib/sdss/allpro/astronomyimage__define.pro)


ASTRONOMYIMAGE__DEFINE[1]

[Previous Routine] [Next Routine] [List of Routines]
 CLASS_NAME:
       astronomyImage

 PURPORSE:
       astronomyImage is intended to be a superclass of classes used
       store image used for astronomical applications.

 SUPERCLASSES:
       This inherets from no classes
 
 SUBCLASSES:
       Subclasses include dataImage, maskImage, and ircamImage

 CREATION:
       astronomyImage are generally created through the init
       of the desired subclass

 METHODS:
	Intrinsic Methods
       This class has the following methods:

       astronomyImage::Clone
       astronomyImage::GetData
       astronomyImage::InMemory
       astronomyImage::Load
       astronomyImage::Magnify
       astronomyImage::OnDisk
       astronomyImage::Save
       astronomyImage::SetData
       astronomyImage::Size

 PROCEDURES USED:
       From the GSFC IDL Astronomy User's Library
            http://idlastro.gsfc.nasa.gov/homepage.html
       READFITS, SXHREAD, SXOPEN, MKHDR, WRITEFITS, SXMAKE, SXWRITE

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. 1997

(See /host/bluemoon/usr2/idllib/sdss/allpro/astronomyimage__define.pro)


ASTRONOMYIMAGE__DEFINE[2]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       astronomyImage::Clone

 PURPOSE:
       This method creates a duplicate image object. If no temporary
       file name is provided, the data for the new image is stored in
       memory. 

 CALLING SEQUENCE:
       Result = oAstronomyImage->Clone(Tempfilename)

 OPTIONAL INPUTS:
       tempFileName: This string contains the file name for the file
                     in which to store the image data, if any.  
	
 OUTPUTS:
       A copy of the image is returned. 

 SIDE EFFECTS:
       The clone is a new object; each must be destroyed separately.

 EXAMPLE:
       imagecopy = exampleimage->clone(tempfilename)

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. 1997

(See /host/bluemoon/usr2/idllib/sdss/allpro/astronomyimage__define.pro)


ASTRONOMYIMAGE__DEFINE[2]

[Previous Routine] [Next Routine] [List of Routines]
 ======================================================================
 
 METHODNAME:
       astronomyImage::Cleanup

 PURPOSE:
       Clean up the memory used by the image object. In particular,
       free the data and header memory 

 CALLING SEQUENCE:
       OBJ_DESTROY, oAstronomyImage

       or

       oAstronomyImage->[astronomyImage::]Cleanup

 INPUTS:
       There are no inputs for this method

 KEYWORD PARAMETERS:
       There are no keyword parameters for this method

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. 1997

RO astronomyImage::Cleanup
            
 self->inMemory
 PTR_FREE, self.dataHeader
 PTR_FREE, self.data

ND

(See /host/bluemoon/usr2/idllib/sdss/allpro/astronomyimage__define.pro)


ASTRONOMYIMAGE__DEFINE[3]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       astronomyImage::GetData

 PURPOSE:
       The method is used to return an array with the image data.

 CALLING SEQUENCE:
       Result = oAstronomyImage->getData()

 OUTPUTS:
       This function returns the data array associated with the image object.

 EXAMPLE:
       imagedataarray = astroimageobject->getData()

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. 1997

(See /host/bluemoon/usr2/idllib/sdss/allpro/astronomyimage__define.pro)


ASTRONOMYIMAGE__DEFINE[4]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       astronomyImage::InMemory

 PURPOSE:
       If the image data is currently stored in a file, this method
       loads the data into memory and destroys the file. Otherwise,
       it has no effect.

 CALLING SEQUENCE:
       oAstronomyImage->InMemory

 EXAMPLE:
       oAstronomyImage->InMemory      

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/astronomyimage__define.pro)


ASTRONOMYIMAGE__DEFINE[5]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       astronomyImage::Load

 PURPOSE:
       This method load an image from disk into the image object.

 CALLING SEQUENCE:
       oAstronomyImage->Load, FileName

 OPTIONAL INPUTS:
	fileName: A string containing the name of the file from which
	          to load the image. If no name is given, the current
	          file name associated with the object is used.

 SIDE EFFECTS:
       The previous data and header information is lost.

 EXAMPLE:
       exampleImage->load, 'exampleImageFile.fits'

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. 1997

(See /host/bluemoon/usr2/idllib/sdss/allpro/astronomyimage__define.pro)


ASTRONOMYIMAGE__DEFINE[6]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       astronomyImage::Magnify

 PURPOSE:
       This method resizes the image.

 CALLING SEQUENCE:
       oAstronomyImage->magnify, Newsize

 INPUTS:
       Newsize:  The desired size of the image. The new size must be
                 an integer miltiple of the current size.

 PROCEDURE:
       This method uses the REBIN function, as described in the IDL
       users manuals.

 EXAMPLE:
       To double the size of an image:
       oAstronomyImage->magnify, 2*oAstronomyImage->size()

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/astronomyimage__define.pro)


ASTRONOMYIMAGE__DEFINE[7]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       astronomyImage::OnDisk

 PURPOSE:
       This method saves the data array to a temporary disk file, and
       uses an array associated with this file to store this
       data. See the IDL documentation on associated variables (the
       ASSOC function) for more information about how this works.

 CALLING SEQUENCE:
       oAstronomyImage->OnDisk

 KEYWORD PARAMETERS:
       TEMPNAME:   Use this keyword to specify the name of the
                   temporary file in which to store the data.

 EXAMPLE:
       oAstronomyImage->OnDisk, TEMPNAME='/tmp/tmpImage.dat'

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/astronomyimage__define.pro)


ASTRONOMYIMAGE__DEFINE[8]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       astronomyImage::Save

 PURPOSE:
       This method saves the image object.

 CALLING SEQUENCE:
       oAstronomyImage->Save, FileName

 OPTIONAL INPUTS:
	fileName: A string containing the name of the file tp save the
	          file to. If no name is given, the current
	          file name associated with the object is used.

 RESTRICTIONS:
       Currently, images can only be saved in the STSDAS file format.

 EXAMPLE:
       exampleImage->save, 'exampleImageName.hhh'

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. 1997

(See /host/bluemoon/usr2/idllib/sdss/allpro/astronomyimage__define.pro)


ASTRONOMYIMAGE__DEFINE[9]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       astronomyImage::SetData

 PURPOSE:
       This method sets the data of the image object. 

 CALLING SEQUENCE:
       oAstronomyImage->SetData, NewDataArray

 INPUTS:
       newData:  This parameter contains the new value of the data
                 array of the image. This will generally be a two
                 dimensional array.

 SIDE EFFECTS:
       The old data associated with the image is lost.

 RESTRICTIONS:

 EXAMPLE:
       exampleImage->setData, newDataArray

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. 1997

(See /host/bluemoon/usr2/idllib/sdss/allpro/astronomyimage__define.pro)


ATLAS_NAME

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

 NAME: 
    ATLAS_NAME

 PURPOSE: 
    Subroutine of get_atlas.  Creates the name of atlas file.

 CALLING SEQUENCE:
    atlas_name, run, camcol, field [, atlasname]

 INPUTS:  
    run: sdss run number
    camcol: camera column
    field: field of the object

 OUTPUTS: 
    atlasname

 REVISION HISTORY:
    Erin Scott Sheldon  3/14/99

(See /host/bluemoon/usr2/idllib/sdss/allpro/atlas_name.pro)


BEGPLOT

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

 PURPOSE:

	This procedure redirects plots from the present display/
	graphics device to another display/graphics device. It
	is a 'macro' to the SET_PLOT and DEVICE graphics routines.  At
	this time only the 'PS' device is fully supported.

	See also KILLPLOT and ENDPLOT.

 CATEGORY:

	Misc.

 CALLING SEQUENCE:

	BEGPLOT

 INPUTS:

	None.

 KEYWORD PARAMETERS:

	These keywords are applicable to all graphics/display devices.

	LAYOUT:  Name of file containing keywords.  See example below.
	DEVICE:  Name of graphics device.
	NAME:  Name to give output file.
       INVBW: Invert b&w color table and make axes labels black for
              printing b&w spectrograms.

	These keywords are applicable to the 'PS', 'PCL', and 'HP'
	graphics device.  See also "IDL Graphics Devices" in IDL
	Reference Manual.

	INCHES:  Set to express sizes and offsets in inches.
	LANDSCAPE:  Set for 'landscape' orientation.  
	XOFFSET: Offset relative to lower left hand corner in
                portrait(default) orientation. Default is 0.75 inches.
	YOFFSET: Offset relative to lower left hand corner in
                portrait(default) orientation. Default is 1.0 inches.
	XSIZE:  Width of graphics output. Default = 5.0 inches.
	YSIZE:  Height of graphics output. Default = 9.0 inches.

	These keywords are specific to the 'PS' graphics device.

	BITS_PER_PIXEL: Integer (1,2,4,8) specifing resolution.
                       Default = 4 unless COLOR keyword set then
                       default = 8.
	BOLD: Set to use bold version of current PostScript font.
	COLOR: Set to enable color output.
	DEMI: Set to use demi version of current PostScript font.
	ENCAPSULATED: Set to create encapsulated PostScript font.
                     Suitable for importing into other documents.
	FONT: Name of PostScript font. See IDL Reference Manual for
             complete list.
	ITALIC: Set to use italic version of current PostScript font.
	LIGHT: Set to use light version of current PostScript font.
	MEDIUM: Set to use meduim version of current PostScript font.
	NARROW: Set to use narrow version of current PostScript font.
	OBLIQUE: Set to use oblique versin of current PostScript font.
	PREVIEW: Set to add 'device independent screen preview' to
                output file when using ENCAPSULATED.
	SCALE_FACTOR: Specifies scale factor applied to entire plot.
                     Default = 1.
 	CT: Number of color table to apply when using COLOR. Default =
           6 (prism).

 COMMON BLOCKS:

	PLOTFILE_COM:
		plotfile - name of output file.
		save_device - name of previous graphics device.
		spool - flag to prevent printing if ENCAPSULATED.

 RESTRICTIONS:
	
	!P.FONT must be set to 0 (zero) for the hardware-drawn (PostScript)
	fonts. If !P.FONT = -1, Hershey vector drawn fonts are used.  Vector 
	fonts should always be used for 3-dimensional plots.

 EXAMPLES:

	To redirect a plot to a PostScript printer named 'printer':

	BEGPLOT
	PLOT,x,y
	ENDPLOT,P='printer'

	To redirect a plot to an Encapsulated PostScript (EPS) file
	and inhibit printing:

	BEGPLOT,NAME='test.eps',/ENCAPSUATED
	PLOT,x,y
	ENDPLOT,/NOPRINT

	To use a 'layout file':

	BEGPLOT,LAYOUT='layoutfile'
	PLOT,x,y
	ENDPLOT

	Layout files can to used to set up the graphics device
	keywords. A syntax similar to Xdefaults files is used.  Each
	line looks like "device.keyword:value". 'device' is the
	name of graphcis device used by SET_PLOT. ('ps' is currently
	the only device supported).  'keyword' is the name of the
	keyword to send to DEVICE, and 'value' is the value to send
	with the keyword (1 is used to set and 0 to unset). A layout
	file to produce a half-page, portrait, EPS file  using the
	Times-Roman 12 point font and PREVIEW would look like:

	ps.font:times
	ps.font_size:12
	ps.portrait:1
	ps.encapsulated:1
	ps.preview:1
	ps.inches:1
	ps.xsize:5.0
	ps.ysize:5.0

	All of the keywords defined above can be set in this manner.

	To abort after running BEGPLOT but before running ENDPLOT, run
	KILLPLOT. This will close the plotfile and reset the graphics
	device to the one being used before BEGPLOT was called.

	See also the documentation for KILLPLOT and ENDPLOT.

 COPYRIGHT NOTICE:

	Copyright 1993, The Regents of the University of California. This
	software was produced under U.S. Government contract (W-7405-ENG-36)
	by Los Alamos National Laboratory, which is operated by the
	University of California for the U.S. Department of Energy.
	The U.S. Government is licensed to use, reproduce, and distribute
	this software. Neither the Government nor the University makes
	any warranty, express or implied, or assumes any liability or
	responsibility for the use of this software.

 MODIFICATION HISTORY:

 	Based on BEGPLT by Phil Klingner, NIS-3, LANL.

	Modified and renamed BEGPLOT. Michael J. Carter, NIS-1, LANL,
	March, 1994.

       Fixed landscape mode bug.  mjc, 1/24/95.

       Added INVBW keyword to load inverse black & white color map - 
       useful for printing spectrograms.

(See /host/bluemoon/usr2/idllib/sdss/allpro/begplot.pro)


BINARY_SEARCH

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

 NAME:
    BINARY_SEARCH

 CALLING SEQUENCE:
    binary_search,arr,x,index

 PURPOSE:
    Perform a binary search on arr, an input array, for the closest match
    to x.

(See /host/bluemoon/usr2/idllib/sdss/allpro/binary_search.pro)


BTC_EXTRACT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       BTC_EXTRACT
 PURPOSE:
	Run sextractor on an image using the parameters passed in param_struct

 CALLING SEQUENCE:
       btc_extract, param_struct, filename

 INPUTS:
	param_struct: a structure containing all the parameters needed
		      to run sextractor
	filename: image to be processed
       
 OUTPUTS:
	

 OPTIONAL OUTPUT ARRAYS:

 INPUT KEYWORD PARAMETERS:
 
 PROCEDURE: This processes an image on disk using the parameters provided.
	

 REVISION HISTORY:
	Tim McKay	UM	1/8/98
	Tim McKay	UM	3/7/98  
		Added check for environment variables 
			EXTRACT_BIN, and EXTRACT_PAR
	Tim McKay	UM	11/3/98
		Altered for proper use of sextractor 2.0.15
	Tim MCKay	UM	1/14/99
		Made work for BTC data from rextract

(See /host/bluemoon/usr2/idllib/sdss/allpro/btc_extract.pro)


BTC_EXTRACT_SETUP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       BTC_EXTRACT_SETUP
 PURPOSE:
	Set up a parameter structure for sextractor operation on btc data

 CALLING SEQUENCE:
       btc_extract_setup, param_struct

 INPUTS:
       
 OUTPUTS:
	param_struct: a structure containing all the parameters needed
		      to run sextractor

 OPTIONAL OUTPUT ARRAYS:

 INPUT KEYWORD PARAMETERS:
 
 PROCEDURE: Prepares a param_struct for BTC sextractor operation
	

 REVISION HISTORY:
	Tim McKay	UM	1/8/98
	Tim McKay	UM	3/7/98  
	Tim McKay	UM 	1/14/99

(See /host/bluemoon/usr2/idllib/sdss/allpro/btc_extract_setup.pro)


CIRC_RADEC

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

 NAME: 
    circ_radec
       
 PURPOSE: 
    Circles an ra and dec position on the input image.  We need 
    a photo structure, an index and the position of the object with that
    index inorder to complete the mapping.	

 CALLING SEQUENCE: 
    circ_radec, photostr, index, objx, objy, ra, dec, image, 
    nodisplay=nodisplay, radius=radius,color=color,box=box
      
                 

 INPUTS: photostr: a photo structure
         index: the index of an object in that structure
         objx, objy: the x and y positions of index object.
         ra, dec:  the ra and dec to be circled.
         image:  the image on which to circle.  
                 Only need this if NOT nodisplay

 INPUT KEYWORD PARAMETERS:
         nodisplay:  if set, image will not be displayed.
         radius: radius of the circle.  Default is image size/10.0
         clr: color index to make the mapping from.
         /box: use a box instead of a circle.  radius will be side of box
         /silent: Shut off the messages except errors.

       
 OUTPUTS: none

 CALLED ROUTINES: 
                  CONVERT2XY
                  POLYWARP
                  KMAP
                  (RDIS_SETUP)
                  (RDIS)
                  TVCIRCLE
                  (TVBOX)

 
 PROCEDURE: 
	convert the ra and dec to x y coordinates
	

 REVISION HISTORY:
	Author: Erin Scott Sheldon Umich 5/25/99
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/circ_radec.pro)


CLOSE_MATCH

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

 PURPOSE:
 this will find close matches between 2 sets of points (t1,s1)
 and (t2,s2) (note t1,t2,s1,s2 are all arrays) in a 2 dimentional space.
 differnt then close_match in that it gives the 'allow' CLOSEST matches
 CALLING SEQUENCE:
 close_match,t1,s1,t2,s2,m1,m2,ep,allow,miss1

 INPUTS:
 t1,s1: the coordinates of the first set
 t2,s2: the coordinates of the second set
 ep:  this is the error which defines a close match. A pair is considered
 a match if |t1-t2| AND |s1-s2| are both less than ep. This is faster
 than doing a euclidean measure on the innermost loop of the program
 and just as good.
 allow: how many matches in the (t2,s2) space will you allow for
 each (t1,s1)

 OUTPUTS:
 m1,m2: the indices of the matches in each space. That is  
 (t1(m1),s1(m1)) matches (t2(m2),s2(m2))
 miss1: this gives the index of the things in x1 NOT found to match (optional)

 OPTIONAL KEYWORD PARAMETERS:
 none

 NOTES:
 It sorts the t2 list so that it can do a binary search for each t1.
 It then carves out the sublist of t2 where it is off by less than ep.
 It then only searches that sublist for points where s1 and s2 differ
 by less than ep. 
 PROCEDURES CALLED:
 binary_search, rem_dup
 REVISION HISTORY:
 written by David Johnston -University of Michigan June 97

   Tim McKay August 97
 	bug fixed, matcharr extended to "long" to accomodate ROTSE I images
   Tim McKay July 99
	bug fixed to correctly handle the first object in list 2, and 
	especially the case with a single object in list 2

(See /host/bluemoon/usr2/idllib/sdss/allpro/close_match.pro)


CLOSE_MATCH_RADEC

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

 PURPOSE:
 this will find close matches between 2 sets of points (t1,s1)
 and (t2,s2) (note t1,t2,s1,s2 are all arrays) in ra dec space.
 
 CALLING SEQUENCE:
 close_match_radec,t1,s1,t2,s2,m1,m2,ep,allow,miss1

 INPUTS:
 t1,s1: the ra dec of the first set
 t2,s2: the ra dec of the second set
 ep:  this is the error which defines a close match. A pair is considered
 a match if |t1-t2|/cos(dec) AND |s1-s2| are both less than ep. This is faster
 than doing a euclidean measure on the innermost loop of the program
 and just as good.
 allow: how many matches in the (t2,s2) space will you allow for
 each (t1,s1)

 OUTPUTS:
 m1,m2: the indices of the matches in each space. That is  
 (t1(m1),s1(m1)) matches (t2(m2),s2(m2))
 miss1: this gives the index of the things in x1 NOT found to match (optional)

 OPTIONAL KEYWORD PARAMETERS:
 none

 NOTES:
 It sorts the t2 list so that it can do a binary search for each t1.
 It then carves out the sublist of t2 where it is off by less than ep.
 It then only searches that sublist for points where s1 and s2 differ
 by less than ep. 
 PROCEDURES CALLED:
 binary_search, rem_dup
 REVISION HISTORY:
 written by David Johnston -University of Michigan June 97

   Tim McKay August 97
 	bug fixed, matcharr extended to "long" to accomodate ROTSE I images
   Tim McKay 6/23/98
	Altered to be an ra dec match, with appropriate scaling of ra range...
   Tim McKay 7/8/99
	Altered to order matches by distance, rather than just ra dec distance

(See /host/bluemoon/usr2/idllib/sdss/allpro/close_match_radec.pro)


COMBINE_ATLAS

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

 NAME: 
    COMBINE_ATLAS

 PURPOSE: 
    Subroutine of get_atlas.  Combines images

 CALLING SEQUENCE:
   combine_atlas,xs, ys, cnum, color,imtot, 
         imu=imu,img=img,imr=imr,imi=imi,imz=imz

 INPUTS:  
          xs: xsize array
          ys: ysize array
          cnum: color numbers
          color: ['u','g'.....
          imtot: output array with all subimages in it.
          imu, img, ....

 OUTPUTS: 
          imtot

 REVISION HISTORY:
    Erin Scott Sheldon  3/14/99  Just a modularization.

(See /host/bluemoon/usr2/idllib/sdss/allpro/combine_atlas.pro)


COMBINE_STRUCTS

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

 PURPOSE:
  takes two arrays of structures str1,str2 which have the
  same number of elements but possibly different tags
  and makes another structure which has the same number of elements
  but the tags of both str1,str2 and has their respective tags 
  values copied into it

 CALLING SEQUENCE
    combine_structs, struct1, struct2, newstruct, structyp=structyp

 INPUTS:
    struct1,struc2: The two structures to be combined. If structure arrays, 
               Must contain the same number of structs.

 KEYWORD PARAMETERS:
   structyp: a string with the name of the new structure.
     if already defined the program will crash.

 Author Dave Johnston UofM

(See /host/bluemoon/usr2/idllib/sdss/allpro/combine_structs.pro)


COMPUTE_SEP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
    COMPUTE_SEP
 PURPOSE:
  compute the seperation in arc seconds and position angle
  between an objects two children if it has two children
  position angle is an angle between 0 degrees and 180 degrees
  NOT 0 to 360 
  so it is not really the position angle of ONE with
  respect to the OTHER (ie. it is order independent)
  0 degrees is horizontal and 90 degrees vertical 
  cat is the sdss photo structure and index is the index of the parent
  assumes two children are indices index+1 and index+2

 CALLING SEQUENCE:
  compute_sep,cat,index,separation,position_angle

Revision History:
	David Johnston 5/20/99

(See /host/bluemoon/usr2/idllib/sdss/allpro/compute_sep.pro)


CONCAT_DSTRUCTS

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

 NAME:
    CONCAT_DSTRUCTS
       
 PURPOSE:
    Concatenate two possibly DIFFERENT structures that have common tags 
    but not necessarily identical tags. 
   
    WARNING: CONCAT_DSTRUCTS just takes the common tags, so some tags
    might be lost!

 CALLING SEQUENCE:
    concat_dstructs,str1,str2,strsum

 INPUTS: 
    str1, str2: two structures.

 OPTIONAL INPUTS:
    NONE

 KEYWORD PARAMETERS:
    NONE
       
 OUTPUTS: 
    strsum: concatenated structure with only common tags from str1,str2

 OPTIONAL OUTPUTS:
    NONE

 CALLED ROUTINES:
    REM_DUP
    COPY_STRUCT
 
 PROCEDURE: 
    
 SIDE EFFECTS:
    The order of tags will follow the order in str1.
	

 REVISION HISTORY:
    Created: 10/12/2000 Erin Scott Sheldon UofM
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/concat_dstructs.pro)


CONCAT_STRUCTS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
    CONCAT_STRUCTS
 
 PURPOSE:
  for concatenating two arrays of structures of the same type
  but not necessarily the same name or order of tag names.

 CALLING SEQUENCE:
   concat_structs, str1, str2, strsum

 INPUTS:
   str1, str2: 2 structures with the same tags to be concatenated.

 OUTPUTS:
   strsum: concatenetion of str1, str2, with tag names in the order
        of str1. If tags have same name but different type, then
        a type conversion is performed, with result having type
        of tag in str1.  Resulting structure has name of str1.

 Author: Dave Johnston  UofM
 Used MATCH procedre to make sure tags all match. Use match indices
   to copy values.

(See /host/bluemoon/usr2/idllib/sdss/allpro/concat_structs.pro)


CONVERT2RD

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

 CALLING SEQUENCE:
    convert2rd,x,y,ra,dec,rac=rac,decc=decc

 PURPOSE:
    Convert from x-y to ra and dec

(See /host/bluemoon/usr2/idllib/sdss/allpro/convert2rd.pro)


CONVERT2XY

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

 CALLING SEQUENCE:
    convert2xy,ra,dec,xout,yout,rac=rac,decc=decc

 PURPOSE:
    Convert from ra and dec to x-y

(See /host/bluemoon/usr2/idllib/sdss/allpro/convert2xy.pro)


COPY_ATLAS

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

 NAME: 
    COPY_ATLAS

 PURPOSE: 
    Subroutine of get_atlas. 

 CALLING SEQUENCE:
  copy_atlas, col,im, xs,ys,size_im, 
              imu=imu, img=img, imr=imr, imi=imi, imz=imz

 INPUTS:  col: color index
          im:  input image
          xs: xsize array
          ys: ysize array
          imu: img: imr: imi: imz:

 OUTPUTS: one of the subimages listed above.

 REVISION HISTORY:
    Erin Scott Sheldon  3/14/99  Just a modularization.

(See /host/bluemoon/usr2/idllib/sdss/allpro/copy_atlas.pro)


DATAIMAGE::ANGLE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::angle

 PURPOSE:
       This method replaces the data with an image where each pixel
       has the theta value of that pixels polar coordinate, where the
       origin is at the specified coordinate. Together with the
       dataImage::radius method, it can be used to get the polar
       coordinates of each pixel.

 CALLING SEQUENCE:
       oDataImage->angle, Pixelcoordinate

 INPUTS:
       Pixelcoordinate: A vector with the coordinates of the polar
                        coordinate systems center.

 EXAMPLE:
       exampleImage->angle, [400,400]

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::BUTTERWORTHFILTER

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::butterworthFilter

 PURPOSE:
       This method applies a Butterworth filter to the image.

 CALLING SEQUENCE:
       oDataImage->butterworthFilter(Cutoff,Order)

 INPUTS:
       Cutoff:  This parameter is the value of the lowest (highest)
                spatial wavelength allowed through the filter.
       Order:   The order of the butterworth filter. Higher values
                will results in more ringing, and a sharper boundry
                between filtered and unfiltered frequencies.

 KEYWORD PARAMETERS:
       LOWPASS: By default, the image is highpass filtered. If this
                keyword is set, it is lowpass filtered instead. This
                correspondonds to smoothing the image.       
       MASK:    One may provide a pixel mask to remove the influence
                unwanted pixels. See the documentation for
                dataImage::frequencyFilter for the handling of masks.
       EXTENDEDSIZE: To reduce edge effects, the filtering may be
                performed on an image which has been padded with
                zeros, which are then masked. This parameter sets the
                size of the padded image.

 PROCEDURE:
       The Cutoff us converted from a wavelength to a wavenumber, the
       butterworth filter is constructed, and then applied to the image data.

 EXAMPLE:
       To apply an butterworth smoothing filter,
       exampleImage->butterworthFilter(10,2,/LOWPASS)

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::CENTER

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::center

 PURPOSE:
       This method moves the center (or some specified coordinate) to
       the corner of the image. This is particularly useful for
       working with PSF images.

 CALLING SEQUENCE:
       oDataImage->center

 KEYWORD PARAMETERS:
       PIXELCOORDS: This keyword holds the coordiantes to be placed
                    at the corner of the image. If not specified, the
                    center is used. 

 EXAMPLE:
       psfDataImage->center

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::CLONE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::clone

 PURPOSE:
       This method creates a duplicate image object. If no temporary
       file name is provided, the data for the new image is stored in
       memory. 

 CALLING SEQUENCE:
       Result = oDataImage->Clone(Tempfilename)

 OPTIONAL INPUTS:
       tempFileName: This string contains the file name for the file
                     in which to store the image data, if any.  
	
 OUTPUTS:
       A copy of the image is returned. 

 SIDE EFFECTS:
       The clone is a new object; each must be destroyed separately.

 EXAMPLE:
       imagecopy = exampleimage->clone(tempfilename)

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. 1997

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::COPY

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::copy

 PURPOSE:
       This method is identical to the dataImage::clone method

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::ELLIPSESPACE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::ellipseSpace

 PURPOSE:
       This method creates a model of the galaxy using fits in
       (intensity, radius, angle) space. The center of the galaxy
       must be provided. This method works well for elliptical
       galaxies where the center of the isophotes varies little with
       the intensity of the isophote.

 CALLING SEQUENCE:
       oDataImage->ellipseSpace, CenterCoord, TransformSize

 INPUTS:
       CenterCoord:   A two element array giving the x,y coordinates
                      of the center of the galaxy in the image.
       TransformSize: The image of the galaxy is often at much higher
                      resolution than necessary for fitting
                      isophotes; transformSize specifies has small an
                      array to regrid the image to before examination
                      of the isophotes. 

 KEYWORD PARAMETERS:
       MASKIMAGE:     An object of type maskImage with the pixels not
                      to be used in the calculation of the isophotes
                      masked. 
       FITTERMS:      The number of terms to use in polynomial
                      fitting of log(radius) to log(intensity). 
       FOURIERTERMS:  The number of terms to retain the the fourier
                      expansion of radius as a function of position
                      angle. 
       SKY:           An estimate of the sky background value. This
                      is important primarily when FITTERMS is also
                      set.
       VERBOSE:       If this keyword is set, the progress of the
                      method is reported at several points in the
                      process. This can be interesting for the
                      impatient.  

 RESTRICTIONS:
       The completeness of the mask is vital to the success of the
       fitting; a small number of high or low pixels may cause very
       serious corruption in the result. For this reason, it is often
       helpful to median filter (or otherwise smooth) the image
       before it is fit.

 PROCEDURE:
       For each unmasked pixel in the resized image, the angle,
       radius, and intensity are calculated. Triangulation is then
       used to calculate an array where the index of one dimension is
       proportional to the log of the intensity, the index of the
       other dimension is proportional to the position angle, and the
       value of each pixel is the triangulated radius. Depending of
       the keyword parameters set, the lines of constant intensity
       may be low pass filtered, the lines of constant angle may
       be replaced by best fits to a (log) polynomial, or
       both. Triangulation is then used to return to the original
       (x,y) coordinate system. For additional details, see Neilsen
       (1998).

 EXAMPLE:
       oDataImage->ellipseSpace, [402,410], [64,64], MASKIMAGE=mask,$
            FITTERMS=2, FOURIERTERMS=4, SKY=1.8

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::ESTIMATEDISPLAYRANGE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::estimateDisplayRange

 PURPOSE:
       This method estimates a good display range for viewing the image.

 CALLING SEQUENCE:
       Result=oDataImage->estimateDisplayRange(Maskimage)

 OPTIONAL INPUTS:
       Maskimage:  A maskImage mask covering bad pixels.
	
 KEYWORD PARAMETERS:
       STRETCH:    This pararmeter is set to 16 by default. Larger
                   values will result in a more uniform appearance in
                   the image, with more extreme values unsaturated.

 OUTPUTS:
       An estimated range for display is returned.

 PROCEDURE:
       

 EXAMPLE:
       To display an image using a reasonable range:
       range=exampleImage->estimateDisplayRange(exampleMask)
       TV,exampleImage->getData(RANGE=range)

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::ESTIMATEK

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::estimateK

 PURPOSE:
       This uses a power spectrum fit to esitmate k, the parameter
       of the Wiener filter.

 CALLING SEQUENCE:
       k=oDataImage->EstimateK(Psf)

 INPUTS:
       Psf:   A dataImage object with the PSF of the image

 KEYWORD PARAMETERS:
       MASK:            A mask which covers pixels not to be use in the
                        fits. Unlike the case of SBF power spectrum
                        fitting, one does not necessarily want to cover
                        all point sources.
       WAVELENGTHRANGE: as per dataImage::pspecFit() 
       POWERRANGE:      as per dataImage::pspecFit() 
       FITDATA:         as per dataImage::pspecFit() 
       SBFCOUNTS:       if this keyword is set, it the noise if fit
                        to the histogram of negative pixel values,
                        and the SBF noise removed to arrive at the
                        final noise.
   

 OUTPUTS:
       This method returns an estimate of the value of "k" which is
       appropriate for use in a Wiener filter.

 RESTRICTIONS:
       This method assumes the image is dominated by randomly
       distributed point sources. If this is not the case, the
       returned value will not necessarily be the appropriate "k"
       value, though it is often still a good estimate in practice.

 PROCEDURE:
       

 EXAMPLE:
       To wiener filter an image with a psf in dataImage psf,
       k=exampleDataImage->estimateK(psf)
       exampleDataImage->wienerFilter,psf,k

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.
       Sept. 30, 1997  EHN adds alternate estimation method triggered
                       by setting the SBFCOUNTS keyword. 

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::ESTIMATESIGMA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::estimateSigma

 PURPOSE:
       This method estimates the sky sigma using the pixels with low
       pixel values. It only provides meaningful results where the
       sky and diffuse background objects have been subtracted.

 CALLING SEQUENCE:
       sigma=oDataImage->estimateSigma(Maskimage)

 OPTIONAL INPUTS:
       Maskimage:  A maskImage object covering the pixels not to be
                   considered. 
	
 OUTPUTS:
       An estimate of the sky standard deviation is returned

 RESTRICTIONS:
       The image must be sky subtracted, and diffuse objects must
       either be subtracted or masked.

 PROCEDURE:
       The sky sigma is estimated to be the square root of the sum of
       the squares of the values of the unmasked, negative pixels. 

 EXAMPLE:
       PRINT,exampleImage->estimateSigma()

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::EXPONENTIALFIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::exponentialFit

 PURPOSE:
       Fit in exponential profile to a section of an image of a
       galaxy, and return the best fits.

 CALLING SEQUENCE:
       Result=oDataImage->exponentialFit(Centercoord,Anglerange,Radiusrange)

 INPUTS:
       Cenctercoord:  A two element array containing the x,y
                      coordinates of the center of the galaxy.
       Anglerange:    The range of angles in which to fit the
                      profile. This range should be small enough that
                      the pixels at a given radius will have roughly
                      the same flux. The angle is measure in radians.
       Radiusrange:   This is the range of radii over which to make
                      the fit. Particularly in double exponential
                      profiles, better sky estimates can be made from
                      large radii only.

 KEYWORD PARAMETERS:
       MASKIMAGE:      An array or maskImage object with a mask
                       covering points not to be used in the fit.
       INITIAL:        A 3 element array, the initial parameters of
                       the fits. The first element is an estimate of
                       the sky, and is usually all that is
                       necessary. At the completion of the
                       procedure. it will hold the best exponential
                       fit parameters.
       RANGEMASK:      A mask covering all pixels not used in the
                       profile fit, of the same type as MASKIMAGE.

 OUTPUTS:
       Fitsky:         The returned value of the function is an array
                       with the fits as follows:
                         FitSky[0,*]  =  the radii of the fit points
                         FitSky[1,*]  =  the fluxes of the fit points 
                         FitSky[2,*]  =  the fit value of the best fit
                                       exponential fit
                         FitSky[3,*]  =  the fit value of the best fit
                                       R^(1/4)

 RESTRICTIONS:

 PROCEDURE:
       Arrays of good pixels and the corresponding radii are
       created. Least squares fits are then made at an expnential
       plus a constant (sky), and an r^(1/4) law plus a constant.

 EXAMPLE:
       To plot the profile and the different fits:
       skyFit=oDataImage->exponentialFit, [401,410], [0.0,0.52],$
                   [30,500], MASKIMAGE=imageMask, INITIAL=[4.5,0.0,0.0]
       PLOT,skyFit[0,*],skyFit[1,*],PSYM=3
       OPLOT,skyFit[0,*],skyFit[2,*]
       OPLOT,skyFit[0,*],skyFit[3,*],LINE=2

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::FOURIERTRANSFORM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::fourierTransform

 PURPOSE:
       This method replaces the data associated with an image with it
       fourier transform

 CALLING SEQUENCE:
       oDataImage->fourierTransform

 KEYWORD PARAMETERS:
       INVERSE: If this keyword is set, the method takes the inverse
                fourier transform.      

 SIDE EFFECTS:
       After the transform is taken, the image data is complex.

 PROCEDURE:
       This method uses the IDL FFT funtion.

 EXAMPLE:
       oDataImage->fourierTransform

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::FREQUENCYFILTER

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::frequencyFilter

 PURPOSE:
       This method replaces the data with the data passed through a
       fourier frequency filter. 

 CALLING SEQUENCE:
       oDataImage->frequencyFilter, Filter       

 INPUTS:
       Filter: This parameter is an array with the frequency filter
               to be applied to the image. If the size of the filter
               is greater than that of the data array, the data is
               padded with zeros before the filtering, and cut back
               to its original size afterwards.

 KEYWORD PARAMETERS:
       MASK:   Either a mask image or an array of the same size as
               the data image, where bad pixels are marked with ones
               and good pixels with zeros. Masked pixels are not used
               in the creation of the filtered image. See the
               PROCEDURE section of this documentation for a
               description of how masked images are handled.

 PROCEDURE:
       The filtered image is created by multiplying the fourier
       transform of the data image by the filter, and useing the
       inverse transform to bring it back into image space. To
       understand the handling of the mask, if provided, it is
       easiest to view the filter as a convolution. In the unmasked
       case, each pixel in the returned image is the weighted average
       of the surrounding pixels in the original image, where the
       weights are determined by the fourier transform of the
       filter. If a mask is provided, the weights of the masked
       pixels are set to zero. This procedure is not mathematically
       justified in the general case, but does provide good results
       where the filter lets through spacial frequencies that are
       large compared to the size of the masked regions. 

 EXAMPLE:
       To apply an "ideal" filter to an image,
       idealFilter=FLTARR(256,256)
       idealFilter(WHERE(DIST(256,256) LT 100)) = 1
       oDataImage->frequencyFilter, idealFilter
       

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::GETDATA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::getData

 PURPOSE:
       This methods returns an array containing the image data,
       optionally scaled to a provided exposure time, or for display.

 CALLING SEQUENCE:
       Result=oDataImage->GetData()

 KEYWORD PARAMETERS:
       TIME:    If this keyword is set, the images is scaled to the
                provided exposure time.
       DISPLAY: If this keyword is set, the image is scaled to a
                0:255 range suitable for display.
       RANGE:   This keword is used to scale the display output to a
                specified range of pixel values. The return array
                will be scaled such that pixels of value range[0]
                will be 0, and those of range[1] will be 255. 
       ERANGE:  If this keyword is set, a value for the RANGE is estimated.

 OUTPUTS:
       This function returns the data array for the image, scaled as
       specified by any present keywords.

 EXAMPLE:
       To display an image such that pixel values between 50 and 4000
       are distinguishable,
       TV, oDataImage->GetData(/ERANGE)       

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::GETPROPERTY

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::GetProperty

 PURPOSE:
       This method gets some of the properties of the data image.

 CALLING SEQUENCE:
       oDataImage->GetProperty, FILENAME=filename, TEMPNAME=tempName,$
                  DATAARRAY=data, EXPOSURETIME=exposureTime,$
                  NEXPOSURES=numberOfExposures, DATAHEADER=dataHeader

 KEYWORD PARAMETERS:
       FILENAME - a string containing the name of the file assiciate 
                  with the data image
       TEMPNAME - a string with the file name of a temporary file for the
                  data to be saved in if onDisk is used
       DATAARRAY- a two dimensional floating point array containing
                  the image data 
       EXPOSURETIME - the exposure time of the image, such that the
                      count rate for a given x,y position equals
                      data(x,y)/exposureTime 
       NEXPOSURES - the number of exposures combined in the image
       DATAHEADER - a structure containing the header information for the
             image, in the format used by the image loading and saving
             routines from the astrolib library
       
 EXAMPLE:
       oDataImage->GetProperty,FILENAME=filename,$
                               EXPOSURETIME=exposureTime
       PRINT,"Image ',filename,' has an exposure time of ',exposureTime

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::IDEALFILTER

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::idealFilter

 PURPOSE:
       This method applies an ideal filter to the image.

 CALLING SEQUENCE:
       oDataImage->idealFilter(Cutoff)

 INPUTS:
       Cutoff:  This parameter is the value of the lowest (highest)
                spatial wavelength allowed through the filter.

 KEYWORD PARAMETERS:
       LOWPASS: By default, the image is highpass filtered. If this
                keyword is set, it is lowpass filtered instead. This
                correspondins to smoothing the image.       
       MASK:    One may provide a pixel mask to remove the influence
                unwanted pixels. See the documentation for
                dataImage::frequencyFilter for the handling of masks.

 PROCEDURE:
       The Cutoff us converted from a wavelength to a wavenumber, the
       ideal filter is constructed, and then applied to the image data.

 EXAMPLE:
       To apply an ideal smoothing filter,
       exampleImage->idealFilter(10,/LOWPASS)

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::LOAD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::load

 PURPOSE:
       This method load an image from disk into the image object.

 CALLING SEQUENCE:
       oDataImage->Load, FileName

 OPTIONAL INPUTS:
	fileName: A string containing the name of the file from which
	          to load the image. If no name is given, the current
	          file name associated with the object is used.

 SIDE EFFECTS:
       The previous data and header information is lost.

 EXAMPLE:
       exampleImage->load, 'exampleImageFile.hhh'

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. 1997

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::NORMALIZE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::normalize

 PURPOSE:
       This method normalizes the total flux of the image to a set
       value. This is particularly useful for normalizing PSF images
       to one count.

 CALLING SEQUENCE:
       oDataImage->normalize

 KEYWORD PARAMETERS:
       TOTAL:  Set this keyword to the desired total value of pixels
               in the image, if different from one.

 EXAMPLE:
       psfDataImage=OBJ_NEW('dataImage')
       psfDataImage->load, 'psfImageFile.hhh'
       psfDataImage->normalize

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::PIXELWAVENUMBER

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::pixelWavenumber

 PURPOSE:
       Returns an array, where the value of each pixel corresponds to
       the wavenumber represented by that pixel in a fourier
       transformed image.

 CALLING SEQUENCE:
       Result = aDataImage->pixelWavenumber()

 KEYWORD PARAMETERS:
       EXTENDEDSIZE:  If the image to be considered is larger than
                      the data image, this keyword can be set to the
                      size desired. Smaller values are not allowed.

 OUTPUTS:
       The result is a two dimensional array of wavenumber values,
       suitable for use in creating frequency filters.

 PROCEDURE:
       This procedure is a wrapper for the DIST function in IDL.

 EXAMPLE:
       To apply an "ideal" filter to an image,
       idealFilter=FLTARR(256,256)
       idealFilter(oDataImage->pixelWavenumber() LT 100)) = 1
       oDataImage->frequencyFilter, idealFilter

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.
       September, 1998 Modified to use DIST to calculte wavenumbers

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::POWERSPECTRUM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::powerSpectrum

 PURPOSE:
       This method replaces the image data by its power spectrum.

 CALLING SEQUENCE:
       oDataImage->powerSpectrum

 EXAMPLE:
       To plot the power spectrum of an image
       testImage=OBJ_NEW('dataImage')
       testImage->load,'imageFile.hhh'
       testImage->powerSpectrum
       TVSCL,ALOG(testImage->getData())

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::PSFFILTER

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::psfFilter

 PURPOSE:
       Frequency filters the image to emphasize point sources. It is
       intended to emphasize point source in front of extended
       sources, such as galaxies. If the galaxy has a bright, point
       source like center, it is often helpful to smooth it out
       before the appliation of this filter.

 CALLING SEQUENCE:
       oDataImage->psfFilter, Psf, Flux

 INPUTS:
       Psf:  A dataImage object with the point spread function of the image.
       Flux: An estimate of the total flux of point sources in the image.

 KEYWORD PARAMETERS:
       MODEL: A dataImage object containing a model for the
              background on which you are detecting point sources.
       SKY:   The sky value. If this is included already in the
              model, this keyword should not be set.

 PROCEDURE:
       This method uses frequency filtering to emphasize point
       sources. It begins by calculating the power spectrum of the
       point sources, using the psf and an estimate of their total
       flux, and the power spectrum of everything else, using the
       model (where available) or the power spectrum of the data
       itself (which assumes the background dominates the point
       sources). A frequency filter is then constructed which lets
       though only those frequencies where the power from the point
       sources is largest compared with other sources. This filter is
       essentially a Wiener filter where everything but the point
       sources is reguareded as noise. 

 EXAMPLE:
       oDataImage->psfFilter, psf, estimatedFlux

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::PSPECFIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::pspecFit

 PURPOSE:
       Fit the power spectrum of the image to a linear function of
       the power spectrum of the PSF. This is primarily useful for
       separation of surface brightness fluctuation (SBF) variance
       from noise variance.

 CALLING SEQUENCE:
       Result=oDataImage->pspecFit(Psf)

 INPUTS:
       Psf:   A dataImage object containing the PSF for the image.

 KEYWORD PARAMETERS:
       MASK:            A maskImage object which masks all pixels not
                        to be used.
       WAVELENGTHRANGE: A two element array giving the range of wavelength
                        over which to fit the power spectra,
       POWERRANGE:      A two element array giving the range of power
                        over which to fit the power spectra,
       FITDATA:         This keyword is set to an array with the
                        results of the fit. Fitdata[0,*] is an array
                        of wavenumbers, Fitdata[1,*] is the
                        corresponding power, and Fitdata[2,*] is the
                        corresponding fit to the power.

 OUTPUTS:
       This method returns a two element array. The first element is
       the constant term in the linear term, and the second element
       is the linear term.

 OPTIONAL OUTPUTS:
       FITDATA:         see the keyword description

 PROCEDURE:
       The fit is performed with the IDL POLY_FIT routine.

 EXAMPLE:
       

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::RADIUS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::radius

 PURPOSE:
       This method replaces the data with an image where each pixel
       contains the distance of that pixel to a specified coordinate.
       It may be used, for exampled, to get distances from the center
       of a galaxy,

 CALLING SEQUENCE:
       oDataImage->radius, CenterCoord

 INPUTS:
       CenterCoord: The coordinate from the the distances are to be
       calculated. 

 EXAMPLE:
       To create an image of the distances to the center of a galaxy
       centered at [410,400] in the image galaxyImage,
       radiusImage=galaxyImage->clone()
       radiusImage->radius, [410,400]

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::RESIZE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::resize

 PURPOSE:
       This method resizes the image. It does not change the pixel
       scale; it merely cuts off or pads the image to make it the
       desired size.

 CALLING SEQUENCE:
       oDataImage->resize, NewSize

 INPUTS:
       newSize: The dimensions of the new image. 

 RESTRICTIONS:
       At present, images cannot be resized such that one dimension
       is larger than the original, while the other is smaller.

 EXAMPLE:
       To ensure the image is 256x256,
       oDataImage->resize, 256

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::SEGMENT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::segment

 PURPOSE:
       Segment the data image. Pixels above the segmentation value
       are set to one, and those below it are set to zero. Often,
       one would want to use the maskImage::segment instead.

 CALLING SEQUENCE:
       oDataImage->segment, Cutoff

 INPUTS:
       Curoff:  The cutoff value for the segmentation.

 EXAMPLE:
       To create a map of the saturated pixels in an image where the
       saturation value is 4000,
       exampleDataImage->segment,400

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::SETPROPERTY

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::SetProperty

 PURPOSE:
       This method sets the properties of the data image.

 CALLING SEQUENCE:
       oDataImage->SetProperty, FILENAME=filename, TEMPNAME=tempName,$
                  DATAARRAY=data, EXPOSURETIME=exposureTime,$
                  NEXPOSURES=numberOfExposures, DATAHEADER=dataHeader

 KEYWORD PARAMETERS:
       FILENAME - a string containing the name of the file assiciate 
                  with the data image
       TEMPNAME - a string with the file name of a temporary file for the
                  data to be saved in if onDisk is used
       DATAARRAY- a two dimensional floating point array containing
                  the image data 
       EXPOSURETIME - the exposure time of the image, such that the
                      count rate for a given x,y position equals
                      data(x,y)/exposureTime 
       NEXPOSURES - the number of exposures combined in the image
       DATAHEADER - a structure containing the header information for the
             image, in the format used by the image loading and saving
             routines from the astrolib library
       

 EXAMPLE:
       oDataImage->setProperty,FILENAME='newImageFile.hhh',$
                               TEMPNAME='/tmp/newImage.dat',$
                               DATAARRAY='newArray'
                               EXPOSURETIME=400

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::TRIANGULATE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::triangulate

 PURPOSE:
       This method replaces masked pixels with values calculated
       using triangulation from nearby food pixels.

 CALLING SEQUENCE:
       oDataImage->trinagulate, Mask

 INPUTS:
       Mask:  The mask image (a maskImage object), where the pixels
              to be triangulated are masked.

 RESTRICTIONS:
       Triangulation of pixels is limited by the limits of IDL's
       trinagulation routines. The method can be quite slow.

 PROCEDURE:
       This pixels surrounding regions of bad pixels are used to
       create a triangulation grid using the IDL procedure
       TRIANGULATE. Replacement values for the bad pixels are then
       calculated using TRIGRID.

 EXAMPLE:
       To view an image with the masked pixels replaced:
       oDataImage=OBJ_NEW('dataImage')
       oDataImage->load,'galaxyData.hhh'
       oMaskImage=OBJ_NEW('maskImage')
       oMaskImage->load,'galaxyMask.hhh'
       oDataImage->tringulate, oMaskImage
       TV,oDataImage->getData(/DISPLAY)

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE::WIENERFILTER

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       dataImage::wienerFilter

 PURPOSE:
       This method replaces the method by a Wiener filtered version
       of the image. For information on using a Wiener filter,
       consult a image processing reference guide, _Digital Image
       Processing_ by Gonzales & Woods (1992), or _The Image
       Processing Handbook_ by Russ (1995).

 CALLING SEQUENCE:
       oDataImage->WienerFilter,Psf,K

 INPUTS:
       Psf:  A dataImage object containing the point spread function
             of the image.
       k:    The parameter "k" of the Wiener filter. 

 RESTRICTIONS:
       There is no accomodation for handling noise or PSF's which
       vary over the image.

 PROCEDURE:
       The Wiener filter is constructed using the supplied PSF and K,
       and then applied to the image.

 EXAMPLE:
       To wiener filter an image,
       psfImage=OBJ_NEW('dataImage')
       psfImage->load, 'imagePSF.hhh'
       dataImage=OBJ_NEW(('dataImage')
       dataImage->load, 'starfield1.hhh'
       k=1.0e-7
       dataImage->wienerFilter,psfImage,k

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DATAIMAGE__DEFINE

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

 PURPOSE:
       This routing defines the dataImage object. The dataImage
       object is intended to be the primary object used to store and
       manipulate astronomical image. 

 CALLING SEQUENCE:
       oDataImage=OBJ_NEW('dataImage')


 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/dataimage__define.pro)


DCENTER

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

 NAME:
    DCENTER
       
 PURPOSE:
    Center up the display

 CALLING SEQUENCE:
    dcenter, xsize, ysize, px, py, silent=silent

 INPUTS: 
    xsize, ysize: the size of the plot.

 OPTIONAL INPUTS:
    NONE

 KEYWORD PARAMETERS:
    NONE
       
 OUTPUTS: 
    px,py: the new positions of the plot region.

 OPTIONAL OUTPUTS:
    NONE

 CALLED ROUTINES:
    
 
 EXAMPLE: 
    plot, [0,1], [0,1], /nodata, xstyle=4, ystyle=4
    pxold = !x.window*!d.x_vsize
    pyold = !y.window*!d.y_vsize
    xsize = px[1] - px[0]
    ysize = py[1] - py[0]
    dcenter, xsize, ysize, px, py
    position=[ [ px(0), py(0)], [ px(1), py(1) ] ]

    plot, x, y, position=position, /device, /noerase, _extra=extra

 REVISION HISTORY:
    ??-??-2000 Erin Scott Sheldon
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/dcenter.pro)


DISPLAY_ATLAS

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

 NAME: 
    DISPLAY_ATLAS

 PURPOSE: 
    Subroutine of get_atlas.  Displays image.

 CALLING SEQUENCE
    display_atlas, objstruct, imtot, i, ret, zoom, run, camcol, 
                   field, obj_id, cnum, rerun=rerun, sep=sep, pa=pa, 
                   noprompt=noprompt,silent=silent,
                   hideradec=hideradec,_extra=extra

 Notes:  1. If plot titles don't fit on view screen, just make screen bigger.
         2. Might want to alter the !p.charsize commands in CASE statement
         to fit your tastes.  Same with titles, etc.


 INPUTS:  imtot:  image containing some atlas images
          i:      index of index of atlas image.  May change in this program.
          ph_id:  index of atlas image
          zoom:   zoom or not?
          run:    sdss run
          camcol: camera column
          field:  field of the object
          obj_id: id of object
          cnum: the requested color indexes
          color_str: color strings ['u','g',...
          struct: a photo structure
	   hideradec: if set it will not include ra dec in title	
          _extra: extra keywords for plotting.

 OUTPUTS: i may have changed
          ret: returns 'next' or 'q' for quit

 REVISION HISTORY:
    Erin Scott Sheldon  3/14/99  Just a modularization.
    Dave Johnston shortened plot titles to fit more info 
    Dave Johnston 5/18/99 added seperation and position angle
	(when nchild eq 2) to title
	added hideradec keyword

(See /host/bluemoon/usr2/idllib/sdss/allpro/display_atlas.pro)


DISPLAY_FCHART

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

 NAME: 
    DISPLAY_FCHART
       
 PURPOSE: 
    display a photo finding chart and circle the object that was used 
    to make the chart.  Label axis with arcminutes from the center.
	

 CALLING SEQUENCE:  display_fchart, fchart, object, objx, objy, clr, 
     box=box, gif=gif, ps=ps, fnameps=fnameps, 
     fnamegif=fnamegif, silent=silent, nodisplay=nodisplay, 
     hideradec=hideradec,circ_rad=circ_rad, nocirc=nocirc, _extra=extra
      
                 

 INPUTS: fchart:  The finding chart
         object:  The photo object used to make the finding chart.
         objx:    x-position of object in the finding chart.
         objy:    y-position
         clr:     color index the finding chart was made from 
                                          used in the title.

 INPUT KEYWORD PARAMETERS:
         box:  Draw a box instead of a circle.
         gif:  If set a gif's are output to cwd.
         ps:   If set a postscript files are created for the requested items.
         fnameps: name of ps file.  Default is fchart.ps
         fnamegif: name if gif file.  Default is fchart.gif
         silent:  If set, program will be silent except for error messages.
         nodisplay: If set, there will be No x-window display of the chart.  
               -May still make ps files.-
         hideradec: Don't show the ra and dec on the plots.
         circ_rad: radius of circle.
         nocirc:  if set, no circle is drawn.
         _extra: any extra plotting command keywords.
       
 OUTPUTS: 

 OPTIONAL OUTPUTS: May output .ps or .gif files if requested.

 CALLED ROUTINES:

                  RADECSTR
                     RADEC
                  SIGMA_CLIP
                  BEGPLOT
                  ENDPLOT
                  RDIS_SETUP
                  RDIS:
                      TVIM2_SCL:
                               TVIM2
                  TVCIRCLE
                  TVBOX


 REVISION HISTORY: 
      Author: Erin Scott Sheldon  Umich 5/25/99
	
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/display_fchart.pro)


ENDPLOT

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

 PURPOSE:

	Closes and saves the current plotfile.  By default, the file
	is then spooled to the printer using the unix 'lpr -r'
	command. Keywords are available to name the plotfile and
	inhibit spooling.

	See also BEGPLOT and KILLPLOT.

 CATEGORY:

	Misc.

 CALLING SEQUENCE:

	ENDPLOT

	There are no user defined inputs.

 INPUTS:

	None.

 KEYWORD PARAMETERS:

	NOPRINT: Set to prevent spooling.

	P: Name (string) of printer to spool plotfile to.  'lpr -r
          -Pprintername' is used.

       SHELL: Set to use an intervening shell process for the
                'spawn, "lpr..."' call.  By default, the 
                /NOSHELL keyword to spawn is used.

 OUTPUTS:

	None.

 COMMON BLOCKS:

	PLOTFILE_COM:  See the documentation for BEGPLOT.

 EXAMPLE:

	See the documentation for BEGPLOT.

 COPYRIGHT NOTICE:

	Copyright 1993, The Regents of the University of California. This
	software was produced under U.S. Government contract (W-7405-ENG-36)
	by Los Alamos National Laboratory, which is operated by the
	University of California for the U.S. Department of Energy.
	The U.S. Government is licensed to use, reproduce, and distribute
	this software. Neither the Government nor the University makes
	any warranty, express or implied, or assumes any liability or
	responsibility for the use of this software.

 MODIFICATION HISTORY:

 	Based on ENDPLT by Phil Klingner, NIS-3, LANL.

	Modified and renamed ENDPLOT. Michael J. Carter, NIS-1, LANL,
	March, 1994.

       Added /noshell keyword in call to 'spawn' to speed up printing.
       Use the /shell keyword to 'endplot' to override. 

(See /host/bluemoon/usr2/idllib/sdss/allpro/endplot.pro)


EQ2SURVEY

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

 NAME:
    EQ2SURVEY
       
 PURPOSE:
    Convert from ra, dec to lambda, eta (SDSS survey coordinates)

 CALLING SEQUENCE:
    eq2survey, ra, dec, lambda, eta

 INPUTS: 
    ra: Equatorial latitude in degrees 
    dec: Equatorial longitude in degrees

 OPTIONAL INPUTS:
    None

 KEYWORD PARAMETERS:
    None
       
 OUTPUTS: 
    lambda: Survey longitude in degrees
    eta: Survey latitude in degrees

 OPTIONAL OUTPUTS:
    None

 CALLED ROUTINES:
    ATBOUND
    ATBOUND2
 
 PROCEDURE: 
    
	

 REVISION HISTORY:
    Written: 5/15/2000  Erin Scott Sheldon
                        Taken from astrotools.
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/eq2survey.pro)


ETA2STRIPENUM

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

 NAME:
    ETA2STRIPENUM
       
 PURPOSE:
    Find which stripe goes with this eta.

 CALLING SEQUENCE:
    stripe = eta2stripenum(eta, southern=southern)

 INPUTS: 
    eta: SDSS survey longitude.

 OPTIONAL INPUTS:
    NONE

 KEYWORD PARAMETERS:
    /southern: This is a southern stripe
       
 OUTPUTS: 
    stripe

 OPTIONAL OUTPUTS:
    NONE

 CALLED ROUTINES:
    NTOSTR
 
 PROCEDURE: 
    
	

 REVISION HISTORY:
    14-NOV-2000 Taken from astrotools
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/eta2stripenum.pro)


EXIST

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
   EXIST
 PURPOSE:
   A very simple check to see if a file exists...
 CALLING SEQEUNCE:
   tmp = Exist('STARS.DAT')
 INPUT:
   FILENAME  This is the filename or search spec. that should be checked.
 OUTPUT:
   TMP       The returned result is 1 is the file or files exist and 0 if
               the file of files do(es) not exist.
 OPTIONAL OUTPUT:
   COUNT     Number of occurances of the given search spec.
 EXAMPLE:
   if exist('tmp.tmp') then print,'Yes' else print,'No'
   if not exist('tmp.tmp') then print,'Create'
   if exist('*.hhh',count) then print,strn(count),' Header files available'
 HISTORY:
   27-JUL-1992 Header added to old routine  (E. Deutsch)
		

(See /host/bluemoon/usr2/idllib/sdss/allpro/exist.pro)


EXTRACT_GALAXIES

[Previous Routine] [Next Routine] [List of Routines]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 NAME: 
    EXTRACT_GALAXIES

 PURPOSE:
     Extracts a clean set of galaxies
 
 Inputs:  pstruct: input photo structure 
	   color_index: bandpass to select on:
          ostruct: output photo structure containing galaxies
          max_mag: maximum magnitude to use (default=24.0)
          no_objc_type:  don't use the photo objc_type to pick galaxies
	   silent: don't make plots

 Outputs: Plots flags for these objects....
	   indices: returns the indices of the galaxies in the original
			struct

 Author:  Phil Fischer
 Date: 1/14/99
 Altered to get galaxies: Erin Scott Sheldon
 Date: 2/19/99
 Added silent and indices options: Tim McKay
 Date: 6/10/99

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Help message
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(See /host/bluemoon/usr2/idllib/sdss/allpro/extract_galaxies.pro)


EXTRACT_STARS

[Previous Routine] [Next Routine] [List of Routines]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 NAME: 

    EXTRACT_STARS

 PURPOSE:
     Extracts a clean set of stars suitable for PSF determination
 
 Inputs:  pstruct: input photo structure 
	   clr: bandpass to select on:
          ostruct: output photo structure containing stars
          max_mag: maximum magnitude to use (default=20)
          indices: the indices of the stars.
	   sig_clip: Number of sigma for clipping large radius objects (default=3)
 Outputs: Plots flags for these objects....

 Author:  Phil Fischer
 Date: 1/14/99

 Modified: Tim McKay
 Date: 4/22/99  Changed the move flag cut to the objc level
		 Fixed indirection of the indices option

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Help message
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(See /host/bluemoon/usr2/idllib/sdss/allpro/extract_stars.pro)


FCHART

[Previous Routine] [Next Routine] [List of Routines]
 NAME: 
    FCHART
       
 PURPOSE: 

    Create a finding chart for the object in index.
	
 CALLING SEQUENCE: 

    fchart, pstruct, index, radius, clr, fchart, dir=dir, 
            silent=silent, objx=objx, objy=objy, nonoise=nonoise

 COMMENTS:  The wrapper obj_info is a very convenient way to use FCHART
            since it makes a nice display.

 INPUTS: 
    
    pstruct:  A photo structure.
              IMPORTANT NOTE: This MUST have objc_rowc as a continuously added
              added number, not restarted at the beginning of each frame.
              Such boundaries are artificial and make it difficult to make 
              finding charts centered on the object.  

              This is done automatically by READ_TSOBJ
    index:    The index of the object in the photo structure which needs
              a finding chart.
    radius:   The box which the object is in will have sides 2*radius
              unless radius is too big. (e.g. bigger that 2048 pixels)
    clr:      The color used to make the finding chart. This follows the
              photo convention: 0,1,2,3,4 -> u,g,r,i,z

 INPUT KEYWORD PARAMETERS:
         dir:  The directory to find the atlas images.
         clr:  The color used to make the finding chart. This follows the
               photo convention: 0,1,2,3,4 -> u,g,r,i,z
         silent: If silent is set, nothing is printed except some errors
         nonoise: if set, no noise is added to image.
         maxsize: maximum size for atlas images. Default is [500,500].  If 
               your images are clipped off (as with large galaxies) increase
               maxsize.
         
 OUTPUTS: 

    fchart:  The image of the finding chart. 

 OPTIONAL OUTPUTS: 
    objx: The x-position of the input object in pixels in image
               coordinates (as opposed to photo objc_rowc, etc)
    objy: Same for y.
    impos: Absolute position of left hand corner of image.

 CALLED ROUTINES: 

    GET_FAMILY
    GET_ATLAS
 
 PROCEDURE: 
  Create a finding chart around an input object from all the objects nearby.
  The trick is to only use the complete images, not the ones with pieces
  cut out of them.  This program uses the get_family procedure to figure
  out which are the good ones:

    orphans:  Those objects with no siblings or parents.
    child of a bad parent: A bad parent will have one child which is 
             a fainter version of itself.
    good parents: The clean parent image. (from which good children 
             are made)
    grandparents: Sometimes there is a grandparent, from which comes
             only one child.  This child has children of its own.
	
  From here, the atlas image  of each good neighbor is the proper color is 
  found and placed within the appropriate box.  
  Note this box may not center on the main object if it is less that 'radius'
  from either the edge of the frame in the column direction. This is also, 
  true if it is near either end of the series of frames read into pstruct.


 REVISION HISTORY: 
     Author  Erin Scott Sheldon UM 03/21/99
     Dave Johnston - was adding way too much noise
        to background in some cases , now it just adds a 
        trace amount of noise to background 
        sky rms sqrt(30)  5/15/99	
     Now allows objects with center outside image to 
     contribute light to the image. Object centers must
     be within maxsize/2.  14-NOV-2000
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/fchart.pro)


FCHART_CIRC_RADEC

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

 NAME: 
    FCHART_CIRC_RADEC
       
 PURPOSE: 
    Build a finding chart and (unless requested otherwise ) circle positions 
    in ra and dec arrays.
	

 CALLING SEQUENCE: 
    fchart_circ_radec, photostr, ra, dec, fchart, 
                      clr=clr, radius=radius, tol=tol,
                      maxsize=maxsize,  
                      nonoise=nonoise, 
                      nocirc=nocirc, 
                      circ_rad = circ_rad, 
                      circ_obj=circ_obj, 
                      nodisplay=nodisplay, psfile=psfile, 
                      silent=silent,
                      objx=objx, objy=objy, photoid=photoid, _extra=extra

 INPUTS: photostr:  A photo structure.  Must contain RUN and CAMCOL tags to
             find atlas directory (calls fetch_dir) Also must contain RA and
             DEC so that CIRC_RADEC can make a good mapping from row,col to
             ra and dec
         ra, dec:   The arrays of ra and dec positions to be circled.  Finding
             chart is made for object in photostr that most closely matches
             the _first_ ra and dec in list.  Note, if you set /nocirc, none
             of the objects in the list will be circled.

 OPTIONAL INPUTS:
         maxsize: maximum size for atlas images; sent to atlas images.  If 
                 your images are being clipped off, you should increase
                 maxsize. default = [500,500]
         clr:       Color to make finding chart.  [0,1,2,3,4]->[u,g,r,i,z]
                 default is clr=2
         radius:    Optional input.  Radius to make finding chart in pixels.
         tol:       Optional input tolerance (in arcsec) used to find nearest 
                    object to ra dec. This should be large to gaurantee it 
                    will find and object.  Default is 500 arcsec. Will search 
                    on first ra dec in list. 
         cird_rad:  array of radii used to make circle around objects in 
                    the list.  Default is size of finding chart/10.0 and 
                    consecutively smaller for each in list.
         circ_obj: If set, circle the object used to make finding chart.
         psfile:    Name of psfile in which to plot.
         photoid:   Can input photoid to make fchart from, else it will find
                    nearest match in ra,dec. If not input, can
                    be returned with this keyword. See below.
         _extra:    Extra plotting options.

 KEYWORD PARAMETERS:
         nonoise: keyword sent to fchart.  Set for no noise added to fchart.
         nodisplay:  If set, won't display the image.
         silent:   Shut off messages except errors.
         nocirc: If set, no circling is done.

 OPTIONAL OUTPUTS:
         fchart:  Return the image.
         objx, objy:  The position of object used to make finding chart.
         photoid:   If not input, returns id used to make finding chart

 CALLED ROUTINES:
                  (CLOSE_MATCH_RADEC)
                  FCHART
                  (DISPLAY_FCHART)
                  (CIRC_RADEC)
                  FETCH_DIR
                  (FETCH_RERUN)
 
 PROCEDURE: 
   if not input in photoid, match first ra and dec in structure to 
   the photostr.  Then make a finding chart and circle all the ra and dec.
	

 REVISION HISTORY:
	Author: Erin Scott Sheldon Umich 5/25/99
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/fchart_circ_radec.pro)


FETCH_DIR

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

 PURPOSE:
    given run camcol and rerun it will retrun
    the directory dir on fsgi03 where this tsObj file lives
    and the directory atldir where the atlas images live
    if given the field it will output the tsObj file as well
    and the atlas file

 CALLING SEQUENCE:
   fetch_dir, run, camcol, rerun [, dir, atldir, file, atlfile,
              field=field, check=check, corrdir=corrdir]

 INPUTS:
    run, camcol, rerun: in integer form
 
 OUTPUTS:
    none

 OPTIONAL INPUTS:
    field: An integer field number.  If input, file and atlfile (tsObj and
           fpAtlas) file names can be returned
    check: If /check, then will make sure directory exists.

 OPTIONAL OUTPUTS:
    dir, atldir: the tsObj directory and fpAtlas directory (objcs)
    file, atlfile: filenames for input field number
    corrdir: the directory holding corrected shape files. Requires
       system variable !SDSS_SHAPECORR_DIR in SDSSIDL_SETUP.PRO
    corratldir:  ''

 NOTES 
    1) Variables !SDSS_DATA_DIR and !SDSS_SHAPECORR_DIR are set in
       sdssidl_setup.  You must have that procedure to run this one.
    2) If /check is set and a file or directory is not found, then
       it is set to ''

 EXAMPLE:
    IDL> fetch_dir,259,5,1,200,dir,file,field=203
    IDL> print,dir
    /usr/sdss/data01/imaging/259/1/calibChunks/5
    IDL> print,file
    /usr/sdss/data01/imaging/259/1/calibChunks/5/tsObj-000259-5-1-0203.fit

(See /host/bluemoon/usr2/idllib/sdss/allpro/fetch_dir.pro)


FETCH_FILE_LIST

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

 PURPOSE:
	for use with read_tsObj
	will return the list of tsObj files in directory dir 
	(the new field-seperarted tsObj files) between start and start+nframe
       Can also have a front other than tsObj if so desired, but
       must have form front-run-camcol-rerun-field.extension

 CALLING SEQUENCE:
	fetch_file_list,dir, files, fnums [, start=start, nframes=nframes,
                    run=run, camcol=camcol, rerun=rerun,  
                    fieldmin=fieldmin, fieldmax=fieldmax, 
                    front=front, nchar=nchar]

 INPUTS:
	dir:  the full directory where the tsObj files live.
         Must be of the form: "..../run/rerun/calibChunks/camcol/" or
         fetch_file_list will fail.

 OPTIONAL INPUTS:
       start: the first field to consider (default is first)
	nframes: the total number of files to fetch (default is max possible)
       front:  The front string in the files.  Default is "tsObj"
       nchar:  The number of characters in the name.  
               Default is 25 for tsObj files.

 OUTPUTS:
	files: a string array of the file names (full path)
	fnums: a "long" array of the field numbers	
       run: the run 
	camcol: the camera collumn
	rerun: the rerun number
		(presumably you had to have known these three
		variables to get the directory 
		but you may not have had them handy
		so are output if you need them)

       fieldmin, fieldmax: first and last field numbers

 EXTERNAL CALLS:
      	none 
 METHOD:
	uses find_file function   
 EXAMPLE
	IDL> fetch_dir,run,camcol,rerun,dir
	IDL> fetch_file_list,dir,files,start=13,nf=20
	IDL> help,files   
   	FILES           STRING    = Array[100]
	IDL> print,files(0)
	/usr/sdss/data02/imaging/273/1/calibChunks/2/tsObj-000273-2-1-0011.fit


 NOTES

 HISTORY:  written by David Johnston -University of Chicago
       Physics Department October 9 1999
       11/13/99  Added "front" and "nchar" inputs  Erin Scott Sheldon
       2/20/2000 made start, nframes optional. defaults set.  E.S.S.
       Now requires strict directory format. Gets run/camcol/rerun from
       directory name. Checks for files with those numbers. 13-Nov-2000 E.S.S.

(See /host/bluemoon/usr2/idllib/sdss/allpro/fetch_file_list.pro)


FETCH_RERUN

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

 PURPOSE:
    will get the newest rerun that exists on disk for run "run"
    does this by CD-ing to the directory from 
    '/usr/sdss/data01/imaging/'+string(run)+'/calibChunks/'
    this directory is symbolically linked to the newest rerun 
    directory. Then just spawn a pwd and look at the 
    directory name

 CALLING SEQUENCE:
    fetch_rerun, run, rerun

 INPUTS:
    run: the run in integer/long form.

 OUTPUTS:
    rerun: the rerun in integer form.

    NOTES: 1) Need !SDSS_DATA_DIR to be defined (see SDSSIDL_SETUP.PRO)
           2) If run directory does not exist, then -1 is returned.

(See /host/bluemoon/usr2/idllib/sdss/allpro/fetch_rerun.pro)


FIELD2STRING

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

 NAME: 
    FIELD2STRING
       
 PURPOSE: 
    Function outputs a string containing field of a photo tsObj 
    file in the correct format.
	

 CALLING SEQUENCE: 
    result = field2string(field)
      
 INPUTS: 
    field
       
 OUTPUTS: 
    field string or '' if error.
 
 PROCEDURE: 
      field should have 4 characters padded with zero's if its
      not big enough.  e.g. if input 33, output is '0033'
	
 REVISION HISTORY:
     Author: Erin Scott Sheldon  Umich 5/25/99
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/field2string.pro)


FINDABTHETA

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

 NAME: 
    FINDABTHETA
       
 PURPOSE: 
    find the axis ratio and position angle of an object with
          e1 and e2 as ellipticity parameters.  Currently only
          works for unweighted or adaptively weighted moments.
	

 CALLING SEQUENCE: 
    findabtheta, e1, e2, aratio, posangle, verbose=verbose
      
                 

 INPUTS: 
    e1, e2: ellipticity parameters.

 INPUT KEYWORD PARAMETERS: 
         /verbose: print the output e1 and e2
         /lupton: if this is set, then use formulae for q and u

       
 OUTPUTS: 
    aratio: axis ratio
    posangle: position angle from the x-axis.

 PROCEDURE: 
	
	

 REVISION HISTORY:
	Author: Erin Scott Sheldon    UofM  5/??/99  
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/findabtheta.pro)


FINDE

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

 NAME: 
    finde
       
 PURPOSE: 
    Find the e1 and  for a perfectly elliptal object with the 
          given axis ratio.  e1_ad and e2_ad are for unweighted or adaptively
          weighted moments.  e1_lup and e2_lup are Robert Luptons q and u
          which are in SDSS PHOTO catalogs.
	

 CALLING SEQUENCE:
    
     finde, aratio, posangle, e1_ad, e2_ad, e1_lup, e2_lup, silent=silent
      
 INPUTS: 
    aratio:  The axis ratio of the object.
    posangle: The positon angle from the x-axis.

 INPUT KEYWORD PARAMETERS:
         /verbose: Print out the result.
       
 OUTPUTS: 
    e1_ad, e2_ad:  Ellipticity parameters in unweighted for adaptively
                   weighted moments.

 OPTIONAL OUTPUTS: 
    e1_lup, e2_lup:  q and u from PHOTO catalog.


 REVISION HISTORY:
	
   Author: Erin Scott Sheldon   U of M  5/25/99 
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/finde.pro)


FIND_RADEC

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

 NAME:
       FIND_RADEC
       
 PURPOSE:
	Find the run, camcol and field that contain the input ra and dec.
       More than one run may be returned if ra,dec is in overlap region
       between the runs.
 
 CALLING SEQUENCE:
       find_radec, ra, dec [, run, camcol, field, 
                   runstr=runstr, colstr=colstr, fstr=fstr, 
                   silent=silent]
                 
 INPUTS: 
       ra, dec: The positions in degrees.

 KEYWORD PARAMETERS:
       /silent: don't print run, camcol, field
       
 OUTPUTS: 
       run, camcol, field

 OPTIONAL OUTPUTS:
       runstr=runstr: run string with standard padded zeros
       colstr=colstr: column string
       fstr=fstr: field string with standard padded zeros.
       

 CALLED ROUTINES:
 
       EQ2SURVEY
       ETA2STRIPENUM
       (SDSSIDL_SETUP)
       MATCH
       MRDFITS
       DELVARX
       ADD_ARRVAL
       NTOSTR


 PROCEDURE: 
	Must have !RADEC_SEARCH_DIR and !SEARCH_RUNS, and !RUN_STATUS defined in
       SDSSIDL_SETUP.PRO  The directory contains the files created
       by FIELD_RANGE.PRO, which finds the lambda-eta range of each field.
       !SEARCH_RUNS is all the runs which have been run through FIELD_RANGE.
       These files contain structures for each field with the following
       tags: field, etamin, etamax, lambdamin, lambdamax. Assumes that
       fields are approximately square in lambda-eta.
       !RUN_STATUS has all the runs we know about on the current machine.

 REVISION HISTORY:
	Author: Erin Scott Sheldon  UofMich 10/15/99 
       Converged to survey coords. 9-OCT-2000 E.S.S.
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/find_radec.pro)


FIND_RADEC_FCHART

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

 NAME:
       FIND_RADEC_FCHART

 PURPOSE:
	Create a finding chart for the input coordinates.

 CALLING SEQUENCE:
       find_radec_fchart, ra, dec [, fchart, pstruct, 
                      clr=clr, radius=radius, maxsize=maxsize, tol=tol,
                      atldir=atldir,  
                      nonoise=nonoise,
                      nocirc=nocirc, 
                      circra=circra, circdec=circdec, 
                      nodisplay=nodisplay, psfile=psfile, 
                      usesao=usesao, silent=silent, 
                      photoid=photoid, objx=objx, objy=objy, 
                      _extra=extra ]

 INPUTS: 
       ra, dec:   position of interest in degrees.

 OPTIONAL INPUTS:
       clr:       bandpass of images from which to create finding chart.
                  Must be an integer [r,g,u,i,z] -> [0,1,2,3,4]
                  Default is red (2)
       radius:    Half length of the square finding chart in pixels.
       maxsize:   maximum size for atlas images; sent to atlas images.  If 
                  your images are being clipped off, you should increase
                  maxsize. default = [500,500]
       tol:       Tolerance for finding nearby object in arcseconds.  
                  Default is 100.
       circra, circdec:  Other positions to circle besides ra,dec
       runuse: find_radec may return more than one run. Set this value
            to an integer to choose which run.
       _extra:    Extra plotting keywords.

 KEYWORD PARAMETERS:
       nonoise:   Set for no noise in fchart.
       usesao:    Use sao to plot image.
         
 OPTIONAL OUTPUTS: 
       pstruct:   A photo structure containing all objects in the frame 
                  of ra,dec as well as the two frames before and after (if 
                  its the first or last frame then it uses next two or 
                  previous two.
       fchart:    The finding chart
       photoid:     Returns Id of nearest object.
       altdir: atlas directory

 CALLED ROUTINES:

       FIND_RADEC 
       TSOBJ_NAME
            RUN_DIR
       READ_PHOTO_COL
       FCHART_CIRC_RADEC
            CIRC_RADEC
       (SAO)

 PROCEDURE: 
	
	Use find_radec to get the run, camcol, and field of an object that
       is nearby to ra,dec and then read in the nearby objects.  Then create 
       a finding chart and circle the ra,dec postion.

 REVISION HISTORY:
	Author: Erin Scott Sheldon  UofMich 10/15/99  
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/find_radec_fchart.pro)


FLAG_SELECT

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

 NAME:
    FLAG_SELECT
 PURPOSE:
    Makes cuts based on flag structure. These cuts are strictly "anded" 
    together, so they must all be true for the object to survive.
 
 Inputs:  pstruct: a photo output structure (must have .flags tag...)
	   flag_struct: Premade flag structure. This will require any
		flags set to 'Y' and insist that any flag set to 'N' be
		off
	   colorindex: which color do you want to cut on...
	   objc: set if you want to select on objc flags
	   input_index: you can input an index, from an earlier selection
		for instance. If this has size(input_index)(0)=0 then
		the returned selection index will be -1

 Outputs: select_index: indices of selected objects....

 Author:  Tim McKay
 Date: 1/8/99
 Phil Fischer: 1/15/99
 Erin Scott Sheldon UM 2/5/00 Added flags2

(See /host/bluemoon/usr2/idllib/sdss/allpro/flag_select.pro)


FXPOSIT2

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	FXPOSIT2
 PURPOSE:
	Return the unit number of a file positioned to the beginning
       of a particular extension.

 CALLING SEQUENCE:
	unit=FXPOSIT(FILE, EXT_NO, /READONLY)

 INPUT PARAMETERS:
	FILE	= FITS file name, scalar string
       EXT_NO  = Extension to be moved to, scalar nonnegative integer

 RETURNS:
       Unit number of file or -1 if an error is detected.

 OPTIONAL KEYWORD PARAMETER:
	READONLY - If this keyword is set and non-zero, then OPENR rather 
		than OPENU will be used to open the FITS file.

 COMMON BLOCKS:
	None.
 SIDE EFFECTS:
	Opens and returns the descriptor of a file.
 PROCEDURE:
	Each FITS header is read in and parsed, and the file pointer is moved
	to where the next FITS extension header until the desired
       extension is reached.
 PROCEDURE CALLS:
	FXPAR(), MRD_HREAD, MRD_SKIP
 MODIFICATION HISTORY:
	Derived from William Thompson's FXFINDEND routine.
       Modified by T.McGlynn, 5-October-1994.
	Modified by T.McGlynn, 25-Feb-1995 to handle compressed
          files.  Pipes cannot be accessed using FXHREAD so
          MRD_HREAD was written.
	W. Landsman 23-Apr-1997    Force the /bin/sh shell when uncompressing 
	W. Landsman 26-May-1997    Non-unix is not just VMS
	Converted to IDL V5.0   W. Landsman   September 1997

(See /host/bluemoon/usr2/idllib/sdss/allpro/fxposit2.pro)


GC2EQ

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

 NAME:
    GC2EQ
       
 PURPOSE:
    convert from great circle to equatorial coordinates

 CALLING SEQUENCE:
    gc2eq, mu, nu, node, inc, ra, dec

 INPUTS: 
    mu, nu: great circle coords.
    node, inc: node and inclination of the stripe.
       
 OUTPUTS: 
   ra,dec: equatorial coords. 


 CALLED ROUTINES:
    ATBOUND
    ATBOND2 

 PROCEDURE: 
    Taken from astrotools
	

 REVISION HISTORY:
    14-NOV-2000  Erin Scott Sheldon UofMich Taken from astrotools
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/gc2eq.pro)


GC2SURVEY

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

 NAME:
    GC2SURVEY
       
 PURPOSE:
    convert from SDSS great circle to SDSS survey coordinates

 CALLING SEQUENCE:
    gc2eq, mu, nu, node, inc, lambda, eta

 INPUTS: 
    mu, nu: great circle coords.
    node, inc: node and inclination of the stripe.
       
 OUTPUTS: 
   lambda, eta: survye coords. 


 CALLED ROUTINES:
    ATBOUND
    ATBOND2 

 PROCEDURE: 
    Taken from astrotools
	

 REVISION HISTORY:
    14-NOV-2000  Erin Scott Sheldon UofMich Taken from astrotools
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/gc2survey.pro)


GENRAND

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

 NAME:  
    GENRAND
       
 PURPOSE:  
    output random numbers from probability function
	

 CALLING SEQUENCE:
      genrand, prob, xvals , nrand, [, rand, cumul=cumul, plt=plt, bin=bin])
                 

 INPUTS: 
    prob: input probablility function.  
    xvals: abscissae
    nrand: How many points to generate from the probability function.

 KEYWORD PARAMETERS:
         /cumul: tells the program that prob is the cumulative 
	         probablility.  Using this option saves processing time.
         /plt: plot histogram if requested
         bin: how to bin the histogram (irrelevent if not /plt )
       
 OUTPUTS: 
    rand:  an array of random numbers generated from prob. size nrand
 
 PROCEDURE: 
  Generates random numbers from the input distribution by inverting
  the cumulative probability function.  Performs linear interpolation.
	

 REVISION HISTORY:
	Author: Erin Scott Sheldon  UofM  1/??/99
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/genrand.pro)


GETUNIQ

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

 NAME: 
    GETUNIQ
       
 PURPOSE: 
    get the unique elements from an array.
	

 CALLING SEQUENCE: 
    getuniq, array, outarr, indices=indices, nonew=nonew
      
                 

 INPUTS: 
    array of any type

 KEYWORD PARAMETERS:
         /nonew: if set, don't make a new array.  Saves space.

 OPTIONAL OUTPUTS:
         outarr: array containing unique elements
         indices: array containing indices of unique elements


 REVISION HISTORY:
	Author: Erin Scott Sheldon UofM 6/15/99
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/getuniq.pro)


GET_ATLAS

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

 NAME:
       GET_ATLAS
 PURPOSE:
	Grab the atlas images for a list of objects.

 CALLING SEQUENCE:
   get_atlas, struct, index, clr=clr, dir=dir, 
              maxsize=maxsize, noprompt=noprompt, nodisplay=nodisplay,
              imtot=imtot, imu=imu, img=img, imr=imr, imi=imi, imz=imz,
              row0=row0, col0=col0, silent=silent, hideradec=hideradec,
              _extra=extra

 INPUTS: struct: photo structure.  Must contain run,field,camcol (rerun)
         index:  array of indices (or just an integer for one object)
 
 OPTIONAL INPUTS: 
         clr: indices of colors to use.  Can be an array.

         Follows photo convention: 0,1,2,3,4 -> u,g,r,i,z

         dir: directory of atlas images. Only needed if the images 
              are not in cwd

         maxsize: maximum size for images.  [500,500] is default.
         noprompt: If set there is no prompting.
         nodisplay: If set there is no display.
         silent: will run silently unless bad images or missing
                 images are found
	  hideradec: will not include ra dec in titles 
         _extra=extra: extra keywords for plotting.

 OPTIONAL OUTPUTS: 
         imtot:  An image containing Atlas images for index 
                 in all 5 colors.  Only returns 
                 the image of the last index that was retrieved.
         imu, img, imr, imi, imz:  The images for individual
                 colors.  Only returns 
                 the image of the last index that was retrieved.
         row0, col0:  objc_rowc, objc_colc position of
                 bottom left corner of atlas image.  Only
                 returns last one found (z for regular use)
 
 PROCEDURE: call external c routine (originally written by R. Lupton) which
      has been modified to link with IDL.  This c program gets an atlas image
      for a given color, run, camcol, field, id.

 CALLED ROUTINES:  missing_atlas
                   atlas_name
                   display_atlas
                   copy_atlas
                   combine_atlas
                   sharable excecutable "call_atlas.so"

 EXAMPLES:
   Look at the atlas images in each bandpass for first 10 objects in frame 35
   of run 109

 IDL> file='/sdss3/data4/run109/tsObj-000109-3-0-0011.fit'
 IDL> read_photo_col, file, struct, struct_type='all', start=35, nframes=1
 IDL> dir = '/sdss3/data4/run109/'
 IDL> index = indgen(10)
 IDL> get_atlas, struct, index, dir=dir

   Save the r' band atlas image with no display or prompting.  If clr is 
   specified, then only that image is retrieved and the program runs faster.

 IDL> get_atlas, struct, 33, dir=dir, clr=2, /noprompt, /nodisplay, $
 IDL> imr=red_image
 

 REVISION HISTORY:
       Author:
       Erin Scott Sheldon    UM      2/5/99  Modified Tim Mckay's 
                                       get_atlas_images which used spawn
                                       to call Lupton's stand alone code.
                                       Linked directly to IDL with 
                                       call_external.  
                                     2/8/99  Let index be an array, added
                                       prompting.  Added subroutine
                                       missing_atlas for when there is 
                                       no atlas image.  Added prompt keyword
                                       Added displaying.
	David Johnston			added hideradec

(See /host/bluemoon/usr2/idllib/sdss/allpro/get_atlas.pro)


GET_FAMILY

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

 PURPOSE: 
    retrieves atlas images for an object and any other objects
    associated with it in a blend.
                                                                            
 Inputs: pstruct: the photo output structure. Must use sarahtags.     
         index: the object's index in pstruct

 Optional inputs: dir: directory of atlas images
                  field: field of the object. 
		   run: run object is from
                  camcol: camera column of object (1-6)
                  maxsize: maximum size for images.  [500,500] is default.
                  prompt: prompting for prompt=1
                  nodisplay: no display if nodisplay =1
                  silent: will run silently unless bad images or missing
                          images are found
                                                                   
 Outputs: parent: the array containing the index of the parent    
	  children: the array containing the indices of the children 
         siblings: the array containing the indices of the siblings  
         im: the atlas image

 Examples:

  View the family of an object and return family.

 IDL> file='/sdss3/data4/run109/tsObj-000109-3-0-0011.fit'
 IDL> read_photo_col, file, struct, struct_type='all', start=35, nframes=10
 IDL> index = 33
 IDL> dir = '/sdss3/data4/run109/'
 IDL> get_family, struct, index, parent, children, siblings, image,dir=dir
           				
 Author: Sarah Monk			
 Dave Johnston : only look in a vicinity of the original object
	not the whole structure. Speeds it up considerably.
                                                                 	

(See /host/bluemoon/usr2/idllib/sdss/allpro/get_family.pro)


GOOD_RERUNS

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

 NAME:
    GOOD_RERUNS
       
 PURPOSE:
    Find the rerun for runs in the !SDSS_DATA_DIR, and see if there
    are any tsObj files there.

 CALLING SEQUENCE:
    good_reruns

 INPUTS: 
    NONE: gets its info from system variables defined in SDSSIDL_SETUP

 OPTIONAL INPUTS:
    NONE:

 KEYWORD PARAMETERS:
    NONE
       
 OUTPUTS: 
    Outputs !RUN_STATUS_FILE, a fits file containing info about
    known runs.

 OPTIONAL OUTPUTS:
    NONE

 CALLED ROUTINES:
    SDSSIDL_SETUP
    ADD_ARRVAL
    FETCH_RERUN
    FETCH_DIR
    FETCH_FILE_LIST
    MWRFITS

 PROCEDURE: 
    
	

 REVISION HISTORY:
    14-NOV-2000 Erin Scott Sheldon UofMich
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/good_reruns.pro)


HEADER_BLOCK

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

 NAME:
    HEADER_BLOCK
       
 PURPOSE:
    This is a template for procedure headers.

 CALLING SEQUENCE:
    

 INPUTS: 
    

 OPTIONAL INPUTS:
    

 KEYWORD PARAMETERS:
    
       
 OUTPUTS: 
    

 OPTIONAL OUTPUTS:
    

 CALLED ROUTINES:
    
 
 PROCEDURE: 
    
	

 REVISION HISTORY:
    
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/header_block.pro)


HIST2D

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

 PURPOSE:
    like the IDL built in function hist_2d
    but better since it can accept floats
    output histogram is a longarray(nxbins,nybins)
    uses only the relevent data in range

  Dave Johnston

(See /host/bluemoon/usr2/idllib/sdss/allpro/hist2d.pro)


HISTOGRAM_2D

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

PURPOSE:
	takes two dimentional data x,y and makes a histogram, 
	hist,with hist_2d.  hist is a structure that also contains
	the scaling parameters so one can display
	it with the right x,y, scale etc.

CALLING SEQUENCE:

	-syntax histogram_2d,x,y,hist,xrange,yrange,nxbins,nybins,silent=silent

INPUTS:
	x ,y : the two one-dimentional arrays that you want histogrammed
	
OUTPUTS:
	hist : the histogram structure contains 3 fields
	.map (the 2D array) , .xrange, .yrange (the two ranges)
	these ranges permit mapping from the data to the histogram map
	and vice versa

KEYWORDS:
	xrange,yrange : the range to include data from
	these are output and saved in the hist structure
	the default is min, max
	if these are flipped like [12,3]
	it will use 3 as min and 12 as max and then flip the histogram
	
	nxbins, nybins : the number of bins for each dimention

	silent : speak no evil	

EXTERNAL CALLS:
	none

METHOD:
	uses hist2d rather than the built in
	IDL routine hist_2d because it has to work with floating
	point numbers as well

EXAMPLE:
  IDL> histogram2d,radius,mag,hist,[0,6],[24,14],250,250
  IDL> tvim2,hist.map,range=[0,100],xrange=hist.xrange,yrange=hist.yrange

NOTES

HISTORY:  written by David Johnston -University of Chicago
       Physics Department 1999

(See /host/bluemoon/usr2/idllib/sdss/allpro/histogram_2d.pro)


INTFUNC

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

 NAME: 
    INTFUNC
       
 PURPOSE: 
    Make a cumulative integral function.  Basically just tabulate
    the integral up to each xi
	

 CALLING SEQUENCE:
   intfunc,f, x [, intfi, plot=plot]

 INPUTS: 
    f: the function
    x: the abcissae

 KEYWORD PARAMETERS:
         /plot: make a plot of the output function
       
 OUTPUTS: 
    the integrated function.

 CALLED ROUTINES: 
          INT_TABULATED
 

 REVISION HISTORY:
	Author: Erin Scott Sheldon UofM  1/??/99
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/intfunc.pro)


IRCAMIMAGE__DEFINE[10]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       ircamImage::plotRaDecCoordinate

 PURPOSE:
       Overplot a location, expressed in R. A. and declination
       on a cloud camera image 

 CALLING SEQUENCE:
       oIrcamImage->plotRaDecCoordinate, ha, dec[, PSYM=psym] [,COLOR=color]
      
 INPUTS:
       ha:          The hour angle, in hours
       declination: The declination, in degrees

 KEYWORD PARAMETERS:
       PSYM:  The symbol to plot
       COLOR: The color index of the point (should be set to 0 for
              plotting on an inverse image)

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. October 10, 2000
                       based on calc_ZDHA by Eric Deutsch

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


IRCAMIMAGE__DEFINE[11]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       ircamImage::plotMoonPosition

 PURPOSE:
       Overplot the position of the moon

 CALLING SEQUENCE:
       oIrcamImage->plotMoonPosition, [, PSYM=psym] [, COLOR=color]
      
 KEYWORD PARAMETERS:
       PSYM:  The symbol to plot
       COLOR: The color index of the point (should be set to 0 for
              plotting on an inverse image)

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. October 12, 2000

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


IRCAMIMAGE__DEFINE[12]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       ircamImage::plotImagePosition

 PURPOSE:
       Overplot the position from a fits header

 OPTIONAL INPUTS:
       filename: the name of the fits file. If this input is not
                 supplied, the header must be supplied through the
                 HEADER keyword. 

 CALLING SEQUENCE:
       oIrcamImage->plotImagePosition, filename
      
 KEYWORD PARAMETERS:
       PSYM:  The symbol to plot
       COLOR: The color index of the point (should be set to 0 for
              plotting on an inverse image)
       HEADER: The image header. If this keyword is set, the value of
              filename is ignored.

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. October 12, 2000

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


IRCAMIMAGE__DEFINE[13]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       ircamImage::contemporaryImage

 PURPOSE:
       Return whether some part of an image exposure occurred during
       some part of a cloud scan.

 OPTIONAL INPUTS:
       filename: the name of the fits file. If this input is not
                 supplied, the header must be supplied through the
                 HEADER keyword. 

 CALLING SEQUENCE:
       oIrcamImage->contemporaryImage, filename
      
 KEYWORD PARAMETERS:
       HEADER: The image header. If this keyword is set, the value of
              filename is ignored.

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. October 12, 2000

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


IRCAMIMAGE__DEFINE[14]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       ircamImage::findContemporaryImages

 PURPOSE:
       Return an array of filenames containing the images
       contemporary to the scan

 OPTIONAL INPUTS:
       filetemplate: the template for the fits file names. If this
                 input is not supplied, the header must be supplied
                 through the HEADER keyword.  

 CALLING SEQUENCE:
       oIrcamImage->findContemporaryImages, filetemplate
      
 KEYWORD PARAMETERS:
 
 OPTIONAL OUTPUTS:
       COUNT: the number of contemporary files

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. October 12, 2000

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


IRCAMIMAGE__DEFINE[15]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       ircamImage::setContemporaryImageQuality

 PURPOSE:
       Set the quality keywords in the headers of contemporary images

 OPTIONAL INPUTS:
       filetemplate: the template for the fits file names. If this
                 input is not supplied, the header must be supplied
                 through the HEADER keyword.  

 CALLING SEQUENCE:
       oIrcamImage->setContemporaryImageQuality, filetemplate
      
 KEYWORD PARAMETERS:
       FILEARRAY: an array of file names of contemporary images. If
                  this is set, the filetemplate parameter is ignored
                  if present
       QUALITY:   The value to which to set the keyword. Defaults to "Bad"
 
 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. October 12, 2000

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


IRCAMIMAGE__DEFINE[16]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       ircamImage::overplotContemporaryImages

 PURPOSE:
       Return an array of filenames containing the images
       contemporary to the scan

 OPTIONAL INPUTS:
       filetemplate: the template for the fits file names. If this
                 input is not supplied, the header must be supplied
                 through the HEADER keyword.  

 CALLING SEQUENCE:
       oIrcamImage->overplotContemporaryImages, filetemplate
      
 KEYWORD PARAMETERS:
       PSYM:  The symbol to plot (may be an array)
       COLOR: The color index of the point (should be set to 0 for
              plotting on an inverse image) (may be an array)
       VERBOSE: Print a table of image names, symbols, and colors

 OPTIONAL OUTPUTS:
       COUNT: the number of contemporary files

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. October 12, 2000

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


IRCAMIMAGE__DEFINE[17]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       ircamImage::loadContemporaryScan

 PURPOSE:
       This procedure loads the first scan contemporary with a
       supplied image

 INPUTS:
       filename: The fits file for which to load a contemporary scan
       scantemplate: The file template for the scan files

 CALLING SEQUENCE:
       result = oIrcamImage->loadContemporaryScan(filename, filetemplate)
      
 OUTPUT:
       The function returns whether or not a contemporary scan was found

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. October 12, 2000

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


IRCAMIMAGE__DEFINE[18]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       ircamImage::plotSunPosition

 PURPOSE:
       Overplot the position of the sun

 CALLING SEQUENCE:
       oIrcamImage->plotSunPosition, [, PSYM=psym] [, COLOR=color]

 KEYWORD PARAMETERS:
       PSYM:  The symbol to plot
       COLOR: The color index of the point (should be set to 0 for
              plotting on an inverse image)

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. October 12, 2000

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


IRCAMIMAGE__DEFINE[19]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       ircamImage::flatten

 PURPOSE:
       do a quick analytical flattening of an ircam image

 CALLING SEQUENCE:
       oIrcamImage->flatten

 OPTIONAL INPUTS:
       centerCoordinates: a 2 element array giving the x and y
                       coordinates of the center

 KEYWORD PARAMETERS:
       MAXIMUMRADIUS: the maximum radius to fit the analytic function
                       (defaults to 150)
       BINNING: the factor to bin the image for the fit
                       (defaults to 5)

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. October 10, 2000
       based heavily on Eric Deutsch's cloudscanread

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


IRCAMIMAGE__DEFINE[1]

[Previous Routine] [Next Routine] [List of Routines]
 CLASS_NAME:
       ircamImage

 PURPOSE:
       An ircamImage object consists of an image from the APO 10
       micron all sky camera. The class methods provide tools for
       examining such images.

 CATEGORY:
       METADATA

 SUPERCLASSES:
       This class inherits from astronomyImage

 SUBCLASSES:
       This class has no subclasses

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. October 10, 2000

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


IRCAMIMAGE__DEFINE[20]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       ircamImage::medianOfNeighbors

 PURPOSE:
       Find the median of neighboring (in time) images

 CALLING SEQUENCE:
       result = oIrcamImage->medinaOfNeighbosrs,files,numberOfNeighbors

 INPUTS:
       files: The file specification

 OPTIONAL INPUTS: 
       numberOfNeighbors: The number of neightboring images to median
                          Defaults to entire night

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. October 12, 2000
       based heavily on Eric Deutsch's cloudscanread

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


IRCAMIMAGE__DEFINE[21]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       ircamImage::replaceWithMedianOfNeighbors

 PURPOSE:
       Replace the data in the object with the median of neightbors

 CALLING SEQUENCE:
       oIrcamImage->replaceWithMedianOfNeighbosrs,files,numberOfNeighbors

 INPUTS:
       files: The file specification 

 OPTIONAL INPUTS:
       numberOfNeighbors: The number of neightboring images to median
                          Defaults to all valid files.

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. October 12, 2000
       based heavily on Eric Deutsch's cloudscanread

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


IRCAMIMAGE__DEFINE[22]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       ircamImage::subtract

 PURPOSE:
       Subtract an image from the ircam image

 CALLING SEQUENCE:
       oIrcamImage->subtract, oAstronomyImage

 INPUTS:
       subtractedImage : the image to be subtracted

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. October 12, 2000
       based heavily on Eric Deutsch's cloudscanread

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


IRCAMIMAGE__DEFINE[23]

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

 PURPOSE:
       This routine defines the structure for an ircamImage object

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. October 10, 2000

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


IRCAMIMAGE__DEFINE[2]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       ircamImage::setProperty

 PURPOSE:
       This method sets the value for a property or group of
       properties for the ircamImage object

 CALLING SEQUENCE:
       oIrcamImage->[ircamImage::]SetProperty

 KEYWORD PARAMETERS:
       FILENAME:      The name of the file for the ircam image
       TEMPFILENAME:  The name of an associated file
       DATA:          The image data
       JULIANDATE:    The (unmodified) julian date of observation
       LATITUDE:      The latitude of observation
       LONGITUDE:     The longitude of observation 
       HEADERFORMAT:  'hhh' or 'fits' depending on the format of the header

 EXAMPLE:
       oIrcamImage->SetProperty, FILENAME='newfile.fit'
 
 MODIFICATION HISTORY:
       Written by: Eric H. Neilsen, Jr.  October 12, 2000

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


IRCAMIMAGE__DEFINE[2]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       ircamImage::Init

 PURPOSE:
       The ircamImage::Init function method initializes the
       ircamImage object

 CALLING SEQUENCE:
       oIrcamImage = OBJ_NEW('ircamImage' [,imageFileName])

       or
 
       Result = oIrcamImage->[ircamImage::]Init([imageFileName])

 OUTPUTS:
       1: successful, 0: unsuccessful.

 KEYWORDS:
       FILENAME:      The name of the file for the ircam image
       TEMPFILENAME:  The name of an associated file
       DATA:          The image data
       JULIANDATE:    The (unmodified) julian date of observation
       LATITUDE:      The latitude of observation
       LONGITUDE:     The longitude of observation 


 EXAMPLE:
       oIrcamImage = OBJ_NEW('ircamImage','001003.1940.fit')

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. October 10, 2000

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


IRCAMIMAGE__DEFINE[3]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       ircamImage::getProperty

 PURPOSE:
       This method gets the value for a property or group of
       properties for the ircamImage object

 CALLING SEQUENCE:
       oIrcamImage->[ircamImage::]GetProperty

 KEYWORD PARAMETERS:
       FILENAME:      The name of the file for the ircam image
       TEMPFILENAME:  The name of an associated file
       DATA:          The image data
       JULIANDATE:    The (unmodified) julian date of observation
       LATITUDE:      The latitude of observation
       LONGITUDE:     The longitude of observation 
       TEMPUSED:      A Boolean specifying if the temp file is used
       HEADERFORMAT:  'hhh' or 'fits' depending on the format of the header

 EXAMPLE:
       oIrcamImage->GetProperty, FILENAME=filename
 
 MODIFICATION HISTORY:
       Written by: Eric H. Neilsen, Jr.  October 12, 2000

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


IRCAMIMAGE__DEFINE[4]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       ircamImage::Load

 PURPOSE:
       This method load an ircam image from disk into the image object.

 CALLING SEQUENCE:
       oIrcamImage->Load, FileName

 OPTIONAL INPUTS:
       fileName: A string containing the name of the file from which
                 to load the image. If no name is given, the current
                 file name associated with the object is used.

 SIDE EFFECTS:
       The previous data and header information is lost.

 EXAMPLE:
       exampleImage->load, 'exampleImageFile.fits'

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. October 10, 2000

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


IRCAMIMAGE__DEFINE[5]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       ircamImage::standardFilename

 PURPOSE:
       This method returns true if the filename appears to be in the
       standard YYMMDD.HHMM format, false otherwise. Some extensions
       (.fit, .fit.gz, .fit.Z, etc.) do not disqualify it.

 CALLING SEQUENCE:
       Result = oIrcamImage->standardFilename([filename])

 KEYWORD PARAMETERS:
       SETJD:         If this keyword is set, set the object julian
                      date based on the file name
       JULIANDATE:    The julian date corresponding to the file name

 OUTPUTS:
       1: is in the standard format, 0: is not in the standard format.

 BUGS:
       The date at which the switches too and from daylight savings
       time occurr are appriximate! Therefore, the time may be an
       hour off on days near the switch.

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. October 10, 2000

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


IRCAMIMAGE__DEFINE[6]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       ircamImage::estimateDisplayRange

 PURPOSE:
       This method estimates a good display range for viewing the image.

 CALLING SEQUENCE:
       Result=oIrcamImage->estimateDisplayRange()

 KEYWORD PARAMETERS:
       STRETCH:    This pararmeter is set to 16 by default. Larger
                   values will result in a more uniform appearance in
                   the image, with more extreme values unsaturated.

 OUTPUTS:
       An estimated range for display is returned.

 PROCEDURE:
       

 EXAMPLE:
       To display an image using a reasonable range:
       range=exampleImage->estimateDisplayRange(exampleMask)
       TV,exampleImage->getData(STRETCH=stretch)

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., October 10, 2000

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


IRCAMIMAGE__DEFINE[7]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       ircamImage::tvscl

 PURPOSE:
       Display the image, nicely scaled. Note that it is a good idea
       to use either the WINDOW or ZDISPLAY keywords, or otherwise
       ensure that the plotting devise has the correct size. If it
       does not, then overplotted points will not be positioned
       correctly. 

 CALLING SEQUENCE:
       Result=oIrcamImage->tvscl()

 KEYWORD PARAMETERS:
       STRETCH:    This pararmeter is set to 16 by default. Larger
                   values will result in a more uniform appearance in
                   the image, with more extreme values unsaturated.
       LINLOG:     Scale the image partially using a log scaling,
                   partially using a linear scaling. This value if
                   linlog is the data value above the minimum at wich
                   the change in scaling occurrs. Designed to
                   reproduce Eric Deutsch's images. Use a value of
                   400 (and the inverse keyword, below) to reproduce
                   the image on the web page. 
       INVERSE:    Display the image in inverse
       OBJECT:     Use object graphics to return an image object, as
                   opposed to drawing onto a window using direct
                   graphics 
       IMAGE:      The IDLgrImage object created from the image data,
                   if the OBJECT keyword is set. WARNING: the user is
                   responsible for destroying the image object. 
       WINDOW:     Create an appropriately sized window
       ZDISPLAY:   Create an appropriately sized virtual display

 EXAMPLE:
       
       exampleImage->tvscl,LINLOG=400,/INVERSE,/WINDOW

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., October 10, 2000

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


IRCAMIMAGE__DEFINE[8]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       ircamImage::plotAzAltCoordinate

 PURPOSE:
       Overplot a location, expressed in aximuth & altitude,
       on a cloud camera image 

 CALLING SEQUENCE:
       oIrcamImage->plotAzAltCoordinate, azimuth, altitude $
                       [, PSYM=psym][,COLOR=color]
      
 INPUTS:
       azimuth:  The azimuth, in degrees
       altitude: The altitude, in degrees

 KEYWORD PARAMETERS:
       PSYM:  The symbol to plot
       COLOR: The color index of the point (should be set to 0 for
              plotting on an inverse image)

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. October 10, 2000
       

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


IRCAMIMAGE__DEFINE[9]

[Previous Routine] [Next Routine] [List of Routines]
 METHODNAME:
       ircamImage::plotHaDecCoordinate

 PURPOSE:
       Overplot a location, expressed in hour angle and declination,
       on a cloud camera image 

 CALLING SEQUENCE:
       oIrcamImage->plotHaDecCoordinate, ra, dec[, PSYM=psym] [,COLOR=color]
      
 INPUTS:
       ha:          The hour angle, in hours
       declination: The declination

 KEYWORD PARAMETERS:
       PSYM:  The symbol to plot
       COLOR: The color index of the point (should be set to 0 for
              plotting on an inverse image)

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. October 10, 2000
                       based on calc_ZDHA by Eric Deutsch

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


KMAP

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

 CALLING SEQUENCE:
   kmap,xin,yin,xout,yout,kx,ky

 PURPOSE:
    this maps (xin,yin) to (xout,yout)
    with the transformation kx,ky
    that were presumably found with polywarp
    the formula is (summation over i,j)
    xout=(kx)ij * xin^j * yin^i
    yout=(ky)ij * xin^j * yin^i
    hence the two matrices kx and ky hold all the 
    transformation coefficients

(See /host/bluemoon/usr2/idllib/sdss/allpro/kmap.pro)


KMAP_INV

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

 CALLING SEQUENCE:
    kmap_inv,x2,y2,x,y,kx,ky,kxi=kxi,kyi=kyi,npoints=npoints

 PURPOSE:
  this find the inverse map for kx and ky (any order)
  and applies it to x2,y2 to output x,y
  note that kx,ky does not in general have an inverse
  this procedure only works when the the map kx,ky is
  approximately a nonsingular linear transformation
  ie. the higher order terms do not dominate the map
  it works by first linearizing the map
  and finding the inverse matrix and using this to generate
  the approximate inverse map range (ie. the domain for kx,ky)
  using this range it maps test points to the x2,y2 neighborhood
  with kx,ky and uses polwarp on their image under the map kx,ky
  to find the right tranformation from x2,y2 to x,y
  it then applies this to x2,y2 to get x,y
  it then checks for accuracy
  then it returns kxi,kyi so that kmap can be used with these 
  for the inverse map in the future
  npoints is the number of points used to find the transformation
  if absent it will be set to the smaller of size(x2) or 10,000

(See /host/bluemoon/usr2/idllib/sdss/allpro/kmap_inv.pro)


LUMDIST

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

 NAME: 
    LUMDIST
       
 PURPOSE:
    calculate luminosity distance
    Currently only works for lambda = 0 universe.  See angdist_lambda.
	

 CALLING SEQUENCE: 
    result = lumdist(z, h=h, omegamat=omegamat, verbose=verbose, $
                   plot=plot,oplot=oplot)
      
 INPUTS:  
    z: redshift

 OPTIONAL INPUTS: 
    h: hubble parameter      default 1.
    omegamat:  omega matter  default 1.
       
 OUTPUTS: 
   dist in Mpc.

 REVISION HISTORY: Erin Scott Sheldon 2/24/99
	
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/lumdist.pro)


MAKEGAUSS

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

 PURPOSE: 
    make an array with values set to a gaussian
    Dave J.  My changes E.S.S.

(See /host/bluemoon/usr2/idllib/sdss/allpro/makegauss.pro)


MAKE_COLOR_FLAG

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	make_color_flag
PURPOSE:
	takes the str from search color_space
	and sets the flag depending on whether the object
	lies in that region of color space (and size-mag space)
	flag values are anded together
	they range from 0 to 15  (four different bits may be set
	depending on whether that object is in each region)
	objects in all four regions have flag=15

CALLING SEQUENCE:
	-syntax make_color_flag,cat,str,flag,
	 psfcounts=psfcounts,petrocounts=petrocounts

INPUTS:
	cat : the sdss photo output structure
	str : the structure output by search_color_space 
	
OUTPUTS:
	flag : the flag arrays, each obejct has a nember 0 to 15	

KEYWORDS:
	psf : if set will use psfcounts rather than the
		    default fibercounts
	petro : if set will use petrocounts rather than the
		    default fibercounts

EXTERNAL CALLS:
	none
	
METHOD:
	just extract the value in each region of str.map
	and sum them
	see search_color_space for details
	
EXAMPLE

NOTES

HISTORY:  written by David Johnston -University of Chicago
	Physics Department 1999

(See /host/bluemoon/usr2/idllib/sdss/allpro/make_color_flag.pro)


MAKE_DEFAULT_TAGS

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

 NAME:
    MAKE_DEFAULT_TAGS
       
 PURPOSE:
    Produces a list of photo tags.  Can be sent to READ_PHOTO_COL or
    RD_TSOBJ

(See /host/bluemoon/usr2/idllib/sdss/allpro/make_default_tags.pro)


MAKE_DEVAUC

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

 PURPOSE:
 Dave Johnston's code.  My Changes. E.S.S.
 This code makes de Vaucouleurs intensity profile, used for elliptal galaxies

(See /host/bluemoon/usr2/idllib/sdss/allpro/make_devauc.pro)


MAKE_EXP

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

 PURPOSE: 
    make an array with values set to an ellitical exponential.

(See /host/bluemoon/usr2/idllib/sdss/allpro/make_exp.pro)


MAKE_FLAG_STRUCT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       MAKE_FLAG_STRUCT
 PURPOSE:
	Set up a parameter structure for sdss flag selection
       Can select on either flags or flags2. 

 CALLING SEQUENCE:
      make_flag_struct, flag_struct 

 INPUTS:
       
 OUTPUTS:
	flag_struct: the structure used for sdss object selection....

 OPTIONAL OUTPUT ARRAYS:

 INPUT KEYWORD PARAMETERS:
 
 PROCEDURE: This sets up the structure for flag selection of sdss objects
	

 REVISION HISTORY:
	Tim McKay	UM	1/8/99
       Philf Fischer           1/15/99
       Erin Scott Sheldon UM 2/5/00 Added flags2

(See /host/bluemoon/usr2/idllib/sdss/allpro/make_flag_struct.pro)


MAKE_GAUSSIAN

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

 PURPOSE:
   make an array with a gaussian in it

(See /host/bluemoon/usr2/idllib/sdss/allpro/make_gaussian.pro)


MAKE_STATUS_STRUCT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       MAKE_STATUS_STRUCT
 PURPOSE:
       Set up a parameter structure for sdss status selection

 CALLING SEQUENCE:
      make_status_struct, status_struct 

 INPUTS:
       
 OUTPUTS:
       status_struct: the structure used for sdss object selection....

 OPTIONAL OUTPUT ARRAYS:

 INPUT KEYWORD PARAMETERS:
 
 PROCEDURE: This sets up the structure for status selection of sdss objects
       

 REVISION HISTORY:
       Ryan Scranton		11/4/99

(See /host/bluemoon/usr2/idllib/sdss/allpro/make_status_struct.pro)


MAKE_TSFLAG_STRUCT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       MAKE_TSFLAG_STRUCT
 PURPOSE:
	Set up a parameter structure for sdss target flag selection.

 INPUTS: none
       
 OUTPUTS:
	flag_struct: the structure used for sdss object selection....
; 
 PROCEDURE: This sets up the structure for target flag selection of sdss objects
	

 REVISION HISTORY: Sarah Monk 5/8/00 (modified from make_flag_struct)

(See /host/bluemoon/usr2/idllib/sdss/allpro/make_tsflag_struct.pro)


MASKIMAGE::ASYMMETRY

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       maskImage::asymmetry

 PURPOSE:
       Thie method returns an array of the asymmetries of the masked
       pixel regions in a supplied data image.

 CALLING SEQUENCE:
       result = oMaskImage->asymmetry(DataImage)

 INPUTS:
       DataImage: A dataImage object, the image in which to consider
                  asymmetries.
 OUTPUTS:
       This method returns an array of the asymmetries of the masked
       pixel regions.

 PROCEDURE:
       The regions are defined as in the default for the IDL
       LABEL_REGION procedure. 

 EXAMPLE:
       To find the indexes of the most symmetric objects only:
       asymArray = oMaskImage->asymmetry(oDataImage)
       symIndex = WHERE(asymArray LT MEDIAN(asymArray))

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/maskimage__define.pro)


MASKIMAGE::CENTER

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       maskImage::center

 PURPOSE:
       Thie method returns an array of the center of flux in masked
       pixel regions, in x and y pixel coordinates..

 CALLING SEQUENCE:
       result = oMaskImage->center(DataImage)

 INPUTS:
       DataImage: A dataImage object, the image in which to consider
                  fluxes.
 OUTPUTS:
       This method returns an array with the x and y values of each
       masked region. For the region with index i, the x and y values
       are:
         x = returnArray[i,0]
         y = returnArray[i,1]

 PROCEDURE:
       The regions are defined as in the default for the IDL
       LABEL_REGION procedure. The x coordinate of a region is the
       mean x value of its pixels, weighted by the flux in the
       corresponding pixel in the supplied dataImage. The y center is
       defined anologously.

 EXAMPLE:
       To print the coordinates of the brightest masked object,
       fluxArray=oMaskImage->luminosity(oDataImage)
       maxObjectIndex=WHERE(MAX(fluxArray) EQ fluxArray)
       coordinateArray=oMaskImage->center(oDataImage)
       PRINT,"Bright object coordinate: ",coordinateArray[maxObjectIndex,*]

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/maskimage__define.pro)


MASKIMAGE::CLOSE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       maskImage::close

 PURPOSE:
       This method performs an closeing operation on the mask.

 CALLING SEQUENCE:
       oMaskImage->close

 KEYWORD PARAMETERS:
       KERNEL:  This keyword can be set to a two dimensional array
                containig the desired kernel. Bu default, a 3x3
                square kernel is used.

 PROCEDURE:
       The closing is performed by the IDL DILATE and ERODE procedures.

 EXAMPLE:
       To close using a cross,
       oMaskImage->close, KERNEL=[[0,1,0],[1,1,1],[0,1,0]]

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/maskimage__define.pro)


MASKIMAGE::DILATE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       maskImage::dilate

 PURPOSE:
       This method performs a dilation operation on the mask.

 CALLING SEQUENCE:
       oMaskImage->dilate

 KEYWORD PARAMETERS:
       KERNEL:  This keyword can be set to a two dimensional array
                containig the desired kernel. Bu default, a 3x3
                square kernel is used.

 PROCEDURE:
       The dilation is performed by the IDL DILATE procedure.

 EXAMPLE:
       To dilate using a cross,
       oMaskImage->dilate, KERNEL=[[0,1,0],[1,1,1],[0,1,0]]

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/maskimage__define.pro)


MASKIMAGE::ERODE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       maskImage::erode

 PURPOSE:
       This method performs an erosion operation on the mask.

 CALLING SEQUENCE:
       oMaskImage->erode

 KEYWORD PARAMETERS:
       KERNEL:  This keyword can be set to a two dimensional array
                containig the desired kernel. Bu default, a 3x3
                square kernel is used.

 PROCEDURE:
       The erosion is performed by the IDL ERODE procedure.

 EXAMPLE:
       To erode using a cross,
       oMaskImage->erode, KERNEL=[[0,1,0],[1,1,1],[0,1,0]]

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/maskimage__define.pro)


MASKIMAGE::FRACTION

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       maskImage::fraction

 PURPOSE:
       This function returns the fraction of unmasked pixels in the mask.

 CALLING SEQUENCE:
       result = oMaskImage->fraction()

 OUTPUTS:
       This function returns a floating point between 0.0 and 1.0,
       the fraction of unmasked pixels.

 EXAMPLE:
       To print a message if all pixels are flagged,
       fraction=oMaskImage->fraction()
       IF (fraction EQ 1.0) THEN PRINT, 'All pixels are masked'

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/maskimage__define.pro)


MASKIMAGE::GETDATA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       maskImage::getData

 PURPOSE:
       This methods returns an array containing the image data.

 CALLING SEQUENCE:
       Result=oMaskImage->GetData()

 OUTPUTS:
       This function returns the data array for the image.

 EXAMPLE:
       To display a mask,
       TVSCL, oMaskImage->GetData()       

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/maskimage__define.pro)


MASKIMAGE::GETPROPERTY

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       maskImage::GetProperty

 PURPOSE:
       This method gets some of the properties of the data image.

 CALLING SEQUENCE:
       oMaskImage->GetProperty, FILENAME=filename, TEMPNAME=tempName,$
                  DATAARRAY=data, DATAHEADER=dataHeader
           
 KEYWORD PARAMETERS:
       FILENAME - a string containing the name of the file assiciate 
                  with the data image
       TEMPNAME - a string with the file name of a temporary file for the
                  data to be saved in if onDisk is used
       DATAARRAY- a two dimensional array containing the image data 
       DATAHEADER - a structure containing the header information for the
             image, in the format used by the image loading and saving
             routines from the astrolib library
       
 EXAMPLE:
       oMaskImage->GetProperty,FILENAME=filename

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/maskimage__define.pro)


MASKIMAGE::INVERT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       maskImage::invert

 PURPOSE:
       This method inverts the sence of the mask: unmasked pixels
       become masked, masked pixels become unmasked.

 CALLING SEQUENCE:
       oMaskObject->invert

 EXAMPLE:
       oMaskObject->invert

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/maskimage__define.pro)


MASKIMAGE::KINGPARAMETERS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       maskImage::kingParameters

 PURPOSE:
       This method fits King profile models to the pixels in a data
       image which correspond to masked regions in the mask
       image. It was designed for measureing globular cluster
       parameters from an image using a mask covering the globular
       clusters.

 CALLING SEQUENCE:
       result = oMaskImage->kingParameters(DataImage, NoiseImage, Psf)

 INPUTS:
       DataImage:  The data image from which to measure the parameters
       NoiseImage: A dataImage object where the value of each pixel
                   is an estimate of the noise in the corresponding
                   pixel of the DataImage.
       Psf:        A dataImage containing the PSF of the data image.

 KEYWORD PARAMETERS:
       ZEROSKY:    If this keyword is set, the sky behind each
                   is forced to zero. Otherwise, the sky level is a
                   free parameter in the fit.

 OUTPUTS:
       This method returns an array with the best fit parameters for
       each masked region, in the form of a two dimentional
       array. The fit parameters for the region with index i can be
       recovered as follows:
       result[i,0] = the reduced chi^2 of the best fit
       result[i,1] = the best fit background (if the ZEROSKY keyword
                     is set, this will be 0.0.
       result[i,2] = the uncertainty in the background. Again, if the
                     ZEROSKY keyword is set, this will be 0.0.
       result[i,3] = the flux of the best fit model
       result[i,4] = the error in the flux of the best fit model
       result[i,5] = the core radius of the best fit model

 RESTRICTIONS:
       Only a small number of core radii are checked, and there is no
       way to customize the examined values. 

 PROCEDURE:
       For each model, the data is fit to several models, incliding a
       point source, and a variety of King profile sources centered
       on the object and convolved by the provided PSF. A best fit
       flux and sky (or flux alone, if the ZEROSKY keyword is set) is
       determined, as well as a reduced chi^2 for each model. The
       model with the lowest reduced chi^2 is selected as the best
       model, and the remainder of the parameters (flux, flux error,
       sky, sky error) are assigned to the values from the fit to
       that model.

 EXAMPLE:
       To print the core radii of masked GC's,
       GCparms = oMaskImage->kingParameters(DataImage, NoiseImage, Psf)
       PRINT, GCparms[*,5]

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/maskimage__define.pro)


MASKIMAGE::LUMINOSITY

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       maskImage::luminosity

 PURPOSE:
       To return the flux in pixel regions in a dataImage which
       correspond to the regions of masked pixels in the mask.

 CALLING SEQUENCE:
       result = oMaskImage->luminosity, DataImage

 INPUTS:
       DataImage: A a dataImage object in which the fluxes of the
                  masked regions are to be measured.

 OUTPUTS:
       This method returns a one dimensional array of fluxes. Each
       element corresponds to contiguous regions of masked pixels,
       and contains the total counts in the masked pixels in the regions.

 EXAMPLE:
       To find the maximum flux of all masked regions,
       PRINT,MAX(oMaskImage->luminosity,oDataImage)

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/maskimage__define.pro)


MASKIMAGE::MAXSIZE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       maskImage::maxSize

 PURPOSE:
       This method removes masked regions greater than a specified
       size from the mask.

 CALLING SEQUENCE:
       oMaskImage->maxSize, Cutoff

 INPUTS:
       Cutoff:  The largest desired size for masked regions. All
                regions greater than (but not equal to) this cutoff
                are unmasked. 

 EXAMPLE:
       To unmask regions of 21 pixels or greater in size, 
       oMaskImage->maxSize, 20

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/maskimage__define.pro)


MASKIMAGE::MINCORERADIUS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       maskImage::minCoreRadius

 PURPOSE:
       This method unmasks regions where the core radius of the best
       fit globular cluster to the pixels in a data image
       corresponding to the region is smaller than some
       threshhold. The primary purpose of this method is to unmask
       cosmic rays, hot pixels, and possibly foreground stars in
       masks of candidate objects.

 CALLING SEQUENCE:
       oMaskImage->minCoreRadius, DataImage, NoiseImage, PSF, MinRc

 INPUTS:
       DataImage:  The data image from which to measure the parameters
       NoiseImage: A dataImage object where the value of each pixel
                   is an estimate of the noise in the corresponding
                   pixel of the DataImage.
       Psf:        A dataImage containing the PSF of the data image.
       MinRc:      The minimum core radius cutoff

 PROCEDURE:
       The core radius is calculated using the maskImage::kingParameters
       procedure, and regions with too low a core radius are unmasked.

 EXAMPLE:
       To unmask regions which probably mask only stars or hot
       pixels (noting the appropriate value for Rc will depend on the
       data set used): 
       minRC=0.2
       oMaskImage->minCoreRadius,DataImage, NoiseImage, Psf, minRc
       
 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/maskimage__define.pro)


MASKIMAGE::MINLUMINOSITY

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       maskImage::minLuminosity

 PURPOSE:
       This method unmasks regions where the total flux in the
       corresponding pixels in a data image are below a specified
       threshhold.

 CALLING SEQUENCE:
       oMaskImage->minLuminosity, DataImage, Cutoff

 INPUTS:
       DataImage: A dataImage object, the image in which to consider
                  fluxes.
       Cutoff:    The minimum luminosity cutoff

 PROCEDURE:
       The flux is calculated using the maskImage::luminosity
       procedure, and regions with too low a flux are unmased

 EXAMPLE:
       In oMaskImage is a mask covering all detected sources in a
       field, to eliminate sources with a flux of fewer than 1000
       counts in image oDataImage,:
       oMaskImage->minLuminosity, oDataImage, 1000.0

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/maskimage__define.pro)


MASKIMAGE::MINRADIALMOMENT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       maskImage::minRadialMoment

 PURPOSE:
       This method unmasks regions where first radial moment of the
       corresponding pixels in a data image is below a specified
       threshhold.

 CALLING SEQUENCE:
       oMaskImage->minRadialMoment, DataImage, Cutoff

 INPUTS:
       DataImage: A dataImage object, the image in which to consider
                  the radial moments.
       Cutoff:    The minimum radial moment cutoff

 PROCEDURE:
       The radial moment is calculated using the
       maskImage::radialMoment procedure.

 EXAMPLE:
       To unmask regions where the mass covers pixels whose first
       radial moment is less than one pixel (very sharp):
       oMaskImage->minRadialMoment, oDataImage, 1.0

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/maskimage__define.pro)


MASKIMAGE::MINSIZE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       maskImage::minSize

 PURPOSE:
       This method removes masked regions smaller than a specified
       size from the mask.

 CALLING SEQUENCE:
       oMaskImage->minSize, Cutoff

 INPUTS:
       Cutoff:  The smallest desired size for masked regions. All
                regions smaller than (but not equal to) this cutoff
                are unmasked. 

 EXAMPLE:
       To unmask all regions with a size other than 20 pixels,
       oMaskImage->maxSize, 20
       oMaskImage->minSize, 20

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/maskimage__define.pro)


MASKIMAGE::MOMENT2

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       maskImage::moment2

 PURPOSE:
       This metbod returns the second order moments of masked objects
       in a supplied dataImage image.

 CALLING SEQUENCE:
       result = oMaskImage->moment2(DataImage)

 INPUTS:
       DataImage:  The dataImage object with the masked image

 OUTPUTS:
       This method returns a three element array:
         result[0] = the x,x moment
         result[1] = the y,y moment
         result[2] = the x,y moment

 EXAMPLE:
       To print the moments of masked objects
       PRINT, oMaskImage->moment2(oDataImage)

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/maskimage__define.pro)


MASKIMAGE::OBJECTSIZE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       maskImage::objectSize

 PURPOSE:
       Thie method returns an array of the sizes of the masked
       regions, in pixels.

 CALLING SEQUENCE:
       result = oMaskImage->objectSize()

 OUTPUTS:
       This method returns a one dimensional array of integers, one
       element for each regions of contiguous masked pixels. Each
       element contains the number of pixels masked in that regions.

 PROCEDURE:
       The regions are defined as in the default for the IDL
       LABEL_REGION procedure.

 EXAMPLE:
       To print the size of the largest region in mask oMaskImage,
       PRINT,MAX(oMaskImage->objectSize())

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/maskimage__define.pro)


MASKIMAGE::OPEN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       maskImage::open

 PURPOSE:
       This method performs an opening operation on the mask.

 CALLING SEQUENCE:
       oMaskImage->open

 KEYWORD PARAMETERS:
       KERNEL:  This keyword can be set to a two dimensional array
                containig the desired kernel. Bu default, a 3x3
                square kernel is used.

 PROCEDURE:
       The opening is performed by the IDL ERODE and DILATE procedures.

 EXAMPLE:
       To open using a cross,
       oMaskImage->open, KERNEL=[[0,1,0],[1,1,1],[0,1,0]]

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/maskimage__define.pro)


MASKIMAGE::POSITIONMASK

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       maskImage::positionMask

 PURPOSE:
       This method sets the data to a mask created using a cutoff in
       the the value in a function of x and y.

 CALLING SEQUENCE:
       oMaskImage->positionMask,ExprString,Cutoff

 INPUTS:
       ExprString: A string containing an expression in x and y. This
                   expression should be of a form that IDL can
                   evaluate it.
       Cutoff:     The cutoff in the expression value for the masking. 

 KEYWORD PARAMETERS:
       LOWER:      If this keyword is set, pixels below the cutoff
                   are masked. Otherwise, pixels above the cutoff are set.

 PROCEDURE:
       The ExprString is evaluated using the IDL EVALUATE function.

 EXAMPLE:
       To mask all pixels whose coordinates are far from pixel 9,8:
       pixFunc='SQRT( (x-9)^2.0+(y-8)^2.0)'
       oMaskImage->positionMask, pixFunc, 100

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/maskimage__define.pro)


MASKIMAGE::RADIALMOMENT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       maskImage::radialMoment

 PURPOSE:
       Thie method returns an array of the radialMoments of the masked
       pixel regions in a supplied data image.

 CALLING SEQUENCE:
       result = oMaskImage->radialMoment(DataImage)

 INPUTS:
       DataImage: A dataImage object, the image in which to consider
                  fluxes.
 OUTPUTS:
       This method returns an array with the first four radial
       moments of each masked region: result[i,n] is n'th radial
       moment of the region with index i.

 PROCEDURE:
       The regions are defined as in the default for the IDL
       LABEL_REGION procedure. 

 EXAMPLE:
       To print the fluxes of masked regions, sorted by their first
       radial moment:
       fluxArray=oMaskImage->luminosity(oDataImage)
       radialMomentArray=oMaskImage->radialMoment(oDataImage)
       radialMomentOrder=SORT(radialMomentArray(*,0))
       PRINT,fluxArray(radialMomentOrder)

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/maskimage__define.pro)


MASKIMAGE::SEGMENT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       maskImage::segment

 PURPOSE:
       This method replaces the data in the mask with a segmentation
       of the data image provided as an argument. 

 CALLING SEQUENCE:
       oMaskImage->segment, DataImage, Cutoff

 INPUTS:
       DataImage:  An object of type dataImage, the image to be
                   segmented
       Cutoff:     The cutoff level for the segmentation

 KEYWORD PARAMETERS:
       LOWER:      If this keyword is set, pixels whose values below
                   the cutoff are masked, where by default those
                   above it are.

 EXAMPLE:
       oMaskImage->OBJ_NEW('maskImage')
       
 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/maskimage__define.pro)


MASKIMAGE::SETPROPERTY

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       maskImage::SetProperty

 PURPOSE:
       This method sets the properties of the mask image.

 CALLING SEQUENCE:
       oDataImage->SetProperty, FILENAME=filename, TEMPNAME=tempName,$
                  DATAARRAY=data, DATAHEADER=dataHeader

 KEYWORD PARAMETERS:
       FILENAME - a string containing the name of the file assiciate 
                  with the data image
       TEMPNAME - a string with the file name of a temporary file for the
                  data to be saved in if onDisk is used
       DATAARRAY - a two dimensional array containing the image data 
       DATAHEADER - a structure containing the header information for the
             image, in the format used by the image loading and saving
             routines from the astrolib library
       

 EXAMPLE:
       oMaskImage->setProperty,FILENAME='newImageFile.hhh',$
                               TEMPNAME='/tmp/newImage.dat',$
                               DATAARRAY='newArray'

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/maskimage__define.pro)


MASKIMAGE__DEFINE

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

 PURPOSE:
       This procedure defines the maskImage object. The maskImage
       object is inteded to be used for two level images,
       particularly where the nonzero level indicates something about
       the corresponding pixel in a dataImage object.

 CALLING SEQUENCE:
       oMaskImage=OBJ_NEW('maskImage')

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen Jr., 1997.

(See /host/bluemoon/usr2/idllib/sdss/allpro/maskimage__define.pro)


MATCHPHOTO

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

 NAME: 
     matchphoto
       
 PURPOSE: 
     match two photo structures by id and field.
     !!!! Use PHOTO_MATCH  its much faster.

 CALLING SEQUENCE: matchphoto, str1, str2, i1, i2, silent=silent
      
 INPUTS: str1, str2: the two structures.  Must include id and field

 INPUT KEYWORD PARAMETERS:
         silent: shut off messages except errors.

 OUTPUTS: i1, i2: The indices of matches.  i1[index] corresponds directly
                  to i2[index]

 REVISION HISTORY:
	Erin Scott Sheldon  UofM  7/4/99
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/matchphoto.pro)


MFACT

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

 PURPOSE: 
    find the factorial of each element in an array.

 CALLING SEQUENCE:
    result = mfact(array)

 INPUTS: 
    array (of numbers)

 OUTPUTS: 
    farray: the array of factorials.

 REVISION HISTORY:
   Author: Erin Scott Sheldon UofM  5/??/98

(See /host/bluemoon/usr2/idllib/sdss/allpro/mfact.pro)


MISSING_ATLAS

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

 NAME:  
    MISSING_ATLAS
       
 PURPOSE: 
    Called by get_atlas 
    figure out what to do if an atlas image is not found.
	

 CALLING SEQUENCE: 
    missing_atlas, request, i, max, noprompt, silent=silent
      
 INPUTS: i, max, prompt
       
 OUTPUTS: 

 OPTIONAL OUTPUT ARRAYS:

 INPUT KEYWORD PARAMETERS:
 
 PROCEDURE: 
	
	

 REVISION HISTORY:  Erin Scott Sheldon UM 1/8/99
	
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/missing_atlas.pro)


MRDFITS3

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

 PURPOSE:
       Read all standard FITS data types into arrays or structures.

 EXPLANATION:
	Further information on MRDFITS is available at
	http://idlastro.gsfc.nasa.gov/mrdfits.html 

 CALLING SEQUENCE:
       Result = MRDFITS( Filename,[Extension, Header],
                       /FSCALE , /DSCALE , /USE_COLNUM, /NO_TDIM,
                       RANGE=[a,b], Columns=[a,b,...]), error_action=x

 INPUTS:
       Filename = String containing the name of the file to be read.
		   Note that the file name may be of the form
                  name.gz or name.Z on UNIX systems.  If so
                  the file will be dynamically decompressed.

       Extension= Extension number to be read, 0 for primary array.
                  Assumed 0 if not specified.

 OUTPUTS:
       Result = FITS data array or structure constructed from
                the designated extension.  The format of result depends
                upon the type of FITS data read.
             Non-group primary array or IMAGE extension:
                A simple multidimensional array is returned with the
                dimensions given in the NAXISn keywords.
             Grouped image data with PCOUNT=0.
                As above but with GCOUNT treated as NAXIS(n+1).
             Grouped image data with PCOUNT>0.
               The data is returned as an array of structures.  Each
               structure has two elements.  The first is a one-dimensional
               array of the group parameters, the second is a multidimensional
               array as given by the NAXIS2-n keywords.
             ASCII and BINARY tables.
               The data is returned as a structure with one column for
               each field in the table.  The names of the columns are
               normally taken from the TTYPE keywords (but see USE_COLNUM).
		Bit field columns
               are stored in byte arrays of the minimum necessary
               length.  Column names are truncated to 15 characters
               if longer, spaces are removed, and invalid characters
               are replaced by underscores.
               Columns specified as variable length columns are stored
               with a dimension equal to the largest actual dimension
               used.  Extra values in rows are filled with 0's or blanks.
		If the size of the variable length column is not
               a constant, then an additional column is created
               giving the size used in the current row.  If the length
               of each element of a variable length column is 0 then
               the column is deleted.

               For FITS files with more than 127 columns, data in the first
               64 elements of the structure are stored in the primary
               structure, the next 64 as a substructure of the 65th
               element, the next 64 as a substructure of the 66th element
               and so forth.

 OPTIONAL OUTPUT:
       Header = String array containing the header from the FITS extenion.

 OPTIONAL INPUT KEYWORDS:
       FSCALE - If present and non-zero then scale data to float
                numbers for arrays and columns which have either
                non-zero offset or non-unity scale.
                If scaling parameters are applied, then the corresponding
                FITS scaling keywords will be modified.
       DSCALE - As with FSCALE except that the resulting data is
                stored in doubles.
       SILENT - Suppress informative messages.
       RANGE  - A scalar or two element vector giving the start
                and end rows to be retrieved.  For ASCII and BINARY
                tables this specifies the row number.  For GROUPed data
                this will specify the groups.  For array images, this
                refers to the last non-unity index in the array.  E.g.,
                for a 3 D image with NAXIS* values = [100,100,1], the
                range may be specified as 0:99, since the last axis
                is suppressed.  Note that the range uses IDL indexing
                So that the first row is row 0.
                If only a single value, x, is given in the range,
                the range is assumed to be [0,x-1].
       USE_COLNUM - When creating column names for binary and ASCII tables
                MRDFITS attempts to use the appropriate TTYPE keyword
                values.  If USE_COLNUM is specified and non-zero then
                column names will be generated as 'C1, C2, ... 'Cn'
                for the number of columns in the table.
       STRUCTYP - The structyp keyword specifies the name to be used
                for the structure defined when reading ASCII or binary
                tables.  Generally users will not be able to conveniently
                combine data from multiple files unless the STRUCTYP
                parameter is specified.  An error will occur if the
                user specifies the same value for the STRUCTYP keyword
                in calls to MRDFITS in the same IDL session for extensions
                which have different structures.
       NO_TDIM  - Disable processing of TDIM keywords.  If NO_TDIM
                is specified MRDFITS will ignore TDIM keywords in
                binary tables.
	TEMPDIR - The tempdir keyword allows the user to specify
		 the directory where temporary files may be created.
		 This directory should be both in the IDL path
                and writable by the user.
	COLUMNS - This keyword allows the user to specify that only a
                subset of columns is to be returned.  The columns
                may be specified either as number 1,... n or by
                name. (If USE_COLNUM is specified this should be C1,...Cn)
		 The use of this keyword will not save time or internal
                memory since the extraction of specified columns
                is done after all columns have been retrieved from the
                FITS file.
       ERROR_ACTION - Set the on_error action to this value (defaults
                to 2).

 EXAMPLE:
       Read a FITS primary array:
               a = mrdfits('TEST.FITS')    or
               a = mrdfits('TEST.FITS', 0, header)
       The second example also retrieves header information.

       Read rows 10-100 of the second extension of a FITS file.
               a = mrdfits('TEST.FITS', 2, header, range=[10,100])

       Read a table and ask that any scalings be applied and the
       scaled data be converted to doubles.  Use simple column names,
       suppress outputs.
               a = mrdfits('TEST.FITS', 1, /dscale, /use_colnum, /silent)

 RESTRICTIONS:
       (1)     Cannot handle data in non-standard FITS formats.
       (2)	Doesn't do anything with BLANK or NULL values or
               NaN's.  They are just read in.  They may be scaled
               if scaling is applied.
 NOTES:
       This multiple format FITS reader is designed to provide a
       single, simple interface to reading all common types of FITS data.
       MRDFITS DOES NOT scale data by default.  The FSCALE or DSCALE
       parameters must be used.

 PROCEDURES USED:
	The following procedures are contained in the main MRDFITS program.
           MRD_IMAGE  		-- Generate array/structure for images.
           MRD_READ_IMAGE 	-- Read image data.
           MRD_ASCII  		-- Generate structure for ASCII tables.
           MRD_READ_ASCII 	-- Read an ASCII table.
           MRD_TABLE 		-- Generate structure for Binary tables.
           MRD_READ_TABLE 	-- Read binary table info.
           MRD_READ_HEAP 	-- Read variable length record info.
           MRD_SCALE 		-- Apply scaling to data.
	    MRD_COLUMNS         -- Extract columns.

	Other ASTRON Library routines used:
	    FXPAR(), FXADDPAR, IEEE_TO_HOST, FXPOSIT, IS_IEEE_BIG()
           MRD_STRUCT(), MRD_SKIP

 MODIfICATION HISTORY:
       V1.0 November 9, 1994 ----  Initial release.
          Creator: Thomas A. McGlynn
 	V1.1 January 20, 1995 T.A. McGlynn
	   Fixed bug in variable length records.
          Added TDIM support -- new routine mrd_tdim in MRD_TABLE.
       V1.2
	   Added support for dynamic decompression of files.
	   Fixed further bugs in variable length record handling.
       V1.2a
          Added NO_TDIM keyword to turn off TDIM processing for
          those who don't want it.
          Bug fixes: Handle one row tables correctly, use BZERO rather than
		BOFFSET.     Fix error in scaling of images.  
       V1.2b 
          Changed MRD_HREAD to handle null characters in headers.
	V2.0 April 1, 1996
          -Handles FITS tables with an arbitrary number of columns.
          -Substantial changes to MRD_STRUCT to allow the use of
          substructures when more than 127 columns are desired.
          -All references to table columns are now made through the
          functions MRD_GETC and MRD_PUTC.  See description above.
          -Use of SILENT will now eliminate compilation messages for
          temporary functions.
          -Bugs in handling of variable length columns with either
	   a single row in the table or a maximum of a single element
          in the column fixed.
          -Added support for DCOMPLEX numbers in binary tables (M formats) for
          IDL versions above 4.0.  
          -Created regression test procedure to check in new versions.
          -Added error_action parameter to allow user to specify
          on_error action.  This should allow better interaction with
          new CHECK facility.  ON_ERROR statements deleted from
          most called routines.
          - Modified MRDFITS to read in headers containing null characters
          with a warning message printed.
       V2.0a April 16, 1996
          - Added IS_IEEE_BIG() checks (and routine) so that we don't
          worry about IEEE to host conversions if the machine's native
          format is IEEE Big-endian.
       V2.1 August 24, 1996
          - Use resolve_routine for dynamically defined functions
          for versions > 4.0
          - Fix some processing in random groups format.
	   - Handle cases where the data segment is--legally--null.
          In this case MRDFITS returns a scalar 0.
          - Fix bugs with the values for BSCALE and BZERO (and PSCAL and
          PZERO) parameters set by MRDFITS.
	V2.1a April 24, 1997  Handle binary tables with zero length columns
       V2.1b May 13,1997 Remove whitespace from replicate structure definition
	V2.1c May 28,1997 Less strict parsing of XTENSION keyword
	V2.1d June 16, 1997 Fixed problem for >32767 entries introduced 24-Apr
	V2.1e Aug 12, 1997 Fixed problem handling double complex arrays
	V2.1f Oct 22, 1997 IDL reserved words can't be structure tag names
	Converted to IDL V5.0   W. Landsman  2-Nov-1997
       Modified by Phil Phischer from MRDFITS
       Modified by Dave Johnston from MRDFITS2
       Changed all sub-programs to end in *3 so they will not conflict
       with new versions. Erin Scott Sheldon

(See /host/bluemoon/usr2/idllib/sdss/allpro/mrdfits3.pro)


NTOSTR

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

 NAME: 
    ntostr
       
 PURPOSE: 
    convert a number to a string.  Cuts off white spaces.
	

 CALLING SEQUENCE: 
    result = ntostr(num, pos2, pos1)

 INPUTS: 
    num:  the number to be converted

 OPTIONAL INPUTS:
   pos2: The number of characters to keep beginning with pos1. Default
         is to return the whole string.
   pos1: starting position.  Default is 0, the first position.
       
 OUTPUTS: 
   The string.

 CALLED ROUTINES:
                   STRTRIM
                   STRMID

 REVISION HISTORY:
	Author: Erin Scott Sheldon  UofM 6/1/99
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/ntostr.pro)


OBJ_INFO

[Previous Routine] [Next Routine] [List of Routines]
 NAME: 
    OBJ_INFO
       
 PURPOSE: 
    For a list of objects (index) make color-color diagrams, size
    vs brightness plot, find its family, and make its own 
    FINDING CHART.

 WARNING: write_gif will not work if plot window is minimized.  i.e. you
          won't have good gifs when you are done if it is minimized.
	

 CALLING SEQUENCE: obj_info, pstruct, index, clr, dir=dir, radius=radius, 
        gif=gif, ps=ps, fchart=fchart, all=all, 
        noprompt=noprompt, silent=silent, nodisplay=nodisplay,
	 hideradec=hideradec
                       
 INPUTS: pstruct: photo structure.  
         IMPORTANT NOTE: This MUST have objc_rowc as a continuously added 
             number, not restarted at the beginning of each frame.  Such
             boundaries are artificial and make it difficult to make 
             finding charts centered on the object.  
             This is done automatically by READ_PHOTO_COL.

         index:  The objects for which to get info.
         clr: The color to use when making the fchart.

 INPUT KEYWORD PARAMETERS: 
           dir:      The directory holding the atlas images.
           radius:   The finding chart for each object will have sides
                     2*radius unless radius is too big. (e.g. radius > 2048)
                 NOTE!!  Will change to radius in arcminutes

           gif:      Set gif keyword to print gifs of all images in cwd.
           ps:       Set ps keyword to print postscripts of all images.
           all:      If all is set, then all objects (not just stars) 
                       are used for the locus of the color-color plots
           noprompt: If noprompt is set, then there is no prompting
           silent:   If silent is set, there will be no messages except
                        for some errors.
	    hideradec: If set it will not include ra dec on anything
		       for example if you are showing unpublished results
		       at a conference and want to be descreet.
           hist:   Will hand this to plot_colors to use 2D histograms
                   instead of scatter plots. Good for large catalogs.
           radrange:  range on petrorads to plot. handed to plot_colors

 OUTPUTS: Files:  (only output if /gif or /ps is used)

     a) The following files are created in the cwd for each object:

            Obj-run-colorcamcol-field-id-type.extension

        examples:
            Obj-000259-3-0248-0234-atlas.gif
            Obj-000259-3-0248-0234-atlas.ps
            Obj-000259-3-0248-0234-colors.gif
            Obj-000259-3-0248-0234-colors.ps
            Obj-000259-3-0248-0234-fchart.gif
            Obj-000259-3-0248-0234-fchart.ps

     b) If index contains more that one object then a color-color plot is
        made with all of them in it.  It uses the entire pstruct
        to make the locus
	The file name is:
            Obj-000259-3-0248-0234-colors-multi.gif
	with the info refering to the FIRST object in the list

 OPTIONAL OUTPUTS: fchart:  The image of the fchart may be returned.

           
 CALLED ROUTINES:  EXTRACT_STARS:
                      MAKE_FLAG_STRUCT
                      FLAG_SELECT
                   PLOT_COLORS
                   BEGPLOT
                   ENDPLOT
                   GET_FAMILY:
                      GET_ATLAS (calls many pros)
                   FCHART
                   DISPLAY_FCHART
                   

 SUBROUTINES: OBJ_PROMPT_USER, OBJ_DISPLAY_FCHART

 EXAMPLES:  This will work on sdss3 if typed exactly:
   (Until we move the data)

 IDL> file='/sdss3/data4/run109/tsObj-000109-3-0-0011.fit'
 IDL> read_photo_col, file, pstruct, struct_typ='all', nframes=20

 IDL> dir='/sdss3/data4/run109/'
 IDL> r=2
 IDL> index = 1002
 IDL> obj_info, pstruct, index, r, dir=dir
 
    Lets say you have a program that selects quasars.  It returns the
      indices of the quasars. Also, you want to generate all the ps and gif
      files at once without any keyboard prompting:

 IDL> findqso, pstruct, index
 IDL> obj_info, pstruct, index, r, dir=dir, /noprompt, /ps, /gif

   If you only want to make the ps files:

 IDL> obj_info, pstruct, index, r, dir=dir, /noprompt, /nodisplay, /ps 

 REVISION HISTORY:  
      Author: Erin Scott Sheldon  UMich 03/21/99
	       David Johnston - changed filename formats to what is described 
                    above. Fixed some bugs with the 'sky' program 5/12/99
              E.S.S.  Made obj_display_fchart in to stand alone proc.
                    display_fchart.pro
			   	
	

 TO DO:  
       1) Make fchart display more similar to SNe:       
          a) give center of picture and object of interest and label axes
             with +/- arcminutes from center.
          b) circle 2 other bright objects and give info.
       2) Gordon's Suggestions.
       3) Change radius keyword to be in arcminutes.

(See /host/bluemoon/usr2/idllib/sdss/allpro/obj_info.pro)


PHOTOMAP

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

 NAME: 
   PHOTOMAP
       
 PURPOSE: 
     map ra and dec to row and col.  The map centers on the first
     ra-dec position in the lists.
     NOTE: If clr is not given, then the program uses
           RED (clr=2) to find the map.
	

 CALLING SEQUENCE:
    photomap, pstruct, order, ra, dec, row, col
                 

 INPUTS: 
     pstruct: a photo structure.  Should cover ra and dec.
         order: order of polynomial to fit
         ra: the ra positions to trasform in degrees.
         dec: the dec positions to transform in degrees.

 OPTIONAL INPUTS: clr:  The index to use for mapping.

 OUTPUTS: row, col:  mapped ra and dec positions.

 CALLED ROUTINES:
                CONVERT2XY
                POLYWARP
                KMAP
 

 REVISION HISTORY:
	Erin Scott Sheldon  U of Michigan  7/8/99
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/photomap.pro)


PHOTO_MATCH

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

 NAME:
    PHOTO_MATCH
       
 PURPOSE:
    Match to lists of photo objects by their run, rerun, camcol, field, 
    and rerun.  This uniquely defines each object.

 CALLING SEQUENCE:
    photo_match, run1, rerun1, camcol1, field1, id1,
                 run2, rerun2, camcol2, field2, id2, m1, m2

 INPUTS: 
    run1, rerun1, camcol1, id1:   unique info for object list #1
    run2, rerun2, camcol2, id2:   unique info for object list #2

 OPTIONAL INPUTS:
    None.

 KEYWORD PARAMETERS:
    None.
       
 OUTPUTS: 
    m1, m2:  match indices for each list.

 OPTIONAL OUTPUTS:
    None.

 CALLED ROUTINES:
    MATCH
 
 PROCEDURE: 
    Match two photo lists putting their run,rerun,camcol,field,id
    into one super index which is a 64 bit number encoding these
    to a unique number . Then a regular "sort match" can be run
    this is therefore a n_log(n) algorithm
	

 REVISION HISTORY:
    Dave Johnston  11/12/99  UChicago
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/photo_match.pro)


PLOTH

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

PURPOSE:	like plotting points but makes a two dimentional
		histogram first and displays that as an image with tvim2
		and returns a histogram structure

CALLING SEQUENCE:
	 ploth,x,y,hist,median=3

INPUTS:	 
	x ,y : the two one-dimentional arrays that you want histogrammed

OUTPUTS:
	hist : the histogram structure contains 3 fields
	.map (the 2D array) , .xrange, .yrange (the two ranges)
	these ranges permit mapping from the data to the histogram map
	and vice versa

KEYWORDS:
	xrange,yrange : the range to include data from
	these are output and saved in the hist structure
	the default is min, max
	if these are flipped like [12,3]
	it will use 3 as min and 12 as max and then flip the histogram
	
	nxbins, nybins : the number of bins for each dimention

	range : the display range given to tvim2
		default is to go around the mean by three sigma
		uses sigma clipping algorithm

	log, sqrt : use log or square root scaling

	median : do a median filter smoothing on a square this size
		should be an odd integer

	smooth : so boxcar average smoothing on a square this size
		should be an odd integer	
	
	g_smooth : do gaussian smoothing with a gaussian of fwhm
		of this amount. Should be a float > 1.0.

	silent : speak no evil	

EXTERNAL CALLS:

	histogram_2d
	tvim2
	make_gaussian

METHOD: call histogram_2d which calls hist_2d (a built in IDL routine)

EXAMPLE

NOTES

	if median,smooth or g_smooth are set the resultant hist.map
	will be smoothed upon output, though if log or sqrt are set they 
	hist.map will NOT be scaled as it is displayed

HISTORY:  written by David Johnston -University of Chicago 
       Physics Department 1999

(See /host/bluemoon/usr2/idllib/sdss/allpro/ploth.pro)


PLOTHIST2

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PLOTHIST2
 PURPOSE:
	Plot the histogram of an array with the corresponding abcissa.

 CALLING SEQUENCE:
	plothist2, arr, xhist, yhist, [, BIN=bin,   ... plotting keywords]

 INPUTS:
	arr - The array to plot the histogram of.   It can include negative
		values, but non-integral values will be truncated.              

 OPTIONAL OUTPUTS:
	xhist - X vector used in making the plot  
		( = indgen( N_elements(h)) * bin + min(arr) )
	yhist - Y vector used in making the plot  (= histogram(arr/bin))

 OPTIONAL INPUT KEYWORDS:
	BIN -  The size of each bin of the histogram,  scalar (not necessarily
		integral).  If not present (or zero), the bin size is set to 1.

		Any input keyword that can be supplied to the PLOT procedure
		can also be supplied to PLOTHIST.
 EXAMPLE:
	Create a vector of 1000 values derived from a gaussian of mean 0,
	and sigma of 1.    Plot the histogram of these value with a bin
	size of 0.1

	IDL> a = randomn(seed,1000)
	IDL> plothist2,a, bin = 0.1,/overplot

 MODIFICATION HISTORY:
	Written     W. Landsman            January, 1991
	Add inherited keywords W. Landsman        March, 1994
	Use ROUND instead of NINT  W. Landsman   August, 1995
       Keyword to overplot added David Johnston U of Mich 1997
	keyword to fill added by David Johnston U of Mich 1997

(See /host/bluemoon/usr2/idllib/sdss/allpro/plothist2.pro)


PLOT_1COLOR

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

 NAME:  
    PLOT_1COLOR
       
 PURPOSE:  
       make color-color plot from sloan colors.  Plot one set of data
	from obj_struct.  Over plot, if requested, from oplot_str
	

 CALLING SEQUENCE:  
   oplot_colors, obj_struct, color, oplot_str=oplot_str,
	index=index, size=size, carr=carr, opcarr=opcarr
      
                 

 INPUTS: 
         obj_struct:  photo objc structure.
	  color:       indicates which colors to plot. 
		       color = 1 for g-r vs u-g
                      color = 2 for r-i vs g-r
                      color = 3 for i-z vs r-i

         oplot_str:   (optional) struct to overplot
         index:       (optional) indexes on obj_struct to use in plotting
	  size:        (optional) if set, oplot_colors also plots size v 
 				brightness

 OUTPUTS:  
           carr:  (optional) output struct containing colors for obj_struct 
	    opcarr:  (optional) output struct containing colors for oplot_str

 OPTIONAL OUTPUT ARRAYS:  
     carr:  (optional) output struct containing colors 
            for obj_struct 
     opcarr:  (optional) output struct containing colors
	       for oplot_str

 INPUT KEYWORD PARAMETERS:
 
 PROCEDURE: 
	
	

 REVISION HISTORY: 
    Authro: Erin Sheldon UM  2/6/99
	
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/plot_1color.pro)


PLOT_COLORS

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

 NAME:  
    PLOT_COLORS
       
 PURPOSE:  
       make color-color plots from sloan colors.  Plot one set of data
	from obj_struct.  Over plot, if requested, from oplot_str.

	DEFAULTS are COUNTS_MODEL for colors, PETRORAD vs. PETROCOUNTS for
       size vs mag plots.  PLOT_COLORS will search for other arrays if
       these are not present.  If the keywords /fibercounts or /psfcounts
       are given, then these arrays are used (if present) for both
       colors and magnitude.

       NOTE: For stars, COUNTS_MODEL is closer to psfcounts than petrocounts or 
             fibercounts.  Also, COUNTS_MODEL give the best colors for galaxies.
             Thus, it is best for showing both stars and galaxies on the same 
             color-color diagrams. That is why it is the default. If you are
             just plotting stars and quasars, then PSFCOUNTS may be the way
             to go; set the /psfcounts keyword.

 CALLING SEQUENCE:  
     plot_colors, obj_struct, oplot_str=oplot_str,index=index, size=size, 
            carr=carr,opcarr=opcarr, psfcounts=psfcounts, fibercounts=fibercounts, 
            psym=psym,title=title,hist=hist,radrange=radrange,
            oplot_clr=oplot_clr, _extra=_extra

 INPUTS: obj_struct:  photo objc structure.  

 OPTIONAL INPUTS:
     index:       indexes on obj_struct to use in plotting
     oplot_str:   struct to overplot
     oplot_clr: The color of the overplotted symbols.  If this is set, 
               the procedure simpctable is called, which sets up a new
               color table and sets certain system variables to these 
               values:
                           system variable set by simpctable
              black=0                (!black)
              white=1                (!white)
              red=2                  (!red)
              green=3                (!green)
              blue=4                 (!blue)
              yellow=5               (!yellow)
              lightblue=6            (!lightblue)
              magenta=7              (!magenta)
              
            Therefore, if you don't want to remember the numbers, just
            call simpctable before calling plot_colors, and use
                         oplot_clr=!magenta  
            or whatever. You can get back to black and white with loadct,0
            Note that the background will always be set to black and the 
            axes white, and these are reversed when you send to postscript.
            WARNING: doesn't work well with the /hist keyword

     radrange:  the range on petrorad to plot
     psym: The over plotting symbol.  Default is a cross-hair.
     title=title: title for upper left hand plot (g-r) vs (u-g)
     _extra=_extra   any extra plotting stuff. 

 INPUT KEYWORD PARAMETERS:
     /size: if set, oplot_colors also plots size v 
            brightness.  DEFAULT is PETROCOUNTS vs. PETRORAD
     /psfcounts:   If set, use psfcounts for colors and magnitude
     /fibercounts: if set, use fibercounts for colors and magnitude
           NOTE: Defaults are 1. COUNTS_MODEL for colors
                              2. PETROCOUNTS for magnitude if /size
     /hist:  use 2D histograms instead of scatter plots , displays them 
              with tvim2

 OPTIONAL OUTPUT ARRAYS:  
    carr:  (optional) output struct containing colors for obj_struct 
    opcarr:  (optional) output struct containing colors for oplot_str

 
 PROCEDURE: 
	
	

 REVISION HISTORY:  Tim Mckay UM
		     Erin Sheldon UM  2/6/99  added over-plotting, comments
		     Dave Johnston UC 5/15/99 made DEFAULT over-plot symbol 
                             to be crosshairs
		     Dave Johnston 7/23/99 added 2D histogram option instead of
				scatter plots. This is good for speed and also
				appearance. Added radrange as a keyword
				this is the range in petrorad to plot.		
                    Erin Sheldon Made plots square
                    Erin Sheldon 05/04/00 Added color overplotting. Improved
                         error handling by checking for existence of 
                         magnitude arrays and size arrays with subroutine
                         PLOT_COLORS_CHECK_TAGS. Improved memory
                         usage.
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/plot_colors.pro)


PLOT_FLAGS

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

 NAME:
    PLOT_FLAGS
 PURPOSE:
    Plots flags for a set of objects 
 
 Inputs:  pstruct: a photo output structure (must have .flags tag...)
	   index: indices of the objects of interest
	   colorindex: which color do you want to look at???

 Outputs: Plots flags for these objects....

 Author:  Tim McKay
 Date: 1/7/99
 Erin Scott Sheldon UM 2/5/00 Added flags2

(See /host/bluemoon/usr2/idllib/sdss/allpro/plot_flags.pro)


PLOT_TSFLAGS

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

 NAME:
    PLOT_TSFLAGS
 PURPOSE:
    Plots target selection flags for a set of objects 
 
 Inputs:  pstruct: a photo output structure (must have .flags tag...)
	   index: indices of the object of interest

 Outputs: Plots flags for these objects

 Author:  Sarah Monk, modified from plot_flags by Tim McKay
 Date: 5/8/00

(See /host/bluemoon/usr2/idllib/sdss/allpro/plot_tsflags.pro)


PRETTYPT

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


 PURPOSE:
      This routine builds a "pretty picture" from SDSS PT images 
      using the files produced by mtFrames.

 CALLING SEQUENCE:
      prettypt, pipeFileName, fitsName, index, minmult, maxv, jpegname

 INPUTS:
      pipeFileName : name of the mtObj file produced by mtFrames, used to 
                     obtain sky value
      fitsName : 3 element array of strings, each of which is the
                 file name of an image in fits format. 
      index : 3 element array of the indexes of the SDSS filters
              corresponding to the red, green, and blue chanels. For
              example, if you want the g, r, and i filters to
              correspond to the blue, green, and red chanels, the
              array would be [1,2,3]. 
      minmult : minimum sky value multiplier. This parameter
                controls count level of the sky in the final picture
                relative to the sky value, scaled by the sky
                noise. Larger values result in smoother, darker skies
                in the pretty picture.
      maxv : maximum count level. A 3 element array containing the
             number of image counts corresponding to 255 (the
             maximum value per chanel) in the final image. 
      jpegName : name of the final output file

 KEYWORD PARAMETERS:
      ALIGNMENT_SECTION : an array defining the section of the image
                          used to align the chanels, in the following
                          format:
                            [[minimumX,maximumX],[minimumY,maximumY]]
      CROP_SIZE : the image size to which the images is to be
                  cropped. For example, if you want the final picture
                  to contain only the central 512 by 768 pixels,
                  CROP_SIZE should be set to [512,768] 
      MAGNIFY_SIZE : the desired final dimensions of the image. After
                  cropping to the size specified in CROP_SIZE
                  (above), the image is magnified the the dimensions
                  speficied by MAGNIFY_SIZE. MAGNIFY_SIZE is a two
                  element array, the first element of which is the x
                  size, and the second of which is the y size. 
      SKY_SECTION : If this keyword is set, the sky value is measured
                    directly rather than being taken from the mtObj
                    file. The section to be measured is specified in
                    the same format as in the ALIGNMENT_SECTION keyword.

 RESTRICTIONS:
      The final size must be an integer factor of 2048


 EXAMPLE:
prettypt, 'mtObj.fit',['g.fit','r.fit','i.fit'],[1,2,3],0.2,[2048,2048,2048],'M53.jpeg',ALIGN=[[898,1152],[898,1152]]


 MODIFICATION HISTORY:
      Written by Eric H. Neilsen, Jr. spring 2000

(See /host/bluemoon/usr2/idllib/sdss/allpro/prettypt.pro)


PRINT_FLAGS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
    PRINT_FLAGS
 PURPOSE:
    Prints flags for a single object....

 Inputs:  pstruct: a photo output structure (must have .flags tag...)
	   index: index of the object of interest

 Outputs: Prints flags status

 Author:  Tim McKay
 Date: 1/7/99
 Erin Scott Sheldon  UM  2/5/00 added flags2, made easier to add flags

(See /host/bluemoon/usr2/idllib/sdss/allpro/print_flags.pro)


PRINT_TSFLAGS

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

 PURPOSE:
    Prints target selection flags for a single object

 Inputs:  pstruct: a photo output structure (must have .flags tag...)
	   index: index of the object of interest

 Outputs: Prints target selection flags status

 Author:  Sarah Monk, modified from print_flags by T. McKay
 Date: 5/8/00
 

(See /host/bluemoon/usr2/idllib/sdss/allpro/print_tsflags.pro)


PTIME

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

 NAME: 
    ptime
       
 PURPOSE: 
    print a time in a hr min sec format. 
	
 CALLING SEQUENCE: 
    ptime, t [, num, tstr=tstr]
      
                 
 INPUTS: 
    t: a time in seconds.

 OPTIONAL INPUTS: 
    num: number of places to keep in seconds. Default is 4, 
         which includes any decimal places.
       
 OUTPUTS: 
    prints the time.

 OPTIONAL OUTPUTS: 
    tstr: a string containing the time in hr min sec format.

 CALLED ROUTINES:
                NTOSTR
 

 REVISION HISTORY:
	Author: Erin Scott Sheldon UofM  7/8/99
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/ptime.pro)


QU2E

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

 NAME: 
    qu2e
       
 PURPOSE: 
    Convert Robert Luptons q and u shape parameters to ellipticity
    parameters as measured by unweighted moments and Gary Bernstein's
    adaptive moments.
	

 CALLING SEQUENCE: 
    qu2e, q, u, e1, e2
      
 INPUTS: 
    q: Shape parameter corresponding to 'e1'
    u: Shape parameter corresponding to 'e2'


 OUTPUTS: 
    e1 and e2.  ellipticity parameters.

 
 PROCEDURE: 
    Robert's scheme uses a 1/r weighting scheme for measuring 
        
          (ixx - iyy)/(ixx + iyy)   and  2ixy/(ixx + iyy)

    For his method, these are equal to:
 
        q = ( 1-r )/( 1+r )*cos(2*theta)
        u = ( 1-r )/( 1+r )*sin(2*theta)

   Where r=axis ratio of object and theta=position angle from x axis

   For unweighted and adaptive schemes, the formulae the same with 
          
        r -> r^2
	

 REVISION HISTORY:
	
   Author: Erin Scott Sheldon  UofM  6/1/99
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/qu2e.pro)


RADECSTR

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

 NAME: 
    RADECSTR
       
 PURPOSE: 
    Wrapper for radec.  Returns string versions of ra and dec.
	

 CALLING SEQUENCE: radecstr, ra, dec, rastr, decstr
      
                 

 INPUTS: ra, dec in degrees.
       
 OUTPUTS: rastr, decstr.  Strings containing ra and dec.

 CALLED ROUTINES: radec
 
 EXAMPLE:
	
	

 REVISION HISTORY: Erin Scott Sheldon U of Mich.  3/28/99
	Dave Johnston	changed h m s to colons and added 
			a little more accuracy to last digits
			of arcseconds ,since the seconds of ra needs 3 
			digits after the decimal to be accurate to	
			subarcsecond level
       Dave Johnston   made it output the negative sign on dec
                       on the "degrees" part even if it is -0

                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/radecstr.pro)


RADEC_MATCH

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

 CALLING SEQUENCE:	
    radec_match.pro,m1,m2,newmatch

 INPUTS:	
    m1: first match structure
    m2: second match structure

 OUTPUTS:	newmatch: combined structure, merged on (ra,dec)
	
 INPUT KEYWORDS:
		angdiff: angular difference (in ") to allow
			
 PROCEDURE:	Merges the two matched structures into a single list
		by matching in ra,dec for the whole thing.

 REVISION HISTORY:  
	Tim McKay		UM	6/23/98	Created

(See /host/bluemoon/usr2/idllib/sdss/allpro/radec_match.pro)


RD2XY

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	RD2XY
 PURPOSE:
	Compute an X and Y position given the RA and DEC and an astrometry
	structure from a FITS header.  A tangent (gnomonic) projection is
	computed directly; other projections are computed using WCSXY2SPH.  
	AD2XY is meant to be used internal to other procedures.   For 
	interactive purposes, use ADXY.

 CALLING SEQUENCE:
	AD2XY, a ,d, astr, x, y   

 INPUTS:
	A -     R.A. in DEGREES, scalar or vector
	D -     Dec. in DEGREES, scalar or vector
	ASTR - astrometry structure, output from EXTAST procedure containing:
   	 .CD   -  2 x 2 array containing the astrometry parameters CD1_1 CD1_2
		in DEGREES/PIXEL                                   CD2_1 CD2_2
	 .CDELT - 2 element vector giving increment at reference point in
		DEGREES/PIXEL
	 .CRPIX - 2 element vector giving X and Y coordinates of reference pixel
		(def = NAXIS/2)
	 .CRVAL - 2 element vector giving R.A. and DEC of reference pixel 
		in DEGREES
	 .CTYPE - 2 element vector giving projection types 

 OUTPUTS:
	X     - row position in pixels, scalar or vector
	Y     - column position in pixels, scalar or vector

 REVISION HISTORY:
	Converted to IDL by B. Boothman, SASC Tech, 4/21/86
	Use astrometry structure,  W. Landsman      Jan. 1994	
       Do computation correctly in degrees  W. Landsman       Dec. 1994
	Only pass 2 CRVAL values to WCSSPH2XY   W. Landsman      June 1995
	Don't subscript CTYPE      W. Landsman       August 1995	
	Changed to RD2XY forces tangent projection  David Johnston 1998

(See /host/bluemoon/usr2/idllib/sdss/allpro/rd2xy.pro)


RDIS

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

 PURPOSE:
    Wrapper for tvim2.  One can zoom, rescale, flip across x or y, or 
    rotate by 180 degrees.

 CALLING SEQUENCE:
       imdis, image [, pls, 
          xmn=xmn, xmx=xmx, ymn=ymn, ymx=ymx, 
          low=low, high=high, 
          log=log, zoom=zoom, full=full, 
          flipx=flipx, flipy=flipy, rot=rot, 
          silent=silent, _extra=extra]

 INPUTS:
       image: image to be displayed
	
 OPTIONAL INPUTS:
       pls:  the plot structure.  If not input, rdis_setup is called.
             You can call rdis_setup yourself and set the equilavent of
             the keywords in the structure:
                         xmn, xmx, ymn, ymx, low, high

 INPUT KEYWORD PARAMETERS:
    THESE OVERIDE PLS
    xmn, xmx, ymn, ymx:  range of x and y values of image to display.
                         these can be set in pls.
    low, high: low and high of image.  
    full: show the full image.
    rot: rotate image
    silent: be quiet.

 PROCEDURE:
	

 REVISION HISTORY:
	Tim McKay	UM	1/29/97
       Erin Scott Sheldon made pls optional input 
                          Cleaned up, added comments.  11/24/99  

(See /host/bluemoon/usr2/idllib/sdss/allpro/rdis.pro)


RDIS_SETUP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       RDIS_SETUP
 PURPOSE:
	Set up a parameter structure for rdis

 CALLING SEQUENCE:
       rdis_setup

 INPUTS:
       
 OUTPUTS:
	lot_struct: a structure containing all the parameters needed
		      to run rdis

 OPTIONAL OUTPUT ARRAYS:

 INPUT KEYWORD PARAMETERS:
 
 PROCEDURE: This just creates a little structure useful for image display

 REVISION HISTORY:
	Tim McKay	UM	1/8/98
	Tim McKay	UM	3/7/98  
		Added check for environment variables 
			EXTRACT_CONFIG, and EXTRACT_PAR
	Tim McKay	UM 	4/27/98
		Altered from rextract_setup 

(See /host/bluemoon/usr2/idllib/sdss/allpro/rdis_setup.pro)


RDIS_ZOOM

[Previous Routine] [Next Routine] [List of Routines]
 Name:
	rdis_zoom
 Purpose:
	Allows zooming in rdis

 Calling sequence:
	rdis_zoom, image, xmin, xmax, ymin, ymax

 Inputs:
	Points selected by user using cursor

 Optional output arrays:


 Revision history:
	Andrew Waltman   UM   5/1/98


(See /host/bluemoon/usr2/idllib/sdss/allpro/rdis_zoom.pro)


RDYANNY

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

 NAME:
    RDYANNY
       
 PURPOSE:
    Read in a minimal Brian Yanny parameter file.  The file must have only 
    one structure definition and one set of data.  

  For more info:  http://www-sdss.fnal.gov:8000/dervish/doc/www/tclP2c.html

 CALLING SEQUENCE:
     rdyanny, file, struct

 INPUTS: 
    file:  The full path filename to the Yanny parameter file.

 OPTIONAL INPUTS:
    None.

 KEYWORD PARAMETERS:
    None.
       
 OUTPUTS: 
    struct: An array of structures.  The structure has a tag for each 
            parameter in the typedef statement at the top of the file.

 OPTIONAL OUTPUTS:
    None.

 CALLED ROUTINES:
    READCOL
 
 PROCEDURE: 
    Figure out the tags from the typedef statement.  Then define a structure
    with these tags.  Read in the data and make an array of the structures, 
    one element for each line of the file.
	

 REVISION HISTORY:
    Author: Erin Scott Sheldon  11/19/99   UofMich
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/rdyanny.pro)


READ_ASTRANS

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

 NAME:
    READ_ASTRANS
       
 PURPOSE:
    Read from an asTrans astrometry transformation file for 
    given run, camcol, and bandpass. Can be used to 
    transform between (row,col), or CCD coordinates, and (mu,nu),
    or great circle coords.

 CALLING SEQUENCE:
    

 INPUTS: 
    read_astrans, run, camcol, clr [, trans, node, inc]

 OPTIONAL INPUTS:
    NONE

 KEYWORD PARAMETERS:
    NONE
       
 OUTPUTS: 
    NONE

 OPTIONAL OUTPUTS:
    trans: The astrometry structure.
    node: The node position of this stripe. 
    inc: Inclination of this stripe. 
       node and inc required by rowcol2munu.pro, and gc2eq.pro or gc2survey.pro

 CALLED ROUTINES:
    FETCH_DIR
    HEADFITS
    MRDFITS
 
 PROCEDURE: 
    asTrans files conain info for each camcol/field/bandpass for a given
    column.  The different camcol/bandpasses are in different 
    extensions.  See http://www-sdss.fnal.gov:8000/dm/flatFiles/asTrans.html
    for details.
	

 REVISION HISTORY:
    Created: 23-OCT-2000 Erin Scott Sheldon
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/read_astrans.pro)


READ_PHOTO_COL

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


 PURPOSE:
     Reads part of a column of SDSS data into one big struct.  

 NOTES: 
    objc_rowc is made continuous from the first field rather than 
    artificially restarting at the beginning of each field.  This can be 
    easily removed by setting /noadd.  rowc[i] are not altered.   

 CALLING SEQUENCE: 
     read_photo_col, filename, struct, start=start, nframes=nframes,
     taglist=taglist, phototags=phototags, addrow=addrow,
     struct_type=struct_type, noadd=noadd, verbose=verbose

 INPUTS:  
    filename: The full path of the photo output fits file (tsObj file)

 OPTIONAL INPUTS:

          start:    Frame to start at relative to the first (does not start
                    at zero.)
          all:      /all to read in all fields.
          nframes:  Optional parameter which tells how many frames to read
                    from filename. NOTE: Default is 50 frames
          maxf:     the maximum number of fields which can be read from file.
                    This is useful if the tag 'nfields' is not in the 
                    structure header. 
                    Although READ_PHOTO_COL can find this number with 
                    FITS_INFO, that is a slow process.
          taglist:  A list of photo tags in all CAPS that the user wants
                    in struct. The default is to call the subroutine
                    make_default_tags.pro
          phototags: The user may provide the list of ALLOWED photo tags
                     in all CAPS.  Usually gotten from struct.
          addrow:   Optional parameter which tells how many rows the user
                    wants to add to objc_rowc (That tag must be in taglist)
                    This may be necessary if there is more that one file
                    for each column.
	   struct_type: The user may specify a _different_ name for the
			structure to be read in, if the file for example
			does not contain default photo information
          noadd:    usr /noadd if you don't want to add up 
                       objc_rowc continuously.
          verbose: Verbosity level. Default is verbose > 1 full.
                       verbose = 0    print only error messages
                       verbose = 1    print minimun of messages
                       verbose > 1    print all messages.  Includes the 
                                      field by field updates.

 OUTPUTS: 
    struct:  The new photo structure.

 CALLED ROUTINES:  
    MAKE_DEFAULT_TAGS
    MAKE_TAGS
    MAKE_STRUCT
    TAG_TYPE
    MRDFITS3

 EXAMPLES:

  Read in 50 frames of data and store it in struct.  run 109, camcol 3

 IDL> file='tsObj-000109-3-0-0011.fit'
 IDL> read_photo_col, file, struct

  Read in a 20 frames beginning with frame 33

 IDL> read_photo_col, file, struct, start=33, nframes=20

 Author:  Erin Scott Sheldon
 Date: 10/7/98
 Modified: 11/20/98  Rewrote addrow stuff.  E.S.S.
           11/23/98  Added start keyword.   E.S.S.
           01/12/99  Added run, camcol, field as required 
                     parameters.  Note these are not tags but are read from 
                     the header. E.S.S.
	    01/19/99  Added the struct_type argument, Tim McKay
           03/21/99  Added (i gt start) and (i lt n_ext) to the 
                     call to where  E.S.S.
	    6/25/99   Added two systems variables needed for 
			when you don't give it n_frames
				'!TEXTOUT'  '!TEXTUNIT'	  
			Dave Johnston  (U Chicago) 
	    6/26/99  Replaced mrdfits2 with mrdfits3. This has the 
		     	keyword deja_vu which allows one to use common
			blocks so that one can remember variables that
			one has already made when the program was called
			before.	This speeds it up considerably.
					Dave Johnston

	   6/26/99  Changed the way that read_photo_col concatonates
			the individual structures from each field into
			the output structure struct. Now it uses pointers
			for each individual struct and keeps and array
			of pointers. Then in the end it makes the big
			output struct and copies everything in.
			This also helps with speed.
				Dave Johnston	
	   6/26/99   Added default nframes=50 and prints time.
                    Added verbose.
          10/8/99   Added /all, maxf=maxf keywords E.S.S.
						

(See /host/bluemoon/usr2/idllib/sdss/allpro/read_photo_col.pro)


READ_TSOBJ

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

 PURPOSE:
    Reads in a column of SDSS data into one big struct.  
    A rewritten version of read_photo_col 
    that reads the newer individually wrapped tsObj files 	

    Notes:
      1) You do not need to put run,rerun,camcol,field in your taglist.  
         These are
         added in automatically by read_tsobj as the minimal tags. 
      2) objc_rowc is made continuous from the first field rather than 
         artificially restarting at the beginning of each field.  This can be 
         easily removed by setting /noadd.  rowc[i] are not altered.  
 
 CALLING SEQUENCE: 
     read_tsobj, dir, struct, start=start, nframes=nframes, all=all, 
               taglist=taglist, phototags=phototags, everytag=everytag, 
               noadd=noadd, 
               nomodrow=nomodrow, 
               front=front, nchar=nchar, tsobjstr=tsobjstr, 
               struct_type=struct_type, verbose=verbose

 
 INPUTS:  
    dir: The full directory where the photo output fits 
         files (tsObj files) live

 OPTIONAL INPUTS:

          start:     Field to start with.  Default is first field.
          nframes:   Optional parameter which tells how many frames to read
                     from filename. Default is 1
          /all:      if set then all fields will be read
          taglist:   A list of photo tags that the user wants
                     in struct. The default is to call the subroutine
                     make_default_tags.pro
          phototags: The user may provide the list of ALLOWED photo tags
                     in all CAPS.  Usually gotten from struct.
          /everytag: If /everytag, then all tags are retrieved.  The tags will 
                     be returned in taglist.
          /nomodrow: don't check for overlap region.  Handy if you are 
                     reading your own files where this has already been done
                     or if you want everything.
          /noadd:    set this keyword if you don't want to add up 
                     objc_rowc continuously.
	   struct_type: The user may specify a _different_ name for the
			structure to be read in, if the file for example
			does not contain default photo information

          front:  The front string in the filename.  Default is "tsObj"
          nchar:  The number of characters in the name.  
                  Default is 25 for tsObj files.
          tsobjstr: info structure to save time on consecutive calls
                    contains tag info and default structure.  If not entered
                    will be set and returned in keyword.  This can then
                    be fed into program and save time.
                    Contains: (1) good tags form first call
                              (2) indices of those tags
                              (3) the tsObj structure used. Saves time because
                                  don't have to read in a field to establish
                                  structure definition.
          verbose: Verbosity level. Default is verbose > 1, full.
                       verbose = 0    print only error messages
                       verbose = 1    print minimun of messages
                       verbose > 1    print all messages.  Includes the 
                                      field by field updates.
	   ex_struct:  This is for adding extra tags onto the output structure.
			These will be left blank so that you can fill them in later.
			The exception is "SEEING" which will be conveniently filled in
			from the header information.
			If tsobjstr is created by read_tsobj then these
			extra tags will be included in the tsobjstr.struct
			for use next time around
			Example:
			IDL> ex={seeing:fltarr(5),probability:0.0,redshift:0.0}
			IDL> read_tsObj, dir, struct, start=13, nframes=100 ,ex_struct=ex
	
	   wstring:   This is a string that you can give to read_tsobj that 
		      contains the "where" function being appied to "lnew"
		      (which is the name of the tsobj structure at each 
		      iteration over fields inside the program).  It is executed to make
		      a cut before it concatonates into the big output structure.
		      This can be used to cut down on memory and execution time
		      if one wants to make a severe cut on the data.
		      Example: (for getting only bright objects)
			IDL>  wstr="where(lnew.counts_model(2) lt 20.0)"
			IDL>  read_tsObj, dir, struct, start=13, nframes=100 ,wstring=wstr	
		      				

 OUTPUTS: struct:   The structure we read into.

 Called Routines:  make_default_tags.pro
                   make_tags.pro
                   make_struct.pro
                   tag_type.pro
		    fetch_file_list.pro

 Examples:

  Read part of a column of data and store it in one struct.  
       run 273, camcol 2 rerun 1 

 IDL> dir='/usr/sdss/data02/imaging/273/1/calibChunks/2/'
 IDL> read_tsObj, dir, struct, start=13, nframes=100

 
 Author:  Erin Scott Sheldon
 Date: 10/7/98
 Modified: 11/20/98  Comment:  Rewrote addrow stuff.
           11/23/98  Comment:  Added start keyword.
           01/12/99  Comment:  Added run, camcol, field as required 
                               parameters.  Note these are not tags but
                               are read from the header.
	    01/19/99  Comment:  Added the struct_type argument, Tim McKay
           03/21/99  Comment:  Added (i gt start) and (i lt n_ext) 
                               to where. (line 159) Erin S. Sheldon
	    6/25/99   Added two systems variables needed for 
			when you don't give it n_frames
				'!TEXTOUT'  '!TEXTUNIT'	  
			Dave Johnston  (U Chicago) 
	    6/26/99  Replaced mrdfits2 with mrdfits3. This has the 
		     	keyword deja_vu which allows one to use common
			blocks so that one can remember variables that
			one has already made when the program was called
			before.	This speeds it up considerably.
					Dave Johnston

	    6/26/99  Changed the way that read_photo_col concatonates
			the individual structures from each field into
			the output structure struct. Now it uses pointers
			for each individual struct and keeps and array
			of pointers. Then in the end it makes the big
			output struct and copies everything in.
			This also helps with speed.
				Dave Johnston	
	    6/26/99   Added default nframes=50 and prints time
						
	    Oct/9/99  Adapted from read_photo_col to make read_tsObj
		Now it reads the new format. These new files are
		individually wrapped by field rather than one column
		being a file.	
           11/13/99 Added "front" and "nchar" inputs.  E.S.S.
           05/03/00 Added tsobjstr, everytag keywords.  Also, no longer
               requires all caps in taglist, and the user can enter
               run,rerun,camcol,field,id
	    10/9/00  Fixed so that it handles "empty" tsobj files
			by skipping over them.  Uses modified version 
			of mrdfits3 which returns 0 for these files  
		     Added wstring keyword so one can apply a cut inside of read_tsobj
			saves memory and time when one is just interested
			in a small subset of the data
		     Added ex_struct keyword  ,one can add on new tags of any type
			by including this extra structure.  It will be included
			in tsobjstr so that it "knows" next time.	
		     If ex_struct or tsobjstr includes the "SEEING" tag
			it will fill it in with the seeing from the header
			which is one number per band per field		
					David Johnston			

(See /host/bluemoon/usr2/idllib/sdss/allpro/read_tsobj.pro)


READ_TSOBJ_MAKE_STRUCT

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

 NAME: 
    READ_TSOBJ_MAKE_STRUCT

 PURPOSE:
   Creates a structure with the user's input parameters.

 CALLING SEQUENCE:
    read_tsobj_make_struct, tags, indices, bigstruct, str

 INPUTS: 
   tags: The tags to be put into the structure str
   indices: the index for each tag in bigstruct 
   bigstruct: the structure from which the new struct
      is to be created.

 Outputs: str: A structure with the users tags in it

 COMMENTS: 
   run,rerun,camcol,field  should not be in tags, as they
      are automatically put into the structure.

 Author:  Erin Scott Sheldon
 Date: 10/7/98
 Modified:  01/12/99  Comment: Made field, camcol, run required 
                               parameters.

(See /host/bluemoon/usr2/idllib/sdss/allpro/read_tsobj_make_struct.pro)


READ_TSOBJ_MAKE_TAGS

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

 NAME:
    READ_TSOBJ_MAKE_TAGS

 PURPOSE:
   Finds all input tags that match with photo tags and puts them into goodtags

 CALLING SEQUENCE:
   read_tsobj_make_tags, taglist, phototags, goodtags, indices

 INPUTS:  
   taglist:  The user input tags.
   phototags: The allowed photo tags

 OUTPUTS: 
   goodtags: Those of the input tags which match to photo tags
   indices: The indices corresponding to the proper photo tags

 Author:  Erin Scott Sheldon
 Date: 10/7/98
 Modified: 11/20/98  Comment:  Corrected erroneous error message. E.S.S.
           05/03/00  Comment:  Rewrote entirely.

(See /host/bluemoon/usr2/idllib/sdss/allpro/read_tsobj_make_tags.pro)


REMOVE_TAGS

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

 NAME:
    REMOVE_TAGS
       
 PURPOSE:
    remove the specified tags from input structure

 CALLING SEQUENCE:
    remove_tags, oldstruct, tagnames, newstruct

 INPUTS: 
    oldstruct: the original structure
    tagnames: the names of tags to be removed (can be an array)

 OPTIONAL INPUTS:
    NONE.

 KEYWORD PARAMETERS:
    NONE.
       
 OUTPUTS: 
    newstruct: the new structure without tags.

 OPTIONAL OUTPUTS:
    NONE

 CALLED ROUTINES:
    
 
 PROCEDURE: 
    
	

 REVISION HISTORY:
    ????? Judith Racusin
    25-OCT-2000 Modified to handle arbitrary tag types. Also error 
          handling. Erin Scott Sheldon
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/remove_tags.pro)


REXTRACT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       REXTRACT
 PURPOSE:
	Run sextractor on an image using the parameters passed in param_struct

 CALLING SEQUENCE:
       rextract, param_struct, filename

 INPUTS:
	param_struct: a structure containing all the parameters needed
		      to run sextractor
	filename: image to be processed
       
 OUTPUTS:
	

 OPTIONAL OUTPUT ARRAYS:

 INPUT KEYWORD PARAMETERS:
 
 PROCEDURE: This processes an image on disk using the parameters provided.
	

 REVISION HISTORY:
	Tim McKay	UM	1/8/98
	Tim McKay	UM	3/7/98  
		Added check for environment variables 
			EXTRACT_BIN, and EXTRACT_PAR
	Tim McKay	UM	11/3/98
		Altered for proper use of sextractor 2.0.15

(See /host/bluemoon/usr2/idllib/sdss/allpro/rextract.pro)


REXTRACT_SETUP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       REXTRACT_SETUP
 PURPOSE:
	Set up a parameter structure for sextractor operation

 CALLING SEQUENCE:
       rextract_setup

 INPUTS:
       
 OUTPUTS:
	param_struct: a structure containing all the parameters needed
		      to run sextractor

 OPTIONAL OUTPUT ARRAYS:

 INPUT KEYWORD PARAMETERS:
 
 PROCEDURE: This just reads in the formatted information from the CV file
	

 REVISION HISTORY:
	Tim McKay	UM	1/8/98
	Tim McKay	UM	3/7/98  
		Added check for environment variables 
			EXTRACT_CONFIG, and EXTRACT_PAR

(See /host/bluemoon/usr2/idllib/sdss/allpro/ctio_extract_setup.pro)


RGBVIEW

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

 NAME:
    RGBVIEW
       
 PURPOSE:
    Create and display a RGB image from red, green, and blue input images.

    SDSS should use red=i, grn=r, blue=g although this will have false
    color.  The result is similar to Steve Kent's images.
    If the device is postscript, then a color postscript is made.
    NOTE: The color map is NOT inverted so there is often large amounts
          of black space.

    Works best on displays with 16 million+ colors.
    At the least the program requires 256 colors to display properly.  
    To insure the you get all the colors, you can request a private color map.  
    This is done when the first window is opened.  You must use this command:
         IDL> window, colors=256

    It won't work except on the first window so you might consider putting
    it in your .idl.startup file.  Note that using a private color map
    may cause "flashing" when you point in the window.

    Also note that the number of colors on your display does not affect
    the optional jpeg/gif files that RGBVIEW outputs because it uses full
    color range when producing them.

    WARNING: this program can use lots of memory. It makes 
    2 copies of each image for speed: one that converted to float and
    sky subtracted and then yet another that is scaled. If your images
    are already sky-subtracted and float then you should modify this program
    so it doesn't make 1 of the extra copies.

 CALLING SEQUENCE:
     rgbview4, rimage, gimage, bimage, sdss=sdss, 
             gamma=gamma, saturation=saturation, 
             contrast=contrast, low_cut=low_cut, 
             nodisplay=nodisplay, 
             jpegfile=jpegfile, giffile=giffile, 
             rsig=rsig, gsig=gsig, bsig=bsig, 
             rsky=rsky, gsky=gsky, bsky=bsky, 
             rmap=rmap, gmap=gmap, bmap=bmap, 
             color_im=color_im, ar=ar, ag=ag, ab=ab, imtot=imtot, 
             xrange=xrange, yrange=yrange, noprompt=noprompt, $
             title=title, xtitle=xtitle, ytitle=ytitle, subtitle=subtitle, 
             noframe=noframe, nolabels=nolabels, 
             _extra=extra_key

 INPUTS: 
    red, grn, blue: The red, green and blue images.  Images must be same size.

 OPTIONAL INPUTS:
    gamma: gamma value.  typical values are 1.5-2.5, default is 2.5.  
           rescales images to (image)^(1./gamma) to bring out low surface
           brightness features.
    saturation: color saturation. Bring out the red and blue by scaling 
                images: red = red * (red/green)^(saturation)
                        blue = blue * (blue/green)^(saturation)
           default value is zero.  Be careful with this, it only works 
           well for very high S/N images, and tends to make things
           look a little unrealistic (see Frei and Gunn..)
    contrast:  The number of sigma above the mean to use in images.
            The default is 15 but good results depend on the image.
            For example, a really bright galaxy will require contrast
            to be set _many_ sigma above mean.
            You will be prompted for a change in contrast unless /noprompt
            is set (good for batch processing)
    low_cut: Lowest value in image to use in # of sigma above mean.  Images
            are sky subtracted, so this number should be greater than zero.
            Default is 0.7sigma
    jpegfile: If a string is sent in this keyword, rgbview will write a 
          jpeg file containing the image with this filename.  If you have
          8-bit display, then this is better than
          the display because it is compressed 24-bit. This file is
             created directly from the images, so no axes or labels will 
             appear.  To save axes, read from the screen: 
             write_gif, file, tvrd(), rmap, gmap, bmap
    giffile: same as above except writes gif (8-bit) image file.  This is
             created directly from the images, not read from the screen, so 
             no axes or labels will appear.  
    rsig, gsig, bsig, : input value for sky noise in r image. Saves time by 
          avoiding sigma-clipping the images.  If not input, these values
          can be returned through these keywords.
    rsky, gsky, bsky: input sky value of r,g,b images.  Avoides running 
          sigma-clipping to find sky.  If not input, these values
          can be returned through these keywords.
    xrange, yrange, noframe, nolabels: see tvim2
    title,xtitle,ytitle,subtitle: Plot labels.
    _extra=extra_key:  Other plotting keywords.

 KEYWORD PARAMETERS:
    sdss: if set, rescales images by energy based on sdss filters.  Doesn't
       always result in better _looking_ images.
    nodisplay: if set, no display is made.  You might use this if you are
          just outputting the jpeg files, maybe in a batch job if used in
          conjunction with /noprompt
    noprompt: if set then don't ask for a change of contrast, etc
       
 OPTIONAL OUTPUTS: 
    rmap,gmap,bmap: color map vectors.  These are the vectors used to display 
           this image.  If using an 8-bit display, they can be sent to 

                IDL> WRITE_GIF, filename, TVRD(), rmap, gmap, bmap
           
           If on 8-bit display, you might need to go back to BW linear display.
           The color map can be reset to BW linear with loadct,0
 
    color_im: a byte 2-d image containing the image used for display with the 
        color maps above.
    ar, ag, ab: red, green, blue byte scaled images used to make full 24-bit
         image (as used to output jpeg images)
    imtot: image containing ar, ag, ab in the form bytarr(3, n, m).  Can be 
         input directly to write_jpeg to produce 24-bit image.
  
 CALLED ROUTINES: (lower case are built in IDL procedures)
    DCENTER
    SIGMA_CLIP
    color_quan
    bytscl
    tv
    tvlct
    (device)
    (write_gif)
    (write_jpeg)

 PROCEDURE: 
    

 REVISION HISTORY:
    Author: Erin Scott Sheldon  UofMich  11/28/99
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/rgbview.pro)


RMDEGEN

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

 NAME: 
    RMDEGEN
       
 PURPOSE: 
    remove the denerate values from an array.  Return an array
    or indices containing only 1 of each value in array.
    THIS PROGRAM IS SLOW.  Use rem_dup of idlastron library.

 CALLING SEQUENCE: 
    rmdegen, array, outarr,indices=indices             

 INPUTS: 
    array of any type

 OPTIONAL OUTPUTS: 
     outarr: an array containing 
     indices: indices of that would be in outarr elements.  Can save
              memory using this option
 
 KEYWORD PARAMETERS: 
    /nonew:  don't make a new array, just find the indices.


 REVISION HISTORY:
	Erin Scott Sheldon  UofM  6/15/99
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/rmdegen.pro)


ROWCOL2MUNU

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

 NAME:
   ROWCOL2MUNU 
       
 PURPOSE:
    convert from row-column to great circle coordinates (mu,nu)

 CALLING SEQUENCE:
    rowcol2munu, trans, field, row, col, mu, nu, ri=ri

 INPUTS: 
    trans: the astrans file for this run,camcol,bandpass. Use 
          READ_ASTRANS to get the astrans file.
    field: the field
    row,col: the row,column to be converted to mu,nu

 OPTIONAL INPUTS:
    ri: the r-i color of the objects. Only necessary for objects
         with r-i > trans.ricut

 OUTPUTS: 
    mu,nu: SDSS great circle coords.

 PROCEDURE: 
    
	

 REVISION HISTORY:
    14-NOV-2000 Creation.  Erin Scott Sheldon UofMich
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/rowcol2munu.pro)


RUN2STRING

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

 NAME: 
    RUN2STRING
       
 PURPOSE: 
    Function outputs a string containing run of a photo tsObj 
    file in the correct format.
	

 CALLING SEQUENCE: 
    result = run2string(run)
      
 INPUTS: 
    run in integer form
       
 OUTPUTS: 
    run string or '' if error.
 
 PROCEDURE: 
    run should have 6 characters padded with zero's if its
    not big enough.  e.g. if input 33, output is '000033'
	
 REVISION HISTORY:
     Authro: Erin Scott Sheldon  Umich 5/25/99
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/run2string.pro)


SAO

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

 PURPOSE:
    Call saoimage externally.  You should modify this if your saoimage
    is not aliased to sao

(See /host/bluemoon/usr2/idllib/sdss/allpro/sao.pro)


SDSSIDL_SETUP

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

 NAME:
    SDSSIDL_SETUP
       
 PURPOSE:
    Define system variables used by sdssidl procedures.

 CALLING SEQUENCE:
    sdssidl_setup

 INPUTS: 
    None.

 OPTIONAL INPUTS:
    None.

 KEYWORD PARAMETERS:
    /silent: If set then only print error messages.
       
 OUTPUTS: 
    None.

 OPTIONAL OUTPUTS:
    None.

 CALLED ROUTINES:
    DEFSYSV
 
 PROCEDURE: 
    Defines !SDSSIDL_DEF, which has a tag for each sdssidl system
        variable. Tag will be 1 if defined or 0 if not defined.
    Sets the file name of the shared object file used in GET_ATLAS.
                          !SOFILE
    Sets the entry name for shared object file.
                          !ENTRY
    Sets base directory for sloan data archives.
	                   !SDSS_DATA_DIR
    Sets base directory for shape corrected data archives
                          !SDSS_SHAPECORR_DIR
    Sets base directory for Ra-Dec search files.
                          !RADEC_SEARCH_DIR
    Sets searchable runs:  Those on which FIELD_RANGE.PRO has been run.
                          !SEARCH_RUNS
                          an array of integers, e.g. [259, 752]
    Sets !RUN_STATUS_FILE, the file that contains !RUN_STATUS struct.
    Sets !RUN_STATUS structure, containing info on known stripes
    and the runs/reruns contained therein. Also has flags set concerning
    possible problems.

 REVISION HISTORY:
    Author: Erin Scott Sheldon  UofMich 11/18/99  
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/sdssidl_setup.pro)


SDSS_EXTRACT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
    SDSS_EXTRACT
 PURPOSE:

    Applies a user defined extraction function to an SDSS column....
  
 INPUTS:  
    filename: name of input fits file
    ofilename: output fits file (will overwrite existing file)
    command_name: command to use for extraction
		This MUST take as arguments
			list (input)
			index (output)
		It should return -1 in the index if nothing passes.
    taglist:  A list of photo tags in all CAPS that the user wants
                    in struct
    nframes:  Optional parameter which tells how many frames to read
                    from filename
    start:    Beginning fram
    max_mag: maximum magnitude to use (default=20)
    sig_clip: Number of sigma for clipping large radius objects (default=3)
    addrow:   Optional parameter which tells how many rows the user
                    wants to add to objc_rowc (That tag must be in taglist)
    groupn: How many frames to take together
 Outputs: fits file containing stars

 Author:  Phil Fischer
 Date: 1/14/9
	
 Modified: Tim McKay
 Date: 5/6/99

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(See /host/bluemoon/usr2/idllib/sdss/allpro/sdss_extract.pro)


SEARCH_COLOR_SPACE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	search_color_space
PURPOSE:
	For taking an sdss catalog and selecting objects of desired	
	colors,magnitude and size. Does this by plotting four plots.
	u-g versus g-r
	g-r versus r-i
	r-i versus i-z
	r versus petrorad(in r color) 
	Then it prompts you to draw a closed curve on all four plots.
	Then it makes a structure with this information stored in it.	
	The structure and a photo catalog can be handed to make_color_flag
	which will then flag each objects with a number 0 to 15
	ie. it will set each of four bits depending on whether the object
	was in each one of the four regions selected. So an object with
	flag =15 was inside of all closed curves drawn.
	This structure can be saved as a binary table and used later for doing
	NON-interactive selections. For example one could define the stellar
	locus once and save it to use again another day.
	

CALLING SEQUENCE:
	-syntax search_color_space,cat,str,qso=qso,
	        all=all,psf=psf,petro=petro,qsofile=qsofile,
	        hist=hist,radrange=radrange

INPUTS:
	cat : the sdss photo-output structure
	
OUTPUTS:
	str : the structure containing your selected regions
	      and the transformation parameters to map
	      the data onto this array. This is used by 
	      make_color_flag.				

KEYWORDS:
	all : if set will use all objects not just stars
	psf : if set will use psfcounts rather than fibercounts
	petro : if set will use petrocounts rather than fobercounts
	qso : if set will over plot known quasars to aid selection
		of quasars	
	qfile : fits binary file of a certain format
		will try default file if this is not given
		quasars from (G. Richards and D. Schneider)
	hist : if set it will use 2D histograms instead of scatter plots
		 (see  "ploth" procedure)
	radrange : the range to use on petrorad default=[0,6]
	_extra=ex : extra keywords handed to ploth or plot

EXTERNAL CALLS:
	extract_stars : called if all is NOT set
	ploth : if hist is set
	mrdfits : if overplotting quasars
	exist
	
METHOD:
	uses IDL function defroi (Define Region Of Interest)
	to make an array having four regions
	the first set to 2^0=1 the second set to 2^1=2 the third 2^2=4
	and the fourth 2^3=8. All other are set to 0.
	The parameters for the linear transformation
	from data to device coordinated are all saved with this array in 
	the structure str. So later one can map a star or galaxy onto this 
	array and read its pixlel. It will map onto four pixles 
	since it has four pairs of data points and these can be summed
	to give it a flag 0 to 15 indicating uniquely whether it is in 
	each of the regions of interest. Most often people will
	use this with "select_colors" wrapper which just outputs the 
	index of objects flagging to 15 (ie. they are in all regions) 
	but this program is slightly more general.	
	
EXAMPLE
	see select_colors
NOTES
DO NOT CHANGE THE WINDOW SIZE
it must remain [640,640] for defroi to work

HISTORY:  written by David Johnston -University of Chicago
	Physics Department 1999

(See /host/bluemoon/usr2/idllib/sdss/allpro/search_color_space.pro)


SELECT_COLORS

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

PURPOSE:
	An interactive tool for selection sdss objects based on their
	colors ,  magnitudes and size. It will make the following four plots:
	u-g versus g-r
	g-r versus r-i
	r-i versus i-z
	r versus petrorad(in r color) 
	Then it prompts you to draw an arbitrary closed curve on all 
	four plots. From these curves it selects the objects having
	parameters contained in all four regions and outputs their index.
		
CALLING SEQUENCE:
   -syntax select_colors,cat,index,str,stars=stars,qso=qso
	qfile=qsofile,hist=hist,radrange=radrange,psf=psf,petro=petro

INPUTS:
	cat : the sdss photo-output structure
	
OUTPUTS:
	index : the index of selected points
	str : the structure that is made by search_color_space
		and given to make_color_fLag
		can be saved as a fits binary table for later use
		(see those two programs for details)
	
KEYWORDS:
	stars : if set will dispay only stars 
	        (so one can see the locus better)
	qso : if set will overplot known quasar colors (to aid 
		selection of quasars)
	qfile : fits binary file of known quasar colors
                 if not given will try the default file		
	hist : if set it will use 2D histograms rather than scatter plots.
		Aids visualization when many objects are plotted and is faster
		when there are many thousands to plot.
	radrange : the range on petrorad , the default is [0,6]
	psf : if set it will use psfcounts instead of fibercounts
	petro  : if set it will use petrocounts instead of fibercounts
	_extra=ex : extra keywords eventually handed to ploth or plot 

EXTERNAL CALLS:
	search_color_space
	make_color_flag
	
METHOD:
	uses IDL function defroi (Define Region Of Interest)
	explained in search_color_space
	and make_color_flag
	
EXAMPLE OF USES:
	defining the stellar locus
	selecting objects with quasar colors
	star galaxy seperation
	looking for interesting objects
	make multiple selections like so:

	IDL> select_colors,cat,stellar
	IDL> select_colors,cat(stellar),qsocolor

	IDL> qsoindex=stellar(qsocolor)
   we have indexed the index so that cat(qsoindex) are indeed the
   selected quasars 		
	
	
NOTES

HISTORY:  written by David Johnston -University of Chicago
	Physics Department 1999

(See /host/bluemoon/usr2/idllib/sdss/allpro/select_colors.pro)


SIGMA_CLIP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
    SIGMA_CLIP
 PURPOSE:
    a simple sigma clipping algoritm

(See /host/bluemoon/usr2/idllib/sdss/allpro/sigma_clip.pro)


SIMPCTABLE

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

 NAME:
    SIMPCTABLE
       
 PURPOSE:
    Create and load a simple 8-color color table

 CALLING SEQUENCE:
    simpctable, red_ct, green_ct, blue_ct, help=help

 SIDE EFFECTS: Loads new color table. Sets these system variables:

       !black = 0
       !white = 1
       !red = 2
       !green = 3
       !blue = 4
       !yellow = 5
       !lightblue = 6 
       !magenta = 7

     These can be sent to plotting procedures

 INPUTS: 
    None

 OPTIONAL INPUTS:
    None

 KEYWORD PARAMETERS:
    /help: if set, a help message is printed showing the values of 
           the system variables set by SIMPCTABLE
       
 OUTPUTS: 
    None

 OPTIONAL OUTPUTS:
     red_ct, green_ct, blue_ct: The red, green, and blue color arrays
     Useful for writing gif files from the plotting window.
 CALLED ROUTINES:
    TVLCT
 
 EXAMPLE:
    IDL> simpctable, rd, gr, bl
    IDL> plot, [0], /nodata, yrange=[-1.2,1.2],xrange=[0,2.*!pi], $
    IDL>    color=!black, background=!white, xstyle=1
    IDL> x = findgen(300)/299.*2.*!pi
    IDL> y = sin(x) + randomn(seed,300)/5.
    IDL> oplot, x, y, color=!blue
    IDL> oplot, x, sin(x), color=!red
    
	

 REVISION HISTORY:
    Written May 09 2000, Erin Scott Sheldon, U. of Michigan
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/simpctable.pro)


SKYFUNCTION

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

 PURPORSE:
       This function estimates the shape of the sky, and is used in
       the ircamImage object. Designed to be used in the standard IDL
       routine curvefit.

 MODIFICATION HISTORY:
       Written by:     Eric H. Neilsen, Jr. October 10, 2000
       based heavily on Eric Deutsch's cloudskyfn

(See /host/bluemoon/usr2/idllib/sdss/allpro/ircamimage__define.pro)


STATUS_SELECT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
   STATUS_SELECT
 PURPOSE:
   Makes cuts based on status structure. These cuts are strictly "anded" 
   together, so they must all be true for the object to survive.
 
 INPUTS:  pstruct: a photo output structure (must have .flags tag...)
          status_struct: Premade status structure. This will require any
               flags set to 'Y' and insist that any flag set to 'N' be
               off
          input_index: you can input an index, from an earlier selection
               for instance. If this has size(input_index)(0)=0 then
               the returned selection index will be -1

 OUTPUTS: select_index: indices of selected objects....

 Author:  Ryan Scranton
 Date: 11/4/99
 Modified from Tim McKay's flag_select.pro

(See /host/bluemoon/usr2/idllib/sdss/allpro/status_select.pro)


SURVEY2EQ

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

 NAME:
    SURVEY2EQ
       
 PURPOSE:
    Convert from lambda, eta (SDSS survey coordinates) to ra, dec

 CALLING SEQUENCE:
    survey2eq, lambda, eta, ra, dec

 INPUTS: 
    lambda: Survey longitude in degrees
    eta: Survey latitude in degrees

 OPTIONAL INPUTS:
    None

 KEYWORD PARAMETERS:
    None
       
 OUTPUTS: 
    ra: Equatorial latitude in degrees
    dec: Equatorial longitude in degrees

 OPTIONAL OUTPUTS:
    None

 CALLED ROUTINES:
    ATBOUND
    ATBOUND2
 
 PROCEDURE: 
    
	

 REVISION HISTORY:
    Written: 5/15/2000  Erin Scott Sheldon
                        Taken from astrotools.
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/survey2eq.pro)


TAG_TYPE

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

 NAME:
    TAG_TYPE

 PURPOSE:
   Finds the type of an input tag

 INPUTS: 
   tag: an input tag

 OUTPUTS: 
   t: the type of the tag

 Author: Erin Scott Sheldon
 Date: 10/7/98

(See /host/bluemoon/usr2/idllib/sdss/allpro/tag_type.pro)


TMPFILE

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

  CALLING SEQUENCE:
	s = tmpfile(prefix=prefix, suffix=suffix)

	Returns a unique filename for scratch use.
	Ex:  myfile = tmpfile(prefix='/tmp/', suffix='.tmp')

(See /host/bluemoon/usr2/idllib/sdss/allpro/tmpfile.pro)


TSFLAG_SELECT

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

 NAME:
    TSFLAG_SELECT
 PURPOSE:
    Makes cuts based on flag structure. These cuts are strictly "anded" 
    together, so they must all be true for the object to survive.
 
 CALLING SEQUENCE:
    tsflag_select, pstruct, flag_struct, select_index

 Inputs:  pstruct: a photo output structure (must have primtarget, sectarget 
          tags...)
	   flag_struct: Premade flag structure. This will require any
		flags set to 'Y' and insist that any flag set to 'N' be
		off

 Outputs: select_index: indices of selected objects....

 Author:  Sarah Monk, modified from flag_select by Tim McKay
 Date: 5/8/00

(See /host/bluemoon/usr2/idllib/sdss/allpro/tsflag_select.pro)


TSOBJ_NAME

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

 NAME: 
    TSOBJ_NAME
       
 PURPOSE: 
    ouputs the filename for a photo tsObj file for the given input 
    parameters
	

 CALLING SEQUENCE: 
    name=tsobj_name(run, camcol, rerun, field)

 INPUTS: 
    run:  the photo run in integer form
    camcol: the photo camera ccd column in integer form.
    rerun: rerun number 
    field: field number

 INPUT KEYWORD PARAMETERS:
    None.
       
 OUTPUTS: 
    tsObj file name.


 CALLED ROUTINES:
                   RUN2STRING
                   FIELD2STRING
 
 PROCEDURE: 
	files have form: tsObj-run-camcol-rerun-field.fit

       run in six characters padded with zeroes.
       field in 4 characters padded with zeroes.

 REVISION HISTORY:
	Author: Erin Scott Sheldon  Umich 5/25/99
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/tsobj_name.pro)


TVIM2

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

 USEAGE:   tvim2,a

           tvim2,a,title=title,xtitle=xtitle,ytitle=ytitle,$
                              xrange=xrange,yrange=yrange,subtitle=subtitle,$
                              scale=scale,range=range,noframe=noframe,aspect

 PURPOSE:  Display an image with provisions for
               
            1. numbered color scale 
            2. plot title
            3. annotated x and y axis 
            4. simplified OPLOT capability

 INPUT    a           image quantity

 Optional keyword input:

	   **NOTE**: This routine now uses the _extra mechanism to pass
		     keywords for put_clr_scl2.

          title       plot title

          xtitle      x axis title
 
          ytitle      y axis title

	   subtitle    x axis subtitle

          xrange      array spanning entire x axis range.  
                      NOTE:  TVIM2 only uses XRANGE(0) and
				XRANGE(N_ELEMENTS(XRANGE)-1).

          yrange      array spanning entire y axis range.  
                      NOTE:  TVIM2 only uses YRANGE(0) and
				YRANGE(N_ELEMENTS(YRANGE)-1).

          scale       if set draw color scale.  SCALE=2 causes steped
                      color scale

          range       two or three element vector indicating physical
                      range over which to map the color scale.  The
                      third element of RANGE, if specified, sets the
                      step interval of the displayed color scale.  It
                      has no effect when SCALE is not set. E.g.,
                      RANGE=[0., 1., 0.1] will cause the entire color
                      scale to be mapped between the physical values
                      of zero and one; the step size of the displayed 
                      color scale will be set to 0.1.

          aspect      the x over y aspect ratio of the output image
                      if not set aspect is set to (size_x/size_y) of the
                      input image.  

          noframe     if set do not draw axis box around image

	   nolabels    If set, inhibits labels on plot and scale.
	  
	   invbw       To invert the color table ie. array=!d.n_colors-1-array
		       before calling tv. The deault is invbw=1 for the
		       postscript device and invbw=0 else.		


 SIDE EFFECTS:        Setting SCALE=2 changes the color scale using the
                      STEP_CT procedure.  The color scale may be returned
                      to its original state by the command, STEP_CT,/OFF

 PROCEDURE            TVIM first determins the size of the plot data window
                      with a dummy call to PLOT.  When the output device is
                      "X", CONGRID is used to scale the image to the size of
                      the available data window.  Otherwise, if the output
                      device is Postscript, scaleable pixels are used in the
                      call to TV.  PUT_COLOR_SCALE draws the color scale and
                      PLOT draws the x and y axis and titles.

 DEPENDENCIES:        PUT_COLOR_SCALE, STEP_CT

 AUTHOR:              Paul Ricchiazzi    oct92 
                      Earth Space Research Group, UCSB

                      Modified version of TVIM by Jeff Bloch, SST-9, LANL

			1.12	10/13/95
		       Added invbw keyword to invert the color table. 
		       The default is invbw=1 for postscript and invbw=0 else.
		       Changed a line to use bytscl function.
				David Johnston UChicago July 1999
                      Centered up the display. Comments, Cleaned up. 
                      Erin Scott Sheldon UMich 11/24/99

(See /host/bluemoon/usr2/idllib/sdss/allpro/tvim2.pro)


TVIM2_SCL

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

 PURPOSE:
 To view a peice of an image and retain the coordinates of the original image in that peice
 CALLING SEQUENCE:
 tvim2_scl,image,xm,xx,ym,yx,range

 INPUTS:
 image is the name of the image to be viewed
 xm is the minimum x coordinate
 xx is the maximum x coordinate
 ym is the minimum y coordinate
 yx is the maximum y coordinate
 range is the range with which to view the image
 
 OUTPUTS:
 A zoomed in peice of an image retaining its original coordinates
 
 OPTIONAL KEYWORD PARAMETERS:
 none

 NOTES:
 
 PROCEDURES CALLED:
 tvim2
 REVISION HISTORY:
 written by Susan Amrose -University of Michigan July 97

(See /host/bluemoon/usr2/idllib/sdss/allpro/tvim2_scl.pro)


WHICH

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

 PURPOSE:
	Determine in which library/directory the procedure or function
	specified is located in the !PATH.  This is useful for finding
	out which library a certain procedure comes from, particularly
	when there are duplicates.  This is similar to the unix
	'which' command.

 CALLING SEQUENCE:
    WHICH, [ proc_name ]          ;Find PROC_NAME in !PATH and display

 OPTIONAL INPUT:
	proc_name - Character string giving the name of the IDL procedure or 
		function.  Do not give an extension.   If omitted, 
		the program will prompt for PROC_NAME.

 OUTPUTS:
	None.

 SIDE EFFECTS
	None.

 PROCEDURE:
	The system variable !PATH is parsed into individual libraries or 
	directories.   Each library or directory is then searched for the
	procedure name.  If not found in !PATH,
	then the ROUTINES.HELP file is checked to see if it is an intrinsic
	IDL procedure.

 EXAMPLE:
	Find out where the procedure CURVEFIT lives.

	IDL> which, 'curvefit'

 RESTRICTIONS:
	None.

 REVISION HISTORY:
	29-MAY-94  Modified from getpro.pro by E. Deutsch
	14-JUL-95  Fixed for IDL 4.0

(See /host/bluemoon/usr2/idllib/sdss/allpro/which.pro)


WMOM

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

 PURPOSE:
    Find mean and sigma of an array, weighting by the standard
         deviation of each point

 CALLING SEQUENCE: 
    wmom, array, sigma, wmean, wsig, werr, wvar=wvar

 PROCEDURE: 
    wi      = 1/sig[i]^2
    wmean   = sum( xi*wi)/sum(wi)
    wsig^2  = sum( wi*(xi-wmean)^2 )/sum(wi)
            
    wmerr^2 = sum( wi^2*(xi - wmean)^2 ) / ( sum(wi) )^2

 REVISION HISTORY:
    Author: Erin Scott Sheldon UofMich  8/99

(See /host/bluemoon/usr2/idllib/sdss/allpro/wmom.pro)


XY2RD

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

 PURPOSE:
	Compute R.A. and Dec in degrees from X and Y and an astrometry structure
	(extracted by EXTAST)  from a FITS header.   A tangent (gnomonic) 
	projection is computed directly; other projections are computed using 
	WCSXY2SPH.
	XY2AD is meant to be used internal to other procedures.  For interactive
	purposes use XYAD.

 CALLING SEQUENCE:
	XY2AD, x, y, astr, a, d   

 INPUTS:
	X     - row position in pixels, scalar or vector
	Y     - column position in pixels, scalar or vector
	ASTR - astrometry structure, output from EXTAST procedure containing:
   	 .CD   -  2 x 2 array containing the astrometry parameters CD1_1 CD1_2
		in DEGREES/PIXEL                                   CD2_1 CD2_2
	 .CDELT - 2 element vector giving physical increment at reference pixel
	 .CRPIX - 2 element vector giving X and Y coordinates of reference pixel
		(def = NAXIS/2)
	 .CRVAL - 2 element vector giving R.A. and DEC of reference pixel 
		in DEGREES
	 .CTYPE - 2 element vector giving projection types 
	 .LONGPOLE - scalar longitude of north pole (default = 180) 
        .PROJP1 - Scalar parameter needed in some projections
	 .PROJP2 - Scalar parameter needed in some projections

 OUTPUT:
	A - R.A. in DEGREES, same number of elements as X and Y
	D - Dec. in DEGREES, same number of elements as X and Y

 RESTRICTIONS:
	Note that all angles are in degrees, including CD and CRVAL
	Also note that the CRPIX keyword assumes an FORTRAN type
	array beginning at (1,1), while X and Y give the IDL position
	beginning at (0,0).
	No parameter checking is performed.

 REVISION HISTORY:
	Written by R. Cornett, SASC Tech., 4/7/86
	Converted to IDL by B. Boothman, SASC Tech., 4/21/86
	Perform CD  multiplication in degrees  W. Landsman   Dec 1994
	Rename xy2rd forces tangent projection	David Johnston

(See /host/bluemoon/usr2/idllib/sdss/allpro/xy2rd.pro)


ZERO_STRUCT

[Previous Routine] [List of Routines]

 NAME:
    ZERO_STRUCT
       
 PURPOSE:
    "Zero" all the elements in a structure. Numbers are set to zero,
           strings to '' etc.

 CALLING SEQUENCE:
    zero_struct, struct

 INPUTS: 
    struct: Structure to be zeroed. Can be an array of structures.

 OPTIONAL INPUTS:
    NONE

 KEYWORD PARAMETERS:
    NONE
       
 OUTPUTS: 
    struct: struct with elements zeroed.

 OPTIONAL OUTPUTS:
    NONE

 CALLED ROUTINES:
    
 
 PROCEDURE: 
    
	

 REVISION HISTORY:
    Created 26-OCT-2000 Erin Scott Sheldon
       
                                      

(See /host/bluemoon/usr2/idllib/sdss/allpro/zero_struct.pro)