## Mosaicking Example

The purpose of this example is to highlight new mosaicking features available in DrizzlePac 2.0. In a prior example we showed how to align and combine mosaics using an iterative process to build up the field of view. With the new software, this can now be done in a single step. Here, we demonstrate how to align two WFC3/IR mosaics of M16. For the full example, which shows how to align these IR frames to the larger UVIS mosaics, see the following tutorial.

### Observations

The WFC3/IR observations were obtained in September 2014 and include 4 tiles in a 2x2 mosaic pattern in F110W and F160W (red squares in HST Footprint). The accompanying UVIS footprints are shown in blue and a portion of the ACS/WFC parallel observations are shown in green. The tile (visit) positions for the IR data are labelled in red, where the visit numbers correspond to the 5th and 6th characters of the HST filename. For more details on the observing strategy, see HST proposal 13926 (PI: Levay)

### Procedure

[1] Align and combine the F160W frames. When 'expand_refcat=True' and 'enforce_user_order=False', TweakReg will select the image with the largest overlap and work out from there, expanding the reference catalog as it goes. The input list 'f160w.list' contains the names of the 8 *flt.fits frames in alphanumeric order.

>>> tweakreg.TweakReg('@f160w.list',\
imagefindcfg={'threshold':50,'conv_width':2.5},\
expand_refcat=True,\
enforce_user_order=False,\
minobj=5,\
shiftfile=True,\
outshifts='shift160_flt.txt',\
sigma=2.8,\
updatehdr=True,\
wcsname='FLT',\
interactive=True,\
ylimit=0.5)

With these detection thresholds, TweakReg finds between 500-600 objects per image. Because no reference image was explicitly defined, TweakReg selects the two images in visit 02 as having the largest overlap and aligns them by matching sources. The first image defines the "reference catalog” with 601 sources while the second image (with 574 sources) is aligned to this catalog, with 478 total matches. Now sources from the second image that have not been matched to the reference catalog are considered as "good new sources" and will be added to the reference catalog. In this case, 74 new sources are added to the reference catalog for total of 675. TweakReg selects visit 04 as having the next largest overlap and matches 63 objects with the expanded reference catalog. By the time of the full set of 8 images are processed, the reference catalog has grown to a total of 2170 sources. In this way (with a large expanded reference catalog), it is now possible to align images that had little or no direct overlap with the starting image.

The contents of the shift file are given below as an example, with an additional column indicating the number of objects matched with the reference frame which was automatically selected as ick902neq_flt.fits. These offsets reflect updates to the header WCS required to correct for small pointing errors.

# image                dx          dy         drot          dscale     xrms       yrms       match
ick902neq_flt.fits     0.000000    0.000000      0.000000    1.000000   0.000000   0.000000   --
ick902n9q_flt.fits     0.028769    0.085079    359.999794    1.000000   0.060854   0.043356   478
ick904obq_flt.fits    -8.747473  -12.125906    359.997217    0.999916   0.049201   0.043300   63
ick904ogq_flt.fits    -8.791378  -12.221958    359.997744    1.000070   0.061581   0.043106   384
ick901hzq_flt.fits    -0.159702    0.419562    359.999331    1.000085   0.057073   0.036684   43
ick901i7q_flt.fits    -0.209366    0.364715      0.000374    0.999920   0.059385   0.051056   446
ick903n4q_flt.fits    -6.982110  -11.973897    359.999316    0.999995   0.065746   0.049929   56
ick903ncq_flt.fits    -7.021394  -12.037023    359.999190    1.000016   0.061807   0.045871   406

[2] Next we combine the full set of F160W images with AstroDrizzle, defining an orientation of -35 degrees such that the pillars are straight up. Because these mosaics contain large extended objects, we set the sky background method to ‘match’ such that only pixels in common between frames are used to compute the sky. The plate scale is set to 0.08”/pix, defined as ~twice the UVIS scale.

>>> astrodrizzle.AstroDrizzle('@f160w.list',\
output='f160w_sc08px10',\
preserve=no,\
clean=no,\
build=no,\
skymethod='match', \
driz_sep_bits='64',\
driz_cr_corr=yes,\
final_bits='64',\
final_wcs=yes,\
final_scale=0.08,\
final_pixfrac=1.0,\
final_rot=-35,\
final_ra=274.721587,\
final_dec=-13.841549,\
final_outnx=4000,\
final_outny=4200)

[3] Now we align the F110W frames to the drizzled F160W reference image. The input list 'f110w.list' contains the names of the 8 *flt.fits frames. DrizzlePac 2.0 now makes it easier to align directly to a reference image by allowing the user to specify separate sets of source finding criteria via the imagefindcfg and refimagefindcfg parameter sets, as shown below.


>>> tweakreg.TweakReg('@f110w.list',\
imagefindcfg={'threshold':60,'conv_width':2.5},\
expand_refcat=False,\
enforce_user_order=False,\
refimage='f160w_sc08px10_drz_sci.fits',\
refimagefindcfg={'threshold':200,'conv_width':2.5},\
minobj=5,\
shiftfile=True,\
outshifts='shift110_flt.txt',\
sigma=2.5,\
updatehdr=True,\
wcsname='FLT',\
interactive=True,\
ylimit=0.5)


With these thresholds, TweakReg finds between 200-300 objects in each F110W frame and ~2900 objects in the F160W reference image. Note that we set 'expand_refcat=False' for this filter since the reference catalog is fully defined by the drizzled F160W mosaic. The shift file below gives the required offsets and fit rms, where the units are now expressed in reference pixels (e.g. 0.08”/pixel versus the F160W shift file where the reference image scale is 0.1283”/pix).

# image                dx          dy          drot          dscale     xrms       yrms       match
ick901hxq_flt.fits     -0.003019    0.471148    0.001507     1.000058   0.186245   0.133508   247
ick901i4q_flt.fits     -0.043820    0.431017    0.001427     1.000071   0.183568   0.127997   230
ick902n7q_flt.fits      0.449591   -0.137317    0.000081     1.000077   0.178102   0.127555   276
ick902nbq_flt.fits      0.376117   -0.191166    0.000470     1.000058   0.170392   0.119254   283
ick903n2q_flt.fits    -10.896301  -19.298041    0.000337     1.000066   0.176379   0.127778   184
ick903n9q_flt.fits    -10.905232  -19.369878    0.000253     1.000073   0.163772   0.132321   194
ick904o9q_flt.fits    -13.619104  -19.629480  359.998923     1.000007   0.151163   0.128454   199
ick904odq_flt.fits    -13.675618  -19.685206  359.998026     1.000008   0.193882   0.129358   201

[4] Finally, we combine the full set of F110W images, where the output reference frame (eg. scale, orientation, image size, etc.) is defined by the drizzled F160W image.

>>> astrodrizzle.AstroDrizzle('@f110w.list',\
output='f110w_sc08px10',\
preserve=no,\
clean=no,\
build=no,\
skymethod='match',\
driz_sep_bits='64',\
driz_cr_corr=yes,\
final_bits='64',\
final_wcs=yes,\
final_refimage='f160w_sc08px10_drz_sci.fits')