xray.Variable

class xray.Variable(dims, data, attrs=None, encoding=None)

A netcdf-like variable consisting of dimensions, data and attributes which describe a single Array. A single Variable object is not fully described outside the context of its parent Dataset (if you want such a fully described object, use a DataArray instead).

Attributes

T
as_index
attributes
attrs Dictionary of local attributes on this variable.
dimensions
dims Tuple of dimension names with which this variable is associated.
dtype
encoding Dictionary of encodings on this variable.
ndim
shape
size
values The variable’s data as a numpy.ndarray

Methods

all([dim, axis, keep_attrs]) Reduce this Variable’s data by applying numpy.all along some dimension(s).
any([dim, axis, keep_attrs]) Reduce this Variable’s data by applying numpy.any along some dimension(s).
argmax([dim, axis, keep_attrs]) Reduce this Variable’s data by applying numpy.argmax along some dimension(s).
argmin([dim, axis, keep_attrs]) Reduce this Variable’s data by applying numpy.argmin along some dimension(s).
argsort(*args, **kwargs)
astype(*args, **kwargs)
clip(*args, **kwargs)
concat(variables[, dim, indexers, length, ...]) Concatenate variables along a new or existing dimension.
conj(*args, **kwargs)
conjugate(*args, **kwargs)
copy([deep]) Returns a copy of this object.
equals(other) True if two Variables have the same dimensions and values; otherwise False.
get_axis_num(dim) Return axis number(s) corresponding to dimension(s) in this array.
identical(other) Like equals, but also checks attributes.
indexed(*args, **kwargs) Return a new array indexed along the specified dimension(s).
isel(**indexers) Return a new array indexed along the specified dimension(s).
isnull(*args, **kwargs) Detect missing values (NaN in numeric arrays, None/NaN in object arrays)
item(*args, **kwargs)
load_data() Manually trigger loading of this variable’s data from disk or a remote source into memory and return this variable.
max([dim, axis, keep_attrs]) Reduce this Variable’s data by applying numpy.max along some dimension(s).
mean([dim, axis, keep_attrs]) Reduce this Variable’s data by applying numpy.mean along some dimension(s).
min([dim, axis, keep_attrs]) Reduce this Variable’s data by applying numpy.min along some dimension(s).
notnull(*args, **kwargs) Replacement for numpy.isfinite / -numpy.isnan which is suitable for use on object arrays.
prod([dim, axis, keep_attrs]) Reduce this Variable’s data by applying numpy.prod along some dimension(s).
ptp([dim, axis, keep_attrs]) Reduce this Variable’s data by applying numpy.ptp along some dimension(s).
reduce(func[, dim, axis, keep_attrs]) Reduce this array by applying func along some dimension(s).
round(*args, **kwargs)
searchsorted(*args, **kwargs)
squeeze([dim]) Return a new Variable object with squeezed data.
std([dim, axis, keep_attrs]) Reduce this Variable’s data by applying numpy.std along some dimension(s).
sum([dim, axis, keep_attrs]) Reduce this Variable’s data by applying numpy.sum along some dimension(s).
to_coord() Return this variable as an xray.Coordinate
to_index() Convert this variable to a pandas.Index
transpose(*dims) Return a new Variable object with transposed dimensions.
var([dim, axis, keep_attrs]) Reduce this Variable’s data by applying numpy.var along some dimension(s).
__init__(dims, data, attrs=None, encoding=None)
Parameters:

dims : str or sequence of str

Name(s) of the the data dimension(s). Must be either a string (only for 1D data) or a sequence of strings with length equal to the number of dimensions.

data : array_like

Data array which supports numpy-like data access.

attrs : dict_like or None, optional

Attributes to assign to the new variable. If None (default), an empty attribute dictionary is initialized.

encoding : dict_like or None, optional

Dictionary specifying how to encode this array’s data into a serialized format like netCDF4. Currently used keys (for netCDF) include ‘_FillValue’, ‘scale_factor’, ‘add_offset’ and ‘dtype’. Well behaviored code to serialize a Variable should ignore unrecognized encoding items.

Methods

__init__(dims, data[, attrs, encoding])
Parameters:
all([dim, axis, keep_attrs]) Reduce this Variable’s data by applying numpy.all along some dimension(s).
any([dim, axis, keep_attrs]) Reduce this Variable’s data by applying numpy.any along some dimension(s).
argmax([dim, axis, keep_attrs]) Reduce this Variable’s data by applying numpy.argmax along some dimension(s).
argmin([dim, axis, keep_attrs]) Reduce this Variable’s data by applying numpy.argmin along some dimension(s).
argsort(*args, **kwargs)
astype(*args, **kwargs)
clip(*args, **kwargs)
concat(variables[, dim, indexers, length, ...]) Concatenate variables along a new or existing dimension.
conj(*args, **kwargs)
conjugate(*args, **kwargs)
copy([deep]) Returns a copy of this object.
equals(other) True if two Variables have the same dimensions and values; otherwise False.
get_axis_num(dim) Return axis number(s) corresponding to dimension(s) in this array.
identical(other) Like equals, but also checks attributes.
indexed(*args, **kwargs) Return a new array indexed along the specified dimension(s).
isel(**indexers) Return a new array indexed along the specified dimension(s).
isnull(*args, **kwargs) Detect missing values (NaN in numeric arrays, None/NaN in object arrays)
item(*args, **kwargs)
load_data() Manually trigger loading of this variable’s data from disk or a remote source into memory and return this variable.
max([dim, axis, keep_attrs]) Reduce this Variable’s data by applying numpy.max along some dimension(s).
mean([dim, axis, keep_attrs]) Reduce this Variable’s data by applying numpy.mean along some dimension(s).
min([dim, axis, keep_attrs]) Reduce this Variable’s data by applying numpy.min along some dimension(s).
notnull(*args, **kwargs) Replacement for numpy.isfinite / -numpy.isnan which is suitable for use on object arrays.
prod([dim, axis, keep_attrs]) Reduce this Variable’s data by applying numpy.prod along some dimension(s).
ptp([dim, axis, keep_attrs]) Reduce this Variable’s data by applying numpy.ptp along some dimension(s).
reduce(func[, dim, axis, keep_attrs]) Reduce this array by applying func along some dimension(s).
round(*args, **kwargs)
searchsorted(*args, **kwargs)
squeeze([dim]) Return a new Variable object with squeezed data.
std([dim, axis, keep_attrs]) Reduce this Variable’s data by applying numpy.std along some dimension(s).
sum([dim, axis, keep_attrs]) Reduce this Variable’s data by applying numpy.sum along some dimension(s).
to_coord() Return this variable as an xray.Coordinate
to_index() Convert this variable to a pandas.Index
transpose(*dims) Return a new Variable object with transposed dimensions.
var([dim, axis, keep_attrs]) Reduce this Variable’s data by applying numpy.var along some dimension(s).

Attributes

T
as_index
attributes
attrs Dictionary of local attributes on this variable.
dimensions
dims Tuple of dimension names with which this variable is associated.
dtype
encoding Dictionary of encodings on this variable.
ndim
shape
size
values The variable’s data as a numpy.ndarray