medcomb

sofia_redux.toolkit.stats.stats.medcomb(data, variance=None, mask=None, mad=False, axis=None, ignorenans=True, robust=0, returned=True, info=None)[source]

Combines a data set using median

Combines the data together using a median. An estimate of the error is given by computing the Median Absolute Deviation (MAD), where MAD = 1.482 * median(abs(x_i - x_med)), and then med_var = MAD^2 / N.

Parameters:
dataarray_like (shape)
maskarray_like (shape), optional

An optional mask of the same shape as data identifying pixels to use in the combination (True=good, False=bad).

variancearray_like (shape), optional

The variances of the data points with the same shape as data. If given a weighted median is performed.

madbool, optional

If True, the Median Absolute Deviation (MAD^2) is returned instead of MAD^2 / N.

axisint, optional

Specifies on which axis the mean operation should be performed.

ignorenansbool, optional

If True, NaNs will be ignored in all calculations.

robustfloat, optional

Set to the sigma threshold to throw bad data out. A data point is identified as an outlier if abs(x_i - x_med)/MAD > thresh where x_med is the median and MAD is the median absolute deviation defined as 1.482*median(abs(x_i - x_med)). Set to a non-integer/non-float or 0 to skip outlier rejection.

returnedbool, optional

Flag indicating whether a tuple (mean, meanvar) should be returned as output (True), or just the mean (False). Default is True.

infodict, optional
If supplied will be updated with:

‘mask’ -> output mask as modified by mask, NaNs, and robust

Returns:
median, [variance]float or numpy.ndarray

The median array and the optional variance array (MAD^2 / N) if returned=True.