meancomb¶
- sofia_redux.toolkit.stats.stats.meancomb(data, variance=None, mask=None, rms=False, axis=None, ignorenans=True, robust=0, returned=True, info=None)[source]¶
(Robustly) averages arrays along arbitrary axes.
This routine will combine data using either a straight mean or weighted mean. If datavar are not given, then a straight mean, <x>, and square of the standard error of the mean, sigma_mu^2 = sigma^2/N are computed. If datavar are given, then a weighted mean and corresponding variance on the mean are computed.
- Parameters:
- dataarray_like of (int or float)
(shape1) input data array
- maskarray_like of bool, optional
(shape1) An optional mask of the same shape as data identifying pixels to use in the combination (True=good, False=bad).
- variancearray_like of float, optional
(shape1) The variances of the data points with the same shape as data. If given a weighted median is performed.
- rmsbool, optional
Set to return the RMS error instead of the error on the mean.
- 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:
- mean, [variance_of_mean](tuple of) float or numpy.ndarray
The mean along the specified axis. When returned is
True
, return a tuple with the average as the first element and the variance of the mean as the second element. The return typenumpy.float64
. If returned,variance_of_mean
isnumpy.float64
. If keepdims then