## DrizzlePac Features

### Support for Automated Mosaic Building

TweakReg now provides support for aligning images that do not directly overlap with the reference image and/or catalog (eg. building mosaics). In the default configuration when the user does not supply their own reference catalog and/or image, this is done by choosing a pair of images (from the input list of images) with the largest overlap in the sky and trying to align them. One image will be used to produce the "reference catalog" while the other image will be aligned to this catalog. Now, the 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. This way, the reference catalog keeps expanding with each new matched image. With a large (expanded) reference catalog now it is possible to align images that did not have a direct overlap with the starting image. This feature can be turned off using the "expand_refcat" parameter only when the user provides his/her own reference catalog that is of high confidence and the user does not desire TweakReg adding new sources to this high quality catalog.

### Mitigation of False Detections

TweakReg’s source finding task (imagefind) now includes additional parameters to exclude false detections and allow the software to more easily solve for the image offsets using matched sources lists. For example, ‘dqbits’ is a list of DQ flag values to include as ‘good’ or to exclude as ‘bad' before generating and matching source lists. For WFC3/UVIS, setting dqbits=-16 will mask hot pixels flagged by the instrument team, eliminating a common problem where TweakReg locks onto hot pixels and solves for the dither pattern. This can occur when users set the detection threshold value too low and hot pixels outnumber astronomical sources. Other new parameters allow selection for sharpness and roundness, which give users better control over source selection criteria and the mitigation of artifacts.

### Align Different HST Cameras

The new TweakReg software makes it easier for users to align different HST detectors by allowing for separate sets parameters (threshold, conv_width, etc) between the input list and the reference image. For example, the command used to align WFC3/UVIS and WFC3/IR images would be:

>>>  tweakreg.TweakReg(‘@wfc3_uvis_flt.list',\
imagefindcfg={'threshold':10,'conv_width':3.5},\
refimage=‘wfc3_ir_f160w_drz_sci.fits',\
refimagefindcfg={'threshold':200,'conv_width':2.5}) 

### Aligning to Non-HST Image

Alignment of HST data to non-HST images refers to the process of modifying the WCS information in the header of the HST image so that sources in the HST images match the positions of the same sources in the non-HST image. This will correct the astrometry of the HST data to match that of the non-HST image, presumably to allow comparisons of the HST data with other published results. The alignment to a non-HST image can only be performed when all distortions have been corrected in the WCS of the non-HST image. Spitzer images, for example, typically include SIP distortion coefficients as part of their WCS. On the other hand, SWIFT and DSS images do not contain any description of distortion in the WCS keywords.

One requirement for getting non-HST images to work with the DrizzlePac code remains an adherence to the FITS standards for multi-extension files and for describing the WCS. The DrizzlePac code relies on wcslib through the astropy.wcs  (previously, the pywcs) library to read in the WCS keywords. In addition, HST multi-extension FITS files specify the extensions using EXTNAME and EXTVER keywords to designate the SCI, ERR and DQ extensions, and the code expects all inputs to conform to the same conventions. This may require updating the headers of the non-HST images to include these keywords to match the format of HST images.
This was done easily for SWIFT data using the following commands:

>>>  from astropy.io import fits as pyfits
>>>  cp sw00031905002uuu_sk.img sw00031905002uuu_sk.fits
>>>  swift = pyfits.open('sw00031905002uuu_sk.fits', mode='update')
>>>  wift.close() 

The file in this example (sw00031905002uuu_sk.fits) can now be used as a reference to align non-HST images with no additional changes. For example, the command to align a set of FLT files to the SWIFT file would be:

>>> tweakreg.TweakReg(‘*flt.fits', \
imagefindcfg={'threshold':10,'conv_width':3.5},\
refimage='sw00031905002uuu_sk.fits',\
refimagefindcfg={'threshold':200,'conv_width':2.5},\
minobj=5,\
updatehdr=True,\
wcsname=’SWIFT',\
interactive=True)


and if you already have a reference catalogue (with the name 'swift.cat'), you would use the following command:

 >>> tweakreg.TweakReg(‘*flt.fits',\
imagefindcfg={'threshold':10,'conv_width':3.5},\
refimage='sw00031905002uuu_sk.fits',\
refcat=’swift.cat',\
minobj=5,\
interactive=True)