xarray.Dataset.pr.to_netcdf

Dataset.pr.to_netcdf(path: Path | str, mode: str = 'w', group: str | None = None, encoding: Mapping | None = None) bytes | None

Write dataset contents to a netCDF file.

Parameters:
pathstr or Path

File path to which to save this dataset.

mode{“w”, “a”}, default: “w”

Write (‘w’) or append (‘a’) mode. If mode=’w’, any existing file at this location will be overwritten. If mode=’a’, existing variables will be overwritten.

groupstr, optional

Path to the netCDF4 group in the given file to open. The group(s) will be created if necessary.

encodingdict, optional

Nested dictionary with variable names as keys and dictionaries of variable specific encodings as values, e.g., {"my_variable": {"dtype": "int16", "scale_factor": 0.1, "zlib": True}, ...}

This supports both the NetCDF4-style compression encoding parameters {"zlib": True, "complevel": 9} and the h5py ones {"compression": "gzip", "compression_opts": 9}. This allows using any compression plugin installed in the HDF5 library, e.g. LZF.