import numpy as np
import dascore as dc
= dc.get_example_patch()
patch # Calculate mean along time axis
= patch.aggregate("time", method=np.nanmean)
patch_time # Calculate median distance along distance dimension
= patch.aggregate("distance", method=np.nanmedian) patch_dist
aggregate
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
The old dimension is kept but its coordiante values are removed. use
Patch.squeeze
to remove them orPatch.update_coords
to set a coordinate value.See also the aggregation shortcut methods in the aggregate module.