Photometry Using Point Spread Functions

Preparation for Running a Psf Fit
Using the Psf Command
Using the Nstar Command
Using the Substar Command
Preparing the Psf Fit for Allstar
Using the Allstar Command

When doing photometry on crowded star fields, such as globular clusters or open clusters, aperture photometry will not yield reliable results. It is better to use a Point Spread Function: a gaussian that can be fitted to all of the stars in the field in order to find their magnitudes. In addition to this tutorial, I recommended reading A User's Guide to Stellar CCD Photometry by Phillip Massey and Lindsey Davis. It will help you get better acquainted with the long process required in finding a good PSF fit.

Preparation for Running a PSF Fit

Before getting started with PSF fitting, you will have to run daofind and/or tvmark to pick out the stars to you want to use for photometry. Once the coordinate file is created, run phot in order to get a .mag file. (See Aperture Photometry) You must have a photometry file for psf to work.

Once all of this has been accomplished, exit the apphot package and enter daophot at the di prompt.

Using the Psf Command

The psf command can be accessed by entering digiphot and then daophot at the cl prompt. Now enter epar psf and set the following parameters:

interac=yes Run psf in interactive mode. It is the best way to create the psf function, because you will be able to choose the stars used.
verify=yes This makes IRAF prompt you for the critical parameters
graphic=stdgraph sets the graphic display
display=stdimage sets the image display

Now you can enter psf filename at the da prompt. You will be prompted for the following information:

Input phtometry file(s): Enter in the name of the .mag file you created earlier. You must have a photometry file, or else psf will not work
Input psf star list(s): If you are starting from scratch, enter "" at the prompt.
If you have allready run psf on the image, you can add on or delete psf stars from your original list. Just enter the name of the .pst file, or enter default. If default is chosen, IRAF will use the most recent (highest number) .pst file.
Output psf image(s): If default is shown in parenthesis, press enter. This will create a numbered .psf.fits file. Alternatively, you can enter a different filename you want.
Output psf star list(s): If default is shown in parenthesis, press enter. This will create a numbered .pst file containing coordinates, magnitudes, ID number, and other information about the stars you have chosen to use for the psf fit. As always, you can enter a different filename if you want.
Output psf star group file(s) If default is shown in parenthesis, press enter. This will create a numbered .psg file containing information about the stars you have chosen for the psf fit along with their nearby neighbors, if applicable. You can enter a different filename if you want.
Analytic PSF function (gauss): "Gauss" should be in parenthesis; press enter. If not, enter gauss at the prompt. This determines the type of function used in the fitting the stars
Order of variable PSF (0): Press enter to accept "0", or enter 0 at the prompt
PSF radius in scale units: Determines the outer radius used to create the psf fit. A radial profile of the star will be created using this radius in order to fit the function.
Massey and Davis suggest using 11 with a fitting radius of 3, or 13 with a fitting radius of 4
Fitting radius in scale units: The inner radius used to create the psf fit. Massey and Davis suggest using a fitting radius about the size of the FWHM; be generous.
Minimum good data value (INDEF): Press enter to accept "indefinite" unless you have an idea of what you want the min data value to be.
Maximum good data value (INDEF): Press enter to accept "indefinite" unless you have an idea of what you want the max data value to be.

Once you have answered the prompts, the cursor will change to a blinking annulus, much like imexamine. If you have specified a psf list in the beginning, a surface plot of each star on that list will be displayed one after the other for your approval. You must either accept them by pressing 'a' or reject them by pressing 'd'. Then you will be free to select other stars by placing the cursor over them. Like imexamine, psf follows keystroke commands. (See help psf for a full listing or press '?' when you enter interactive mode).

a Adds a star to the psf list
IRAF will display a surface plot of the star you have chosen along with coordinates and preliminary magnitudes from the photometry file you supplied.
Examine the plot, and decide whether or not you want to use this as a psf star. It should not have a flat top, which indicates saturation. The peak should appear pointy. The star should be evident above background noise. (It's best if the surface below the peak appears flat; however, this will depend on the uniformity of the background counts and the signal to noise ratio. You will not be able to achieve a smooth surface for some stars; just make sure the peak is easily recognizable above all the noise.)
To continue and accept the star for the psf list, press 'a'. If you have changed your mind, press 'd' and the star will not be added to the list
d Deletes a star from the psf list
Keep an eye on the IRAF command window. It will be telling you which stars are being added and deleted on the list.
l Lists the current psf stars in the IRAF command window
z Rebuilds the psf list from scratch
w Writes the psf to the psf image file
This is VERY IMPORTANT. You should press 'w' right before quitting, or else you will have to go back and run psf again.
q Exits psf

Select your psf stars. Three to five will be good enough, unless there is a great amount of variation across the image. (In this case, Massey and Davis suggest that having as many as twenty is a good idea.) Choose as many stars as you can that don't have many neighbors but still have a good profile. In a star cluster, this will be more difficult than it seems. At any rate, try to choose as many good stars as possible to obtain an appropriate fit.

Next you will have fit stars with the psf function using nstar and subtract them from your image with substar in order to see how good of a fit you have obtained.

Using the Nstar Command

The command nstar can be accessed in the same package as psf by entering digiphot and then daophot at the cl prompt. Nstar will fit the psf function you have created to each of the stars in the group file (.psg) simultaneously.

First, look at the .psg list created by psf by entering ! more filename at the IRAF command prompt. Note the stars that have neighbors listed. (They will all have the same identifying numbers, although their id numbers from the photometry file you used will also be displayed.) Look at the stars in your image and determine a smaller PSF radius that will not overlap with neighboring stars. (Running tvmark with the coordinates from your photometry file will aid you in identifying which stars you need to evaluate.)

Now you can enter nstar filename at the IRAF command prompt, where filename corresponds to the image you will be evaluating. You will receive the following prompts:

Input groupfile: If default is in parenthesis, press enter or to accept it or enter "default" at the prompt. This will cause the most recent .psg file to evaluated. Otherwise, enter the name of the file you want to be used.
Output photometry file (default): Press enter to accept default in parenthesis or enter "default" at the prompt. This will create a numbered .nst file containing photometry for the group stars. Alternatively, you may enter a different name for the outupt file.
Output rejections file: Enter "" at the prompt, because you do not need a rejections file.
Recenter the stars (yes): Press enter to accept the default of "yes"
Refit the sky (no): Press enter to accept the default of "no"
Use group sky values (yes): Press enter to accept the default of "yes"
Psf radius in scale units: Enter the smaller radius that you determined before executing the nstar command
Fitting radius in cale units: Enter the fitting radius you have been using
Maximum group size number of stars (60): Press enter to accept the default size of "60"
Minimum good data value (INDEF): Press enter to accept "indefinite" unless you have an idea of what you want the min data value to be
Maximum good data value (INDEF): Press enter to accept "indefinite" unless you have an idea of what you want the max data value you be


Nstar will fit the psf to the stars in the .psg list, and return a .nst file that you can now use with substar to see how well you psf fit worked.

Using the Substar Command

Substar will subtract the stars you have fitted with the psf function from the original image. It runs in the same package as psf; just enter digiphot and then daophot at the cl prompt.

Enter substar filename at the IRAF command prompt, where filename corresponds to the image you are evaluating. You will receive the following prompts:

Input photometry file (default): Press enter to accept default in parenthesis or enter "default" at the prompt. This will use the most recent .nst file created by nstar. You can enter an alternative filename if you want.
Input exclude file: Enter "" at the prompt. You do not want to exclude any stars
PSF image (default): Press enter to accept default in parenthesis or enter "default" at the prompt. This will use the most recent .psf file. Alternatively, you can enter a different filename.
Subtracted image (default): Press enter to accept default in parenthesis or enter "default" at the prompt. This will cause a numbered .sub.fits file to be created. Alternatively, you can enter the filename you want to be used for the output.
Psf radius: Use the smaller radius that you determined before running nstar
Minimum good data value (INDEF): Press enter to accept "indefinite" unless you have an idea of what you want the min data value to be
Maximum good data value (INDEF): Press enter to accept "indefinite" unless you have an idea of what you want the max data value to be

When substar is done running, display the output file. It is best to open it in a separate frame from the original image, and blink them to see the differences. If there is little to no residuals left over from the subtracted stars, you have gotten a good psf fit. However, if some of the residuals look strange or opposite from the other stars' residuals, it is best if you go back and delete that star from the psf list. (In this case, run psf with your old star list.) Then repeat the process with nstar and substar.

If you are happy with the stars you have chosen for the fit, you can go on to delete the neighbor stars to create an even better fit, and then run allstar.

Preparing the Psf Fit for Allstar

Follow these steps in order to create the final psf fit:

  1. Run substar again. This time, enter the name of the your psf star list (.pst) file as the Input exclude file. This will delete the neighbor stars from your image, but not the psf stars. (Don't forget to keep the smaller psf radius!!)
  2. Run psf again. This time, use the subtracted image you have just created. Be careful to fill out the filenames for inputs and outputs, or else you will get some complicated files like .sub.fits.pst and the like. If you leave "default" on for the inputs, IRAF will look for a .sub.fits.mag file that doesn't exist. This time you can use the larger psf radius that you used the first time. Input your old .pst file and accept all of the stars.
  3. You can run nstar and substar again, just to be sure the fit is good, but you don't really have to.
Now you are ready to use allstar, which will fit the psf to all the stars in your photometry (.mag) file.

Using the Allstar Command

Once you have obtained a good psf fit with stars that have no neighbors, you can run allstar to fit the rest of the stars in your image. Allstar runs in the same package as psf; just enter digiphot and then daophot at the cl prompt.

Enter allstar filename at the IRAF command prompt, where filename corresponds to the image you are working on. You will receive the following prompts:

Input photometry file (default): Press enter to accept default in parenthesis or enter "default" at the prompt. This will use the most recent .mag file for the image. Alternatively, you can enter a filename of your choosing.
PSF image (default): Press enter to accept default in parenthesis or enter "default" at the prompt. This will use the most recent .psf file for the image. Alternatively, you can enter a filename of your choosing.
Output photometry file (default): Press enter to accept default in parenthesis or enter "default" at the prompt. This will create a numbered .als file containing magnitudes and information for all of your stars. Alternatively, you can enter a filename of your choosing.
Subtracted image (default): Press enter to accept default in parenthesis or enter "default" at the prompt. This will create a numbered .sub.fits file with all of the stars subtracted from your image (if they are in the .mag file). Alternatively, you can enter a filename of your choosing.
Output rejections file: Enter "" at the prompt. You do not need a rejections file.
Recenter the stars (yes): Press enter to accept the default of "yes"
Use group sky values (yes): Press enter to accept the default of "yes"
Refit the sky (no): Press enter to accept the default of "no"
Psf radius in scale units: Use the psf radius you decided on in the very beginning. (13 for a fitting radius of 4; 11 for a fitting radius of 3).
Fitting radius in scale units: Use the fitting radius you decided on in the very beginning.
Maximum group size in number of stars (60): Press enter to accept the default of "60"
Minimum good data value (INDEF): Press enter to accept "indefinite" unless you have an idea of what you want your min data value to be
Maximum good data value (INDEF): Press enter to accept "indefinite" unless you have an idea of what you want your max data value to be

Once allstar has finished (it might take awhile), look at the subtracted image and blink it with your original. If there are little to no residuals, you have done a good job!! However, if the image looks bad or the stars aren't fully subtracted, you should start over. Keep in mind that saturated stars will look bad when they are used with the psf. It is best not to start doing photometry on them in the first place. Stars just underneath or next to another will now appear and you can mark and repeat the psf fitting on them. Keep in mind, however, not to include stars that are just underneath or near to a larger star when you are using the psf fit for the first time.