coarsen#
- pypillometry.signal.coarsen(y, n, factor, block=1, min_frac=0.5)[source]#
Coarser block means from block means (see
block_mean()): means of factor consecutive blocks, weighted by their numbers of valid samples.- Parameters:
y (np.ndarray) – block means (NaN where missing) and numbers of valid samples
n (np.ndarray) – block means (NaN where missing) and numbers of valid samples
factor (int) – number of blocks per new block
block (int, optional) – number of raw samples per block of the input (for min_frac); default 1
min_frac (float, optional) – a new block is missing unless at least this fraction of its
factor * blockraw samples is valid (default 0.5)
- Return type:
- Returns:
y, n (np.ndarray) – as for
block_mean(), for blocks offactor * blockraw samples
Examples
>>> y, n = coarsen(np.array([1., 3., np.nan, 4.]), np.array([4, 2, 1, 4]), 2, block=4) >>> y, n (array([1.66666667, 4. ]), array([6, 4]))