Skip to content

Coadding

Adam Wright edited this page Apr 3, 2019 · 10 revisions

Running coadd scripts

The central coaddition script is do_coadd_batch.sh, which has several different modes:

  • good : weighted-sum = measurement/lensing image (lensing band only)
  • all : median combined = detection image (every band)
  • exposure : This does not add exposures together, it just places 10 CCDs together pixel-matched to the “all” image making individual-exposure coadds. It's necessary for all filters, since it's needed for photometry as well as backmasking. (every band)
  • 3s : coadds the SDSS 3s exposure (as needed)
  • gabodsid : weighted-sum coadd split by gabodsid (as needed)
  • rotation : weighted-sum coadd split by rotation and gabodsid (as needed)
  • pretty : coadds the deep and 3s cluster exposure (as needed)

Within do_coadd_batch.sh many subscripts are called, but they basically correspond to three different tasks:

  1. Make catalogs
  2. Make sky-subtracted images (*.sub.fits are sky subtracted images)
  3. Run swarp and make coadds

The ones which make the catalogs and the sky-subtracted images happen in the "all" mode only, hence the "all" mode must come first in the list. If you would like to not have to re-make the cats and sub.fits images, then you can indicate that with the last two entries on the command line (e.g. ./do_coadd_batch.sh ${cluster} ${filter} 'all exposure ...(other modes)...' conditions_file yes yes), the 1st yes indicates keeping the catalogs and the 2nd indicates keeping the sub.fits images. The part after that runs swarp, which has three main scripts (along with one that adds the ring-mask and one that updates the coadd header):

  1. prepare_coadd_swarp.sh: makes the header files for the individual chips (images and flags) and the coadds (e.g. coadd.head)
  2. resample_coadd_swarp_para.sh: resamples the individual chips (images and flags) without coadding yet (this can be done in parallel). *.resamp.fits are resampled outputs.
  3. perform_coadd_swarp.sh: actually coadds the resampled chips producing coadd.fits, coadd.flag.fits, and coadd.weight.fits

Actual coadd call examples:

  • all filters: ./do_coadd_batch.sh ${cluster} ${filter} 'all exposure ...(other modes)...' conditions_file no no 2>&1 | tee -a OUT-coadd_${cluster}_${filter}_all.log
  • lensing filter: ./do_coadd_batch.sh ${cluster} ${filter} 'all exposure good ...(other modes)...' 2>&1 | tee -a OUT-coadd_${cluster}_${filter}.log

Output examples from ~/data/MACS0416-24/W-J-B/SCIENCE/coadd_MACS0416-24_all/:

  • this does median combine for detection image
  • if there are bright stars with large stellar halos then you need to run the stellar halo correction
  • main output is the output image: coadd.fits
  • ds9 -rgb -colorbar no -blue W-J-B/SCIENCE/coadd_MACS0416-24_all/coadd.fits -green W-C-RC/SCIENCE/coadd_MACS0416-24_all/coadd.fits -red W-S-Z+/SCIENCE/coadd_MACS0416-24_all/coadd.fits &

coaddition of flags and weights

We can only read the flag values when detecting objects. Since detection is done on the “all” image, it's coadd.flag.fits and coadd.weight.fits in the coadd_${cluster}_all/ directory that are the important ones. So, for example, the rings are not flagged for the “good” coadd image, which is fine (in fact, in the 'good' mode the flags come from a simple ic command: ic -p 8 '16 1 %1 1e-6 < ?' coadd.weight.fits > coadd.flag.fits). Note that the rings don't show up in the weights.

coaddition and swarp

The primary tool used for coaddition is swarp. Where scamp left off (with astrometric calibrated headers), swarp now picks up. For more on the particular header keywords which are relevant for projection (e.g. the tranformation matrix, which is currently encoded in CD1_1,CD1_2,CD2_1,CD2_2, and was previously contained in CDELT1 and CDELT2, as well as the very simple things encoded within CTYPE1, CTYPE2, CRVAL1, CRVAL2, CRPIX1, CRPIX2, and EQUINOX) must be carried over from the scamp output, see here: http://www.stsci.edu/hst/HST_overview/documents/multidrizzle/ch44.html

fixing coadd headers

it's hard to keep the book-keeping for the header keywords correct as you go, so you might need this: see ~/wtgpipeline/adam-fix_coadd_headers/FIX_COADD_HEADERS

CHOOSE A LENSING BAND and PUT THE RIGHT COLUMNS IN THE RIGHT FILES

see here: https://github.com/arwright3/gravitas/wiki/CHOOSE-A-LENSING-BAND-and-PUT-THE-RIGHT-COLUMNS-IN-THE-RIGHT-FILES