make_template

sofia_redux.instruments.exes.make_template.make_template(data, header, weighting_frame, weights=None, illum=None, good_frames=None, collapsed=False)[source]

Make a spectral template for weighting and shifting spectra.

Good frames are weighted by 1/weighting_frame^2 and averaged together, then the resulting frame is averaged in the spectral direction, and replicated over the spectral elements. The result is an average spatial profile that can be cross-correlated with individual 2D spectral frames, to determine spatial shifts or coadd weighting.

Parameters:
datanumpy.ndarray

3D data cube [nframe, ny, nx]. Input data is assumed to be distortion corrected and rotated as needed to align the spectral direction along the x-axis.

headerHeader

FITS header associated with the data.

weighting_framenumpy.ndarray

Weighting frame (eg. flat or uncertainty image). May be a single 2D frame [ny, nx] to apply to all frames or a 3D cube [nframe, ny, nx].

weightsnumpy.ndarray

1D array [nframe] of weights to use for input frames. If weight=0, frame will be skipped.

illumnumpy.ndarray

2D array [ny, nx] indicates illuminated regions of the frame. 1 = illuminated, 0 = unilluminated, -1 = pixel that does not correspond to any region in the raw frame (before undistortion).

good_framesnumpy.ndarray, optional

1D array of indices of good frames. If provided, any frame not in good_frames will be skipped.

collapsedbool, optional

If set, the average template collapsed along the spectral dimension will be returned instead of the full 2D array.

Returns:
templatenumpy.ndarray

2D spatial template [ny, nx], or 1D [ny] if collapsed is set.