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.

__init__(data=None, coords=None, dims=None, name=None, attrs=None)[source]#

Methods

__init__([data, coords, dims, name, attrs])

assign_coords([coords])

Assign new coordinates to this object.

conj()

Return the complex conjugate, element-wise.

conjugate()

Return the complex conjugate, element-wise (alias of conj()).

copy([deep, data])

Return a copy of this array.

drop_coords(*names)

Return a new DataArray with the named coordinates removed.

drop_dims(*dims)

Return a new DataArray with dims and their coordinates removed.

equals(other)

Return True if 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 DataArray from an xarray.DataArray da.

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 DataArray backed 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.

to_xarray()

Convert to the xarray implementation of the DataArray structure.

transpose(*dims)

Return a new DataArray object with transposed dimensions.

Attributes

T

Transposed array with dimension order reversed.

coords

The Coordinates container for this array.

data

The underlying array (numpy, dask, or VirtualArray).

dims

Tuple of dimension names in axis order.

dtype

NumPy dtype of the underlying data array.

empty

True if any dimension has size zero.

loc

Label-based indexer; supports da.loc[label] and da.loc[label] = value.

nbytes

Total byte size of the underlying data.

ndim

Number of dimensions.

shape

Shape tuple of the underlying data array.

size

Total number of elements.

sizes

Dict-like mapping from dimension name to its size.

values

Materialised numpy array of all values.