Astronomy 480 - IRAF Tutorial for Exercise V
Introduction to PSF Fitting and DAOphot

Learning Goals

Files Used

Processed images of the globular cluster M92.

Introduction

The original motivation for PSF fitting methods was for crowded field photometry, where often stellar images are blended, and any reasonable size aperture might include more than one star. DAOphot was developed by Dr. Peter Stetson at the Dominion Astrophysical Observatory, Victoria BC, for precise ground-based photometry in the crowded fields of globular clusters. It has since been incorporated into IRAF as the PSF fitting package. If you want to know all the gory details see Stetson (1987). However, even for uncrowded environments PSF methods may still yield improved signal-to-noise by more than 10% compared to aperture photometry, since more of the available information is being used. The profiles of stars from the ground have been found to consist of an approximately Gaussian core, due to seeing. In addition, the profiles have large wings decreasing only as an inverse square in intensity, largely a result of atmospheric scattering off dust and aerosols, plus dirt and scratches in the optical system. Use of profile fitting techniques can remove most of the variations due to seeing changes, as well as enabling larger effective radii to be used.

Procedure (in DAOphot)

Here is a summary of the procedure one must follow.

  1. Find all the stars on the frame above a user-set brightness threshold. The task daofind in daophot convolves a Gaussian profile (of approximately the correct FWHM-PSF) with each pixel, and can therefore discriminate between extended sources, stars, cosmic rays and CCD defects.
  2. Run aperture photometry upon all the stars.
  3. Deselect stars too close to the edge, or too faint and not within a group. Choose a set of bright, isolated stars spread across the frame – the PSF stars.
  4. Build a semi-empirical model PSF. Each of the PSF stars is scaled according to its aperture magnitude estimate, the weighted average is then fitted with a suitable analytic function, and a look-up table computed of the residuals (interpolating between the remainder value for each pixel). The analytic functions used are chosen from bivariate Gaussian, Moffat or Lorentz functions (or you can set it to auto and it finds the best). An iterative procedure may be required to produce a `clean' PSF in some cases, whereby PSF modelling and fitting is performed, faint neighbors of PSF stars are identified on a frame with the PSF stars subtracted, fitted themselves and subtracted and the procedure repeated.
  5. Using the centroid of a star as the profile center, and sky level as determined for aperture photometry, the PSF model is shifted and scaled to fit the observed stellar image by non-linear least-squares. The scaling yields the magnitude estimate.
  6. To cope with the blending of stellar PSFs, the stars are grouped together before fitting if there is overlap, and each star in a group is fitted at the same time.

Although the PSFis modelled over a large radius (typically twice the FWHM), one may choose the central region over which the fitting is done. About 1 times the FWHM PSF works well, that is, about the same as the radius used for the preceding aperture photometry.

hintThought Questions: Read over these 6 summaries and see if you can (mentally) translate from "astrospeak" to "student-speak." What does "FWHM" refer to? Why is this quantity important? Why might we expect "seeing" to produce a Gaussian curve from the light produced by a point source?

Using DAOphot

DAOphot flowchart
Figure 1. PSF fitting photometry flowchart

In this assignment you will be asked to log your data onto the answer worksheet. Because the final results depend crucially on your answers at the beginning, make sure you check your parameters with your instructor, TA, or the web page on-line. For clarity, Figure 1 shows a flowchart showing the various steps involved. Review these steps and consider whether or not they seem reasonable. We'll go through them with the M92 dataset.

Throughout this handout, we will use "m920004" as the image you work on. However, this could just be any fully processed (i.e. bias- and dark-subtracted, and QE corrected) image on which you want to do photometry, especially one with many, many stars in the field. Make sure you use only the fully processed M92 files here.


 

key (Note the key at the left as you will need to repeat the following steps for m920006 once you finish with m920004.)

Generating the star coordinate list

First you need to set the characteristics of the CCD image data in the datapars file; daoedit is a useful task for this, providing you with information on the FWHM PSF of stars, sky mean and sky sigma.

ecl> digiphot # Did you "unlearn" it first?
di> daophot  
di> disp m920004 1  
da> daoedit m920004  
? # list cursor options
  # WHAT PARAMETER SETS ARE USED?
r # produce radial plot for star, FWHM PSF, sky mean and sigma tabulated in graphics window.
a # gives you an on-screen record

Now do Problem #1, repeating the steps for 5 stars in each filter.

Select isolated stars over a range of brightnesses to get representative values. We are getting set up to determine parameter values for the task datapars. The values we set are crucial for the success of DAOphot! After you determine your values, check them against those shown on-line to make sure that yours are not only reasonable but also ones that will work. It is OK if yours are slightly different from the on-line ones.

hintNOTE: These parameter files require either the image header keyword OR the actual value for some parameters. You usually do not need to provide both.

The other critical parameters you need to set in datapars are:

Find the actual image header keywords for the following parameters and enter them in datapars:

Now do Problem #2, filling in the table. Do not run daofind quite yet.

hint Thought questions: What would happen with the number of stars selected if you set datamin too low? Too high? We will be working with images of M92, a globular cluster taken through a visual and a blue filter. Would you expect the datamin (minimum detection threshold) value to be greater or less in the visual filter than in the blue? For a given datamin, would you expect more stars to be selected in the visual image or the blue? Why? Why would we even want to set a datamax value? Under what conditions would setting this value be required?

After you have filled out the table with your values, compare those values with the instructor's or TA's copy of the datapars listing to see if your values are reasonable.

warning Cautionary Note: You will most likely need to run daofind many times until you get results that you are satisfied with. Each time you run it, more output files are generated. The best thing to do is delete those files before rerunning daofind so that all files are version ".1" as in m920004.mag.1, m920004.coo.1, etc. DON'T TRUST YOUR MEMORY TO KNOW WHICH VERSION OF .MAG, .COO, AND OTHER FILES GENERATED GO WITH WHICH OTHER VERSIONS. Trust your instructor on this fine point of working within IRAF; deleting files and starting completely over will save you time in the long run.

da> daofind m920004 #defaults should be okay- threshold may sometimes require adjustment
HIT THE SPACEBAR TO ACTIVATE THE PHOTOMETRY. You will then "q" and "w" just like qphot.
da> tvmark 1 m920004.coo.1 mar=cir rad=3 # mark ID'd stars on image
da> txdump >> m920004.coo #generate simple ascii coordinate list.
m920004.coo.1
#respond to prompt
xc,yc
#respond to prompt
da> tvmark 1 m920004.coo mar=cir rad=4 # check results

In m920004.coo you now have a list of all stars upon which daophot thinks it can perform PSF fitting. If only a few stars were selected, then perhaps some of the parameter values need to be adjusted. What do you think?

Perform aperture photometry

This part of the tutorial and exercise is extremely important! Make sure you understand what is going on. It helps to use phelp often and seriously.

The task phot uses a number of different parameter files: its very own photpars, the general CCD/image one (datapars), one for centering (centerpars) and yet another for the sky fitting (fitskypars). You need to edit each of these. Remember, it is usually an excellent idea to "unlearn" each parameter set before entering in your values. Accept the defaults as as given, unless itemized below.

da> epar photpars  
apertures = ?
# choose an appropriate aperture size for relatively faint stars
da> epar centerpars  
calgorithm = centroid
#calgori
cbox = 5.0
 
da> epar fitskypars  
salgorithm = mode
#salgori
annulus = ?
# choose sensible values here to start with
dannulus = ?
 

Now do Problem #3. After marking down your choices, compare them with those of a classmate and then your instructor or TA before proceeding.

da>lpar phot # What’s there? Do you see what other tasks are called?
da> phot m920004 m920004.coo # output file m920004.mag.1 (same as qphot)

Get a listing of the files in your directory. If you run phot more than once, you get more than one ".mag" file for an image. The second file is named ".mag.2" and if you run phot again, you get a ".mag.3" etc. The program will not overwrite a .mag file. This also happens to the .coo files and the .als files, and so on. We STRONGLY recommend that you either move the previous output files to a subdirectory or delete them altogether. Having multiple versions of these files WILL result in confusion and irregular results. Previous statement has been proven many times before. See warning with the warning above.

hintNOTE: At this stage you should check our output ".mag" file. If there are a large number of INDEFs present, then you have not done a good enough job so far. Find out where those INDEFs are occurring. Are they for the airmass? For the filter used? For the magnitude and magnitude error? You need to tweak parameters until your output file shows fewer than a dozen INDEFs. THIS IS IMPORTANT!

Select PSF template stars

First set your PSFparameters:

da> epar daopars # give your values a run first
function = auto
 
psfrad = ?
# the radius within which the stars, PSFis defined
fitrad = ?
# region in which fitting performed

Then select your stars interactively:

da> epar pstselect # 5 is probably all you will need
maxnpsf = 5
 
interac = yes
 

Five is a reasonable number of stars to use to make template. The fainter they are, the more you need; it is all a matter of making a good model. Choose isolated, fairly bright stars. Now may be a good time to do a "phelp pstselect."

da> pstselect m920004

Accept the defaults echoed or change them. The program accepts the .mag file with the HIGHEST version number.

MAKE SURE YOU CAN SEE ALL OF EVERY WINDOW!

Select suitable PSF stars (i.e. bright and isolated), saving each one as desired until you reach maxnpsf, save and quit.

The steps are "a" for add when in the image, and "a" for accept when in the graph as you examine the 3-D profile. It is best if you do not rush the program here. We found that it takes a few seconds to activate the graphics window. You can delete a star from the list by putting the cursor over it and hitting "d."

da> ls #Your directory should contain a m920004.pst.1 file

hintThought questions: Will you need to change some of the parameters when dealing with the blue image? Since we will be graphing the visual magnitude against the B-V color, what we need to have is the same stars in both lists, and hopefully lots of them. But, this may come at the expense of throwing some of the V stars out, or getting closer to the noise level in the B image. For observations of a globular cluster (with exposure times and bandwidths of the filters roughly equal), why might we expect more stars in the visual bandpass than the blue?

Now go back to the key and do the steps again for m920006.


Generate the model PSF

There has to be the same number of lines in each ".lis" file. IRAF processes these lists on a line-by-line basis.

da> ls m92*.fits > im.lis # generate list of images
da> ls *.mag.1 > mag.lis #generate corresponding list of mag files
da> ls *.pst.1 > pst.lis #
da> psf @im.lis @mag.lis @pst.lis interac- #run PSF non-interactively; the @ sign tells the program to look in the file for lines of data

hintNOTE: We ran the PSF task two times, once for each filter. We could have done it a couple more times for the other two images (one more V, one more B), but you get the idea. What would we have done if we had 50 images instead? More time would have to be spent examining the images. What we want the program to do is maintain the same order of stars and IDs. If that happened, then we could list all of the images in a batch file and let the computer go. That's not practical herewith the shifts in pixel coordinates and uneven selection of stars.

Now to examine the model PSF (something you should ALWAYS do under PSF fitting photometry!):

da> lpar seepsf  
da> seepsf m920004.fits.psf.1 m920004.fits.psf.1s
da> seepsf m920006.fits.psf.1 m920006.fits.psf.1s
da> disp m920004.fits.psf.1s # display
da> disp m920006.fits.psf.1s # display
Use imexam to check that profile looks like that of single star (No sign of contamination from near neighbors)
da> imexam  

Now do Problem #4.

Perform PSF fitting photometry

da> ls *psf.1.fits > psf.lis # generate list of PSFfiles

The next step finally produces the PSF fitting photometry files *.als.1 - nothing short of magic.

da> allstar @im.lis @mag.lis @PSF.lis

Now do Problem #5, and check your results with those of another student and with your instructor.


Matching the stars from your results

You will need to obtain a program called "match." This program, written in C and PERL, is a terrific time saver. Following are the steps you should take to install the program in one of your directories. You will be deleting these files after you finish this exercise, but we figured the installation process is an important one for you to learn. NOTE: MATCH IS RUN UNDER LINUX, NOT IRAF!

Summarize here, as much as you can understand, what you think the .configure, make, and make check commands are doing.

 

 

 

Have your instructor initial that you’ve tried to figure things out: ___________

One of the extracted files is called "match.html." It describes how to use match to extract the information for stars that are "matched" in both the visual and blue images. You should read through the introduction, preparing the input, and usage sections of the manual.

Within IRAF, extract the ID, XCENTER, YCENTER, MAG, AND MERR from your two *.als.1 files. You should not run match in your bin directory but rather in the directory where your processing has been occurring.

Noting that the first column of the table is given the index number "0," the following command works fine for our work if you extracted the information exactly as given (substitute your file names for the italized names):

match starsA.dat 1 2 3 starsB.dat 1 2 3 outfile=matched id1=0 id2=0

Compare the results side-by-side by using the following command

diff --side-by-side *mt* | less

References