apply_fluxcal

sofia_redux.calibration.pipecal_util.apply_fluxcal(data, header, config, variance=None, covariance=None, write_history=True)[source]

Apply a flux calibration factor to an image.

The image is calibrated as:

calibrated = flux / cal_factor

If provided, the variance and/or covariance are propagated as well, as:

calibrated_variance = variance / cal_factor^2
calibrated_covariance = covariance / cal_factor^2

The provided header is also updated with calibration keys and, optionally, a history message.

Parameters:
dataarray

Image to calibrate.

headerastropy.io.fits.header.Header

FITS header to update.

configdict-like

Calibration configuration values, as produced by pipecal.pipecal_config.pipecal_config.

variancearray, optional

Variance image to propagate, if desired.

covariancearray, optional

Covariance image to propagate, if desired.

write_historybool, optional

If set, a history message will be added to the header.

Returns:
array, or 2- or 3-length tuple

If only data is provided, it is returned as an array. If variance is provided, the return value is (data, variance). If covariance is provided, the return value is (data, variance, covariance); if the variance was not provided, it will be set to None.