aggregate

function of dascore.proc.aggregate source

aggregate(
    patch: Patch ,
    dim: str | collections.abc.Sequence[str, collections.abc.Sequence[str], None] = None,
    method: str | collections.abc.Callable[str, Callable] = mean,
)-> ‘PatchType’

Aggregate values along a specified dimension.

Parameters

Parameter Description
patch The input Patch.
dim The dimension along which aggregations are to be performed.
If None, apply aggregation to all dimensions sequentially.
If a sequence, apply sequentially in order provided.
method The aggregation to apply along dimension. Options are:
mean
median
min
max
sum
std
first
last
Note

Examples

import numpy as np
import dascore as dc
patch = dc.get_example_patch()
# Calculate mean along time axis
patch_time = patch.aggregate("time", method=np.nanmean)
# Calculate median distance along distance dimension
patch_dist = patch.aggregate("distance", method=np.nanmedian)