Flat

Flat field frames give information on the response of the detector, allowing to measure variations in efficiency at small (pixel-to-pixel), intermediate (fringing) and large (the blaze function) scale. Whereas in the optical regime the flats are usually twilight or dome flats, in the NIR regime the flats sometimes consist of a pair of illuminated (denoted as ON-Flats) and not-illuminated (OFF-Flats) frames.

This section presents algorithms to combine single flatfields into a master flatfield with increased SNR.

In PyHDRL this is hdrl.func.Flat.

Modes

hdrl.func.Flat.Mode.FreqLow

Derives the low frequency part of the master flatfield — often also denoted as the shape of the flatfield.

The algorithm multiplicatively normalizes the input images by the median (considered to be noiseless) of the image to unity. An optional static mask stat_mask can be provided in order to define the pixels that should be taken into account when computing the normalisation factor. This allows the user to normalize the flatfield e.g. only by the illuminated section. In the next step, all normalized images are collapsed into a single master flatfield. Finally, the master flatfield is smoothed by a median filter controlled by filter_size_x and filter_size_y. The associated error of the final master frame is the error derived via error propagation of the previous steps, i.e. the smoothing itself is considered noiseless. If the smoothing kernel is set to unity, i.e. filter_size_x = 1 and filter_size_y = 1, no final smoothing will take place but the resulting masterframe is simply the collapsed normalized flatfield.

hdrl.func.Flat.Mode.FreqHigh

Derives the high frequency part of the master flatfield — often also denoted as the pixel-to-pixel variation of the flatfield.

The algorithm first divides each input image by the smooth image obtained with a median filter (controlled by filter_size_x and filter_size_y). Concerning the error propagation, the smoothed image is considered to be noiseless, i.e. the relative error associated to the normalised images is the same as the one of the input images. Then all residual images are collapsed into a single master flatfield.

To distinguish between illuminated and not illuminated regions/pixels (i.e. orders in an echelle flat image), the user may provide an optional static mask stat_mask. In this case the smoothing procedure is done twice, once for the illuminated region and once for the blanked region.

The collapsing can be done with all methods currently implemented in hdrl.func.Collapse.

Compute

Instantiate hdrl.func.Flat with the smoothing kernel sizes and the mode, then call compute() with an hdrl.core.ImageList, a hdrl.func.Collapse instance, and an optional cpl.core.Mask. If no static mask is needed, pass None.

compute() returns a namedtuple FlatResult with:

  • master: master flat image (hdrl.core.Image)

  • contrib_map: contribution map (cpl.core.Image)

Example

collapse = hdrl.func.Collapse.Mean()
stat_mask = None
flat = hdrl.func.Flat(filter_size_x, filter_size_y, hdrl.func.Flat.Mode.FreqLow)
results = flat.compute(imglist, collapse, stat_mask)
mflat = results.master
cmap = results.contrib_map