HOW-TO View processing results as a mosaic (MEF file)

It is sometimes useful to look at the results of a processing step not chip-by-chip, but at all chips simultaneously. One such processing result could be the overall illumination correction in FITS-format (see the figure below).

Illumination correction for the R filter

The eight illumination correction frames derived for the R filter (#844) of the Wide-Field Imager combined into one multi-extension FITS file.

To facilitate this, a little tool has been created that can merge the separate results for every chip back into a Multi-Extension FITS (MEF) file [1]. This tool can be found in version control under $AWEPIPE/astro/util/Image.py. Given below is an example of how to merge the BiasFrames for a given day back into an MEF file using this tool:

Example 1.
    awe> from astro.main.BiasFrame import BiasFrame
    awe> from astro.util.Image import Image
    awe> biases = []
    awe> for i in range(8):
    ...   bias = BiasFrame.select(instrument='WFI', date='2000-04-28', chip='ccd5%s' % i)
    ...   bias.retrieve()
    ...   biases.append(bias)
    awe> len(biases)
    8
    awe> MEF = Image('output_MEF.fits')
    awe> MEF.frames = biases
    awe> MEF.make()

The frames used MUST first exist on disk in your local directory (cf. retrieve() method) and be a consistent set for the instrument (e.g., one frame for each of the 8 chips of the WFI instrument). The output MEF with the name “output_MEF.fits” can then be viewed in eg. skycat. Note that the possibility of viewing a complete MEF file depends on the viewer you use. Be aware, that for instruments with larges numbers of chips, the memory requirements are correspondingly larger. For OmegaCAM, a 32 CCD instrument, the output file will be greater than 1GB on disk.

In the next example, extended syntax is shown in addition to optimal command-lines for different viewers. In this case, if frames are used, they will be retrieved by default unless the retrieve option is explicitly set to False.

Example 2.
    awe> # normally imported automatically
    awe> from astro.util.Image import Image
    awe>
    awe> # using instantiated frames
    awe> img = Image('output.fits', frames=list_of_frames)
    awe> # img.frames can also be set directly
    awe>
    awe> # using filenames
    awe> img = Image('output.fits', filenames=list_of_filenames)
    awe> # img.filenames can also be set directly
    awe>
    awe> img.make()

    awe> # view with skycat allowing greater zoom range
    awe> os.system('skycat -min_scale -20 output.fits')
    awe> # you must select "Display as one Image"
    awe>
    awe> # view with ds9 in mosaic image mode
    awe> os.system('ds9 -mosaicimage wcs output.fits')
    awe> # you can select Zoom -> Zoom to Fit Frame and
    awe> # Scale -> Scope -> Global to scale like skycat

All the descriptions above assume a non-RawFrame type is used. If a RawFrame type is used (i.e., with trim regions still intact), the frame_type option MUST be set to ‘raw’ for a proper chip-to-chip alignment. Using RawFrame types is generally not done as the RawFitsData is already available as a multi-extension FITS image.

[1]The RawFrames were made from a MEF associated with their RawFitsData object.