SPACE TELESCOPE SCIENCE INSTITUTE Operated for NASA by AURA RIA Training Report 2008 Part I ACS MultiDrizzling of NGC 4449 Tiffany Michelle Borders Space Telescope Science Institute October 24, 2008 ABSTRACT This paper presents Part I of my RIA training data project. This paper discusses the results of using MultiDrizzle on a mosaic image with subpixel dithers of NGC 4449. Introduction Multidrizzle is a PyRAF based script and can be used as a method for removing geometric distortion and combining dithered datasets into clean, undistorted and photometrically reliable output products. MultiDrizzle can provide automated image registration, cosmic ray reject and final image combination of dithered images. The user can control various parameters which control the individual steps, such as sky subtraction, image registration, ‘drizzling’ onto separate output images, creation of a clean median image and subsequent cosmic ray masks, as well as the final image combination (Koekemoer 2002). Each of these various steps will be discussed in the following sections. The purpose of this assignment is to become familiar with running MultiDrizzle. For this project I followed a worked example provided on the ACS MediaWikki page1 . My goal c 2008 The Association of Universities for Research in Astronomy, Inc. All Rights Reserved. Copyright 1 http://incubator.stsci.edu/mediawiki/index.php/ACS is to not only learn about MultiDrizzle but also to provide feedback on this example as it is currently undergoing revisions. Data & Observations The data, in this example, are a combination of eight ACS/WFC images of the galaxy NGC 4449 (Program ID 10585, PI Aloisi) observed in F555W. These data were retrieved from MAST2 (Multimission Archive at STScI). Table 1 provides information on the datasets. The top four images in Table 1 correspond to the left half of the galaxy (image association j9cd01020) and the bottom four images correspond to the right half of the galaxy (image association j9cd020) which can be seen in the shift of the RA and Dec. Dataset Observation Date RA/Dec (Deg) POSTARG1 (arcsec) POSTARG2 (arcsec) Exposure Time (sec) j9cd01kqq flt j9cd01l5q flt j9cd01ldq flt j9cd01mfq flt j9cd02phq flt j9cd02ppq flt j9cd02pxq flt j9cd02q5q flt 2005-11-10 2005-11-10 2005-11-10 2005-11-10 2005-11-11 2005-11-11 2005-11-11 2005-11-11 187.0656,+44.1148 187.0656,+44.1148 187.0656,+44.1148 187.0656,+44.1148 187.0128,+44.0854 187.0128,+44.0854 187.0128,+44.0854 187.0128,+44.0854 0.000 0.123 0.247 0.370 0.000 0.123 0.247 0.370 0.000 0.84 2.984 3.068 0.000 0.084 2.984 3.068 608 615 616 621 608 615 616 621 Table 1: Dataset Information. MultiDrizzle The MultiDrizzle script carries out the following steps. Individual steps can be selected by turning each step on/off. These steps described by Koekemoer 2002 include: 1. Static Mask- Identify negative bad pixels, based on examining all the images and include them in the data-quality array 2 http://archive.stsci.edu/ 2 2. Sky Subtraction- Sky-subtract each input image 3. Drizzle Separate- Drizzle the input images onto separate, registered outputs (using shifts computed from the headers) 4. Median- Create a median image from the separate drizzled images 5. Blot- “Blot” the median image back to each original input image frame 6. Cosmic Ray Rejection- Use each blotted image to create a derivative image and compute cosmic ray masks) 7. Final Drizzle- Do the final drizzle combination, using the newly created cosmic ray masks. A python script was created to run each part of this MultiDrizzle example. These scripts are located in the Appendix A. Writing these scripts not only deemed useful for repeatedly running MultiDrizzle but also served as a training tool to learn python. The following sections of this document summarize what I accomplished in each section of the example. Detailed information about each step is provided on the web in the example itself. Initial Setup In order to organize these data the images have been renamed in a meaningful way. Appendix A contains the script mdrz step0.py which takes a list of images and renames the images according to a list created of the output images. These images have been renamed ‘f555w pos? 0? flt.fits’ where the first index refers to the target position (POS A or POS B) and the second index refers to the sub-pixel dithers 1 - 4 in the box pattern. Refining the Image Alignment Small residual offsets can be significant enough to degrade final image combinations and therefore it is important to verify the presence of image-to-image shifts, rotations and/or scale variations before combining data with MultiDrizzle. These residual offsets may be determined by separately drizzling onto a common output frame. MultiDrizzle uses the information stored in the World Coordinate System (WCS) of the image header to align images. 3 In MultiDrizzle when driz separate = yes the input images are corrected for geometric distortion and drizzled onto separate output frames which have a common WCS. MultiDrizzle takes the ∗ flt’s and splits then into ∗ single sci.fits and ∗ single wht.fits. These images are used to create the median image, needed for the cosmic ray rejection step further on. Appendix A contains the python script (mdrz step1.py) used to run MultiDrizzle with driz separate = yes. The next step is to create a shift file which defines the residual offsets between images (offsets which are not accounted for using the header WCS). In this example, we run DAOFIND on each image to determine the positions of the stars on the image (mdrz step2.py in Appendix A). We use use the IRAF task xyxymatch to match the pixel coordinates (mdrz step3.py in Appendix A). We also need to compute the geometric transformation using the matched star list. This can be done by using the the IRAF task GEOMAP (mdrz step4.py in Appendix A). The resulting offsets can be recorded in the form of a shift file. This file contains the residual offsets which were derived using GEOMAP. The columns are image, x resid, y resid, rotation and scale. Note that there were no significant roation or scale terms found so they are left blank. During this process I discovered that the shift.dat file CAN NOT contain tabs or MultiDrizzle will fail. Warren Hack has been made aware of this problem and hopes to make a correction to the MultiDrizzle code so that it will not fail with tabs in the shift file. The values determined for my shift.dat are identical for the POSA images when compared to the ones provided on the web for this example but are slightly off for the POSB. The biggest difference is 0.2 pixels for the f555w posb 02 flt.fits image. # units: pixels # form: delta # frame: output # refimage: refimage.fits f555w_posa_01_flt.fits f555w_posa_02_flt.fits f555w_posa_03_flt.fits f555w_posa_04_flt.fits f555w_posb_01_flt.fits f555w_posb_02_flt.fits f555w_posb_03_flt.fits f555w_posb_04_flt.fits 0.00 -0.05 0.10 0.02 -20.17 -20.17 -20.19 -20.17 0.00 -0.05 0.08 0.06 18.67 18.69 18.73 18.74 4 Creating the Median This step combines the ∗ single sci.fits and ∗ single wht.fits images to create a single ‘median’ image and exclude the bad pixels. From my experience I found this to be a very important step. I conducted a number of experiments testing various combinations of changing the parameters driz sep bits and f inal bits. These tests were done as an experiment to see how different values of driz sep bits and f inal bits changed the median. By changing the bits which were to be included and excluded in making the median turned out to be the biggest contributors to making a good median. Table 2 shows the tests which were conducted and evaluated. Each test was run with combine type = median. driz sep bits final bits Test Test Test Test Test 1 2 3 4 5 0 4192 4320 128 4320 0 0 4192 0 0 Table 2: MultiDrizzle test runs with combine type = median. I evaluated each test by examining the median product visually and comparing each run to each other. In particular, I focused on determining the test which produced the cleanest median image. In all cases, there was a little bit of residual (black pixels) in the center of the image and I was looking for a median which reduced these bad pixels. Test 1 turned out to be a good start, however, there was still a bit of residual in the center of the image. Test 2 did not turn out as well as Test 1 and contained more messy bad pixels. Test 3 was a slight improvement over Test 2 but still didn’t look great. Test 4, however, was an improvement over Test 1 and produced the best median image but didn’t remove the bad pixels entirely. Test 5 was not necessarily an improvement over Test 4 for it had turned the bad black pixels into white pixels. From these test and based on the criteria I used to determine the best run Test 4 turned out to be the winner. As an addition experiment I conducted a run with combine type = minmed. Table 4 shows the tests which were conducted and evaluated. The median of Test 6 turned out to be cleaner than Test 7. I compared, by visual inspection, Test 6 to Test 4 and determined that the median of Test 6 was cleaner and reduced the amount of black pixels in the center 5 driz sep bits final bits Test 6 Test 7 4192 0 0 0 Table 3: MultiDrizzle median runs with combine type = minmed. of the image. Since Test 6 turned out to be the overall best median run I decided to use Test 6 to complete the final drizzle. Computing the Cosmic Ray Masks In this step we run MultiDrizzle by turning blot = yes and drz cr = yes which transforms the median image back to the reference frame of each original input image and then derives cosmic ray masks. When blot = yes this task takes the median images and uses the PyRAF blot task to apply the geometric distortion and to transform it back to the reference frame of each of the original individual input images. When drz cr = yes MultiDrizzle uses the original input images, the blotted median image and the derivative of the blotted images to create a cosmic ray mask for each input image. This will create both a ∗ sci? crmask.fits image and a ∗ sci? cor.fits, a clean version of the original ∗ flt.fits images where flagged pixels are replaced with pixels from the blotted median image. Script mdrz step6.py in Appendix A shows the parameters used for this part. Final Drizzle & Optimizing Scale and Pixfrac for Subsampled Data Taking my best run (Test 6) I made four tests changing f inal scale and f inal pixf rac. It should be noted that these tests were also conducted on Test 4 but the results turned out almost identical so I decided to focus on Test 6. Changing the f inal scale and f inal pixf rac is also another very important part of the MultiDrizzle process and it is highly recommended that one experiment with different combinations of these parameters. Table 4 contains the scale, f inal scale and the f inal pixf rac for the four tests I conducted. It should be noted that each scale (fraction) is multiplied by the plate scale of 0.05”/pix to get the f inal scale parameter. For each of these scale tests I measured the image statistics on four different quadrants of the weighted image. Using the IRAF task IMSTAT I looked at the statistics on roughly 6 Scale Scale Scale Scale Test Test Test Test 1 2 3 4 Scale(fraction) f inal scale (arcsec/pix) f inal pixf rac 1 0.8 0.7 0.6 0.05 0.04 0.035 0.03 1 0.9 0.8 0.7 Table 4: MultiDrizzle median runs with combine type = minmed. the same region on each quadrant of each weighted image. These results are found in Table 5. I arbitrarily labeled these quadrants so that quad 1 is the upper left, quad 2 is the upper right, quad 3 is the lower left, and quad 4 is the lower right. From these results I looked for the case where the rms (STDDEV from IMSTAT) is consistently the lowest. Based on this criteria Scale Test 2 and Scale Test 3 consistently have the lowest rms compared to the other runs. We also want to keep the run which meets the general requirement that the statistics of the weight image satisfy an rms/median < 20% (where median is MIDPT in IMSTAT). From Table 5 we see that only in Scale Test 4 does the rms/median actually exceed rms/median > 20%. This is an indication that the ‘scale’ and ‘pixfrac’ parameters have been ‘shrunk’ too far. I have also included figures of the contour’s and psf ’s of the same star for each Scale Test. Figures 1 and 2 show the contour and psf of this star for Scale Test 1. Figures 3 and 4 show the contour and psf of this star for Scale Test 2. Figures 5 and 6 show the contour and psf of this star for Scale Test 3. Figures 7 and 8 show the contour and psf of this star for Scale Test 4. Based on these psf plots Scale Test 1 and Scale Test 2 have the nicest PSF’s with a minimal amount of scatter. Table 6 shows the PSF FWHM (pixels), scale (arsec), the PSF FWHM (arsec), the ellipticity and the peak value of the profile fit as measured from IMSTAT. Based on these results we want to keep the run which not only satisfies the rms/median < 20% criteria but also has the narrowest PSF. Scale Test 3 meets this criteria and has the smallest PSF FWHM (arcsec). Also from Table 6 we can see that the ellipticity is just slightly more circular than the other runs. Thus, Scale Test 3 is crowned the winner. Analysis From the median tests I conducted I determined that the best run is Test 6 which involved using driz sep bits = 4192, f inal bits = 0 and combine type = minmed. However, I should mention that while this median imaged turned out the best the final drizzled product 7 Quadrant RMS Median RMS/Median 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 206.7 162.6 143.6 174.2 124 138.5 112.5 119.4 145.2 135.5 121.4 99.31 196.1 150.3 146.2 137.4 2561. 2574. 2473. 2428. 1587. 1575. 1570. 1536. 1217. 1214. 1170. 1189. 911.2 884.1 858.3 804.2 0.081 0.063 0.058 0.072 0.078 0.088 0.072 0.078 0.119 0.112 0.104 0.084 0.215 0.170 0.170 0.171 Scale Test 1 Scale Test 2 Scale Test 3 Scale Test 4 Table 5: Results of Scale Tests for Test 6 Scale Scale Scale Scale Test Test Test Test 1 2 3 4 PSF FWHM (pixels) Scale (arcsec) PSF FWHM (arcsec) Ellipticity Peak 1.90 2.45 2.56 3.13 0.0250 0.0200 0.0175 0.0125 0.0475 0.049 0.0448 0.047 0.02 0.02 0.01 0.02 34.23 22.38 18.89 14.62 Table 6: PSF FWHM. of Test 4 (driz sep bits = 128, f inal bits = 0 and combine type = median) turned out practically identical to Test 6. The image statistics were almost entirely identical so it was difficult to determine which run was better so my decision to go with Test 6 was based merely on visual inspection of the median image. From the Scale Tests performed on Test 6, I have determined that Scale Test 3 produced the best results. Scale Test 3 involved using f inal scale = 0.035 and f inal pixf rac = 0.8. Scale Test 3 has a consistently low rms (STDDEV), the rms/median satisfies the rms/median < 20% criteria and the psf is sharp 8 Fig. 1.— Contour of star for Scale Test 1. Fig. 2.— PSF of star for Scale Test 1. and narrow. Figure 9 shows the results of the final drizzled image of this best run. 9 Fig. 3.— Contour of star for Scale Test 2. Fig. 4.— PSF of star for Scale Test 2. Acknowledgments I would like to thank Jennifer Mack for providing this example which has allowed me to discover the use and power of MultiDrizzle. I would also like to thank Max Mutchler for his help and for answering my questions. I would also like to thank Abhi and Brian for all our discussions on MultiDrizzle. 10 Fig. 5.— Contour of star for Scale Test 3. Fig. 6.— PSF of star for Scale Test 3. References HST Data Handbook for ACS, Version 5.0 (Baltimore: STScI) HST Dither Handbook, Version 2.0 (Baltimore: STScI) Koekemoer, A., 2002, HST Calibration Workshop., 337 - 340 Whitelight, L., Redstar, W. & Smith B. 2000, Paper Abbr., 10, 100 11 Fig. 7.— Contour of star for Scale Test 4. Fig. 8.— PSF of star for Scale Test 4. 12 Fig. 9.— Final Drizzled Image using Scale Test 3. 13 Appendix A A. Python Scripts Fig. 10.— mdrz step0.py 14 mdrz_step1.py 10/20/08 1:40 PM ################################################################################ # Multidrizzle Script # Script to run multidrizzle in steps # Step 1- Separate Files # # Written by Tiffany Borders ################################################################################ # # # # # # # # INPUTS: 1. Calibrated Images *_flt.fits 2. Reference Files *_idc.fits & *_dxy.fits OUTPUTS: 1. *_single_sci_fits & *_single_wht.fits 2. *_coeffs?.dat (one for each chip) 3. The mask files *_single_mask?.fits & *_final_mask?.fits #Load the packages we need import pyraf,os from pyraf import iraf from iraf import stsdas, analysis, dither, multidrizzle iraf.unlearn(multidrizzle) iraf.stsdas.analysis.dither.multidrizzle(\ input='*_flt.fits',\ output='f555w',\ clean='no',\ build='no',\ static='no',\ skysub='no',\ driz_separate='yes',\ median='no',\ blot='no',\ driz_cr='no',\ driz_combine='no') Page 1 of 1 Fig. 11.— mdrz step1.py 15 mdrz_step2.py 10/20/08 1:36 PM ################################################################################ # Multidrizzle Script # Script to run multidrizzle in steps # Step 2- DAOFIND # # Written by Tiffany Borders ################################################################################ #Load the packages we need import pyraf,os from pyraf import iraf from iraf import apphot #iraf.unlearn(daofind) iraf.apphot.daofind.findpar(\ thresh='40') iraf.apphot.daofind.datapar(\ sigma='0.01') iraf.apphot.daofind(\ image='@daolst_in.dat',\ output='@daolst_out.dat',\ inter='no',\ verify='no') Page 1 of 1 Fig. 12.— mdrz step2.py 16 mdrz_step3.py 10/20/08 1:36 PM ################################################################################ # Multidrizzle Script # Script to run multidrizzle in steps # Step 3 # xyxymatch # Written by Tiffany Borders ################################################################################ #Load the packages we need import pyraf,os from pyraf import iraf from iraf import immatch iraf.xyxymatch(\ input='@posa_lst_in.dat',\ reference='f555w_posa_01.cdt',\ output='@posa_lst_out.dat',\ xin = '0',\ yin='0',\ xrot='0',\ yrot='0',\ matching = 'tolerance',\ toler='2') iraf.xyxymatch(\ input='@posb_lst_in.dat',\ reference='f555w_posa_01.cdt',\ output='@posb_lst_out.dat',\ xin ='-20',\ yin='19',\ xrot='0',\ yrot='0',\ matching = 'tolerance',\ toler='2') Page 1 of 1 Fig. 13.— mdrz step3.py 17 mdrz_step4_I.py 10/20/08 1:47 PM ################################################################################ # Multidrizzle Script # Script to run multidrizzle in steps # Step 4- tcalc, fields, geomap,imcopy # # Written by Tiffany Borders ################################################################################ #Load the packages we need import pyraf,os from pyraf import iraf from iraf import ttools,immatch iraf.tcalc(\ table='*match*.cdt',\ outcol='c7',\ equals='c1-3839.5') iraf.tcalc(\ table='*match*.cdt',\ outcol='c8',\ equals='c2-2180.5') iraf.tcalc(\ table='*match*.cdt',\ outcol='c9',\ equals='c3-3839.5') iraf.tcalc(\ table='*match*.cdt',\ outcol='c10',\ equals='c4-2180.5') fieldslst=open("fieldslst_in.dat",'r') my_data=fieldslst.readlines() fieldslst.close() for item in my_data: my_geomap_file = "%s_sub.cdt" % (item.strip()[:item.strip().rfind(".")]) my_final_file = iraf.fields(\ files=item.strip(),\ fields='7,8,9,10',\ Stdout=1) outf = open(my_geomap_file, 'w') for line in my_final_file: if line != "": outf.write("%s\n" % (line)) outf.close() Page 1 of 1 Fig. 14.— mdrz step4.py 18 mdrz_step4_II.py 10/20/08 1:48 PM iraf.geomap(\ input='@geolst.dat',\ datab='cdt.db',\ fitgeom='rscale',\ reject='3',\ maxiter='5',\ interactive='no') iraf.imcopy(\ input='f555w_posa_01_single_sci.fits',\ output='refimage.fits') Page 1 of 1 Fig. 15.— mdrz step4.py 19 mdrz_step5.py 10/20/08 1:35 PM ################################################################################ # Multidrizzle Script # Script to run multidrizzle in steps # Step 5- Multidrizzle -> Creating the Median # # Written by Tiffany Borders ################################################################################ #Load the packages we need #Load the packages we need import pyraf,os from pyraf import iraf from iraf import stsdas, analysis, dither, multidrizzle iraf.unlearn(multidrizzle) iraf.stsdas.analysis.dither.multidrizzle(\ input='*_flt.fits',\ output='f555w',\ shiftfile='shift.dat',\ static='yes',\ skysub='yes',\ driz_separate='yes',\ driz_sep_fillval=99999,\ median='yes',\ driz_sep_bits='4192',\ final_bits='0',\ combine_type='minmed',\ combine_nhigh=0,\ combine_hthresh=99990) Page 1 of 1 Fig. 16.— mdrz step5.py 20 mdrz_step6.py 10/20/08 1:35 PM ################################################################################ # Multidrizzle Script # Script to run multidrizzle in steps # Step 6- CR Mask # # # Written by Tiffany Borders ################################################################################ #Load the packages we need import pyraf,os from pyraf import iraf from iraf import stsdas, analysis, dither, multidrizzle iraf.unlearn(multidrizzle) iraf.stsdas.analysis.dither.multidrizzle(\ input='*_flt.fits',\ output='f555w',\ shiftfile='shift.dat',\ static='no',\ skysub='yes',\ driz_separate='no',\ median='no',\ driz_combine='no',\ blot='yes',\ driz_cr='yes',\ driz_cr_corr='yes',\ crbit='8192',\ driz_cr_snr='4.0 3.0',\ driz_cr_scale='1.2 0.7') Page 1 of 1 Fig. 17.— mdrz step6.py 21 mdrz_step7.py 10/20/08 1:34 PM ################################################################################ # Multidrizzle Script # Script to run multidrizzle in steps # Step 7- Final Drizzle # # Written by Tiffany Borders ################################################################################ #Load the packages we need import pyraf,os from pyraf import iraf from iraf import stsdas, analysis, dither, multidrizzle iraf.unlearn(multidrizzle) iraf.stsdas.analysis.dither.multidrizzle(\ input='*_flt.fits',\ output='f555w',\ final_bits=4192,\ shiftfile='shift.dat',\ static='yes',\ skysub='no',\ driz_separate='no',\ median='no',\ blot='yes',\ driz_cr ='no',\ driz_comb='yes',\ final_rot='INDEF') Page 1 of 1 Fig. 18.— mdrz step7.py 22 mdrz_step8.py 10/20/08 1:34 PM ################################################################################ # Multidrizzle Script # Script to run multidrizzle in steps # Step 8- Optimizing Scale and Pixfrac for Subsampled Data # # Written by Tiffany Borders ################################################################################ #Load the packages we need import pyraf,os from pyraf import iraf from iraf import stsdas, analysis, dither, multidrizzle iraf.unlearn(multidrizzle) iraf.stsdas.analysis.dither.multidrizzle(\ input='*_flt.fits',\ output='f555w',\ final_bits=4192,\ shiftfile='shift.dat',\ static='yes',\ skysub='no',\ driz_separate='no',\ median='no',\ blot='no',\ driz_cr ='no',\ driz_comb='yes',\ final_scale='0.04',\ final_pixfrac='0.9',\ final_rot='INDEF') Page 1 of 1 Fig. 19.— mdrz step8.py 23