derasterize

sofia_redux.instruments.exes.derasterize.derasterize(data, header, dark_data=None, dark_header=None, overlap=32, fit_buffer=5)[source]

Read and recombine a rasterized flat file.

When background fluxes are high, raster flats are taken in subarray chunks to avoid saturating the detector. These chunks are stored in a custom format in the raw FITS file and need special handling to be reassembled into a full-frame flat for use with the science data.

The procedure is:

  1. Divide the input cube into detector stripes.

  2. Call readraw for each stripe to coadd raw readouts.

  3. Use overlap regions to fit and correct for gain and offset differences between stripes.

  4. Assemble corrected stripes into a full 1024 x 1024 array.

Parameters:
datanumpy.ndarray

3D data cube [nframe, nspec, nspat].

headerfits.Header

Header of FITS file. May be updated in place.

dark_datanumpy.ndarray, optional

3D raw raster dark data [nframe, nspec, nspat]. Must match the input data if provided.

dark_headerfits.Header, optional

Header of dark FITS file.

overlapint, optional

The size of the overlap region in each detector stripe.

Returns:
deraster, variance, mask3-tuple of numpy.ndarray

The derasterized and coadded data, variance, and good data mask. The deraster and variance arrays have shape (nframes, ny, nx). The mask has shape (ny, nx) and Boolean data type, where True indicates a good pixel; False indicates a bad pixel.