xray.Dataset¶
- class xray.Dataset(variables=None, coords=None, attrs=None)¶
A netcdf-like data object consisting of variables and attributes which together form a self describing dataset.
Dataset implements the mapping interface with keys given by variable names and values given by DataArray objects for each variable name.
One dimensional variables with name equal to their dimension are coordinates, which means they are saved in the dataset as Coordinate objects.
Attributes
attributes attrs Dictionary of global attributes on this dataset coordinates coords Dictionary of xray.Coordinate objects used for label based indexing. dimensions dims Mapping from dimension names to lengths. indexes noncoordinates Dictionary of DataArrays whose names do not match dimensions. noncoords Dictionary of DataArrays whose names do not match dimensions. variables Dictionary of Variable objects contained in this dataset. virtual_variables A frozenset of variable names that don’t exist in this dataset but for which could be created on demand. Methods
all([dim, keep_attrs]) Reduce this Dataset’s data by applying numpy.all along some dimension(s). any([dim, keep_attrs]) Reduce this Dataset’s data by applying numpy.any along some dimension(s). apply(func[, keep_attrs]) Apply a function over noncoordinate variables in this dataset. argmax([dim, keep_attrs]) Reduce this Dataset’s data by applying numpy.argmax along some dimension(s). argmin([dim, keep_attrs]) Reduce this Dataset’s data by applying numpy.argmin along some dimension(s). close() Close any datastores linked to this dataset concat(datasets[, dim, indexers, mode, ...]) Concatenate datasets along a new or existing dimension. copy([deep]) Returns a copy of this dataset. drop_vars(*names) Returns a new dataset without the named variables. dump(filepath, **kwdargs) Dump dataset contents to a location on disk using the netCDF4 package. dump_to_store(store) Store dataset contents to a backends.*DataStore object. dumps(**kwargs) Serialize dataset contents to a string. equals(other) Two Datasets are equal if they have the same variables and all variables are equal. from_dataframe(dataframe) Convert a pandas.DataFrame into an xray.Dataset get((k[,d]) -> D[k] if k in D, ...) groupby(group[, squeeze]) Group this dataset by unique values of the indicated group. identical(other) Two Datasets are identical if they have the same variables and all variables are identical (with the same attributes), and they also have the same global attributes. indexed(*args, **kwargs) Return a new dataset with each array indexed along the specified dimension(s). isel(**indexers) Return a new dataset with each array indexed along the specified dimension(s). items(() -> list of D’s (key, value) pairs, ...) iteritems(() -> an iterator over the (key, ...) iterkeys(() -> an iterator over the keys of D) itervalues(...) keys(() -> list of D’s keys) labeled(*args, **kwargs) Return a new dataset with each variable indexed by tick labels along the specified dimension(s). load_data() Manually trigger loading of this dataset’s data from disk or a remote source into memory and return this dataset. load_store(store[, decode_cf, ...]) Create a new dataset from the contents of a backends.*DataStore max([dim, keep_attrs]) Reduce this Dataset’s data by applying numpy.max along some dimension(s). mean([dim, keep_attrs]) Reduce this Dataset’s data by applying numpy.mean along some dimension(s). merge(other[, inplace, overwrite_vars, compat]) Merge the variables of two datasets into a single new dataset. min([dim, keep_attrs]) Reduce this Dataset’s data by applying numpy.min along some dimension(s). prod([dim, keep_attrs]) Reduce this Dataset’s data by applying numpy.prod along some dimension(s). ptp([dim, keep_attrs]) Reduce this Dataset’s data by applying numpy.ptp along some dimension(s). reduce(func[, dim, keep_attrs]) Reduce this dataset by applying func along some dimension(s). reindex([copy]) Conform this object onto a new set of coordinates, filling in missing values with NaN. reindex_like(other[, copy]) Conform this object onto the coordinates of another object, filling in missing values with NaN. rename(name_dict[, inplace]) Returns a new object with renamed variables and dimensions. sel(**indexers) Return a new dataset with each variable indexed by tick labels along the specified dimension(s). select(*args, **kwargs) Returns a new dataset that contains only the named variables and their coordinates. select_vars(*names) Returns a new dataset that contains only the named variables and their coordinates. squeeze([dim]) Return a new dataset with squeezed data. std([dim, keep_attrs]) Reduce this Dataset’s data by applying numpy.std along some dimension(s). sum([dim, keep_attrs]) Reduce this Dataset’s data by applying numpy.sum along some dimension(s). to_dataframe() Convert this dataset into a pandas.DataFrame. to_netcdf(filepath, **kwdargs) Dump dataset contents to a location on disk using the netCDF4 package. unselect(*args, **kwargs) Returns a new dataset without the named variables. update(other[, inplace]) Update this dataset’s variables and attributes with those from another dataset. values(() -> list of D’s values) var([dim, keep_attrs]) Reduce this Dataset’s data by applying numpy.var along some dimension(s). - __init__(variables=None, coords=None, attrs=None)¶
To load data from a file or file-like object, use the open_dataset function.
Parameters: variables : dict-like, optional
coords : dict-like, optional
Do not use: not yet implemented!
attrs : dict-like, optional
Global attributes to save on this dataset.
.. warning:: For now, if you wish to specify ``attrs``, you *must* use
a keyword argument: ``xray.Dataset(variables, attrs=attrs)``. The
``coords`` argument is reserved for specifying coordinates
independently of other variables for use in a future version of xray.
For now, coordinates will extracted automatically from variables.
Methods
__init__([variables, coords, attrs]) To load data from a file or file-like object, use the open_dataset function. all([dim, keep_attrs]) Reduce this Dataset’s data by applying numpy.all along some dimension(s). any([dim, keep_attrs]) Reduce this Dataset’s data by applying numpy.any along some dimension(s). apply(func[, keep_attrs]) Apply a function over noncoordinate variables in this dataset. argmax([dim, keep_attrs]) Reduce this Dataset’s data by applying numpy.argmax along some dimension(s). argmin([dim, keep_attrs]) Reduce this Dataset’s data by applying numpy.argmin along some dimension(s). close() Close any datastores linked to this dataset concat(datasets[, dim, indexers, mode, ...]) Concatenate datasets along a new or existing dimension. copy([deep]) Returns a copy of this dataset. drop_vars(*names) Returns a new dataset without the named variables. dump(filepath, **kwdargs) Dump dataset contents to a location on disk using the netCDF4 package. dump_to_store(store) Store dataset contents to a backends.*DataStore object. dumps(**kwargs) Serialize dataset contents to a string. equals(other) Two Datasets are equal if they have the same variables and all variables are equal. from_dataframe(dataframe) Convert a pandas.DataFrame into an xray.Dataset get((k[,d]) -> D[k] if k in D, ...) groupby(group[, squeeze]) Group this dataset by unique values of the indicated group. identical(other) Two Datasets are identical if they have the same variables and all variables are identical (with the same attributes), and they also have the same global attributes. indexed(*args, **kwargs) Return a new dataset with each array indexed along the specified dimension(s). isel(**indexers) Return a new dataset with each array indexed along the specified dimension(s). items(() -> list of D’s (key, value) pairs, ...) iteritems(() -> an iterator over the (key, ...) iterkeys(() -> an iterator over the keys of D) itervalues(...) keys(() -> list of D’s keys) labeled(*args, **kwargs) Return a new dataset with each variable indexed by tick labels along the specified dimension(s). load_data() Manually trigger loading of this dataset’s data from disk or a remote source into memory and return this dataset. load_store(store[, decode_cf, ...]) Create a new dataset from the contents of a backends.*DataStore max([dim, keep_attrs]) Reduce this Dataset’s data by applying numpy.max along some dimension(s). mean([dim, keep_attrs]) Reduce this Dataset’s data by applying numpy.mean along some dimension(s). merge(other[, inplace, overwrite_vars, compat]) Merge the variables of two datasets into a single new dataset. min([dim, keep_attrs]) Reduce this Dataset’s data by applying numpy.min along some dimension(s). prod([dim, keep_attrs]) Reduce this Dataset’s data by applying numpy.prod along some dimension(s). ptp([dim, keep_attrs]) Reduce this Dataset’s data by applying numpy.ptp along some dimension(s). reduce(func[, dim, keep_attrs]) Reduce this dataset by applying func along some dimension(s). reindex([copy]) Conform this object onto a new set of coordinates, filling in missing values with NaN. reindex_like(other[, copy]) Conform this object onto the coordinates of another object, filling in missing values with NaN. rename(name_dict[, inplace]) Returns a new object with renamed variables and dimensions. sel(**indexers) Return a new dataset with each variable indexed by tick labels along the specified dimension(s). select(*args, **kwargs) Returns a new dataset that contains only the named variables and their coordinates. select_vars(*names) Returns a new dataset that contains only the named variables and their coordinates. squeeze([dim]) Return a new dataset with squeezed data. std([dim, keep_attrs]) Reduce this Dataset’s data by applying numpy.std along some dimension(s). sum([dim, keep_attrs]) Reduce this Dataset’s data by applying numpy.sum along some dimension(s). to_dataframe() Convert this dataset into a pandas.DataFrame. to_netcdf(filepath, **kwdargs) Dump dataset contents to a location on disk using the netCDF4 package. unselect(*args, **kwargs) Returns a new dataset without the named variables. update(other[, inplace]) Update this dataset’s variables and attributes with those from another dataset. values(() -> list of D’s values) var([dim, keep_attrs]) Reduce this Dataset’s data by applying numpy.var along some dimension(s). Attributes
attributes attrs Dictionary of global attributes on this dataset coordinates coords Dictionary of xray.Coordinate objects used for label based indexing. dimensions dims Mapping from dimension names to lengths. indexes noncoordinates Dictionary of DataArrays whose names do not match dimensions. noncoords Dictionary of DataArrays whose names do not match dimensions. variables Dictionary of Variable objects contained in this dataset. virtual_variables A frozenset of variable names that don’t exist in this dataset but for which could be created on demand.