AstroDrizzle: Aperture Photometry Accuracy

The goal of this demonstration is to assert the accuracy of aperture photometry measurements on ACS/WFC images using the new software package Drizzlepac. With this goal in mind, we compare stellar instrumental magnitudes calculated using individual FLT images from the HST pipeline with the instrumental magnitudes of the same sources estimated using the AstroDrizzle output.

Observational Data

This example describes the combination of two sets of three ACS/WFC images of open cluster NGC 6791 (Program 9815, PI Ivan King) which were obtained with the filters F606W and F814W. The GO used three orbit visit for each filter, taking three short (30 sec) exposures with POS TARGS in order to achieve a 3-way sub-pixel dither pattern. The interchip gap was not covered in these observations. Table 1 provides some basic information on the images which are available from the HST archive for those who wish to repeat this experiment.

Dataset Filter POS-TARG1 POS-TARG2 Exposure time
j8ny01suq F606W 0.000 0.000 30.0
j8ny01t4q F606W 0.0665 0.1886 30.0
j8ny01teq F606W 0.1827 0.0813 30.0
j8ny02yuq F814W 0.000 0.000 30.0
j8ny02z9q F814W 0.0665 0.1886 30.0
j8ny02zqq F814W 0.1827 0.0813 30.0

 

Table 1: HST/ACS datasets used in our experiment. The exposure time is given in seconds.

Image Registration

We begin by performing an image alignment. This task is crucial to obtain accurate photometry. We create a text file with the names of the FLT images, one for each filter. We call them list_f606w and list_f814w. In what follows we explain the registration method with filter F814W only. We work within the Pyraf environment:

> pyraf

We begin by performing an image alignment. This task is crucial to obtain accurate photometry. We create a text file with the names of the FLT images, one for each filter. We call them list_f606w and list_f814w. In what follows we explain the registration method with filter F814W only. We work within the Pyraf environment:

> pyraf

The task AstroDrizzle (AD) (the main task within the software package DrizzlePac) differs from MultiDrizzle in the handling of the distortion model. AD handles different components as separate inputs: polynomial coefficients, column corrections for the CCDs, and non-polynomial offsets. The new task updatenpol updates the headers with new keywords and also appends several arrays as new extensions that contain the full distortion model.

--> import drizzlepac
--> unlearn updatenpol
--> epar updatenpol

This will open a new window called TEASL (Task Editor And Launcher) which is a user interface. This GUI allows the user to change parameters: For the task updatenpol we write:

input = @list_f814w
refdir = /your/path/to/reference/files/

This should run without any problems and the images are now ready for registration. We now use the new task tweakreg which computes residual offsets for a group of flat field-calibrated images. These offsets are incorporated into the images by updating their WCS information to match that of a reference image.

--> unlearn tweakreg
--> epar tweakreg

In the tweakreg TEAL interface, we modify the following parameters:

input = @list_f814w
conv_width = 3.5
threshold = 200.

The value conv_with = 3.5 is approximately twice the FWHM measured directly on several bright unsaturated stars using the IRAF task imexamine. The value threshold = 200.0 is much higher than the default, simply to choose the brightest objects for catalog matching.

tweakreg finds sources in each image and outputs catalogs. This should take a few seconds if you had set a high threshold. The code then matches the catalogs to a reference file (usually the first in the list: in our case j8ny02yuq_flt.fits)

When the matching is finished between the first two files, a window will pop up and show the residuals for the matched stars, and tweakreg will also output the residual shifts in X (XSH) and Y (YSH), the rotation angle (ROT) and the scale (SCALE). Also, the RMS values for the fitting are presented. One would expect to obtain an RMS lower than 0.05 in both X and Y for good alignment. This process might take several iterations and it is recommended to spend some time with this until a good registration is achieved.

tweakreg prompts the user to accept or reject the solution. If you are not happy with the solution, you may want to select different threshold values or even input your own list of sources for the catalog matching. In our case, using the above non-default parameters values we get very good RMS values and we accept the solution for both images. Figure 1 shows the residuals for image j8ny02z9q and Table 2 presents the catalog matching solutions for all F814W images.

Output plot from the task tweakreg
Figure 1: Output plot from the task tweakreg showing the residuals in X and Y. These residuals are calculated by matching source catalogs between the reference image (j8ny02yuq) and the second image in our list (j8ny02z9q).
Dataset XSH YSH ROT SCALE XRMS YRMS
j8ny02yuq 0.000 0.000 0.000 1.000    
j8ny02z9q -0.161562 0.118522 359.99992 1.000001 0.031426 0.030819
j8ny02zqq -0.249673 0.248745 359.99997 1.000007 0.032765 0.033977

 

Table 2: Output values of the catalog matching process for the F814W images. Estimated residual shifts in X (XSH) and Y (YSH), the rotation angle (ROT) and the scale (SCALE) are shown. The rotation angle is given in degrees; the residual shifts (XSH, YSH) are in units of pixels.

Once we are satisfied with the results, we re-run tweakreg with the following parameters:

input = @list_f814w
updatehdr = yes
conv_eidth = 3.5
threshold = 200.

This will update the headers' WCS in all images to have exactly the same orientation and the images are registered and ready for AstroDrizzle. Expect to run AstroDrizzle several times on your data, so it would be important to save copies of these files in a separate folder.

Combining Observations with AstroDrizzle

All the necessary information for successfully combining the input data is at hand at this point. The header WCS of each image has been updated and this information provides the corrections to the alignment of the images to allow AstroDrizzle to correctly identify and remove cosmic rays. AstroDrizzle is a wrapper of several algorithms that will produce the final aligned and cosmic-ray-cleaned image. It is organized in seven steps which may be turned on or off by the user depending on your needs.

Because the default AstroDrizzle parameters may not provide optimal data products for all HST instruments, the user is strongly advised to inspect the quality of the cosmic ray rejection and to experiment with different parameter values.

In the following sections we present an example that requires a parameter value change.

AstroDrizzle: first run

We begin by running all the steps in AstroDrizzle except the last one, checking out the output and verifying the correct alignment. We reset the task astrodrizzle and look at the parameters using the TEAL interface:

--> unlearn astrodrizzle
--> epar astrodrizzle

We modify the following parameters:

input = @list_f814w
output = f814w
driz_combine = no

In the TEAL toolbar (found below the menu bar) we click the Execute button. This will use the current parameters and run the task. The parameter values are saved to the configuration file listed at the top of the window. The task should take execute the first six steps in less than 10 minutes.

By setting

static = yes

AD creates a static bad-pixel mask from the data.

skysub = yes

means that AD will subtract the sky from each drizzled image. Sky subtraction is recommended for effective cosmic ray flagging and removal, but only if sufficient blank sky is available to perform an accurate determination. The sky value is calculated independently for each of the two ACS chips, and the lowest value is taken to represent the true value for both chips.

median = yes

means that AD will create a median image from the separate drizzled input images, allowing for a variety of combination and rejection algorithms. The default value

combine_type = minmed

is designed to perform optimally in the case of combining only a few images like in our current example.

blot = yes

means that the median image is transformed back to the reference frame of each original input image. AD will compare the original and blotted median images to identify cosmic rays in the next step.

By setting

driz_cr = yes

AD uses the original input images, the blotted median image, and the derivative of the blotted image to create a cosmic ray mask for each input image. It is a good practice to blink the science FITS files (*_flt.fits) with their corresponding cosmic ray masks (*_sc1_crmask.fits and *_sc2_crmask.fits) in order to verify that visible cosmic rays are actually being masked.

AstroDrizzle: second run

Now that the cosmic ray masks have been computed, we can create the final mosaic by running step 7 only and turning off all intermediate processing steps.

--> unlearn astrodrizzle
--> epar astrodrizzle

In the TEAL interface, we modify the following parameters:

input = @list_f814w
output = f814w
static = no
skysub = no
driz_separate = no
median = no
blot = no
driz_cr = no
driz_combine = yes
final_units = counts

Note that the sky is not removed in this second run because we will perform aperture photometry on the final product and we will compare the photometry with the one obtained using the original FLT images which contain the original sky. Also note that the units of the final drizzled image will be in electrons. We achieve this by setting final units to counts.

By setting

driz_combine = yes

AD takes the original input FLT images, together with the final masks, and drizzles them onto a single output image called f814w_drz_sci.fits. By default, the scale of the output ACS/WFC image is 0.05"/pixel. This image contains the science which has been corrected for distortion and represents the combination of the three input FLT images. Each pixel covers an equal area on the sky. Figure 2 shows the output image f814w_drz_sci.fits.

F814W
Figure 2: (Left) The F814W astrodrizzled science image output. (Right) The corresponding weight image.

The second important AD product is the file f814w_drz_wht.fits which is shown in Figure 2. The chip gaps are clearly visible as are column defects and cosmic ray features. It is important to examine the weight image, specially the centers of stars that will be subject to aperture photometry. This may be achieved by blinking the science product and the weight image together. For example, with SAOImage DS9, we can display both images in two frames, and activate the pixel table from the menu:

Analysis-> Pixel Table...

Zoom into a small field, match the two frames and blink them. If an imprint of the sources is observed in the weight image, this means that a problem with the cosmic ray rejection has occurred and this problem will translate into an apparent loss of flux and a wrongful estimation of the magnitudes. This effect can be very subtle but with devastating consequences to the final photometry. This is also useful to identify sources that may have been hit by a cosmic ray or that fall on a bad column. We need to avoid those sources for the final photometry.

 

cartoon of a star
Figure 3: Cartoon of a single star (left) and a detail of the central pixels (right) that have been given a low weight. This problem is cased by using very strict cosmic ray rejection parameters. See text on how to avoid this problem.

Figure 3 shows a cartoon of a star that presents flagged central pixels. The left plot shows the actual pixel map of the star in the final science drizzled image. The plot at the right represents the central 7x7 pixel map of the weight image. The numbers represent the integer value of the weight. Note that some of the central pixels have a lower weight value that the rest. This is an undesirable effect that needs to be avoided and it was caused by a very conservative cosmic ray rejection algorithm.

In the first AD run we used the default values

driz_cr_scale = 1.2 0.7

which are too stringent and causes in this case some pixels to be flagged in the centre of some stars of interest. This is causing the final image to be degraded, and we may improve it by relaxing this parameter to

driz_cr_scale = 1.7 0.7

AstroDrizzle: third run

We start all over again. We erase the current files and recover the tweakreged images that we had saved in a different folder and we run AD on them once again

--> unlearn astrodrizzle
--> epar astrodrizzle

In the TEAL interface, we modify the following parameters:

input = @list_f814w
output = f814w
driz_cr_scale = 1.7 0.7
driz_combine = no

This process will create more relaxed cosmic ray masks for our images.

AstroDrizzle: fourth run

In the final stage, we run step 7 in AD, turn off sky subtraction and set the image units to electrons:

--> unlearn astrodrizzle
--> epar astrodrizzle

In the TEAL interface, we modify the following parameters:

input = @list_f814w
output = f814w
static = no
skysub = no
driz_separate = no
median = no
blot = no
driz_cr = no
driz_combine = yes
final_units = counts

Aperture Photometry on the Drizzled Science Data

Source identification

We create a master catalog of sources using the drizzled output obtained with the original F814W FLT images. We use the IDL code FIND from the Astronomy User's IDL Library to acomplish the task. Any other software (SExtractor, daofind will do). All parameters were set as defaults except for:

hmin = 80.0   (threshold intensity)
fwhm = 2.0  pixels  (FWHM to be used in the convolve filter)

​We then proceed to clean the list from false detections, specially around bright stars and in background galaxies that fall in the field of view. We also delete the sources with cosmic ray impacts and those that fall on top of bad columns.

The final catalog (master.xy) has ~1500 stars. This open cluster lies in a rich Galactic field, so many of these stars may not belong to the cluster itself. A completeness study is beyond the goal of our experiment.

Aperture photometry using DAOPHOT

We calculated the aperture photometry (instrumental magnitudes) with the widely used task phot within PyRAF. We begin by loading the photometry package in PyRAF and resetting the parameters to default values:

--> daophot
  --> unlearn datapars
  --> unlearn fitskypars
  --> unlearn photpars
  --> unlearn centerpars
  --> unlearn phot
  --> epar phot

and we use the following non-default parameters to measure the stars in the master catalog (master.xy):

datapars.gain = "CCDGAIN"
  datapars.readnoise = 8.66
  datapars.epadu = 1.0
  datapars.exposure = "EXPTIME"

The readout noise of one single ACS/WFC is ~5 electrons. For three combined images it is sqrt(3) * 5 = 8.66 electrons. The exposure time in the final drizzled image has been updated to 90.0 seconds in the header keyword EXPTIME.

In order to include most of the light from each source, we use an aperture radius of 8.0 WFC pixels (0.4") and we measure the sky in an annulus with radii 20 and 25 WFC pixels. The zeropoint is set to zero in order to obtain instrumental magnitudes.

fitskypars.annulus = 20.0 
  fitskypars.dannulu = 5.0
  photpars.apertur = 8.0
  photpars.zmag = 0.0

We allow the code to perform a re-centering of the stars using a centroid algorithm, and we execute phot.

centerpars.calgorithm = "centroid"
  phot.image = "f814w_drz_sci.fits"
  phot.coords = "master.xy"
  phot.output = "f814w.mag"

We repeat the same procedure with the F606W drizzled output.

Figure 4 shows two color-magnitude diagrams (CMD) obtained for the stars in our catalog: [F814W, F606W-F814W](left), and [F606W, F606W-F814W] (right).

 

Color magnitude diagrams
Figure 4: Color magnitude diagrams of the stars in the master.xy list. These are instrumental magnitudes measured on the drizzled output images.

Aperture Photometry on the Individual FLT images

In order to ascertain the quality of the photometry obtained using the AD output, we compare it with aperture photometry obtained with the input FLT images which are pipeline output that include corrections for bias and flat field.

Source identification

We use the same catalog (master.xy) as in the previous section. The star's coordinates are given in the drizzled reference system. We calculate the coordinates in the FLT reference system with the task pixtopix

--> unlearn pixtopix
--> epar pixtopix

For example, to obtain the coordinates in the WFC2 chip we use the following parameters:

inimage = "j8ny02yuq_flt.fits[1]" 
outimge = "f814w_drz_sci.fits"
direction = backward
coords = "master.xy"

This method allows us to create two stellar catalogs (one for each chip) that we name: master_wfc1.xy and master_wfc2.xy.

Aperture photometry using DAOPHOT

We calculate the aperture photometry (instrumental magnitudes) with the phot task for consistency.

According to the ACS Instrument Handbook, if one wants to perform photometry directly on the distorted FLT files, it is necessary to perform a field-dependent correction which is achieved by multiplying the measured flux on the FLT image by the pixel area at the corresponding position using a pixel area map (PAM).

Once each input FLT has been corrected with the PAM, we are able to proceed with the aperture photometry.

As with the AD images before we set:

datapars.gain = "CCDGAIN"
datapars.readnoise = 5.0
datapars.epadu = 1.0
datapars.exposure = "EXPTIME"

The readout noise of one single ACS/WFC is 5 electrons. The exposure time of each FLT image is 30.0 seconds. Same header keyword (EXPTIME) as with the AD images.

The pixel scale in the FLT images is 0.05". As with the AD images, we use an aperture radius of 8.0 WFC pixels and we measure the sky in an annulus with radii 20 and 25 WFC pixels. Also, the zeropoint is set to zero in order to obtain instrumental magnitudes.

fitskypars.annulus = 20.0 
fitskypars.dannulu = 5.0
photpars.apertur = 8.0
photpars.zmag = 0.0

We allow the code to perform a re-centering of the stars using a centroid algorithm, and we execute phot as in the following example:

centerpars.calgorithm = "centroid"
phot.image = "j8ny02yuq_flt.fits[1]"
phot.coords = "master_wfc2.xy"
phot.output = "j8ny02yuq_flt.mag"

We repeat the same procedure for the six FLT images (three F814W images and three F606W images), both chips in each case.

Figure 5 shows two color-magnitude diagrams (CMD) obtained for the stars in our catalog: [F814W, F606W-F814W] (left), and [F606W, F606W-F814W] (right).

Colour magnitude diagrams
Figure 5: Colour magnitude diagrams of the stars in the master_wfc1.xy and master_wfc2.xy lists. These are instrumental magnitudes measured on the original FLT images after PAM correction.

Aperture Photometry Comparison

NGC 6791 is a nearby (~4000 pc), old (8-12 Gyr) open cluster with an unusual metallicity ([Fe/H]=+0.3) which has been studied in great detail (see e.g. Stetson, P. et al. 2003, PASP, 115, 413 and King, I. et al., 2005, AJ, 130, 626).

The HST images obtained with the Advanced Camera for Surveys WFC for GO program 9815 (PI I. King) provide an excellent set of images to study the quality of the photometry performed on the AstroDrizzle output.

In the previous two sections we estimated the instrumental magnitude of ~1500 stars using the AD output and the original FLT images. Figure 6 shows the difference in magnitude (AD-FLT) for each star in our catalog as a function of instrumental magnitude. The stars of interest lie in the instrumental magnitude range [-10.0, -6.0]. We observe that most of the stars in this range are matched within 0.01 mag. Fainter sources present larger dispersion, but also larger errors as expected from individual 30 sec exposures.

residuals
Figure 6: Star by star instrumental magnitude comparison.

Figure 7 provides a comparison of our results with the published CMD in King, I. et al. (2005). The horizontal scales of the plots are the same. The vertical scales are different but the red boxes could be used as a visual aid for the comparison.

The left panel shows the [F814W, F606W-F814W] CMD from King, I. et al. (2005). The magnitudes in this plot were calculated by the authors using DAOPHOT, ALLSTAR and, for the brightest stars, they used the method of Anderson & King, 2000, PASP, 112, 1360 . The zero points were determined with the procedures described in Bedin et al. 2005, MNRAS, 357, 1038. The right panel is our instrumental aperture photometry performed on the AD output images.

cmd comparison
Figure 7: [F814W, F606W-F814W] CMD comparison. (Left) CMD taken from King, I. et al. (2005). (Right) CMD obtained with simple aperture photometry on the AD output.

Our analysis shows that it is possible to achieve optimal aperture photometry using the AstroDrizzle output, provided that the combined images are created with carefulness and that cosmic rays are properly removed.