The reduction of Mosaic camera images at first glance is just like that of any other CCD camera, ignoring the immense amount of data contained in a single Mosaic image. As is standard, reduction requires overscan correction, followed by zero, dark, and flat field corrections. In detail, however, full reduction of Mosaic data requires a number of steps not normally encountered in the routine reduction of other CCD camera images. The driving factor in Mosaic reduction is the expectation that the observer will not simply obtain a single Mosaic exposure of an astronomical field, but will most likely want to construct a deep integration from several Mosaic images spatially offset or "dithered" from each other to cover both the gaps between the individual CCDs and their extensive regions of defects. Stacking dithered Mosaic images places high demands on the uniformity of the initial data reduction as well as requiring several additional steps once the basic reduction of the individual exposures is complete. Further, the large portion of defective areas in the present "engineering grade" CCDs complicates many of these steps. The Mosaic camera also has a spatially variable pixel scale that has important implications for ensuring a uniform photometric zeropoint in the reduced images. This article touches on the basic aspects of Mosaic image reduction that we explored while reducing data from the NOAO Deep-Wide Imaging Survey, which was largely done using an earlier version of the IRAF MSCRED package. At this writing we are still refining the reduction software and learning about the camera. We share what we found here with the caveat that this is still a work in progress.
Good data reduction begins with obtaining good calibration data at the telescope. The Mosaic CCDs operate at warmer temperatures than usual, so good dark frames are required, in addition to the usual zero frames. Further, we recommend that you obtain darks with exposures similar to your science images. While many of the dark features will scale with time, there are regions of charge overflow that may be not completely linear. Dome flats provide a fair basic flattening of the frames to 2% or so, but night sky flats or illumination corrections will be required to produce images that can be stacked without introducing obvious artifacts. In the course of the NOAO Deep-Wide Survey, which works on regions of "blank" sky, we naturally obtained the images we needed to generate sky flats, and were able to flatten the images to 0.1%; at this time we have not attempted to use twilight flats and cannot comment on them.
The default Mosaic dither pattern is a sequence of five exposures designed to insure at least 80% coverage for all portions of an astronomical field, given the gaps between the CCDs and many of the large defects, which in a number of cases are even wider than the gaps. Other things to be aware of include the small wells and nonlinear response of CCD4. This chip saturates at only 4 x 104 e-, and becomes nonlinear by more than 1% above 1.5 x 104 e-. At this time we are investigating the nonlinearity, which is unexpected, but the full well still sets a hard limit to the exposure level. In contrast, the other seven CCDs appear to be highly linear up to this exposure level, and have much larger wells. Lastly, good astrometry is required to register and stack the Mosaic images. We have excellent solutions for the R and V band filters, but the scale varies slightly with color, so you may want to image an astrometric field if you are using filters not bracketed by these colors. The Mosaic support team will eventually supply solutions for most of the filters.
Almost all of the basic image reduction is done under the IRAF MSCRED package. Before you get started, you should be aware that the Mosaic multi-extension FITS data format means that you will have to be careful to stick to the routines in MSCRED that can handle this format. In many cases, useful routines from CCDRED have been rewritten with the same name to be available in the MSCRED package. IRAF routines in other packages can be used on one CCD at a time either in scripts or the command line, but will not work directly on an entire mosaic image at once. At present we are still working on this issue, but there is an MSCCMD routine that acts as an interpreter, allowing you to use traditional IRAF routines on the Mosaic files.
One of the first things that you're likely to do is to stack sequences of zero, dark, and flat exposures to produce "superimages" to feed into CCDPROC. On the assumption that the darks and zeros are all the same, using ZEROCOMBINE and DARKCOMBINE presents no complications. On the other hand, you are likely to want to scale the flats by their modes, and this at present can be tricky. Because of the importance of image defects, modes and other statistics can be biased by bad values. To estimate modes in our reductions to date, for example, we wrote a script that estimated the mode in two passes. The first pass restricted the range of allowable pixel intensities to "plausible" values to exclude "wild" numbers; the second pass used the mode from the first pass to limit the range of allowable values to between zero and twice the initial mode. With the first version of the software, we had to write a stand-alone FORTRAN program that averaged the modes from the eight CCDs with sigma rejection (and that ignored CCD4, as well) and then feed the scale factors to the combining task. These improved algorithms for mode estimations and combining to a single scaling value for each exposure will be part of the standard MSCRED version by the time you read this article.
With good zero, dark, and flat field images in hand, the basic image reduction is done with the MSCRED version of CCDPROC. If your data consists of a dither-sequence that you intend to stack later, we recommend that you do not interpolate over bad pixels; this is more logically done downstream, as we discuss later. One of the last basic steps that you may attempt is to build a sky flat or illumination correction from a portion of your reduced data. You could try going directly to a sky flat without any prior reduction with a dome flat (or any other serviceable flat), but working with roughly-flattened data first allows for more accurate estimation of the mode in the presence of faint astronomical sources, and further allows for better detection and rejection of biased regions of the images. At the same time, flat field reductions will produce wild values in the defect regions, so extra care is required when estimating modes or other statistics from flattened data.
In passing, we mention that we hope to establish a basic database of calibration images that can help you get started in your own reductions. For example, we have already found that a flat field from an earlier month provides an excellent initial reduction of new data. We also have an excellent ad hoc bad pixel mask that we will continue to refine. At the same time, the dark current appears to vary from run to run, so you will want to obtain your own dark frames.
A key assumption in traditional reduction of CCD images is that the pixel scale is uniform and that a properly reduced blank sky image will have a uniform and flat appearance. Unfortunately, this is not correct when the pixel scale varies over the field. In the case of Mosaic, the pixel scale decreases approximately quadratically from the field center, with the pixels in the field corners being 6% smaller in the radial direction, and 8% smaller in area, given the complete astrometric description of the field. Pixels in field corners thus would properly detect only 92% of the sky level seen in the field center, even with uniform sensitivity. At the same time the same number of total photons would be detected from a star regardless of how many pixels the PSF would be distributed over. Forcing the sky to be uniform over the image would have the deleterious effect of causing the photometric zeropoint to vary from center to field corners by 8%. Note that this effect is different from vignetting, where the flux actually delivered to the image margins is less than that at the center, an effect that is corrected by the flat field.
In practice, the photometric effect of the variable pixel scale can be ignored provided that the reduced images will be part of a dither-sequence to be stacked later on. As discussed below, prior to stacking the images, they first must be regridded to a tangent-plane projection, which has pixels of essentially constant angular scale. This is done with the MSCIMAGE task, which regrids the pixels and has a "flux conservation" option that can scale the pixels photometrically by the associated area change. If this function is disabled, then "improperly" flattened images will have a uniform zeropoint restored with this option turned off. In short, the flat field is already adjusted (if inappropriately) for the different pixel sizes, so MSCIMAGE would then do no further adjustment. Stars would be too bright in the corners of the flattened images, but after regridding, their total fluxes would be seen to be scaled down to the appropriate values.
If the Mosaic images are to be analyzed individually, however, as might be done for standard star fields, then after the flat field reductions are complete, the differential scale effects must be restored. At present we are in the process of developing a routine in the MSCRED package to do this, without actually regridding the image with MSCIMAGE (which can also be done with images not part of a dither-set). The correction process is simple; the scale at any point in the Mosaic field is already known from the astrometry, so one could just calculate and multiply by a correction surface. The final image would appear to have a variable sky level, but would be photometrically uniform. We are contemplating allowing an option to subtract a sky level prior to the correction and perhaps adding it back afterwards. In the latter case, the sky would be cosmetically but not photometrically uniform, and could cause confusion if the frame is ultimately regridded to a constant scale. We also note that performing surface photometry on Mosaic images with their native sampling can cause biased results unless care is taken to track the changes in the pixel scale.
In many ways the real work of reducing Mosaic data comes when preparing to stack the images to make a final deep image free from gaps and artifacts. Not only is there a premium on having well-flattened data to begin with, but one must also understand the relative photometric and sky level variations among the images in a dither-set. At any point in the final stacked image, different frames will be making differing contributions. Any differences in scaling will produce noticeable artifacts in the final sky background or zeropoint. In practice we have found that the stacking works beautifully with data obtained under clear conditions and with no bright stars near the fields; on the other hand we have found that simple reduction strategies produce very poorly stacked images if the shape of the sky over the field or scattered light contributions varied over the course of a dither-sequence (or over the course of the night used to define the sky flat).
The first step in stacking the reduced Mosaic images is to register them to a common coordinate system. This is done with the MSCZERO and MSCREGISTER programs. The MSCZERO routine can be used to set the coordinate system origin for any given image, given a known position or even ad hoc position for any star. There are three important uses of MSCZERO. The first is to set the coordinate zero point fairly accurately and then read back coordinates. With a reference star one can obtain useful "real-time" coordinates at the telescope. We did this to check asteroid detections against known asteroid positions. The second use of MSCZERO is to identify a list of stars in one "fiducial" image that will be located in the other images in the dither-set. A third use is to reset the origins of the other images in the dither-set to match the fiducial image in the event that the coordinate origin is lost or corrupted (as happened a few times in our reductions). The MSCZERO routine uses the known astrometric description of the Mosaic field so that the location of any star identified can be used to set a global origin. In passing, we note that the quality of the astrometric solution is excellent; stars can be located to a fraction of a pixel (0.26" at the 4-m) in all portions of the field.
Registering the images in a dither-set to the fiducial image can in principle be done entirely with a single star using MSCZERO, but MSCREGISTER offers more options and has the ability to use a number of stars to find the best registration. At this time we are still experimenting with MSCREGISTER, but have had the best luck with identifying about 10 stars or so in the fiducial image and asking MSCREGISTER to locate them in the other dither-set images. MSCREGISTER uses the astrometric solution and recorded relative telescope offsets to locate the registration stars in a given image (it can also be assisted by running the images through MSCZERO if this assumption fails for some reason). Once a given star is located, it is cross-correlated with the same star in the fiducial image to calculate a positional offset. You have the option to review the quality of the match to decide if it is acceptable. The final offset is the average of the individual offsets, with a check for outliers. At this time, we think this interactive approach gives the best confidence that the correct offsets are being used. In the future, we hope to automate rejection of poor cross-correlation matches. MSCREGISTER presently has the option to find an offset by cross-correlating random regions of the images, but at present this often leads to computing offsets from regions with no bright objects or containing large defects.
The penultimate step in stacking Mosaic images is to regrid them into common tangent-plane projections using MSCIMAGE. The use of a common projection aligned to the centers of the pixels is done so that the shift and stack step does not require any further resampling. Up to this point the individual CCD images are each stored in their own partition in the multi-extensions FITS files. MSCIMAGE "pastes" the individual CCDs into a large single FITS image, accounting for their accurate relative positions and rotations, given the astrometric description of the field. MSCIMAGE further regrids the pixels into a tangent-plane projection, which yields pixels of essentially constant angular size over the extent of the Mosaic field. This is also the best point to fold in knowledge of the bad pixel map. The bad pixel map itself can be regridded by MSCIMAGE, giving the final routine, MSCSTACK, complete knowledge of where the bad pixels are. If the bad pixels had been replaced prior to this point, and had not been flagged in the Mosaic images themselves, their locations would have been unavailable in the final stacking.
Regridding the Mosaic images of necessity requires a method to calculate new pixels interpolated from the original ones. One can select from any number of the standard IRAF interpolation routines; however, given the immense quantity of the data involved, we have always selected bilinear interpolation for speed considerations. Unfortunately, bilinear interpolation smooths the noise slightly, and as the new pixel grid beats against the original grid, the noise in the tangent-plane image shows bands of coherent noise structure. This will be reduced somewhat in the final stacked image, given the spatial decoherence of the images in the dither-set. At this time we are experimenting with improving the speed-performance of higher-order interpolation methods to avoid smoothing of the data. Lastly, as noted above, MSCIMAGE has the option to correct the flux in the regridded pixels for the variable pixel scale. Use of this option should only be invoked when this information is preserved in the flattened images to begin with.
The final step is to combine the reprojected dither-set images using MSCSTACK. This is the stage where careful attention must be paid to variations in zeropoint and sky level among the images. Even on photometric nights, the sky level is likely to change over the course of the dither-sequence. We have used the image modes to track the sky level, but again, one must be careful that the mode is not biased by the abundant bad pixels and defects. In detail for our reductions to date, we calculated the average sky level for a dither-sequence and then gave MSCSTACK a file specifying additive offsets for each image about this average. At this stage you should also account for any photometric variations among the images. MSCSTACK can also accept a file of multiplicative offsets. These might be based on an atmospheric extinction curve on photometric nights, or determined by comparing stars among the dither-set; we are exploring the use of MSCREGISTER to measure photometric as well as spatial offsets among stars. At this writing, we are also upgrading MSCSTACK to include options for calculating both forms of scaling, so specifying the scale factors in an external file may be no longer required.
The final stacking of the image by MSCSTACK can be done with any of the standard combining algorithms within the IRAF combine tasks. We have preferred to use an average value with sigma rejection; we also make complete use of the bad pixel map at this stage to eliminate known defects. One might be tempted to use a simple median, but in the limiting case of a large number of images this will still only yield ~ 80% of the signal-to-noise available from an average. On the presumption that most vectors of pixels to be stacked will be "OK," an average (with occasional rejection) will give the best answer.
Going all the way through to this stage has produced final stacked images of variable quality, depending on the conditions of the observation. In non-photometric conditions the sky may not be flat; further, scattered light from nearby objects may affect the sky over large areas---unfortunately, the pattern of scattered light varies as the telescope is dithered. A further complication is that computation of an average mode for an image may be affected by scattered light that affects only a small portion of the Mosaic field. At this time we are still working on a solution for stacking images of this type; the solution is likely to require fitting and subtracting a sky surface to the individual Mosaic images prior to feeding them to MSCSTACK. When conditions are favorable, however, we have produced beautifully flat stacked images free from defect, showing the full scientific potential of Mosaic camera, and providing a suitable reward for our hard work.
Tod Lauer, Frank Valdes