Creating the Master Fringe & SVD Mode Images

Images which have been corrected for bias, dark, and flat-field effects are photometrically consistent: the number of counts in each pixels is proportional to the number of photons incident on the pixel, with the same proportionality for all pixels. However, it may still necessary to perform additional corrections to make the images scientifically useful. There may be additive background contributions which do not represent features of the sky, but are rather due to features of the instrument. At CFHT, we correct for two major classes of additive background components: fringes and large-scale structures.

We discuss the causes of these two types of additive components, and the general technique in some detail elsewhere (Fringe Corrections); in this document, we discuss the programming details of the `mkfringe' system which is used to create the master fringe and master SVD mode images. This system is one of the more complex components of the Elixir system since it involves several processing steps, and various diagnostic measurements of the correction are provided. We will first discuss the fringe creation portion; much of the SVD mode creation system is quite similar.

A few definitions are needed to describe the different data involved. First, each version of a fringe frame for a given filter is defined by a set of parameters which together we call a 'config'. A config is represented by a word built by connecting the relevant parameters; a config consists of RUNID.TYPE.FILTER.VERSION. RUNID is a word which identifies the camera run (ie, 01Bk04). TYPE is the word 'fringe' for the fringe frames and 'mode' for the SVD mode frames. FILTER is the filter name (ie, I, Z). VERSION is a number to distinguish different versions within the previous set of parameters.

There are essentially four types of data involved in the process of building the fringe frames. First, there are data which are relevant to a specific CONFIG, such a the list of all input images or the name of a jpeg representation of the complete output image. Second, there are data which are relevant to a single CCD for a given CONFIG, such as the master fringe image for a given chip, or the collection of statistics on a given chip; we represent these data in the discussion below with the word CONFIG.CCD. Third, there are data which are relevant to a given input image, such as a jpeg image of the master frame or a collection of statistics on the given frame; we represent these with the word MOSAIC in the discussion below. The fourth type of data are relevant to a specific chip in a MOSAIC, such as a single input CCD image; we represent these with the word MOSAIC.CCD.

The fringe creation process involves a variety of steps, and two major stages. We will first outline the process, then discuss the steps in detail later on.

Stage 1: Image Preparation

  • Select the input images.
  • Create initial lists
  • Detrend all input images.
  • Rebin the images, extract high / low frequencies
  • Measure fringe statistics on input images
  • Create jpegs of input images
  • Measure fringe parameters
  • Create lists for web pages

Stage 2: Master Creation

  • Measure fringe parameters from subset
  • Create lists for master fringe process
  • Create master fringe frame
  • Apply master to all input images
  • Measure fringe statistics on all residual images
  • Create jpegs of residual images
  • Measure fringe parameters
  • Create lists for web pages

Stage 3: Image Registration

  • Assign Image meta-data
  • Register image in detrend database

In addition to these three stages, there is a process by which the user can use a web browser to examine the input images, view a representation of the residuals and statistics of each input image, and refine the selection of the input images used to create the master image. In practice, the user runs the Image Preparation step once, then performs a series of image selection and Master fringe frame creation to choose the best set of input images. At this point, the user accepts the results and runs the third stage of Image Registration.

Let's look at each of the steps in detail.

Stage 1: Image Preparation

Select the input images

Images are selected from the image registration database. It is necessary for the images to have the sky counts measured, which means they must have been passed though the imstats system. Images are selected if the satisfy several conditions: 1) They must be use of the appropriate filters (currently I, Z, NB920). 2) They must have sky counts greater than a specific threshold. 3) They must not be saturated in any chip. 4) They must have a sky flux (counts / sec) within specific limits. 5) All 12 chips must be available on disk.

Create Initial Lists

The fringe and mode creation processes as implemented in `mkfringe' use a number of text files to keep track of the many pieces of data involved in the process. During the preparation stage, once we have identified all possible input images, we can create lists of the possible derived products. Some of these lists are simply used to record the accounting information needed by the mkfinge process; some are used as input by program steps which need to know the names of the images. Some of these lists are per CONFIG, while others are per MOSAIC.

Detrend all input images

Before the images can be combined to generate a master fringe frame, they must first be detrended to remove all instrumental signatures. In the mkfringe process, these detrended images are stored in SPLIT format in a particular, specified directory. It is necessary to distinguish several versions of each image, we use a varient on the standard SPLIT naming convention. If an image has OBSID 654321o, the detrended images are stored as file with names of the form 654321oNN.fits (where NN represents the CCD in question) in a directory names 654321o.det (det for detrended). Note that a standard SPLIT image would have no extension '.det'.

Rebin the images, extract high / low frequencies

We separate out the high-spatial-frequency patterns (fringes) from the low-spatial-frequency patterns (eg scattered light) by creating two separate images from the detrended image. The fringe patterns observed in the CFH12K are fairly large scale, always more than a few pixels wide. We can save disk space and substantial time by rebinning the images on a scale smaller that this. We create a 4x4 median-binned image, from which we extract the high and low frequencies. The lowest frequency structures are removed by median-binning by a factor of 256x256 from the original image, producing very small images (4x8 pixels per CCD with CFH12K). These small images are used to construct a spline-fit model which is subtracted from the 4x4 scale image. The large image, representing only the higher-spatial frequencies, is stored as OBSID.med, while the small image, representing only large-scale structures, is stored as OBSID.map. From this point, the fringe and SVD mode creation processes diverge; the OBSID.med images are used to construct the fringe frame while the OBSID.map images are used to construct the SVD mode images.

Measure fringe statistics on input images

Each image has a characteristic fringe strength. We measure this independently on each chip using the fringe pair coordinate lists described in 'Fringe Corrections' . The box used at each point is scaled by the 4x4 binning factor of the previous step. The collection of MIN / MAX pairs are used to determine the fringe amplitude for the chip and the sky level. The 12 values per full mosaic are stored in a file OBSID.med.stats.

Create jpegs of input images

The web-based tool to select the best input images requires large and small jpeg images for each complete mosaic. In this step, we create two jpeg images for each input OBSIDo.med image. These are saved as OBSIDo.med.medbin.jpg and OBSID.med.tenbin.jpg. The first uses a very large-scale median-binning to produce a tiny thumbnail image, while the second produces a larger image with an effective total binning of 16 from the original scale.

Measure fringe parameters

The recipe we use for both fringe master creation and the fringe correction improve the individual chip-by-chip measurements of the fringe strength by comparing the fringe amplitude on all chips. Such a step is useful because a given chip is likely to be affected by the presence of particularly bright stars or large-scale structure, while the mosaic as a whole is less likely to be affected. The process is effective because the fringe amplitude is a measurement of a real physical parameter in the sky: the strength of the emission lines responsible for the fringe pattern. However, even though the fringe pattern is measuring a real parameter, each chip has a different response to the emission lines. This logic implies that the variations in the fringe amplitude for a given chip will be correlated with the variations on each of the other chips. This is in fact what we see. We can use the correlation to determine an optimal fringe amplitude for each full mosaic, and therefore determine the 'best' fringe amplitude for each chip from the common amplitude seen across the mosaic. To make such a measurement, we need to determine the correlation between the fringe amplitude in the different chips. First we find the chip with the maximum fringe amplitude, which will have the strongest response to the emission lines. Next we determine a linear fit to the collection of fringe measurements on chip A vs the reference chip. The result is a collection of 12 linear fits, and reference chip (for which the linear fit has a slope of 1, intercept of 0, by definition). These fringe fit parameters are stored in the file CONFIG.fitpar for later use. Note also that the optimal fringe amplitude determined from these fits are used to determine a relative scaling of the fringe pattern between each of the input images when they are merged into a master image.

Create lists for web pages

We collect the various pieces of informatnio in the different lists to generate information needed on the web pages, and move the various jpeg to the appropriate web directory. At this point, the user may run the web tool to select the input images.

Stage 2: Master Creation

The next major stage is to use the selected images to create a master fringe frame, and determine fringe residuals using that frame. This section is invoked by running 'mkfringe run'. If the image preparation stage has been run, it possible, but not necessary for the user to adjust the selection of input images.

Measure fringe parameters from subset

Only the selected subset of images are used to re-determine the fringe correlation fits for each chip. These new fits are used to determine optimal fringe pattern strength for each of the images in the selected subset. A list is created for each chip which contains one line for each input file in a format required by the flips process which creates the master frame. This file includes the name of the image, the sky level for that image, and the factor for scaling the fringe amplitude.

Create master fringe frame

This is the heart of the fringe master creation. The selected input images are used to create the master fringe frame, called CONFIG.CCD.fr.fits. Each of the images first has the sky subtracted, then the remaining fringe pattern is scaled relative to the image with the largest amplitude fringe pattern. All images are then median-combined. The result image has the sky reset to the sky of the original input image. The fringe amplitude and the sky level are arbitrary numbers.

Apply master to all input images

We calculate residual images by applying the new master fringe frame to each of the input images. The resulting residual images are saved as OBSIDo.def (for defringing). Each of these images should have a minimal remaining fringe pattern.

Measure fringe statistics on all residual images

The standard recipe is used to measure the amplitude of the residual fringe pattern. These values are saved in a text file OBSIDo.def.stats which is used to construct statistics for the web browswer image selection tool.

Create jpegs of the residual images

Just as for the input images, each residual image has a set of greyscale jpeg images constructed which are used in the web tool to show the quality of the defringing or to guide the choice of images for exclusion or inclusion. The only difference it the dynamic range of the fringe frame. In the case of the input images, the full white-to-black range is set of 1% of the sky flux, while for the residuals, the full range is set to 0.2% of the sky flux. These images are called OBSIDo.def.medbin.jpg and OBSIDo.def.tenbin.jpg.

The remaining stages duplicate steps discussed above: measuring the fringe fits from the selected subset, calculating statistics for the collection of input images & residual images, and creating the necessary files needed by the web tool. At this point, the user can again refine the input image selection or choose to accept the master frame. If the image has been accepted, the next stage is to register the image in the database.

Image Registration

Assign Image meta-data

The first step before image registration can take place is to convert the 4x4 binned image into a full 1x1 scale image. This is a convenient time to add a variety of data to the fringe frame headers. This meta-data includes the information about the fringe correlation fit parameters, which is used by the defringing process to avoid re-measuring the fringe amplitude for the master image. In addition, information about the fringe creation process are also added to the header for documentation purposes.

Register image in detrend database

The last step is to add the image to the detrend database. This involves adding a row in the database table for each master CCD, as well as copying the master images themselves to the detrend database directories.