coadd

sofia_redux.toolkit.image.coadd.coadd(hdr_list, data_list, var_list, exp_list, method='mean', weighted=True, robust=True, sigma=8.0, maxiters=5, spectral=False, cube=False, wcskey=' ', rotate=True, fit_order=2, window=7.0, smoothing=2.0, adaptive_algorithm=None, edge_threshold=0.7, reference='first')[source]

Coadd total intensity or spectral images.

The WCS is used to transform images into a common coordinate system. By default, the reference field is the WCS for the first data set provided. Optionally, the reference may be corrected for target position motion, as for a non-sidereal target.

For coadd methods ‘mean’ or ‘median’, each image is interpolated into the reference frame, then all images are combined using the chosen statistic. Note that this method may be memory-intensive for large fields. The coadd method ‘resample’ uses locally weighted polynomial surface fits to resample data onto the output grid (see sofia_redux.toolkit.resampling for more information). Exposure maps are always generated by interpolating and summing individual maps.

The output may be either a 2D image, for either spectral or imaging data, or a 3D spectral cube (cube = True). If cube is set, then the method is always ‘resample’.

Parameters:
hdr_listlist of astropy.io.fits.Header

List of headers associated with the data to combine. The first header in the list is used as the reference.

data_listlist of numpy.ndarray of float

List of flux arrays to combine.

var_listlist of numpy.ndarray of float

List of variance arrays associated with flux arrays.

exp_listlist of numpy.ndarray of float

List of exposure time maps associated with the flux arrays.

method{‘mean’, ‘median’, ‘resample’}, optional

Method for combining data into the output map. For ‘mean’ or ‘median’, data is interpolated into the output grid, then combined with the selected statistic. For ‘resample’, data are sampled onto the output grid with locally weighted polynomial fits.

weightedbool, optional

If set, input flux values will be weighted by the variance values, for ‘mean’ or ‘resample’ methosds.

robustbool, optional

If set, input flux values will be sigma-clipped before combining, for ‘mean’ or ‘median’ methods.

sigmafloat, optional

The sigma value to use for clipping if the robust option is set.

maxitersint, optional

Maximum number of sigma-clipping iterations to use if the robust option is set.

spectralbool, optional

If not set, any dimensions higher than 2 in the input WCS will be ignored. This is required for compatibility with old-style FORCAST imaging data (pipeline version < 2.0).

cubebool, optional

If set, spectral data is assembled into a 3D cube (nw, ny, nx) instead of a 2D spectral image (nw, ny).

wcskeystr, optional

Indicates the WCS to use for assembling data. If ‘ ‘, the primary WCS is used. For spectral data, the alternate WCS with key ‘A’ is expected.

rotatebool, optional

If set, data is rotated to set North up and East left, in RA/Dec coordinates. This option is not recommended for 2D spectral images.

fit_orderint, optional

The polynomial fit order to use with the ‘resample’ method.

windowfloat, optional

The local fitting window (in pixels) to use with the ‘resample’ method.

smoothingfloat, optional

The Gaussian smoothing radius (in pixels) to use with the ‘resample’ method.

adaptive_algorithm{‘scaled’, ‘shaped’, None}, optional

Algorithm for adaptive smoothing kernel. If scaled, only the size is allowed to vary. If shaped, the kernel shape and rotation may also vary.

edge_thresholdfloat, optional

Used to determine how much of the image edges should be masked, Specified as a fraction of the fit window; lower values clip more pixels.

reference{‘first’, ‘target’}, optional

If set to ‘target’, the output coordinates for each input file will be corrected for target motion, as recorded in the TGTRA and TGTDEC keywords. This is necessary to correct for the motion of non-sidereal targets. If TGTRA/DEC are not found, no correction will be made.

Returns:
headerastropy.io.fits.Header

The output header with appropriate WCS.

fluxnumpy.ndarray

The output flux image or cube.

variancenumpy.ndarray

The output variance image or cube.

expmapnumpy.ndarray

The exposure map associated with the flux. This array will always be 2D, even for cube outputs.