ClimoDataArrayAccessor

class ClimoDataArrayAccessor(data, registry=<climopy.cfvariable.CFVariableRegistry object>)[source]

Bases: climopy.accessor.ClimoAccessor

Accessor for xarray.DataArrays. Includes methods for working with pint quantities and CFVariable variables, several stub functions for integration with free-standing climopy functions (similar to numpy design), and an interface for transforming one physical variable to another. Registered under the name climo (i.e, usage is data_array.climo). The string representation of this accessor displays its cfvariable information (if the data array name is found in the variable_registry).

Parameters
  • data (xarray.DataArray or xarray.Dataset) – The data.

  • registry (cfvariable.CFVariableRegistry) – The variable registry.

Notes

This adds pint.Quantity support for the operations loc, sel, interp, and groupby. Otherwise, weighted and coarsen already work, but resample and rolling are broken and may be quite tricky to fix.

Attributes Summary

cfvariable

Return a CFVariable based on the DataArray name, the scalar coordinates, and the coordinate reductions referenced in cell_methods.

magnitude

The magnitude of the data values of this DataArray (i.e., without units).

quantity

The data values of this DataArray as a pint.Quantity.

units

The units of this DataArray as a pint.Unit, taken from the underlying pint.Quantity or the 'units' attribute.

units_label

The units of this DataArray formatted LaTeX-style.

Methods Summary

__getattr__(attr)

Return a coordinate, attribute, or cfvariable property.

__getitem__(key)

Return a quantified coordinate or a selection along dimensions with translated dictionary indexing.

__setitem__(key, value)

Set values along dimensions with translated dictionary indexing.

absargmax([dim])

Return the coordinates of global maxima along the dimension.

absargmin([dim])

Return the coordinates of global minima along the dimension.

absmax([dim])

Return the global maxima along the dimension.

absmin([dim])

Return the global minima along the dimension.

anomaly(*args, **kwargs)

Anomaly with respect to mass-weighted average.

argloc([dim, value])

Return the coordinate(s) of a given value along the dimension.

argmax([dim])

Return the coordinates of local maxima along the dimension.

argmin([dim])

Return the coordinates of local minima along the dimension.

autocorr(dim, **kwargs)

Return the autocorrelation along the input dimension.

autocovar(dim, **kwargs)

Return the autocovariance along the input dimension.

average([dim])

Return the mass-weighted average.

centroid([dataset])

Return the value-weighted average wavenumber.

convergence(*args, **kwargs)

Return the spherical meridional convergence.

cumanomaly(*args, **kwargs)

Anomaly relative to cumulative mass-weighted average.

cumaverage(dim[, reverse, weight, skipna])

Return the cumulative mass-weighted average.

cumintegral(dim[, skipna])

Return the cumulative mass-weighted integral.

dequantify()

Return a copy of the xarray.DataArray with underlying data stripped of its units and units written to the 'units' attribute.

derivative([indexers, centered])

Take the nth order centered finite difference for the specified dimensions.

divergence([cos_power, centered])

Return the spherical meridional divergence.

hist(dim[, bins])

Return the histogram along the given dimension.

integral([dim])

Return the mass-weighted integral.

mask(mask[, dataset])

Return a copy of the data with a mask applied according to some preset pattern.

max([dim])

Return the local maxima along the dimension.

min([dim])

Return the local mimima along the dimension.

normalize()

Return a copy of the data normalized with respect to time.

quantify()

Return a copy of the xarray.DataArray with underlying data converted to pint.Quantity using the 'units' attribute.

reduce([indexers, dataset, centroid, …])

Reduce the dimension of a xarray.DataArray with arbitrary method(s).

runmean([indexers])

Return the running mean along different dimensions.

slope(dim)

Return the best-fit slope with respect to some dimension.

timescale(dim[, maxlag, imaxlag])

Return a best-fit estimate of the autocorrelation timescale.

to_base_units([coords])

Return a copy with the underlying data converted to base units.

to_compact_units([coords])

Return a copy with the underlying data converted to “compact” units.

to_standard_units([coords])

Return a copy with the underyling data converted to the cfvariable standard_units value.

to_units(units[, context])

Return a copy converted to the desired units.

to_variable(dest[, standardize])

Transform this variable to another variable using two-way transformations registered with register_transformation.