xarray.load_dataarray#
- xarray.load_dataarray(filename_or_obj, **kwargs)[source]#
Open, load into memory, and close a DataArray from a file or file-like object.
The file must contain a single data variable.
This is a thin wrapper around
open_dataarray(). It differs from open_dataarray in that it loads the Dataset into memory, closes the file, and returns the Dataset. In contrast, open_dataarray keeps the file handle open and lazy loads its contents. All parameters are passed directly to open_dataarray. See that documentation for further details.- Returns:
datarray (
DataArray) – The newly created DataArray.
See also
Examples
>>> da = xr.DataArray([1.0, 2.0, 3.0], dims="x", name="a") >>> da.to_netcdf("example.nc")
The data is loaded into memory and the file is closed again:
>>> xr.load_dataarray("example.nc") <xarray.DataArray 'a' (x: 3)> Size: 24B array([1., 2., 3.]) Dimensions without coordinates: x