Aggregation

class weatherbenchX.aggregation.AggregationState(sum_weighted_statistics: Any, sum_weights: Any)[source]

An object that contains a sum of weighted statistics and a sum of weights.

Allows for aggregation over multiple chunks before computing a final weighted mean.

sum_weighted_statistics

Structure containing summed/aggregated statistics, as a DataArray or nested dictionary of DataArrays, or None.

Type:

Any

sum_weights

Similar structure containing the corresponding summed weights.

Type:

Any

class weatherbenchX.aggregation.Aggregator(reduce_dims: Collection[str], bin_by: Sequence[Binning] | None = None, weigh_by: Sequence[Weighting] | None = None, masked: bool = False, skipna: bool = False)[source]

Defines aggregation over set of dataset dimensions.

Note on NaNs: By default, all reductions are performed with skipna=False, meaning that the aggregated statistics will be NaN if any of the input statistics are NaN. Currently, there is one awkward use case, where even if the input NaNs are outside the binning mask, e.g. if NaNs appear in a different region from the binning region, the aggregated statistics will still be NaN. Use the masking option to avoid this.

reduce_dims

Dimensions to average over. Any variables that don’t have these dimensions will be filtered out during aggregation.

Type:

Collection[str]

bin_by

List of binning instances. All bins will be multiplied.

Type:

Sequence[weatherbenchX.binning.Binning] | None

weigh_by

List of weighting instance. All weights will be multiplied.

Type:

Sequence[weatherbenchX.weighting.Weighting] | None

masked

If True, aggregation will only be performed for non-masked (True on the mask) values. This requires a ‘mask’ coordinate on the statistics passed to aggregate_statistics.

Type:

bool

skipna

If True, NaNs will be omitted in the aggregation. This option is not recommended, as it won’t catch unexpected NaNs.

Type:

bool