xdas.DataArray#
- class xdas.DataArray(data=None, coords=None, dims=None, name=None, attrs=None)[source]#
N-dimensional array with labeled coordinates and dimensions.
It is the equivalent of an xarray.DataArray but with custom coordinate objects. Most of the DataArray API follows the DataArray one. DataArray objects also provide virtual dataset capabilities to manipulate huge multi-file NETCDF4 or HDF5 datasets.
- Parameters:
data (array_like) – Values of the array. Can be a VirtualSource or a VirtualLayout for lazy loading of netCDF4/HDF5 files.
coords (dict of Coordinate) – Coordinates to use for indexing along each dimension.
dims (sequence of string, optional) – Name(s) of the data dimension(s). If provided, must be equal to the keys of coords.
name (str, optional) – Name of this array.
attrs (dict_like, optional) – Attributes to assign to the new instance.
- Raises:
ValueError – If dims do not match the keys of coords.
Methods
__init__([data, coords, dims, name, attrs])assign_coords([coords])Assign new coordinates to this object.
conj()Return the complex conjugate, element-wise.
Return the complex conjugate, element-wise (alias of
conj()).copy([deep, data])Return a copy of this array.
drop_coords(*names)Return a new
DataArraywith the named coordinates removed.drop_dims(*dims)Return a new
DataArraywith dims and their coordinates removed.equals(other)Return
Trueif other has equal data, coordinates, dims, name, and attrs.expand_dims(dim[, axis])Add an additional dimension at a given axis position.
from_dict(dct)Create a DataArray from a dictionary.
from_netcdf(fname[, group])Lazily read a data array from a NetCDF file.
from_stream(st[, dims])Convert an obspy stream into a data array.
from_xarray(da)Build a
DataArrayfrom anxarray.DataArrayda.get_axis_num(dim)Return axis number corresponding to dimension in this array.
isel([indexers, drop])Return a new DataArray selecting indexes along the specified dimension(s).
load()Load the data into memory and return a new
DataArraybacked by a numpy array.plot(*args, **kwargs)Plot a DataArray.
rename([new_name_or_name_dict])Return a new DataArray with renamed coordinates, dimensions or a new name.
sel([indexers, method, endpoint, drop])Return a new DataArray selecting index labels along the specified dimension(s).
swap_dims([dims_dict])Return a new DataArray with swapped dimensions.
to_dict()Convert the DataArray to a dictionary.
to_netcdf(fname[, mode, group, virtual, ...])Write DataArray contents to a netCDF file.
to_stream([network, station, location, ...])Convert a data array into an obspy stream.
Convert to the xarray implementation of the DataArray structure.
transpose(*dims)Return a new DataArray object with transposed dimensions.
Attributes
Transposed array with dimension order reversed.
The
Coordinatescontainer for this array.The underlying array (numpy, dask, or
VirtualArray).Tuple of dimension names in axis order.
NumPy dtype of the underlying data array.
Trueif any dimension has size zero.Label-based indexer; supports
da.loc[label]andda.loc[label] = value.Total byte size of the underlying data.
Number of dimensions.
Shape tuple of the underlying data array.
Total number of elements.
Dict-like mapping from dimension name to its size.
Materialised numpy array of all values.