Using SExtractor and Tweakreg
Sometimes there are very few or hardly any stars in some images, and so the images are not very amenable to the use of the stellar daofind-based software for the built-in tweakreg source detection and measurement. In cases where there are many galaxies, however, software such as SExtractor, a package which is widely-used in the extragalactic community, may be used to generate external catalogs which can then be fed to tweakreg to improve alignments. Major differences in this method include the fact that the DQ arrays are not used in SExtractor, so you need to make CR-cleaned images first rather than relying on the ability to exclude objects based on the DQ flag values as you can do with the built-in task imagefindpars.
Making cr-clean.fits images involves an iterative process whereby you first combine images that are most likely to be nearly aligned already based on their wcs info and the fact that they were taken both in the same visit (on the same guide star acquisition) and in the same filter. Once you align images taken in the same visit + same filter combination, you will have cr-clean.fits images of the sort necessary for running SExtractor and getting better results, since SExtractor does not do well with images still containing lots of cosmic rays, whether they are in otherwise empty areas of the images or they are superimposed on the objects in the image. Other factors within SExtractor itself which can help determine and improve the accuracy of the results are minimum object sizes, the size of typical objects in the images relative to the size of the blocks in the "mesh" used to measure the sky background, the sigma level of thresholds for the object detection and measurement, the use of perhaps a smaller number of the brightest objects, the use of objects with the most consistent and simplest, more nuclear-concentrated morphology across all the bandpasses, and the use of weight images to give preference in the measurement sample of objects to those which have higher S/N by virtue of being in areas where more images overlap or where fewer pixels have been hit by cosmic rays or contain bad pixels which have been thrown out of the stack, so that the signal level is the highest. This latter factor is not included in these most simple of examples, but is discussed more in Frontier Fields documentation and scripts, for example.
In this simplest of examples, we employ mostly default parameters in both SExtractor and tweakreg to achieve a rough accuracy of about ~0.15 pixels rms. Better results may be possible with more involved and refined techniques and parameter values.
Observations
The data in this example are comprised of 4 exposures in the same filter, all from Visit 0X of HST program 10092. Figure 1 shows the dither pattern and field of view. Table 1 presents more details of the dithers, etc.
Procedure
First, before doing anything else, be sure to use the latest geometric distortion info, following the instructions at the ACS geometric distortion page at http://www.stsci.edu/hst/acs/analysis/distortion and then continue as below. This initial preparatory step is necessary to do manually at present, but should be incorporated into the OPUS pipeline and done automatically with data retrieval from the Archive by the late Summer or Fall of 2015.
Summary of Steps:
[1] Examine the data & observing program structure; note same visit/ filter.
[2] Do initial single drizzle to produce *_crclean.fits files (cosmic rays removed). Set driz_cr_corr = True in AstroDrizzle Step 6 parameters.
[3] Download and install SExtractor. We recommend version 2.8.6 or later.
Check first to see if it has already been installed on your system. If not, you may find it at http://www.astromatic.net/software/sextractor where you will also get the necessary start-up files, default.sex, default.param, default.nnw, and default.conv.
[4] Run SExtractor to produce catalogs for use in tweakreg alignment. We used mostly default parameters, but specified detect_minarea=3 and detect_thresh=7 in the default.sex SExtractor file in this example. We also specified a PSF FWHM=0.08 in the default.sex file, but this is only used for the stellarity parameter measurement in SExtractor and nothing else.
Below we show two examples of the commands to use:
UNIX > sex -catalog_name j8xi0xs0q_crclean_ext1.cat -checkimage_name j8xi0xs0q_crclean_ext1_check.fits j8xi0xs0q_crclean.fits'[0]' UNIX > sex -catalog_name j8xi0xs0q_crclean_ext4.cat -checkimage_name j8xi0xs0q_crclean_ext4_check.fits j8xi0xs0q_crclean.fits'[3]'
[5] Visually inspect and clean up SExtractor catalogs, iterating if needed.
You may clean up and/or omit various candidate objects from your source lists for matching in several ways which can be combined. In this original example, some sources were edited out of the lists by hand, so we do not include files from use of any other methods here, but only mention some of those other possible methods.
To trim out the sources around the edges of the chips in a 100-pixel border, you may instead use an awk command of the form:
UNIX> awk '($1 !~ /#/ && $1>100 && $1<3996 && $2>100 && $2<1948)' j8xi0xs0q_crclean_ext1.cat > j8xi0xs0q_crclean_trimv1_ext1.cat
You may instead use DS9 regions files to specify exclusion zones which the tweakreg task will take as part of its input, instructing it to ignore the sources within a given area.
If you set up your default.sex file to use a specific magnitude system and define the zeropoint and gain, you can also specify bright and faint flux limits for the tweakreg task to include and exclude objects within or without certain ranges or limits. NOTE: When using magnitudes rather than regular flux measurements, you would specify maxflux = 24.0 and minflux = 20.0 to select and trim the magnitude range to include only sources from magnitude 20.0 to 24.0 in your input SExtractor catalog for use in matching sources although the name of the parameters make that seem counterintuitive and to prefer the opposite. One will encounter crashes with errors if using the values for these parameters in the same sense for magnitudes as for regular fluxes.
[6] Prepare control file for inputting SExtractor catalogs into tweakreg.
This is the same file that tweakreg creates called coords_catfile.lis which contains the names of the files to be aligned and the catalog files for the two chips in the order extension 1 and extension 4 (what SExtractor called extensions 0 and 3) all on the same line. It doesn't matter what you call this file or your catalog files so long as your tweakreg parameters refer to the correct image to be registered and as long as it properly references the correct catalog names for each image on the same line, in the case of ACS/WFC or WFC/UVIS it must be the catalog for extension 1 and then extension 4.
[7] Run tweakreg, iteratively, if needed, inputting the SExtractor catalogs. Again, we used mostly default parameter settings.
Before playing with sigma levels etc. in tweakreg, you may first want to try some of the various other means of selectively removing some objects to optimize the solution which are mentioned above.
[8] Proceed with alignment of other same visit/same filter combinations if available, then use tweakback to align all images to a common reference frame across all visits and filters, concluding with final drizzle, per filter, of all co-aligned frames.
Recommended uses
Images for which there are very few or no stars or in which stars are too bright and saturated, but in which there are a good number of galaxies which can be used for alignment, or in images with few stars and which were taken over a long enough time baseline such that some stars may have moved due to their proper motion.