write

MHS_HDF.write(data, filename, **kwargs)

Save a xarray.Dataset to a NetCDF4 file

Parameters
  • data – A xarray.Dataset object. It may contain ‘pseudo’ groups (i.e. variables with / in their names). Those variables will be saved in subgroups.

  • filename – A string or a FileInfo object with the path where the data should be stored.

Returns

None

Examples

from typhon.files import NetCDF4
import xarray as xr

fh = NetCDF4()
data = xr.Dataset({
    "data/temperature": ("time", [0, 1]),
    "lat": ("time", [0, 1]),
    "lon": ("time", [0, 1]),
}, coords={
    "time": ("time", [0, 1]),
})

# Save the dataset:
fh.write(data, "filename.nc")