diff_arr

sofia_redux.instruments.exes.diff_arr.diff_arr(data, header, abeams, bbeams, variance, mask=None, dark=None, black_dark=False)[source]

Subtract sky frames, nod pairs, or a dark frame.

If header[‘INSTMODE’] is ‘MAP’, then the B beams are assumed to be sky frames. They are averaged, and the resulting frame is subtracted from each designated A frame. Otherwise, B beams are subtracted pair-wise from neighboring A beams.

The output array has a number of frames equal to the number of input A nods. If an input bad pixel mask is provided, pixels are marked bad in the output mask if there were any bad pixels at that location in the subtracted frames, i.e. the input A and B masks are or-combined.

If a dark frame is provided and black_dark is True, then the dark is subtracted from identified B nods instead of performing A-B subtraction. This is intended to provide clean sky frames for calibration purposes. In this case, the output data has a number of frames equal to the number of input B nods.

Parameters:
datanumpy.ndarray

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

headerfits.Header

Header of FITS file.

abeamsarray-like of int

Index numbers of A frames in data cube.

bbeamsarray-like of int

Index numbers of B frames in data cube.

variancenumpy.ndarray

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

masknumpy.ndarray, optional

Bad pixel array [nspec, nspat] indicating valid data (True=good, False=bad).

darknumpy.ndarray, optional

If provided, and black_dark is True, this array is subtracted from the B nods instead of performing nod-subtraction.

black_darkbool, optional

If True, the dark array is subtracted instead of performing nod subtraction.

Returns:
diff_data, diff_var, diff_mask3-tuple of numpy.ndarray

The differenced data, associated variance, and propagated bad pixel mask. All have dimensions [ndiff, nspec, nspat]. In the mask, True=good, False=bad.