ClimoDataArrayAccessor.reduce¶
- ClimoDataArrayAccessor.reduce(indexers=None, dataset=None, centroid=False, weight=None, mask=None, **kwargs)[source]¶
Reduce the dimension of a
xarray.DataArray
with arbitrary method(s).- Parameters
indexers (dict, optional) – A dict with keys matching dimensions and values representing the “reduction modes” for the dimensions. Values can be any of the following:
Reduction mode
Description
array-like
The value(s) at this location using
self.interp
.param-spec
Parameter name passed to
self.get
, e.g.'trop'
.'int'
Integral along the dimension.
'avg'
Weighted mean along the dimension.
'anom'
Weighted anomaly along the dimension.
'lcumint'
Cumulative integral from the left.
'rcumint'
Cumulative integral from the right.
'lcumavg'
Cumulative average from the left.
'rcumavg'
Cumulative average from the right.
'lcumanom'
Anomaly w.r.t. cumulative average from the left.
'rcumanom'
Anomaly w.r.t. cumulative average from the right.
'mean'
Simple arithmetic mean.
'sum'
Simple arithmetic sum.
'min'
Local minima along the dimension.
'max'
Local maxima along the dimension.
'argmin'
Location(s) of local minima along the dimension.
'argmax'
Location(s) of local maxima along the dimension.
'argzero'
Location(s) of zeros along the dimension.
'absmin'
Global minimum along the dimension.
'absmax'
Global maximum along the dimension.
'absargmin'
Location of global minimum along the dimension.
'absargmax'
Location of global maximum along the dimension.
'timescale'
For time dimension only. The e-folding timescale.
'autocorr'
For time dimension only. The autocorrelation.
'hist'
For time dimension only. The histogram.
dataset (
xarray.Dataset
, optional) – The associated dataset. This is needed for 2D reduction of isentropic data, and may also be needed for 2D reduction of horizontal data with 2D latitude/longitude coords in the future.centroid (bool, optional) – Get the value-weighted average wavenumber using
centroid
. Units are distance.weight (str or
xarray.DataArray
, optional) – Additional weighting parameter name orxarray.DataArray
, used for averages and integrations. Mass weighting is applied automatically.mask ({None, ‘land’, ‘sea’, ‘trop’, ‘pv’}, optional) – The 2-dimensional mask to apply before taking the weighted average. Presets will be added to this.
**indexers_kwargs – The keyword arguments form of
indexers
. One ofindexers
orindexers_kwargs
must be provided.**truncate_kwargs – Dimension names with the suffix
_min
,_max
, or_lim
used to constrain the range within which the above reduction methods are executed. For exampledata.reduce(lev='mean', lev_min=500 * ureg.hPa)
takes the average in the bottom half of the atmosphere. Bounds do not have to have units attached. Bounds can also take on the value of aparam
variable, e.g.lev_max='tropopause'
. Multiple-valuedmin
ormax
bounds will be reduced for each bounds selection, then the resulting reduction will be concatenated along atrack
dimension.**kwargs – Remaining keyword arguments are passed to relevant functions like
find
andrednoisefit
.
- Returns
xarray.DataArray – The data with relevant dimension(s) reduced.