ClimoAccessor¶
- class ClimoAccessor(data, registry=<climopy.cfvariable.CFVariableRegistry object>)[source]¶
Bases:
object
Accessor with properties and methods shared by
xarray.DataArray
s andxarray.Dataset
s. Registered under the nameclimo
(i.e, usage isdata_array.climo
anddataset.climo
).- Parameters
data (xarray.DataArray or xarray.Dataset) – The data.
registry (cfvariable.CFVariableRegistry) – The variable registry.
Notes
This adds
pint.Quantity
support for the operationsloc
,sel
,interp
, andgroupby
. Otherwise,weighted
andcoarsen
already work, butresample
androlling
are broken and may be quite tricky to fix.Attributes Summary
Wrapper of
CFAccessor
that supports automatic cacheing for speed boosts.Wrapper of
coords
that returns always-quantified coordinate variables or variables transformed from the native coordinates usingClimoDataArrayAccessor.to_variable
(e.g.Redirect to the underlying
xarray.Dataset
orxarray.DataArray
.Call
loc
with support forpint.Quantity
indexers and assignments and coordinate name aliases.The coordinate
DataArray
for the “parameter sweep” axis.The active
CFVariableRegistry
used to look up variables withcfvariable
.Methods Summary
add_cell_measures
([measures, dataset, …])Add cell measures to the
coords
and update thecell_measures
attribute(s).add_scalar_coords
([verbose])Add dummy scalar coordinates for missing longitude, latitude, and vertical dimensions and update the
cell_methods
attribute(s) to indicate the missing coordinates were reduced by averaging.enforce_global
([longitude, latitude, …])Add a circularly overlapping longitude coordinate, latitude coordinates for the north and south poles, and pressure coordinates for the mean sea-level and “zero” pressure levels.
groupby
(group, *args, **kwargs)A unit-friendly
groupby
indexer.interp
([indexers, method, assume_sorted, …])Call
interp
with support for units and indexer aliases.isel
([indexers, drop, drop_cell_measures])Call
isel
with support for units and indexer aliases.mean
([dim, skipna, weight])Return the mean along dimension(s), preserving attributes and coordinates.
replace_coords
([indexers])Return a copy with coordinate values added or replaced (if they already exist).
sel
([indexers, method, tolerance, drop, …])Call
sel
with support for units and indexer aliases.sel_hemisphere
(which[, invert])Select a hemisphere or average of hemispheres.
sel_pair
(key)Return selection from a pseudo “parameter” axis.
sel_time
([date])Return an
DataArray
orDataset
with the time coordinate filtered to times matching some datetime component.standardize_coords
([verbose])Infer and standardize coordinates to satisfy CF conventions with the help of
guess_coord_axis
andcf_xarray.CFAccessor.rename_like
.sum
([dim, skipna, weight])Return the sum along dimension(s), preserving attributes and coordinates.
truncate
([bounds, ignore_extra, dataset])Restrict the coordinate range using
ClimoAccessor.interp
.update_cell_attrs
(other)Update
cell_methods
andcell_measures
attributes from another object onto thexarray.DataArray
or every array in thexarray.Dataset
.update_cell_methods
([methods])Update the
cell_methods
attribute on thexarray.DataArray
or on every array in thexarray.Dataset
with the input methods.