Drizzlepac tests

These are tests performed on the Tololo 1247 galaxy data, using F140LP (SBC) and F336W (WFC3) data.

Configuration parameters for the two filters/instruments are taken from the standard LARS setup. For Drizzlepac run in Python the parameters are easiest given as a config file *.cfg. An example cfg file for F140LP is given below.

tol1247_sbc_driz.cfg:
task_name = astrodrizzle#
input = flt.fits# Input files (name, suffix, or @list)
output = "tol1247_sbc"# Rootname for output drizzled products
runfile = astrodrizzle.log# File for logging the script commands
updatewcs = False# Update the WCS keywords?
wcskey = ""# WCS version to use in processing
proc_unit = native# Units used during processing
coeffs = True# Use header-based distortion coefficients?
context = True# Create context image during final drizzle?
group = ""# Single extension or group to be combined/cleaned
build = False# Create multi-extension output file for final drizzle?
crbit = 4096# Bit value for CR ident. in DQ array
stepsize = 10# Step size for drizzle coordinate computation
resetbits = 4096# Bit values to reset in all input DQ arrays
num_cores = None# Max CPU cores to use (n<2 disables, None = auto-decide)
[STATE OF INPUT FILES]
preserve = True# Copy input files to archive directory, if not already archived?
overwrite = False# Copy input files into archive, overwriting if required?
clean = True# Delete temporary files after completion?
restore = False# Copy input files FROM archive directory for processing?
[STEP 1: STATIC MASK]
static = False# Create static bad-pixel mask from the data?
static_sig = 4.0# "Sigma
rms below mode to clip for static mask"
[STEP 2: SKY SUBTRACTION]
skysub = True# "Perform sky subtraction?"
skywidth = 0.3# "Bin width for sampling sky statistics (in sigma)"
skystat = median# "Sky correction statistics parameter"
skylower = None# "Lower limit of usable data for sky"
skyupper = None# "Upper limit of usable data for sky"
skyclip = 5# "Number of clipping iterations"
skylsigma = 4.0# Lower side clipping factor (in sigma)
skyusigma = 4.0# Upper side clipping factor (in sigma)
skyuser = ""# KEYWORD indicating a sky subtraction value if done by user.
skyfile = ""# Name of file with user-computed sky values.
[STEP 3: DRIZZLE SEPARATE IMAGES]
driz_separate = True# "Drizzle onto separate output images?"
driz_sep_kernel = turbo# Shape of kernel function
driz_sep_wt_scl = exptime# "Weighting factor for input data image"
driz_sep_pixfrac = 1.0# Linear size of drop in input pixels
driz_sep_fillval = None# Value to be assigned to undefined output points
driz_sep_bits = 0# Integer mask bit values considered good
[STEP 3a: CUSTOM WCS FOR SEPARATE OUTPUTS]
driz_sep_wcs = False# "Define custom WCS for separate output images?"
driz_sep_refimage = ""# Reference image from which to obtain a WCS
driz_sep_rot = None# "Position Angle of drizzled image's Y-axis w.r.t. North (degrees)"
driz_sep_scale = None# Absolute size of output pixels in arcsec/pixel
driz_sep_outnx = None# Size of separate output frame's X-axis (pixels)
driz_sep_outny = None# Size of separate output frame's Y-axis (pixels)
driz_sep_ra = None# right ascension output frame center in decimal degrees
driz_sep_dec = None# declination output frame center in decimal degrees
[STEP 4: CREATE MEDIAN IMAGE]
median = True# "Create a median image?"
median_newmasks = True# "Create new masks when doing the median?"
combine_maskpt = 0.3# "Percentage of weight image value below which it is flagged as a bad pixel."
combine_type = minmed# "Type of combine operation"
combine_nsigma = 4 3# "Significance for accepting minimum instead of median"
combine_nlow = 0# "minmax: Number of low pixels to reject"
combine_nhigh = 0# "minmax: Number of high pixels to reject"
combine_lthresh = None# Lower threshold for clipping input pixel values
combine_hthresh = None# "Upper threshold for clipping input pixel values"
combine_grow = 1# Radius (pixels) for neighbor rejection
[STEP 5: BLOT BACK THE MEDIAN IMAGE]
blot = True# "Blot the median back to the input frame?"
blot_interp = poly5# Interpolant (nearest,linear,poly3,poly5,sinc)
blot_sinscl = 1.0# Scale for sinc interpolation kernel
blot_addsky = True# "Add sky using MDRIZSKY value from header?"
blot_skyval = 0.0# Custom sky value to be added to blot image
["STEP 6: REMOVE COSMIC RAYS WITH DERIV, DRIZ_CR"]
driz_cr = False# Perform CR rejection with deriv and driz_cr?
driz_cr_corr = False# "Create CR cleaned _cor file and a _crmask file?"
driz_cr_snr = 3.5 3.0# "Driz_cr.SNR parameter"
driz_cr_grow = 1# Driz_cr_grow parameter
driz_cr_ctegrow = 0# Driz_cr_ctegrow parameter
driz_cr_scale = 1.2 0.7# Driz_cr.scale parameter
[STEP 7: DRIZZLE FINAL COMBINED IMAGE]
driz_combine = True# "Perform final drizzle image combination?"
final_wht_type = EXP# Type of weighting for final drizzle
final_kernel = square# Shape of kernel function
final_wt_scl = exptime# Weighting factor for input data image
final_pixfrac = 1.0# Linear size of drop in input pixels
final_fillval = None# "Value to be assigned to undefined output points"
final_bits = 4096# Integer mask bit values considered good
final_units = cps# Units for final drizzle image (counts or cps)
[STEP 7a: CUSTOM WCS FOR FINAL OUTPUT]
final_wcs = True# "Define custom WCS for final output image?"
final_refimage = ""# Reference image from which to obtain a WCS
final_rot = 0.0# "Position Angle of drizzled image's Y-axis w.r.t. North (degrees)"
final_scale = 0.04# Absolute size of output pixels in arcsec/pixel
final_outnx = 1000# "Size of FINAL output frame X-axis (pixels)"
final_outny = 1000# Size of FINAL output frame Y-axis (pixels)
final_ra = 192.57878# right ascension output frame center in decimal degrees
final_dec = -23.565964# declination output frame center in decimal degrees
[INSTRUMENT PARAMETERS]
gain = ""#
gnkeyword = ""#
rdnoise = ""#
rnkeyword = ""#
exptime = ""#
expkeyword = ""#

In [1]:
import drizzlepac
from drizzlepac import astrodrizzle
from drizzlepac import tweakreg
from drizzlepac import tweakback
import pylab as p
import pyfits as pyf
import numpy
from numpy import ma, finfo, float32
adriz=astrodrizzle.AstroDrizzle
twreg=tweakreg.TweakReg
twback=tweakback.tweakback
The following tasks in the stwcs.gui package can be run with TEAL:
     apply_headerlet          archive_headerlet          attach_headerlet     
     delete_headerlet         extract_headerlet         headerlet_summary     
    restore_headerlet             updatewcs              write_headerlet


The following task in the fitsblender package can be run with TEAL:
                                  blendheaders                                  
The following tasks in the drizzlepac package can be run with TEAL:
    astrodrizzle       imagefindpars          pixtopix            pixtosky      
     resetbits            skytopix           tweakback            tweakreg      
     updatenpol
In [*]:
# First drizzle the images separately
# NB, this cannot be run in ipython notebook mode, only in terminal
adriz('j*flt.fits',configobj='tol1247_sbc_driz.cfg')
adriz('i*flt.fits',configobj='tol1247_wfc3_driz.cfg')

Log of SBC drizzle:
Setting up logfile : astrodrizzle.log
AstroDrizzle Version 1.0.2(13-July-2012) started at: 15:34:11.419 (16/04/2013)

==== Processing Step Initialization started at 15:34:11.422 (16/04/2013)

WARNING: No cte correction will be made for this SBC data.

WARNING: No cte correction will be made for this SBC data.



==== Processing Step Initialization finished at 15:34:14.03 (16/04/2013)
==== Processing Step Static Mask started at 15:34:14.040 (16/04/2013)
==== Processing Step Static Mask finished at 15:34:14.041 (16/04/2013)
==== Processing Step Subtract Sky started at 15:34:14.041 (16/04/2013)
==== Processing Step Subtract Sky finished at 15:34:14.29 (16/04/2013)
==== Processing Step Separate Drizzle started at 15:34:14.298 (16/04/2013)
-Generating simple FITS output: jbz901w2q_single_sci.fits
-Generating simple FITS output: jbz901w5q_single_sci.fits
==== Processing Step Separate Drizzle finished at 15:34:15.343 (16/04/2013)
==== Processing Step Create Median started at 15:34:15.345 (16/04/2013)
reference sky value for image jbz901w2q_flt.fits is 0.0
reference sky value for image jbz901w5q_flt.fits is 0.0

Saving output median image to: tol1247_sbc_med.fits
==== Processing Step Create Median finished at 15:34:16.735 (16/04/2013)
==== Processing Step Blot started at 15:34:16.736 (16/04/2013)
Blot: creating blotted image: jbz901w2q_flt.fits[sci,1]
Using default C-based coordinate transformation...
-Generating simple FITS output: jbz901w2q_sci1_blt.fits
Blot: creating blotted image: jbz901w5q_flt.fits[sci,1]
Using default C-based coordinate transformation...
-Generating simple FITS output: jbz901w5q_sci1_blt.fits
==== Processing Step Blot finished at 15:34:18.807 (16/04/2013)
==== Processing Step Driz_CR started at 15:34:18.808 (16/04/2013)
==== Processing Step Final Drizzle started at 15:34:18.808 (16/04/2013)
-Generating simple FITS output: tol1247_sbc_drz_sci.fits
==== Processing Step Final Drizzle finished at 15:34:22.004 (16/04/2013)

AstroDrizzle Version 1.0.2 is finished processing at 15:34:22.005 (16/04/2013)!

-------------------- --------------------
Step Elapsed time
-------------------- --------------------

     Initialization          2.6169 sec.  
        Static Mask          0.0003 sec.  
       Subtract Sky          0.2567 sec.  
   Separate Drizzle          1.0447 sec.  
      Create Median          1.3900 sec.  
               Blot          2.0715 sec.  
            Driz_CR          0.0000 sec.  
      Final Drizzle          3.1960 sec.

==================== ====================
Total 10.5761 sec.
Trailer file written to: astrodrizzle.log

Now, run tweakreg to find the WCS offset between the two drizzled frames. The task runs source detection on both frames with the same threshold and using a convolution kernel. With default setting the number of found sources in the SBC frame is 2. Making them less conservative (using a more narrow kernel and a lower threshold), the number of found sources are increased to seven and six of them are used for matching. The found sources are shown further below.

In [1]:
# Again, this cannot be run in ipython notebook
twreg('tol1247_sbc_drz_sci.fits',\
        refimage='tol1247_wfc3_drz_sci.fits',\
        conv_width=2.5,threshold=1.5,shiftfile=True,\
        outshifts="shift_tol1247_sbc.dat",updatehdr=False,minobj=3,sigma=2.)
In [42]:
sbcima=pyf.getdata('tol1247_sbc_drz_sci.fits')
wfcima=pyf.getdata('tol1247_wfc3_drz_sci.fits')
flag_sbc=sbcima<finfo(float32).eps
flag_wfc=wfcima<finfo(float32).eps
sbcima_m=ma.array(sbcima,mask=flag_sbc)
wfcima_m=ma.array(wfcima,mask=flag_wfc)
p.figure(figsize=(16,34))
p.subplot(121)
p.imshow(p.log10(sbcima_m),vmin=-4,vmax=2,cmap=p.cm.hot)
p.axis([400,600,400,600])
twcat=p.loadtxt('tol1247_sbc_drz_sci_sci1_xy_catalog.coo')
p.plot(twcat[:,0],twcat[:,1],'go',ms=10,mec='g',mew=2,mfc='none')
p.subplot(122)
p.imshow(p.log10(wfcima_m),vmin=-3,vmax=7,cmap=p.cm.hot)
p.axis([400,600,400,600])
twcat2=p.loadtxt('tol1247_wfc3_drz_sci_sci1_xy_catalog.coo')
p.plot(twcat2[:,0],twcat2[:,1],'go',ms=10,mec='g',mew=2,mfc='none')
p.show()
In [34]:
# Then actually apply the new wcs to the images
twreg('tol1247_sbc_drz_sci.fits',\
        refimage='tol1247_wfc3_drz_sci.fits',\
        conv_width=2.5,threshold=1.5,\
        updatehdr=True,minobj=3,sigma=2.,wcsname='TWEAK_WFC3DRZ')
In [44]:
# Next, apply the new wcs to the original SBC flt frames using tweakback
twback('tol1247_sbc_drz_sci.fits',input='j*flt.fits',verbose=True)
Performing "rscale" fit

....Updating header for jbz901w2q_flt.fits...


Processing jbz901w2q_flt.fits[('SCI', 1)]

Updating header for jbz901w2q_flt.fits[1]
WCS Keywords

CD_11  CD_12: -5.1116712038306271e-06 -5.5581732551091034e-06
CD_21  CD_22: -4.876800487716674e-06 4.3101685514096097e-06
CRVAL    : 192.57833584600286 -23.566397849074598
CRPIX    : 512.0 512.0
NAXIS    : 1024 1024
Plate Scale : 0.033877703923389929
ORIENTAT : -52.207676107389815

....Updating header for jbz901w5q_flt.fits...


Processing jbz901w5q_flt.fits[('SCI', 1)]

Updating header for jbz901w5q_flt.fits[1]
WCS Keywords

CD_11  CD_12: -5.1115144574568255e-06 -5.5580227039961555e-06
CD_21  CD_22: -4.8766653353876958e-06 4.3100384517192157e-06
CRVAL    : 192.57856875233659 -23.566386384575583
CRPIX    : 512.0 512.0
NAXIS    : 1024 1024
Plate Scale : 0.033876722820369437
ORIENTAT : -52.207762064701853
In [45]:
# And finally drizzle the tweaked flt frames
adriz('j*flt.fits',configobj='tol1247_sbc_driz.cfg')