earth2studio.statistics
.mean#
- class earth2studio.statistics.mean(reduction_dimensions, weights=None, batch_update=False)[source]#
Statistic for calculating the sample mean over a set of given dimensions.
- Parameters:
reduction_dimensions (List[str]) – A list of names corresponding to dimensions to perform the statistical reduction over. Example: [‘lat’, ‘lon’]
weights (torch.Tensor, optional) – A tensor containing weights to assign to the reduction dimensions. Note that these weights must have the same number of dimensions as passed in reduction_dimensions. Example: if reduction_dimensions = [‘lat’, ‘lon’] then assert weights.ndim == 2. By default None.
batch_update (bool, optional) – Whether to applying batch updates to the mean with each invocation of __call__. This is particularly useful when data is recieved in a stream of batches. Each invocation of __call__ will return the running mean. By default False.
- __call__(x, coords)[source]#
Apply the mean operation over the tensor x.
If batch_update was passed True upon metric initialization then this method returns the running sample mean over all seen batches.
- Parameters:
x (torch.Tensor) – Input data to compute sample mean.
coords (CoordSystem) – Coordinates referring to the input data, x.
- Return type:
tuple[Tensor, OrderedDict[str, ndarray]]