src/pys5p/biweight.py
def __biweight_axis(data, axis, spread=False):
    """
    Calculate biweight parameters, along a given axis

    Notes
    -----
    Data should not contain any invalid value
    """
    # calculate median and median absolute difference
    if np.isnan(data).any():
        all_nan = np.isnan(data).all(axis=axis)
        biweight_median = np.nanmedian(data, axis=axis, keepdims=True)
        delta = data - biweight_median
        delta_median = np.nanmedian(np.abs(delta), axis=axis, keepdims=True)
        _mm = delta_median != 0.
        delta_median[~_mm] = np.nan
        _mm = np.squeeze(_mm) & ~all_nan
    else:
        biweight_median = np.median(data, axis=axis, keepdims=True)
        delta = data - biweight_median
        delta_median = np.median(np.abs(delta), axis=axis, keepdims=True)
        _mm = delta_median != 0.
        delta_median[~_mm] = np.nan
        _mm = np.squeeze(_mm)
    biweight_median = np.squeeze(biweight_median)

    # calculate biweight median
    wmx = np.clip(1 - (delta / (6 * delta_median)) ** 2, 0, None) ** 2
    biweight_median[_mm] += \
        np.nansum(wmx * delta, axis=axis)[_mm] / np.nansum(wmx, axis=axis)[_mm]
    del wmx
    gc.collect()
    if not spread:
        return biweight_median

    # calculate biweight variance
    umn = np.clip((delta / (9 * delta_median)) ** 2, None, 1)
    del delta_median
    biweight_var = np.nansum(delta ** 2 * (1 - umn) ** 4, axis=axis)
    del delta
    gc.collect()
    biweight_var[_mm] /= \
        np.nansum((1 - umn) * (1 - 5 * umn), axis=axis)[_mm] ** 2
    biweight_var[_mm] *= np.sum(np.isfinite(data), axis=axis)[_mm]

    return (biweight_median, np.sqrt(biweight_var))

    Calculate biweight parameters, along a given axis

    Notes
    -----
    Data should not contain any invalid value
    
Calculate biweight parameters, along a given axis
Notes

Data should not contain any invalid value
Calculate biweight parameters along a given axis Notes Data should not contain any invalid value
def __biweight_axis(data, axis, spread=False):
    if np.isnan(data).any():
        all_nan = np.isnan(data).all(axis=axis)
        biweight_median = np.nanmedian(data, axis=axis, keepdims=True)
        delta = data - biweight_median
        delta_median = np.nanmedian(np.abs(delta), axis=axis, keepdims=True)
        _mm = delta_median != 0.
        delta_median[~_mm] = np.nan
        _mm = np.squeeze(_mm) & ~all_nan
    else:
        biweight_median = np.median(data, axis=axis, keepdims=True)
        delta = data - biweight_median
        delta_median = np.median(np.abs(delta), axis=axis, keepdims=True)
        _mm = delta_median != 0.
        delta_median[~_mm] = np.nan
        _mm = np.squeeze(_mm)
    biweight_median = np.squeeze(biweight_median)
    wmx = np.clip(1 - (delta / (6 * delta_median)) ** 2, 0, None) ** 2
    biweight_median[_mm] += \
        np.nansum(wmx * delta, axis=axis)[_mm] / np.nansum(wmx, axis=axis)[_mm]
    del wmx
    gc.collect()
    if not spread:
        return biweight_median
    umn = np.clip((delta / (9 * delta_median)) ** 2, None, 1)
    del delta_median
    biweight_var = np.nansum(delta ** 2 * (1 - umn) ** 4, axis=axis)
    del delta
    gc.collect()
    biweight_var[_mm] /= \
        np.nansum((1 - umn) * (1 - 5 * umn), axis=axis)[_mm] ** 2
    biweight_var[_mm] *= np.sum(np.isfinite(data), axis=axis)[_mm]
    return (biweight_median, np.sqrt(biweight_var))
def __biweight_axis ( data , axis , spread = False ) : if np . isnan ( data ) . any ( ) : all_nan = np . isnan ( data ) . all ( axis = axis ) biweight_median = np . nanmedian ( data , axis = axis , keepdims = True ) delta = data - biweight_median delta_median = np . nanmedian ( np . abs ( delta ) , axis = axis , keepdims = True ) _mm = delta_median != 0. delta_median [ ~ _mm ] = np . nan _mm = np . squeeze ( _mm ) & ~ all_nan else : biweight_median = np . median ( data , axis = axis , keepdims = True ) delta = data - biweight_median delta_median = np . median ( np . abs ( delta ) , axis = axis , keepdims = True ) _mm = delta_median != 0. delta_median [ ~ _mm ] = np . nan _mm = np . squeeze ( _mm ) biweight_median = np . squeeze ( biweight_median ) wmx = np . clip ( 1 - ( delta / ( 6 * delta_median ) ) ** 2 , 0 , None ) ** 2 biweight_median [ _mm ] += np . nansum ( wmx * delta , axis = axis ) [ _mm ] / np . nansum ( wmx , axis = axis ) [ _mm ] del wmx gc . collect ( ) if not spread : return biweight_median umn = np . clip ( ( delta / ( 9 * delta_median ) ) ** 2 , None , 1 ) del delta_median biweight_var = np . nansum ( delta ** 2 * ( 1 - umn ) ** 4 , axis = axis ) del delta gc . collect ( ) biweight_var [ _mm ] /= np . nansum ( ( 1 - umn ) * ( 1 - 5 * umn ) , axis = axis ) [ _mm ] ** 2 biweight_var [ _mm ] *= np . sum ( np . isfinite ( data ) , axis = axis ) [ _mm ] return ( biweight_median , np . sqrt ( biweight_var ) )
Calculate biweight parameters, along a given axis
Notes
Calculate biweight parameters along a given axis Notes
"""
    Calculate biweight parameters, along a given axis

    Notes
    -----
    Data should not contain any invalid value
    """ # calculate median and median absolute difference # calculate biweight median # calculate biweight variance
data
axis
spread