#first I'll load some basic tools, please make sure you've started this notebook with "ipython notebook --pylab"
import matplotlib.pyplot as plt
import pyfits
import numpy as np
Here is an example of what a crowded field might look like:
image=pyfits.getdata('../data/nic2_f110w_dn.fits') #this is a drizzled nicmos image of the galactic bulge in units of DN, exptime ~ 94,072 s
plt.imshow(image,vmin=1000,vmax=12000,cmap=plt.cm.gray)
plt.colorbar()
<matplotlib.colorbar.Colorbar instance at 0x108d8e830>
The above image is about a 20 arcsec FOV on one side. That's a lot of stars in a small area, with lots of spoilers and neighbors. PSF photometry is your best bet
I'll bold highlight things which do well as functions
When line identifiers (A, B, ..) repeat, it means those operations are another iteration of the same process
A. Find stars in the image and run aperture photometry (maybe with iraf.daofind and iraf.apphot). This whole part can be scripted for repitition and analysis. It's also a common function you can use for regular aperture photometry
Be careful of the aperture you use to retrieve the photometry, consider crowding and the structure of the instruments PSF
Find as many stars as you can, you can always throw the junk out later
save your photometry parameters so that more stars can be selected with the same defaults later in the process if necessary
decide if doing photometry on the subtracted image with centroiding on gives you a better or worse location estimate for the first go around
only pixels in the good data range defined in your datapars are used for the fit make sure these are set at the beginning of the process
the detector noise characteristics you enter here are used during the PSF fits
if you were just doing aperture photometry, you would stop here and apply your aperture correction to the measured values and be done.
B. Examine the PSF structure of the brightest and most isolated stars in the image to determine what kind of fitting radius you might use, what your model psf radius should be and what kind of analytical fit will be best. The goal is only to use the brightest, most isolated stars to create your model so that you can cleanly fit the other stars which have issues without introducing more problems.
#put example of psf here
C. Setup all your DAOPARS
D. Select the model PSF stars from your image
they shouldn't have any close neighbors (at least as far away as your fitting radius, preferably more) - use iraf.daophot.pstselect to preselect a group of stars for you
display the image with the selected stars marked and examine them for neighbors or stars which weren't detected by your finding routine
do photometry on any undetected star and add this information back into your photometry file
write a script that takes the list of stellar coordinates you want to add, performs photometry on them, then concatinates this new photometry with the original output photometry file.
E. Create your first PSF image by running daophot.psf
#show an example image of what the psf looks like
F. Remove the neighboring spoiler stars(the group list) from your image using the psf you just created
Worth Considering
You've performed aperture photometery on these stars under varying background conditions. A pass of aperture photometry on the original science image most likely uses the modal value of the pixels in your sky annulus to predict a sky value to subtract from the stellar flux inside your aperture. When you perform PSF photometry, allstar can also recalculate the sky around each star AFTER neighbors have been subtracted using the median pixel values. How accurate either of these assumtions are should be considered for the completeness study you perform afterwards with artificial stars in your science frame.
A. If you found more hidden stars, run your handy scripted functions on them to collect their photometry from the subtracted image and add them to your master photometry file which also renumbers everything again. If you centered the stars when finding them in the subtracted image, don't recenter them in the aperture photometry later on if you redo the photometry from the original image.
F. Remove the neighboring spoiler starts from the original image
E. Recompute your PSF model with daophot.psf
Repeat steps A, F, and E until you can subtract all the neighboring stars cleanly from the image.
G. Run daophot.allstar on your original science image, to get your final PSF photometry values for each star
#show a plot comparing aperture and psf photometry results
Using your final PSF model and original science image, write a set of functions:
which can be used to iteratively add artificial stars into your image and then retrieve them using exactly the same methods as above
generate a random list of star locations and magnitudes, save this for reference later!
use daophot.addstar to add this list of stars into your science image, it will also add Poisson noise to the stars using the value of the gain
run A. to find stars in the newly created, artifical star populated image, and run aperture photometry
using your PSF model, run daophot.allstar to collect the psf photometry
which matches your list of artificial star locations to the psf photometry information you just retrieved and save a file which contains the input and output information for each artificial star
make fun comparison plots of your aperture and psf photometry, your retrieval success, and anything else that sounds exciting after 5 beers.
#show an example of a completness plot