DAOPHOT library


List of Routines


Routine Descriptions

APER

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

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

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

 OPTIONAL KEYWORD INPUTS:
	PRINT - if set and non-zero then APER will also write its results to
		a file APER.PRT.   One can specify the output file name by
		setting PRINT = 'filename'.
	SILENT -  If supplied and non-zero then no output is displayed to the
		terminal.
	FLUX   -  If set, output fluxes instead of magnitudes.
	SETSKYVAL - Use this keyword to force the sky to a specified value 
		rather than have APER compute a sky value.    SETSKYVAL 
		can either be a scalar specifying the sky value to use for 
		all sources, or a 3 element vector specifying the sky value, 
		the sigma of the sky value, and the number of elements used 
		to compute a sky value.   The 3 element form of SETSKYVAL
		is needed for accurate error budgeting.

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

 PROCEDURES USED:
	DATATYPE(), GETOPT, MMM, STRN(), STRNUMBER()
 REVISON HISTORY:
	Adapted to IDL from DAOPHOT June, 1989   B. Pfarr, STX
	Adapted for IDL Version 2,               J. Isensee, July, 1990
	Code, documentation spiffed up           W. Landsman   August 1991
	TEXTOUT may be a string                  W. Landsman September 1995
	FLUX keyword added	                 J. E. Hollis, February, 1996
	SETSKYVAL keyword, increase maxsky       W. Landsman, May 1997
	Work for more than 32767 stars           W. Landsman, August 1997
						  

(See /local/rsi/idl_5/astron/pro/daophot/aper.pro)


CNTRD

[Previous Routine] [Next Routine] [List of Routines]
  NAME: 
	CNTRD
  PURPOSE:
	Compute the centroid coordinates of a stellar object 
	using the algorithm in the DAOPHOT FIND subroutine.

  CALLING SEQUENCE: 
	CNTRD, img, x, y, xcen, ycen, [ fwhm , /SILENT, /DEBUG]

  INPUTS:     
	IMG - Two dimensional image array
	X,Y - Scalar or vector integers giving approximate stellar center

  OPTIONAL INPUT:
	FWHM - floating scalar; Centroid is computed using a box of half
		width equal to 1.5 sigma = 0.637* FWHM.  CNTRD will prompt
		for FWHM if not supplied

  OUTPUTS:   
	XCEN - the computed X centroid position, same number of points as X
	YCEN - computed Y centroid position, same number of points as Y

	Values for XCEN and YCEN will not be computed if the computed
	centroid falls outside of the box, or if the computed derivatives
	are non-decreasing.   If the centroid cannot be computed, then a 
	message is displayed and XCEN and YCEN are set to -1.

  OPTIONAL OUTPUT KEYWORDS:
	SILENT - Normally CNTRD prints an error message if it is unable
		to compute the centroid.   Set /SILENT to suppress this.
	DEBUG - If this keyword is set, then CNTRD will display the subarray
		it is using to compute the centroid.

  PROCEDURE: 
	Maximum pixel within distance from input pixel X, Y  determined 
	from FHWM is found and used as the center of a square, within 
	which the centroid is computed as the value (XCEN,YCEN) at which 
	the derivatives of the partial sums of the input image over (y,x)
	with respect to (x,y) = 0.

  MODIFICATION HISTORY:
	Written 2/25/86, by J. K. Hill, S.A.S.C., following
	algorithm used by P. Stetson in DAOPHOT.
	Allowed input vectors        G. Hennessy       April,  1992
	Fixed to prevent wrong answer if floating pt. X & Y supplied
		W. Landsman        March, 1993
	Convert byte, integer subimages to float  W. Landsman  May 1995

(See /local/rsi/idl_5/astron/pro/daophot/cntrd.pro)


DAOERF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	DAOERF
 PURPOSE:         
	Calulates the intensity, and derivatives, of a 2-d Gaussian PSF
 EXPLANATION:
	Corrects for the finite size of a pixel by integrating the Gaussian
	over the size of the pixel.    Used in the IDL-DAOPHOT sequence.   

 CALLING SEQUENCE:
	DAOERF, XIN, YIN, A, F, [ PDER ] 

 INPUTS:
	XIN - input scalar, vector or array, giving X coordinate values
	YIN - input scalar, vector or array, giving Y coordinate values, must 
		have same number of elements as XIN.
	A - 5 element parameter array describing the Gaussian
		A(0) - peak intensity
		A(1) - X position of peak intensity (centroid)
		A(2) - Y position of peak intensity (centroid)
		A(3) - X sigma of the gaussian (=FWHM/2.345)         
		A(4) - Y sigma of gaussian

 OUTPUTS:
	F - array containing value of the function at each (XIN,YIN) 
	    The number of output elements in F and PDER is identical with
		the number of elements in X and Y

 OPTIONAL OUTPUTS:
	PDER - 2 dimensional array of size (NPTS,5) giving the analytic
		derivative at each value of F with respect to each parameter A.

 REVISION HISTORY:
	Written: W. Landsman                October, 1987

(See /local/rsi/idl_5/astron/pro/daophot/daoerf.pro)


DAO_VALUE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	DAO_VALUE
 PURPOSE:
	Returns the value of a DAOPHOT point-spread function at a set of points.
 EXPLANATION:
	The value of the point-spread function is the sum of a
	two-dimensional integral under a bivariate Gaussian function, and 
	a value obtained by interpolation in a look-up table.  DAO_VALUE will
	optionally compute the derivatives wrt X and Y

 CALLING SEQUENCE:
	Result = DAO_VALUE( xx, yy, gauss, psf, [ dvdx, dvdy ] )

 INPUTS:
	XX,YY   - the real coordinates of the desired point relative 
		to the centroid of the point-spread function.
	GAUSS  -  5 element vector describing the bivariate Gaussian
	GAUSS(0)- the peak height of the best-fitting Gaussian profile.
	GAUSS(1,2) - x and y offsets from the centroid of the point-spread 
		function to the center of the best-fitting Gaussian.
	GAUSS(3,4) - the x and y sigmas of the best-fitting Gaussian.
	PSF  -  a NPSF by NPSF array containing the look-up table.

 OUTPUTS:
    RESULT - the computed value of the point-spread function at
             a position XX, YY relative to its centroid (which 
             coincides with the center of the central pixel of the
             look-up table).

 OPTIONAL OUTPUTS:
       DVDX,DVDY - the first derivatives of the composite point-spread
             function with respect to x and y.

 NOTES
 	although the arguments XX,YY of the function DAO_VALUE
	are relative to the centroid of the PSF, the function RINTER which
	DAO_VALUE calls requires coordinates relative to the corner of the 
	array (see code).

 PROCEDURES CALLED:
	DAOERF, RINTER()
 REVISON HISTORY:
	Adapted to IDL by B. Pfarr, STX, 11/17/87 from 1986 STSDAS version
	of DAOPHOT

(See /local/rsi/idl_5/astron/pro/daophot/dao_value.pro)


FIND

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	FIND
 PURPOSE:
	Find positive brightness perturbations (i.e stars) in an image 
 EXPLANATION:
	Also returns centroids and shape parameters (roundness & sharpness).
	Adapted from 1986 STSDAS version of DAOPHOT.

 CALLING SEQUENCE:
	FIND, image, [ x, y, flux, sharp, round, hmin, fwhm, roundlim, sharplim 
		PRINT= , /SILENT ]

 INPUTS:
	image - 2 dimensional image array (integer or real) for which one
		wishes to identify the stars present

 OPTIONAL INPUTS:
	FIND will prompt for these parameters if not supplied

	hmin -  Threshold intensity for a point source - should generally 
		be 3 or 4 sigma above background
	fwhm  - FWHM to be used in the convolve filter
	sharplim - 2 element vector giving low and high cutoff for the
		sharpness statistic (Default: [0.2,1.0] ).   Change this
		default only if the stars have siginificantly larger or 
		or smaller concentration than a Gaussian
	roundlim - 2 element vector giving low and high cutoff for the
		roundness statistic (Default: [-1.0,1.0] ).   Change this 
		default only if the stars are significantly elongated.

 OPTIONAL INPUT KEYWORDS:
	SILENT - Normally, FIND will write out each star that meets all
		selection criteria.   If the SILENT keyword is set and 
		non-zero, then this printout is suppressed.
	PRINT - if set and non-zero then T_FIND will also write its results to
		a file FIND.PRT.   Also one can specify a different output file 
		name by setting PRINT = 'filename'.

 OPTIONAL OUTPUTS:
	x - vector containing x position of all stars identified by FIND
	y-  vector containing y position of all stars identified by FIND
	flux - vector containing flux of identified stars as determined
		by a gaussian fit.  Fluxes are NOT converted to magnitudes.
	sharp - vector containing sharpness statistic for identified stars
	round - vector containing roundness statistic for identified stars

 NOTES:
	The sharpness statistic compares the central pixel to the mean of the
	surrounding pixels.   If this difference is greater than the originally
	estimated height of the Gaussian or less than 0.2 the height of the
	Gaussian (for the default values of SHARPLIM) then the star will be
	rejected. 

 PROCEDURE CALLS:
	DATATYPE(), GETOPT
 REVISION HISTORY:
	Written W. Landsman, STX  February, 1987
	ROUND now an internal function in V3.1   W. Landsman July 1993
	Change variable name DERIV to DERIVAT    W. Landsman Feb. 1996
	Use /PRINT keyword instead of TEXTOUT    W. Landsman May  1996
	Changed loop indicies to type LONG       W. Landsman Aug. 1997

(See /local/rsi/idl_5/astron/pro/daophot/find.pro)


GETPSF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GETPSF
 PURPOSE:
	To generate a point-spread function (PSF) from observed stars. 
 EXPLANATION:
	The PSF is represented as a 2-dimensional Gaussian
	(integrated over each pixel) and a lookup table of residuals.
	The lookup table and Gaussian parameters are output in a FITS
	image file.   The PSF FITS file created by GETPSF can be
	read with the procedure RDPSF.      Adapted from the 1986 STSDAS 
	version of DAOPHOT

 CALLING SEQUENCE:
	GETPSF, image, xc, yc, apmag, sky, [ronois, phpadu, gauss, psf, 
			idpsf, psfrad, fitrad, psfname, /DEBUG ]

 INPUTS:
	IMAGE  - input image array
	XC     - input vector of x coordinates (from FIND), these should be
		IDL (first pixel is (0,0)) convention.
	YC     - input vector of y coordinates (from FIND)
	APMAG  - vector of magnitudes (from APER), used for initial estimate
		of gaussian intensity.  If APMAG is multidimensional, (more
		than 1 aperture was used in APER) then the first aperture
		is used.
	SKY    - vector of sky values (from APER)                

 OPTIONAL INPUTS:
	The user will be prompted for the following parameters if not supplied.

	RONOIS - readout noise per pixel, (in electrons, or equivalent photons)
	PHPADU - photons per analog digital unit, used to scale the data
		numbers in IMAGE into photon units
	IDPSF  - subscripts of the list of stars created by 
		APER which will be used to define the PSF.   Stars whose
		centroid does not fall within PSFRAD of the edge of the frame,
		or for which a Gaussian fit requires more than 25 iterations,
		will be ignored when creating the final PSF.
	PSFRAD - the scalar radius, in pixels, of the circular area within
		which the PSF will be defined.   This should be slightly larger
		than the radius of the brightest star that one will be
		interested in.
	FITRAD - the scalar radius, in pixels of the circular area used in the
		least-square star fits.  Stetson suggest that FITRAD should
		approximately equal to the FWHM, slightly less for crowded
		fields.  (FITRAD must be smaller than PSFRAD.)
	PSFNAME- Name of the FITS file that will contain the table of residuals,
		and the best-fit Gaussian parameters.    This file is 
		subsequently required for use by NSTAR.  

 OPTIONAL OUTPUTS:
	GAUSS  - 5 element vector giving parameters of gaussian fit to the 
		first PSF star
		GAUSS(0) - height of the gaussian (above sky)
		GAUSS(1) - the offset (in pixels) of the best fitting gaussian
			and the original X centroid
		GAUSS(2) - similiar offset from the Y centroid 
		GAUSS(3) - Gaussian sigma in X
		GAUSS(4) - Gaussian sigma in Y
	PSF    - 2-d array of PSF residuals after a Gaussian fit.

 PROCEDURE:
	GETPSF fits a Gaussian profile to the core of the first PSF star 
	and generates a look-up table of the residuals of the
	actual image data from the Gaussian fit.  If desired, it will then
	fit this PSF to another star (using PKFIT) to determine its precise 
	centroid, scale the same Gaussian to the new star's core, and add the
	differences between the actual data and the scaled Gaussian to the
	table of residuals.   (In other words, the Gaussian fit is performed
	only on the first star.)

 OPTIONAL KEYWORD INPUT:
	DEBUG - if this keyword is set and non-zero, then the result of each
		fitting iteration will be displayed.

 PROCEDURES CALLED
	DAOERF, MAKE_2D, MKHDR, RINTER(), PKFIT, STRNUMBER(), STRN(), WRITEFITS

 REVISON HISTORY:
	Adapted from the 1986 version of DAOPHOT in STSDAS
	IDL Version 2  W Landsman           November 1988
	Use DEBUG keyword instead of !DEBUG  W. Landsman       May 1996

(See /local/rsi/idl_5/astron/pro/daophot/getpsf.pro)


GROUP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GROUP
 PURPOSE:
	Assign stars with non-overlapping PSF profiles into distinct groups
 EXPLANATION:
	Part of the IDL-DAOPHOT sequence

 CALLING SEQUENCE:
	GROUP, X, Y, RCRIT, NGROUP

 INPUTS:
	X - vector, giving X coordinates of a set of stars.
	Y - vector, giving Y coordinates of a set of stars.
	RCRIT - scalar, giving minimum distance between stars of two
		distinct groups.  Stars less than this distance from
		each other are always in the same group.    Stetson suggests
		setting the critical distance equal to the PSF radius +
		the Fitting radius.

 OUTPUTS:
	NGROUP - integer vector, same number of elements as X and Y,
		giving a group number for each star position.  Group
		numbering begins with 0.

 METHOD:
	Each position is initially given a unique group number.  The distance
	of each star is computed against every other star.   Those distances
	less than RCRIT are assigned the minimum group number of the set.   A
	check is then made to see if any groups have merged together.

 PROCEDURES USED:
	REM_DUP()

 REVISION HISTORY:
	Written W. Landsman  STX                  April, 1988
	Major revision to properly merge groups together  W. Landsman   Sep 1991
	Work for more than 32767 points    W. Landsman  March 1997

(See /local/rsi/idl_5/astron/pro/daophot/group.pro)


MMM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	MMM
 PURPOSE: 
	Estimate the sky background in a stellar contaminated field.
 EXPLANATION:  
	MMM assumes that contaminated sky pixel values overwhelmingly display 
	POSITIVE departures from the true value.  Adapted from DAOPHOT 
	routine of the same name.

 CALLING SEQUENCE:
	MMM, sky, [ skymde, sigma, skew, HIGHBAD = , DEBUG =  ]

 INPUTS:
	SKY - Array or Vector containing sky values.  This version of
		MMM does not require SKY to be sorted beforehand.  SKY
		is unaltered by this program.

 OPTIONAL OUTPUTS:
	SKYMDE - Scalar giving estimated mode of the sky values
	SIGMA -  Scalar giving standard deviation of the peak in the sky
		histogram.  If for some reason it is impossible to derive
		SKYMDE, then SIGMA = -1.0
	SKEW -   Scalar giving skewness of the peak in the sky histogram
		If no output variables are supplied or if /DEBUG is set
		then the values of SKYMDE, SIGMA and SKEW will be printed.

 OPTIONAL KEYWORD INPUTS:
	HIGHBAD - scalar value of the high "bad" pixel level (e.g. cosmic rays)
		If not supplied, then there is assumed to be no high bad
		pixels.
	DEBUG - If this keyword is set and non-zero, then additional information
		is displayed at the terminal.

 RESTRICTIONS:
	Program assumes that low "bad" pixels (e.g. bad CCD columns) have
	already been deleted from the SKY vector.

 METHOD:
	The algorithm used by MMM consists of roughly two parts:
	(1) The average and sigma of the sky pixels is computed.   These values
	are used to eliminate outliers, i.e. values with a low probability
	given a Gaussian with specified average and sigma.   The average
	and sigma are then recomputed and the process repeated up to 20
	iterations:
	(2) The amount of contamination by stars is estimated by comparing the 
	mean and median of the remaining sky pixels.   If the mean is larger
	than the median then the true sky value is estimated by
	3*median - 2*mean
         
 REVISION HISTORY:
	Adapted to IDL from 1986 version of DAOPHOT in STSDAS, 
	W. Landsman, STX Feb 1987
	Adapted for IDL Version 2, J. Isensee, STX, Sept 1990
	Added HIGHBAD keyword, W. Landsman January, 1991
	Fixed occasional problem with integer inputs    W. Landsman  Feb, 1994

(See /local/rsi/idl_5/astron/pro/daophot/mmm.pro)


NSTAR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	NSTAR
 PURPOSE:
	Simultaneous point spread function fitting (adapted from DAOPHOT)
 CALLING SEQUENCE:
	NSTAR, image, id, xc, yc, mags, sky, group, [ phpadu, readns, psfname,
		magerr, iter, chisq, peak, /PRINT , /SILENT, /VARSKY, /DEBUG ]

 INPUTS:
	image - image array
	id    - vector of stellar ID numbers given by FIND
	xc    - vector containing X position centroids of stars (e.g. as found
		by FIND)
	yc    - vector of Y position centroids
	mags  - vector of aperture magnitudes (e.g. as found by APER)
		If 9 or more parameters are supplied then, upon output
		ID,XC,YC, and MAGS will be modified to contain the new
		values of these parameters as determined by NSTAR.
		Note that the number of output stars may be less than 
		the number of input stars since stars may converge, or 
		"disappear" because they are too faint.
	sky   - vector of sky background values (e.g. as found by APER)
	group - vector containing group id's of stars as found by GROUP

 OPTIONAL INPUT:
	phpadu - numeric scalar giving number of photons per digital unit.  
		Needed for computing Poisson error statistics.   
	readns - readout noise per pixel, numeric scalar.   If not supplied, 
		NSTAR will try to read the values of READNS and PHPADU from
		the PSF header.  If still not found, user will be prompted.
	psfname - name of FITS image file containing the point spread
		function residuals as determined by GETPSF, scalar string.  
		If omitted, then NSTAR will prompt for this parameter.

 OPTIONAL OUTPUTS:
	MAGERR - vector of errors in the magnitudes found by NSTAR
	ITER - vector containing the number of iterations required for
		each output star.  
	CHISQ- vector containing the chi square of the PSF fit for each
		output star.
	PEAK - vector containing the difference of the mean residual of
		the pixels in the outer half of the fitting circle and
		the mean residual of pixels in the inner half of the
		fitting circle

 OPTIONAL KEYWORD INPUTS:
	SILENT - if set and non-zero, then NSTAR will not display its results
		at the terminal
	PRINT - if set and non-zero then NSTAR will also write its results to
		a file NSTAR.PRT.   One also can specify the output file name
		by setting PRINT = 'filename'.
	VARSKY - if this keyword is set and non-zero, then the sky level of
		each group is set as a free parameter.
	DEBUG - if this keyword is set and non-zero, then the result of each
		fitting iteration will be displayed.

 PROCEDURES USED:
	DAO_VALUE(), READFITS(), REMOVE, SPEC_DIR(), STRN(), SXPAR()

 COMMON BLOCK:
	RINTER - contains pre-tabulated values for cubic interpolation
 REVISION HISTORY
	W. Landsman                 ST Systems Co.       May, 1988
	Adapted for IDL Version 2, J. Isensee, September, 1990
	Minor fixes so that PRINT='filename' really prints to 'filename', and
	it really silent if SILENT is set.  J.Wm.Parker HSTX 1995-Oct-31
	Added /VARSKY option   W. Landsman   HSTX      May 1996

(See /local/rsi/idl_5/astron/pro/daophot/nstar.pro)


PKFIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	PKFIT
 PURPOSE:
	Subroutine of  GETPSF to perform a one-star least-squares fit 
 EXPLANATION:
	Part of the DAOPHOT PSF photometry sequence

 CALLING SEQUENCE:
	PKFIT, f, scale, x, y, sky, radius, ronois, phpadu, gauss, psf, 
				errmag, chi, sharp, Niter, /DEBUG 
 INPUTS:
	F      - NX by NY array containing actual picture data.           
	X, Y   - the initial estimates of the centroid of the star relative
		to the corner (0,0) of the subarray.  Upon return, the
		final computed values of X and Y will be passed back to the
		calling routine.
	SKY  -   the local sky brightness value, as obtained from APER
	RADIUS-  the fitting radius-- only pixels within RADIUS of the
		instantaneous estimate of the star's centroid will be
		included in the fit, scalar
	RONOIS - readout noise per pixel, scalar
	PHPADU - photons per analog digital unit, scalar
	GAUSS -  vector containing the values of the five parameters defining
		the analytic Gaussian which approximates the core of the PSF.
	PSF   -  an NPSF by NPSF look-up table containing corrections from
		the Gaussian approximation of the PSF to the true PSF.

 INPUT-OUTPUT:
	SCALE  - the initial estimate of the brightness of the star,
		expressed as a fraction of the brightness of the PSF.
		Upon return, the final computed value of SCALE will be
		passed back to the calling routine.
 OUTPUTS:
	ERRMAG - the estimated standard error of the value of SCALE
		returned by this routine.
	CHI    - the estimated goodness-of-fit statistic:  the ratio
		of the observed pixel-to-pixel mean absolute deviation from
		the profile fit, to the value expected on the basis of the
		noise as determined from Poisson statistics and the 
		readout noise.
	SHARP  - a goodness-of-fit statistic describing how much broader  
		the actual profile of the object appears than the
		profile of the PSF.
	NITER -  the number of iterations the solution required to achieve
		convergence.  If NITER = 25, the solution did not converge.
		If for some reason a singular matrix occurs during the least-
		squares solution, this will be flagged by setting NITER = -1.

 RESTRICTIONS:
	No parameter checking is performed
 REVISON HISTORY:
	Adapted from the official DAO version of 1985 January 25
	Version 2.0 W. Landsman STX             November 1988

(See /local/rsi/idl_5/astron/pro/daophot/pkfit.pro)


RDPSF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	RDPSF
 PURPOSE:
	Read the FITS file created by GETPSF in the DAOPHOT sequence 
 EXPLANATION:
	Combines the Gaussian with the residuals to create an output PSF array.

 CALLING SEQUENCE:
	RDPSF, PSF, HPSF, [ PSFNAME]

 OPTIONAL INPUTS
	psfname - string giving the name of the FITS file containing the PSF
		residuals

 OUTPUTS
	psf - array containing the actual PSF
	hpsf - header associated with psf

 PROCEDURES CALLED:
	DAO_VALUE(), MAKE_2D, SXADDPAR, READFITS(), SXPAR()
 REVISION HISTORY:
	Written W. Landsman              December, 1988
	Checked for IDL Version 2, J. Isensee & J. Hill, December, 1990

(See /local/rsi/idl_5/astron/pro/daophot/rdpsf.pro)


SKY

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SKY
 PURPOSE:
	Determine the sky level in an image using the the procedure MMM
 EXPLANATION:
	Approximately 4000 uniformly spaced pixels are selected for the
	computation.  Adapted from the DAOPHOT routine of the same name.

 CALLING SEQUENCE:
	SKY, image, [ skymode, skysig, CIRCLE = ,/SILENT ]

 INPUTS:
	IMAGE - One or two dimensional array

 OPTIONAL OUTPUT ARRAYS:
	SKYMODE - Scalar, giving the mode of the sky pixel values of the 
		array IMAGE, as determined by the procedure MMM.
	SKYSIG -  Scalar, giving standard deviation of sky brightness

 INPUT KEYWORD PARAMETERS:
	CIRCLERAD - Use the keyword to have SKY only select pixels within
		the specified pixel radius of the center of the image.  If 
		CIRCLERAD = 1, then the radius is set equal to half the image
		width.   Useful when the data is restricted to a circular area
		of the image.

	SILENT - If this keyword is supplied and non-zero, then SKY will not
		display the sky value and sigma at the terminal

 PROCEDURE:
	A regular grid of points, not exceeding 4000 in number, is extracted
	from the image array.  The mode of these pixel values is determined
	by the procedure MMM.

 PROCEDURE CALLS:
	MMM
 REVISION HISTORY:
	Written, W. Landsman   STX Co.            September, 1987     
	Changed INDGEN to LINDGEN                 January, 1994
	Fixed display of # of points used         March, 1994

(See /local/rsi/idl_5/astron/pro/daophot/sky.pro)


SRCOR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SRCOR
 PURPOSE:
       Correlate the source positions found on two lists.
 CALLING SEQUENCE:
       srcor,x1in,ylin,x2in,y2in,dcr,ind1,ind2
 INPUTS:
       x1in,y1in - First set of x and y coordinates.  The program
                   marches through this list element by element,
                   looking in list 2 for the closest match.  So, the program
	            will run faster if this is the shorter of the two lists.
	            Unless you use the option or magnitude keyword, there is
	            nothing to guarantee unique matches.  
       x2in,y2in - Second set of x and y coordinates.  This list is
                   searched in its entirety every time one element of list 1
                   is processed.
       dcr - Critical radius outside which correlations are rejected;
             but see 'option' below.
 OPTIONAL KEYWORD INPUT:
       option - Changes behavior of program and description of output
                lists slightly, as follows: 
       OPTION=0 or left out
             Same as older versions of SRCOR.  The closest match from list2
             is found for each element of list 1, but if the distance is
             greater than DCR, the match is thrown out.  Thus the index
             of that element within list 1 will not appear in the IND1 output
             array.
       OPTION=1
             Forces the output mapping to be one-to-one.  OPTION=0 results,
             in general, in a many-to-one mapping from list 1 to list 2.
             Under OPTION=1, a further processing step is performed to
             keep only the minimum-distance match, whenever an entry from
             list 1 appears more than once in the initial mapping.
       OPTION=2
             Same as OPTION=1, except the critical distance parameter DCR
             is ignored.  I.e., the closest object is retrieved from list 2
             for each object in list 1 WITHOUT a critical-radius criterion,
             then the clean-up of duplicates is done as under OPTION=1.
       magnitude
             An array of stellar magnitudes corresponding to x1in and y1in.  
             If this is supplied, then the brightest star from list 1
             within the selected distance of the star in list 2 is taken.
             The option keyword is ignored in this case.
	spherical
	      If SPHERICAL=1, it is assumed that the input arrays are in
	      celestial coordinates (RA and Dec), with x1in and x2in in
	      decimal hours and y1in and y2in in decimal degrees.  If
	      SPHERICAL=2 then it is assumed that the input arrays are in
	      longitude and latitude with x1in,x2in,y1in,y2in in decimal
	      degrees.  In both cases, the critial radius dcr is in
	      *arcseconds*.  Calculations of spherical distances are made
	      with the gcirc program.
 OUTPUTS:
       ind1 - index of matched stars in first list
       ind2 - index of matched stars in second list
 COMMON BLOCKS:
       none
 SIDE EFFECTS:
       none
 METHOD:
       See under keyword LEVEL above.
 REVISON HISTORY:
	Adapted from UIT procedure  J.Wm.Parker, SwRI 29 July 1997

(See /local/rsi/idl_5/astron/pro/daophot/srcor.pro)


SUBSTAR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SUBSTAR
 PURPOSE:
	Subtract a scaled point spread function at specified star position(s).
 EXPLANATION:
	Part of the IDL-DAOPHOT photometry sequence

 CALLING SEQUENCE:
	SUBSTAR, image, x, y, mag, [ id, psfname, /VERBOSE] 

 INPUT-OUTPUT:
	IMAGE -  On input, IMAGE is the original image array.  A scaled
		PSF will be subtracted from IMAGE at specified star positions.
		Make a copy of IMAGE before calling SUBSTAR, if you want to
		keep a copy of the unsubtracted image array

 INPUTS:
	X -   REAL Vector of X positions found by NSTAR (or FIND)
	Y -   REAL Vector of Y positions found by NSTAR (or FIND)        
	MAG - REAL Vector of stellar magnitudes found by NSTAR (or APER)
		Used to scale the PSF to match intensity at star position.
		Stars with magnitude values of 0.0 are assumed missing and 
		ignored in the subtraction.

 OPTIONAL INPUTS:
	ID -  Index vector indicating which stars are to be subtracted.  If
		omitted, (or set equal to -1), then stars will be subtracted 
		at all positions specified by the X and Y vectors.

	PSFNAME - Name of the FITS file containing the PSF residuals, as
		generated by GETPSF.  SUBSTAR will prompt for this parameter
		if not supplied.      

 OPTIONAL INPUT KEYWORD:
	VERBOSE - If this keyword is set and nonzero, then SUBSTAR will 
		display the star that it is currently processing      

 COMMON BLOCKS:
	The RINTER common block is used (see RINTER.PRO) to save time in the
	PSF calculations

 PROCEDURES CALLED:
	DAO_VALUE(), READFITS(), REMOVE, SXOPEN, SXPAR(), SXREAD()
 REVISION HISTORY:
	Written, W. Landsman                      August, 1988
	Added VERBOSE keyword                     January, 1992
	Fix star subtraction near edges, W. Landsman    May, 1996
	Assume the PSF file is in FITS format  W. Landsman   July, 1997

(See /local/rsi/idl_5/astron/pro/daophot/substar.pro)


T_APER

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	T_APER
 PURPOSE:
	Driver procedure (for APER) to compute concentric aperture photometry.
 EXPLANATION:
	Data is read from and written to disk FITS ASCII tables.   
	Part of the IDL-DAOPHOT photometry sequence

 CALLING SEQUENCE:
	T_APER, image, fitsfile, [ apr, skyrad, badpix, PRINT=, NEWTABLE=, 
			/SILENT, SETSKYVAL = ]

 INPUTS:
	IMAGE   - input data array
	FITSFILE  - disk FITS ASCII table name (from T_FIND).  Must contain
		the keywords 'X' and 'Y' giving the centroid of the source
		positions in FORTRAN (first pixel is 1) convention.   An
		extension of .fit is assumed if not supplied.

 OPTIONAL INPUTS:
	User will be prompted for the following parameters if not supplied.

	APR    -  Vector of up to 12 REAL photometry aperture radii.
	SKYRAD  - Two element vector giving the inner and outer radii
		to be used for the sky annulus
	BADPIX  - Two element vector giving the minimum and maximum
		value of a good pixel (Default [-32765,32767])

 OPTIONAL KEYWORDS INPUTS:
	PRINT - if set and non-zero then NSTAR will also write its results to
		a file aper.prt.   One can specify a different output file 
		name by setting PRINT = 'filename'.
	SILENT - If this keyword is set and non-zero, then APER will not
		display photometry results at the screen, and the results 
		will be automatically incorporated in the FITS table without
		prompting the user
	NEWTABLE  - Name of output disk FITS ASCII table, scalar string.   
		If not supplied, then the input FITSFILE will be updated with 
		the aperture photometry results.
	SETSKYVAL - Use this keyword to force the sky to a specified value 
		rather than have APER compute a sky value.    SETSKYVAL 
		can either be a scalar specifying the sky value to use for 
		all sources, or a 3 element vector specifying the sky value, 
		the sigma of the sky value, and the number of elements used 
		to compute a sky value.   The 3 element form of SETSKYVAL
		is needed for accurate error budgeting.

 PROMPTS:
	T_APER requires the number of photons per analog digital unit
	(PHPADU), so that it can compute Poisson noise statistics to assign
	photometry errors.    It first tries to find the PHPADU keyword in the
	original image header, and if not found will look for the GAIN, 
	CCDGAIN and finally ATODGAIN keywords.   If still not found, T_APER 
	will prompt the user for this value.

 PROCEDURES:
	APER, FTADDCOL, FTGET(), FTINFO, FTPUT, READFITS(), SXADDPAR, 
	SXPAR(), WRITEFITS 
 REVISON HISTORY:
	Written   W. Landsman   ST Systems Co.            May 1988
	Store results as flux or magnitude                August 1988
	Added SILENT keyword  W. Landsman                 Sep. 1991
	Changed ERR SKY to ERR_SKY W. Landsman   March 1996
	Replace TEXTOUT keyword with PRINT keyword  W. Landsman  May 1996
	Check CCDGAIN or ATODGAIN keywords to find phpadu W. Landsman May 1997

(See /local/rsi/idl_5/astron/pro/daophot/t_aper.pro)


T_FIND

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	T_FIND
 PURPOSE:
	Driver procedure (for FIND) to locate stars in an image.
 EXPLANATION:
	Finds positive brightness perturbations (i.e stars) in a 
	2 dimensional image.  Output is to a FITS ASCII table.

 CALLING SEQUENCE:
	T_FIND, image, im_hdr, [ fitsfile, hmin, fwhm, sharplim, roundlim, 
					PRINT = , /SILENT ]
 INPUTS:
	image - 2 dimensional image array (integer or real) for which one
		wishes to identify the stars present
	im_hdr - FITS header associated with image array

 OPTIONAL INPUTS: 
	T_FIND will prompt for these parameters if not supplied

	fitsfile - scalar string specifying the name of the output FITS ASCII
		table file
	fwhm - FWHM to be used in the convolving filter
	hmin - Threshold intensity for a point source - should generally
		be 3 or 4 sigma above background level
	sharplim - 2 element vector giving low and high Limit for 
		sharpness statistic (Default: [0.2,1.0] )
	roundlim - 2 element vector giving low and high Limit for
		roundness statistic (Default: [-1.0,1.0] )

 OPTIONAL INPUT KEYWORDS:
	PRINT - if set and non-zero then NSTAR will also write its results to
		a file FIND.PRT.   One can specify the output file name by
		setting PRINT = 'filename'.
	SILENT -   If this keyword is set and non-zero, then FIND will work
		silently, and not display each star found

 OUTPUTS:
	None

 PROCEDURES CALLED:
	CHECK_FITS, FDECOMP, FIND, FTADDCOL, FTCREATE, SXADDHIST, SXADDPAR, 
	SXDELPAR, SXPAR(), WRITEFITS

 REVISION HISTORY:
	Written W. Landsman, STX  May, 1988
	Added phpadu, J. Hill, STX, October, 1990
	New calling syntax output to disk FITS table, W. Landsman    May 1996
	Work with more than 32767 stars  W. Landsman August 1997

(See /local/rsi/idl_5/astron/pro/daophot/t_find.pro)


T_GETPSF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	T_GETPSF
 PURPOSE:
	Driver procedure (for GETPSF) to generate a PSF from isolate stars.
 EXPLANATION:
	Generates a point-spread function from one or more isolated stars.
	List of stars is read from the FITS ASCII table output of T_APER.
	PSF is represented as a sum of a Gaussian plus residuals.
	Ouput residuals are written to a FITS image file.

 CALLING SEQUENCE:
	T_GETPSF, image, fitsfile, [ idpsf, psfrad, fitrad, psfname, 
					/DEBUG, NEWTABLE =]

 INPUTS:
	IMAGE - image array
	FITSFILE  - scalar string giving name of disk FITS ASCII table.  Must 
		contain the keywords 'X','Y' (from T_FIND) and 'AP1_MAG','SKY'
		(from T_APER).

 OPTIONAL INPUTS:
	IDPSF - vector of stellar ID indices indicating which stars are to be 
		used to create the PSF.    Not that the PSF star should be 
		specified *not* by its STAR_ID value, but rather by the its 
		row number (starting with 0) in the FITS table
	PSFRAD - the radius for which the PSF will be defined
	FITRAD - fitting radius, always smaller than PSFRAD
	PSFNAME - name of FITS image file to contain PSF residuals,
		scalar string
	GETPSF will prompt for all the above values if not supplied.

 OPTIONAL KEYWORD INPUT
	NEWTABLE - scalar string specifying the name of the output FITS ASCII
		table.   If not supplied, then the input table is updated with
		the keyword PSF_CODE, specifying which stars were used for the
		PSF.
	DEBUG - if this keyword is set and non-zero, then the result of each
		fitting iteration will be displayed.

 PROMPTS:
	T_GETPSF will prompt for the readout noise (in data numbers), and
	the gain (in photons or electrons per data number) so that pixels can
	be weighted during the PSF fit.   To avoid the prompt, add the 
	keywords RONOIS and PHPADU to the FITS ASCII table header.     

 PROCEDURES USED:
	FTADDCOL, FTGET(), FTPUT, GETPSF, READFITS(), SXADDHIST, SXADDPAR, 
	SXPAR(), WRITEFITS, ZPARCHECK
 REVISION HISTORY:
	Written  W. Landsman     STX           May, 1988
	Update PSF_CODE to indicate PSF stars in order used, W. Landsman Mar 96
	I/O to FITS ASCII disk files  W. Landsman    May 96

(See /local/rsi/idl_5/astron/pro/daophot/t_getpsf.pro)


T_GROUP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	T_GROUP
 PURPOSE:
	Driver procedure (for GROUP) to place stars in non-overlapping groups.
 EXPLANATION:
	This procedure is part of the DAOPHOT sequence that places star
	positions with non-overlapping PSFs into distinct groups   
	Input and output are to FITS ASCII tables

 CALLING SEQUENCE:
	T_GROUP, fitsfile, [ rmax, XPAR = , YPAR = , NEWTABLE = ]

 INPUTS:
	FITSFILE -  Name of disk FITS ASCII table containing the X,Y positions
		in FITS (FORTRAN) convention (first pixel is 1,1)

 OPTIONAL INPUTS:
	rmax - maximum allowable distance between stars in a single group

 OPTIONAL INPUT KEYWORDS:
	XPAR, YPAR - scalar strings giving the field name in the output table
		containing the X and Y coordinates.   If not supplied,
		then the fields 'X' and 'Y' are read.
	NEWTABLE - scalar giving name of output disk FITS ASCII table.   If not
		supplied, 

 PROCEDURES:
	FTADDCOL, FTGET(), FTINFO, FTPUT, GROUP, READFITS(), SXADDHIST, 
	SXADDHIST, WRITEFITS
 REVISION HISTORY:
	Written, W. Landsman        STX Co.      May, 1996

(See /local/rsi/idl_5/astron/pro/daophot/t_group.pro)


T_NSTAR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	T_NSTAR
 PURPOSE:
	Driver procedure (for NSTAR) for simultaneous PSF fitting.  
 EXPLANATION:
	Input and output are to disk FITS ASCII tables.

 CALLING SEQUENCE:
	T_NSTAR, image, fitsfile, [psfname, groupsel, /SILENT, /PRINT
				NEWTABLE = , /VARSKY ]
 INPUTS:
	IMAGE - 2-d image array
	FITSFILE  - scalar string giving name of disk FITS ASCII table.  Must 
		contain the keywords 'X','Y' (from T_FIND) 'AP1_MAG','SKY'
		(from T_APER) and 'GROUP_ID' (from T_GROUP).   This table
		will be updated with the results of T_NSTAR, unless the 
		keyword NEWTABLE is supplied.   

 OPTIONAL INPUTS:
	PSFNAME - Name of the FITS file created by T_GETPSF containing
		PSF residuals, scalar string
	GROUPSEL - Scalar or vector listing the groups to process.  For
		example, to process stars in groups 2 and 5 set
		GROUPSEL = [2,5].  If omitted, or set equal to -1,
		then NSTAR will process all groups.

 OPTIONAL KEYWORD INPUTS:
	VARSKY - If this keyword is set and non-zero, then the mean sky level
		in each group of stars, will be fit along with the brightness
		and positions.
	SILENT - if set and non-zero, then NSTAR will not display its results
		at the terminal
	PRINT - if set and non-zero then NSTAR will also write its results to
		a file NSTAR.PRT.   One can specify the output file name by
		setting PRINT = 'filename'.
	NEWTABLE  - Name of output disk FITS ASCII table to contain the results
		of NSTAR.   If not supplied, then the input FITSFILE will be 
		updated.  
	DEBUG - if this keyword is set and non-zero, then the result of each
		fitting iteration will be displayed.

 PROCEDURES CALLED:
	FTADDCAL, FTINFO, FTGET(), FTPUT, NSTAR, SXADDHIST, 
	SXADDPAR, SXPAR(), READFITS(), WRITEFITS
 REVISION HISTORY:
	Written        W. Landsman         STX Co.    May, 1988
	Check for CCDGAIN, ATODGAIN keywords to get PHPADU  W. Landsman May 1997
	Fixed typo preventing compilation, groupsel parameter W.L. July 1997

(See /local/rsi/idl_5/astron/pro/daophot/t_nstar.pro)


T_SUBSTAR

[Previous Routine] [List of Routines]
 NAME:
	T_SUBSTAR
 PURPOSE:
	Driver procedure (for SUBSTAR) to subtract scaled PSF values 
 EXPLANATION:
	Computes residuals of the PSF fitting program

 CALLING SEQUENCE:
	T_SUBSTAR, image, fitsfile, id,[ psfname, /VERBOSE, /NOPSF ]

 INPUT-OUTPUT:
	IMAGE -  On input, IMAGE is the original image array.  A scaled
		PSF will be subtracted from IMAGE at specified star positions.
		Make a copy of IMAGE before calling SUBSTAR, if you want to
		keep a copy of the unsubtracted image array
 INPUTS:
	FITSFILE  - scalar string giving the name of the disk FITS ASCII 
		produced as an output from T_NSTAR.   

 OPTIONAL INPUTS:
	ID -  Index vector indicating which stars are to be subtracted.  If
		omitted, (or set equal to -1), then stars will be subtracted 
		at all positions specified by the X and Y vectors.
		(IDL convention - zero-based subscripts)
	PSFNAME - Name of the FITS file containing the PSF residuals, as
		generated by GETPSF.  SUBSTAR will prompt for this parameter
		if not supplied.      
 OPTIONAL INPUT KEYWORD:
	VERBOSE - If this keyword is set and non-zero, then the value of each
		star number will be displayed as it is processed.
	NOPSF - if this keyword is set and non-zero, then all stars will be 
		be subtracted *except* those used to determine the PSF.
		An improved PSF can then be derived from the subtracted image.
		If NOPSF is supplied, then the ID parameter is ignored
 NOTES:
	T_SUBSTAR does not modify the input FITS table.

 PROCEDURES USED:
	FTGET(), READFITS(), SUBSTAR
 REVISION HISTORY:
	Written, R. Hill, ST Sys. Corp., 22 August 1991
	Added NOPSF keyword   W. Landsman        March, 1996
	Use FITS format for PSF resduals         July, 1997

(See /local/rsi/idl_5/astron/pro/daophot/t_substar.pro)