xray.open_dataset(filename_or_obj, group=None, decode_cf=True, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, engine=None, chunks=None)

Load and decode a dataset from a file or file-like object.


filename_or_obj : str, file or xray.backends.*DataStore

Strings are interpreted as a path to a netCDF file or an OpenDAP URL and opened with python-netCDF4, unless the filename ends with .gz, in which case the file is gunzipped and opened with scipy.io.netcdf (only netCDF3 supported). File-like objects are opened with scipy.io.netcdf (only netCDF3 supported).

group : str, optional

Path to the netCDF4 group in the given file to open (only works for netCDF4 files).

decode_cf : bool, optional

Whether to decode these variables, assuming they were saved according to CF conventions.

mask_and_scale : bool, optional

If True, replace array values equal to _FillValue with NA and scale values according to the formula original_values * scale_factor + add_offset, where _FillValue, scale_factor and add_offset are taken from variable attributes (if they exist).

decode_times : bool, optional

If True, decode times encoded in the standard NetCDF datetime format into datetime objects. Otherwise, leave them encoded as numbers.

concat_characters : bool, optional

If True, concatenate along the last dimension of character arrays to form string arrays. Dimensions will only be concatenated over (and removed) if they have no corresponding variable and if they are only used as the last dimension of character arrays.

decode_coords : bool, optional

If True, decode the ‘coordinates’ attribute to identify coordinates in the resulting dataset.

engine : {‘netcdf4’, ‘scipy’, ‘pydap’, ‘h5netcdf’}, optional

Engine to use when reading netCDF files. If not provided, the default engine is chosen based on available dependencies, with a preference for ‘netcdf4’.

chunks : dict, optional

If chunks is provided, it used to load the new dataset into dask arrays. This is an experimental feature; see the documentation for more details.


dataset : Dataset

The newly created dataset.