MCPcopy
hub / github.com/pydata/xarray / open_dataarray

Function open_dataarray

xarray/backends/api.py:631–859  ·  view source on GitHub ↗

Open a DataArray from a file or file-like object containing a single data variable. This is designed to read netCDF files with only one data variable. If multiple variables are present then a ValueError is raised. Parameters ---------- filename_or_obj : str, Path, file-like

(
    filename_or_obj: T_PathFileOrDataStore,
    *,
    engine: T_Engine = None,
    chunks: T_Chunks = None,
    cache: bool | None = None,
    decode_cf: bool | None = None,
    mask_and_scale: bool | None = None,
    decode_times: (
        bool | CFDatetimeCoder | Mapping[str, bool | CFDatetimeCoder] | None
    ) = None,
    decode_timedelta: bool | CFTimedeltaCoder | None = None,
    use_cftime: bool | None = None,
    concat_characters: bool | None = None,
    decode_coords: Literal["coordinates", "all"] | bool | None = None,
    drop_variables: str | Iterable[str] | None = None,
    create_default_indexes: bool = True,
    inline_array: bool = False,
    chunked_array_type: str | None = None,
    from_array_kwargs: dict[str, Any] | None = None,
    backend_kwargs: dict[str, Any] | None = None,
    **kwargs,
)

Source from the content-addressed store, hash-verified

629
630
631def open_dataarray(
632 filename_or_obj: T_PathFileOrDataStore,
633 *,
634 engine: T_Engine = None,
635 chunks: T_Chunks = None,
636 cache: bool | None = None,
637 decode_cf: bool | None = None,
638 mask_and_scale: bool | None = None,
639 decode_times: (
640 bool | CFDatetimeCoder | Mapping[str, bool | CFDatetimeCoder] | None
641 ) = None,
642 decode_timedelta: bool | CFTimedeltaCoder | None = None,
643 use_cftime: bool | None = None,
644 concat_characters: bool | None = None,
645 decode_coords: Literal["coordinates", "all"] | bool | None = None,
646 drop_variables: str | Iterable[str] | None = None,
647 create_default_indexes: bool = True,
648 inline_array: bool = False,
649 chunked_array_type: str | None = None,
650 from_array_kwargs: dict[str, Any] | None = None,
651 backend_kwargs: dict[str, Any] | None = None,
652 **kwargs,
653) -> DataArray:
654 """Open a DataArray from a file or file-like object containing a single
655 data variable.
656
657 This is designed to read netCDF files with only one data variable. If
658 multiple variables are present then a ValueError is raised.
659
660 Parameters
661 ----------
662 filename_or_obj : str, Path, file-like, bytes, memoryview or DataStore
663 Strings and Path objects are interpreted as a path to a netCDF file
664 or an OpenDAP URL and opened with python-netCDF4, unless the filename
665 ends with .gz, in which case the file is gunzipped and opened with
666 scipy.io.netcdf (only netCDF3 supported). Bytes, memoryview and
667 file-like objects are opened by scipy.io.netcdf (netCDF3) or h5netcdf
668 (netCDF4).
669 engine : {"netcdf4", "scipy", "pydap", "h5netcdf", "zarr", None}\
670 , installed backend \
671 or subclass of xarray.backends.BackendEntrypoint, optional
672 Engine to use when reading files. If not provided, the default engine
673 is chosen based on available dependencies, by default preferring
674 "netcdf4" over "h5netcdf" over "scipy" (customizable via
675 ``netcdf_engine_order`` in ``xarray.set_options()``). A custom backend
676 class (a subclass of ``BackendEntrypoint``) can also be used.
677 chunks : int, dict, 'auto' or None, default: None
678 If provided, used to load the data into dask arrays.
679
680 - ``chunks='auto'`` will use dask ``auto`` chunking taking into account the
681 engine preferred chunks.
682 - ``chunks=None`` skips using dask. This uses xarray's internally private
683 :ref:`lazy indexing classes <internal design.lazy indexing>`,
684 but data is eagerly loaded into memory as numpy arrays when accessed.
685 This can be more efficient for smaller arrays, though results may vary.
686 - ``chunks=-1`` loads the data with dask using a single chunk for all arrays.
687 - ``chunks={}`` loads the data with dask using engine preferred chunks if
688 exposed by the backend, otherwise with a single chunk for all arrays.

Calls 3

open_datasetFunction · 0.70
valuesMethod · 0.45
set_closeMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…