ClimoAccessor

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

Bases: object

Accessor with properties and methods shared by xarray.DataArrays and xarray.Datasets. Registered under the name climo (i.e, usage is data_array.climo and dataset.climo).

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

cf

Wrapper of CFAccessor that supports automatic cacheing for speed boosts.

coords

Wrapper of coords that returns always-quantified coordinate variables or variables transformed from the native coordinates using ClimoDataArrayAccessor.to_variable (e.g.

data

Redirect to the underlying xarray.Dataset or xarray.DataArray.

loc

Call loc with support for pint.Quantity indexers and assignments and coordinate name aliases.

parameter

The coordinate DataArray for the “parameter sweep” axis.

variable_registry

The active CFVariableRegistry used to look up variables with cfvariable.

Methods Summary

add_cell_measures([measures, dataset, …])

Add cell measures to the coords and update the cell_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 or Dataset 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 and cf_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 and cell_measures attributes from another object onto the xarray.DataArray or every array in the xarray.Dataset.

update_cell_methods([methods])

Update the cell_methods attribute on the xarray.DataArray or on every array in the xarray.Dataset with the input methods.