mpas_tools.io.open_dataset
- mpas_tools.io.open_dataset(filename, engine=None, logger=None, **kwargs)[source]
Open an
xarray.Datasetfrom a NetCDF file, accounting for quirks specific to MPAS components. This is a thin wrapper aroundxarray.open_dataset()that selects the NetCDFenginefrommpas_tools.io.default_enginewhenengineis not given.Specifying an
engineexplicitly is important becausexarray.open_dataset()otherwise sniffs the file for “magic bits” to auto-select a backend, and that probe can crash onNETCDF3_64BIT_DATA(CDF5) files. Settingmpas_tools.io.default_engine(e.g. to'netcdf4') provides a single, process-wide way to avoid that crash without modifying every call site.- Parameters:
filename (str or path-like or file-like) – The path to the NetCDF file to open, passed on to
xarray.open_dataset()engine ({'netcdf4', 'scipy', 'h5netcdf'}, optional) – The library to use for reading the NetCDF file. The default is
mpas_tools.io.default_engine, which can be modified but which defaults toNone(xarray auto-selects the backend)logger (logging.Logger, optional) – A logger to write messages to. Reserved for future diagnostics; no error recovery is performed because the CDF5 backend-sniffing failure is a hard crash that cannot be caught.
**kwargs – Additional keyword arguments passed on to
xarray.open_dataset()(e.g.decode_times,decode_cf,mask_and_scale)
- Returns:
ds (xarray.Dataset) – The opened dataset