| peak | noao.digiphot.daophot | peak |
peak -- fit the PSF model to single stars
peak image photfile psfimage peakfile rejfile
PEAK computes x and y centers, sky values and magnitudes for all the stars in photfile by fitting the PSF model in psfimage to single stars in image . PEAK reads initial estimates of the centers and magnitudes along with the sky values from the photometry file photfile . Photfile is usually the output of the DAOPHOT PHOT task but may also be the output of PEAK itself, NSTAR, ALLSTAR, GROUP or PSF. The computed centers, sky values, and magnitudes are written to peakfile along with the number of iterations it took to fit the star, the goodness of fit statistic chi, and the image sharpness statistic sharp. If rejfile is defined only stars that are successfully fit are written to peakfile . The remainder are written to rejfile . Otherwise all the stars are written to peakfile . Peakfile and rejfile are APPHOT/DAOPHOT text databases if the DAOPHOT package parameter text is "yes", STSDAS binary table databases if it is "no".
The coordinates read from photfile are assumed to be in coordinate system defined by wcsin . The options are "logical", "tv", "physical", and "world" and the transformation from the input coordinate system to the internal "logical" system is defined by the image coordinate system. The simplest default is the "logical" pixel system. Users working on with image sections but importing pixel coordinate lists generated from the parent image must use use the "tv" or "physical" input coordinate systems.
The coordinate system of the PSF model is the coordinate system defined by the wcspsf parameter. Normally the PSF model was derived from the input image and this parameter default to "logical". However if the PSF model was derived from a larger image which is a "parent" of the input image, then wcspsf should be set to "tv" or "physical" depending on the circumstances.
The coordinates written to peakfile and rejfile are in the coordinate system defined by wcsout . The options are "logical", "tv", and "physical". The simplest default is the "logical" system. Users wishing to correlate the output coordinates of objects measured in image sections or mosaic pieces with coordinates in the parent image must use the "tv" or "physical" coordinate systems.
If cache is yes and the host machine physical memory and working set size are large enough, the input image pixels are cached in memory. If cacheing is enabled and the first measurement will appear to take a long time as the entire image must be read in before the measurement is actually made. All subsequent measurements will be very fast because PEAK is accessing memory not disk. The point of cacheing is to speed up random image access by making the internal image i/o buffers the same size as the image itself. However if the input object lists are sorted in row order and sparse cacheing may actually worsen not improve the execution time. Also at present there is no point in enabling cacheing for images that are less than or equal to 524288 bytes, i.e. the size of the test image dev$ypix, as the default image i/o buffer is exactly that size. However if the size of dev$ypix is doubled by converting it to a real image with the chpixtype task then the effect of cacheing in interactive is can be quite noticeable if measurements of objects in the top and bottom halfs of the image are alternated.
By default PEAK computes new centers for all the stars in photfile . However if the DAOPARS parameter recenter is "no", PEAK assumes that the x and y centers in photfile are the true centers and does not refit them. This option can be quite useful in cases where accurate center values have been derived from an image that has been through some non-linear image restoration algorithm, but the photometry must be derived from the original unrestored image.
By default PEAK uses the sky value in photfile . However if the DAOPARS parameter fitsky is "yes", then PEAK computes a new sky value as part of the non-linear least-squares fit. Recomputing the sky can significantly reduce the scatter in the magnitudes in regions where the sky background is varying rapidly, but users may need to increase the fitrad parameter to include more sky pixels in the fit. Users should experiment cautiously with this option.
Only pixels within the good data range delimited by the DATAPARS task parameters datamin and datamax are included in the fit. Most users set datamin and datamax to exclude pixels outside the linearity regime of the detector. By default all the data is fit. Users are advised to determine the values of these parameters for their detector and set the values in DATAPARS before beginning DAOPHOT reductions.
Only pixels within the fitting radius set by the DAOPARS task parameter fitrad divided by the DATAPARS parameter scale are included in the fit. Since the non-linear least-squares fits determine three unknowns, the x and y position of the star's centroid and its brightness, the value of fitrad must be sufficiently large to include at least three pixels in the fit. To accelerate the convergence of the non-linear least-squares fitting algorithm, pixels within fitrad are assigned weights which are inversely proportional to the radial distance of the pixel from the x and y centroid of the star, falling from a maximum at the centroid to zero at the fitting radius. Fitrad must be sufficiently large to include at least three pixels with non-zero weights in the fit. Values of fitrad close to the full-width at half-maxima of the PSF are recommended.
PEAK performs a weighted fit to the PSF. The weight of each pixel is computed by combining the radial weighting function described above with weights derived from the expected random errors computed using the values of the DATAPARS parameters readnoise and epadu specified by the user. Both to obtain optimal fits, and because PEAK employs a conservative formula, dependent on readnoise and epadu , for reducing the weights of deviant pixels which do not approach the model as the fit proceeds, users are strongly advised to determine the values of these parameters accurately, and to enter these values in DATAPARS before beginning any DAOPHOT reductions.
For each star to be fit, PEAK extracts a subraster from image which is N by N pixels square where N is approximately 2 * psfrad / scale + 1 pixels wide. Psfrad is the PSF radius specified in the DAOPARS task and scale is the scale factor specified in the DATAPARS task. Psfrad may be less than or equal to, but can never exceed the value of the image header parameter "PSFRAD" in psfimage . Psfrad should be set to a value several pixels larger than fitrad in order to permit the x and y centroids to wander during the fitting process.
Along with the computed x and y centers and magnitudes, PEAK outputs the number of times the PSF fit had to be iterated to reach convergence for each star. The minimum number of iterations is three. The maximum number of iteration permitted is specified by the maxiter parameter in the DAOPARS task. Obviously the results for stars which have reached the maximum iteration count should be viewed with suspicion. However since the convergence criteria are quite strict, (the computed magnitude must change by less than .001 magnitudes or 0.05 sigma whichever is larger and the x and y centroids must change by less than 0.01 pixels from one iteration to the next), even these stars may be reasonably well measured.
PEAK computes a goodness of fit statistic chi which is essentially the ratio of the observed pixel-to-pixel scatter in the fit residuals to the expected scatter. Since the expected scatter is dependent on the DATAPARS task parameters readnoise and epadu , it is important for these values to be set correctly. A plot of chi versus magnitude should scatter around unity with little or no trend in chi with magnitude, except at the bright end where saturation effects may be present.
Finally PEAK computes the statistic sharp which estimates the intrinsic angular size of the measured object outside the atmosphere. Sharp is roughly defined as the difference between the square of the width of the object and the square of the width of PSF. Sharp has values close to zero for single stars, large positive values for blended doubles and partially resolved galaxies, and large negative values for cosmic rays and blemishes.
Because PEAK cannot fit stars in crowded fields with overlapped images like the NSTAR and ALLSTAR tasks do, and for sparsely populated frames aperture photometry produced by PHOT is often just as good and faster to compute, PEAK has few unique functions. PEAK is often useful however for fitting and removing single stars in images where the stars are interfering with the real object of interest such as a galaxy. In that case the PEAK results can be input to SUBSTAR which will then remove the interfering stars. Another potential use of PEAK is the removal of stars from sparsely populated sky flats in preparation for smoothing.
If verbose = yes, a single line is output to the terminal for each star fit or rejected. Full output is written to allstarfile and rejfile . At the beginning of these two files a header listing the current values of the parameters is written. For each star fit/rejected the following quantities are written to the output file.
id xcenter ycenter mag merr msky niter sharpness chi pier perr
Id is the id number of the star. Xcenter and ycenter are the fitted coordinates in pixels. Mag and merr are the fitted magnitude and magnitude error respectively. Msky is the individual sky value for the star. Niter is the number of iterations it took to fit the star and sharpness and chi are the sharpness and goodness of fit statistic respectively. Pier and perror are the photometry error code and accompanying error message respectively.
If no errors occur during the fitting process then pier is 0. Non-zero values of pier flag the following error conditions.
0 # No error 1 # The sky is undefined 2 # There are too few good pixels to fit the star 3 # The fit is singular 4 # The star is too faint
1. Compute the PSF model for the test image dev$ypix. Good stars for making the PSF model can be found at (442,410), (348,189), and (379,67).
da> datapars.epadu = 14.0
da> datapars.readnoise = 75.0
... set the gain and readout noise for the detector
da> daofind dev$ypix default fwhmpsf=2.5 sigma=5.0 threshold=20.0
... answer verify prompts
... find stars in the image
... answer will appear in ypix.coo.1
da> phot dev$ypix default default annulus=10. dannulus=5. \
apertures = 3.0
... answer verify prompts
... do aperture photometry on the detected stars
... answer will appear in ypix.mag.1
da> display dev$ypix 1
da> psf dev$ypix default "" default default default psfrad=11.0 \
fitrad=3.0 mkstars=yes display=imdr
... verify the critical parameters
... move the image cursor to a candidate star and hit the a key,
a plot of the stellar data appears
... type ? for a listing of the graphics cursor menu
... type a to accept the star, d to reject it
... move to the next candidate stars and repeat the previous
steps
... type l to list all the psf stars
... type f to fit the psf
... move cursor to first psf star and type s to see residuals,
repeat for all the psf stars
... type w to save the PSF model
... type q to quit, and q again to confirm
... the output will appear in ypix.psf.1.imh, ypix.pst.1 and
ypix.psg.1
da> peak dev$ypix default default default default
... the results will appear in ypix.pk.1 and ypix.prj.1
da> pdump ypix.pk.1 sharpness,chi yes | graph
... plot chi versus sharpness, the stars should cluster around
sharpness = 0.0 and chi = 1.0, note that that the frame does
not have a lot of stars
da> substar dev$ypix ypix.pk.1 "" default default
... subtract the fitted stars
da> display ypix.sub.1 2
... note that the psf stars subtract reasonably well but other
objects which are not stars don't
2. Run peak on a section of the input image using the photometry file and PSF model derived in example 1 for the parent image and writing the results in the coordinate system of the parent image.
da> peak dev$ypix[150:450,150:450] default default default default \
wcsin=tv wcspsf=tv wcsout=tv
... answer the verify prompts
... fit the stars
... the results will appear in ypix.pk.2 and ypix.prj.2
da> display dev$ypix[150:450,150:450] 1
... display the image
da> pdump ypix.pk.2 xc,yc yes | tvmark 1 STDIN col=204
... mark the stars
da> substar dev$ypix ypix.pk.2 "" default default
... subtract stars from parent image
... the output images is ypix.sub.2
da> substar dev$ypix[150:450,150:450] ypix.pk.2 "" default default \
wcsin=tv wcspsf=tv wcsout=tv
... subtract stars from the peak input image
... the output images is ypix.sub.3
datapars,daopars,nstar,allstar