The MegaPipe image stacking pipeline

The MegaPipe image stacking pipeline MegaPipe Stacking Procedure

MegaPipe Stacking Procedure

This page describes the procedures used to generate the stacked images and catalogues for the MegaCam image stacking pipeline. In short, the procedure is to calibrate each CCD from each exposure of the MegaCam mosaic camera to high precision astrometrically and photometrically, and then add the images together.

Image grouping

The images are grouped according to the following criteria:

  • The centres of the images in a group must be at most 0.1 degrees apart.
  • There must be at least 4 images taken in a single filter.
  • Images taken in other filters are included in the group if there are more than 4 images taken in each filter.

Each image in a group must

  • have an exposure time of 50 seconds or more. This is so that there are enough objects to do the calibration
  • be photometrically calibratable. This means the image must meet one of the following criteria:
    • It lies within the SDSS, and thus may be directly calibrated
    • It was taken on a photometric night, so that the Elixir photometric calibration is valid
    • It overlaps an image that is calibratable by one of the preceding methods
  • Be public, as defined by the CFHT propritary policy period.
  • Be free from major problems that preclude good calibration as discussed in the following section.

Quality control

The data are retrieved from the CADC archive. The images have already been detrended with the Elixir pipeline. The images come with a fairly accurate (0.5-1.0 arcsecond) astrometric solution and a photometric calibration. One CCD of each exposure is inspected visually. Exposures with obviously asymmetric PSF's (due to loss of telescope tracking) or other major defects such as terrible seeing, bad focus, or poor atmospherique transparency are discarded. In some images, one or more of the CCD's in the mosaic are dead. These images are also discarded.

Astrometric calibration

The AstroGwyn astrometric calibration pipeline is run on the images. The first step is to run SExtractor on each image. The parameters are set so as to extract only the most reliable objects (5 sigma detections in at least 5 pixels). This catalogue is further cleaned of cosmic rays and extended objects. This leaves only real objects with well defined centres: stars and (to some degree) compact galaxies.

This observed catalogue is matched to the astrometric reference catalogue. The (x,y) coordinates of the observed catalogue are converted to (RA, Dec) using the initial Elixir WCS. The catalogues are shifted in RA and Dec with respect to one another until the best match between the two catalogues is found. If there is no good match for a particular CCD (for example when the initial WCS is erroneous), its WCS is replaced with a default WCS and the matching procedure is restarted. Once the matching is complete, the astrometric fitting can begin. Typically 20 to 50 sources per CCD are found with this initial matching.

Elixir provides a first order solution for the WCS with typical errors on the order of 1 arcsecond. AstroGwyn improves on this to provide a higher order solution with an accuracy of typically 0.1 arcseconds. As the accuracy of the WCS improves, the observed and reference catalogues are compared again to increase the number of matching sources. A larger number of matching sources makes the astrometric solution more robust against possible errors (proper motions, spurious detections, etc.) in either catalogue.

The higher order terms are determined on the scale of the entire mosaic. That is to say, the distortion of the entire focal plane is measured. This distortion is well described by a polynomial with second and fourth order terms in radius measured from the centre of the mosaic. The distortion appears to be stable over time, even when some of the MegaPrime optics are flipped. Determining the distortion in this way means that only 2 parameters need to be determined (the coefficients of r2 and r4) with typically (20-50 stars per chip) * (36 chips) =~ 1000 observations. If the analysis is done chip-by-chip, a third order solution requires (20 parameters per chip)*(36 chips)= 720 parameters. This is less satisfactory.

From the global distortion, the distortion local to each CCD is determined. The local distortion is translated into a linear part (described by the CD matrix) and a higher order part (described by the PV keywords). The CD/PV transformation was described in detail in an appendix that was removed from first draft of the MegaPipe paper. The higher order part is 3rd order as well, but the coefficients depend directly and uniquely on the 2 parameter global radial distortion. The error introduced by this translation is less than 0.001 arcseconds.

For the first band to be reduced (the i-band, if it exists, otherwise the order of preference is r, g, z, u), these source catalogues are matched with the an external astrometric catalogue to provide the initial astrometric solution. If available, the SDSS catalogue is used, otherwise the 2MASS catalog is used.

For the other bands, the observed catalogues are first matched to the external catalogue and then matched to a catalogue generated using the first image in order to precisely register the images in the different bands. The final astrometric calibration has an internal uncertainty of about 0.03 arcseconds and an external uncertainty of about 0.1 arcseconds, as discussed on the checks on astrometry page.

Photometric calibration

The Sloan Digital Sky Survey DR9 serves as the basis of the photometric calibration. The Sloan ugriz filters are not identical to the MegaCam filters. The colour terms between the two filter sets can be described by the following equations:

u_Mega = u_SDSS - 0.241 (u_SDSS - g_SDSS)
g_Mega = g_SDSS - 0.153 (g_SDSS - r_SDSS)
r_Mega = r_SDSS - 0.024 (g_SDSS - r_SDSS)
i_Mega = i_SDSS - 0.085 (r_SDSS - i_SDSS)
z_Mega = z_SDSS + 0.074 (i_SDSS - z_SDSS)

The relations for the griz bands come from the analysis of the SNLS group. The relation for the u band comes from the CFHT web pages.

All images lying in the SDSS can be directly calibrated without referring to other standard stars such as Smith standards. The systematic uncertainties in the SDSS photometry are about 0.02 magnitudes (Ivezic, et al., 2004). The presence of at least 1000 usable sources in each square degree reduces the random error to effectively zero. It is possible to calibrate the individual CCDs of the mosaic individually with about 30 standards in each. For each MegaCam image, the observed catalogue is matched to the SDSS catalogue for that patch of sky. The difference between the instrumental MegaCam magnitudes and the SDSS magnitudes (transferred to MegaCam system using the equations above) gives the zero-point for that exposure or that CCD. The zero-point is determined by median, not mean. There are about 10000 SDSS sources per square degree, but when one cuts by stellarity and magnitude this number drops to around 1000. It is best to only use the stars (the above colour terms are more appropriate to stars than galaxies) and to only use the objects with 17<mag<20 (the brighter objects are usually saturated in the MegaCam image and including the fainter objects only increases the noise in the median). This process can used for data from any night. It is not necessary for the night to be photometric.

For objects outside the SDSS, the Elixir photometric keywords are used, with modifications. The Elixir zero-points were compared to those determined from the SDSS using the procedure above for a large number of images. There are systematic offsets between the two sets of zero-points, particularly for the u band. These offsets show variations with epoch, which are caused by modifications to Elixir pipeline. There also differential offsets between the CCDs of a single image. For MegaPipe, the offsets are applied from the Elixir zero-points to bring them in line with the SDSS zero-points. A detailed analysis of these offsets has been made.

The Elixir photometric keywords are only valid on photometric nights. Archival data from the SkyProbe real-time sky-transparency monitor is used to determine if a night was photometric or not. Data taken on photometric nights is processed first through the astrometric and photometric pipelines to generate a catalogue of in-field standards. These standards are then used to calibrate any non-photometric data in a group. If none of the exposures in a group was taken on a photometric night, that group cannot be processed.

Coaddition

The calibrated images were coadded using the program SWarp. Here is the SWarp configuration file. The resulting stacks are simple FITS files (not multi-extension FITS files) measuring about 20000 pixels by 20000 pixels or about 1 degree by 1 degree, depending on the input dither pattern, and are about 1.7 Gb in size. They have a sky level of 0 ADU. They are scaled to have a photometric zero-point of 30.000 in AB magnitudes - that is to say, for each source:

    AB_magnitude = -2.5 * log10(ADU) + 30.000
  

A weight map (inverse variance) of the same size is also produced.

Photometric catalogue

SExtractor is run on each stack using the weight map. Here is the SExtractor configuration file. The resulting catalogues only pertain to a single band image; no multi-band catalogues have been generated. While this fairly simple approach works well in many cases, it is probably not optimal in some situations. Depending on the application, some users may wish to run their own catalogue generation software on the stacks.