mpas_tools.io.write_netcdf

mpas_tools.io.write_netcdf(ds, fileName, fillValues=None, format=None, engine=None, char_dim_name=None)[source]

Write an xarray.Dataset to a file with NetCDF4 fill values and the given name of the string dimension. Also adds the time and command-line to the history attribute.

Parameters:
  • ds (xarray.Dataset) – The dataset to save

  • fileName (str) – The path for the NetCDF file to write

  • fillValues (dict, optional) – A dictionary of fill values for different NetCDF types. Default is mpas_tools.io.default_fills, which can be modified but which defaults to netCDF4.default_fillvals

  • format ({'NETCDF4', 'NETCDF4_CLASSIC', 'NETCDF3_64BIT',) – ‘NETCDF3_CLASSIC’}, optional The NetCDF file format to use. Default is mpas_tools.io.default_format, which can be modified but which defaults to 'NETCDF3_64BIT'

  • engine ({'netcdf4', 'scipy', 'h5netcdf'}, optional) – The library to use for NetCDF output. The default is the same as in xarray.Dataset.to_netcdf() and depends on format. You can override the default by setting mpas_tools.io.default_engine

  • char_dim_name (str, optional) – The name of the dimension used for character strings, or None to let xarray figure this out. Default is mpas_tools.io.default_char_dim_name, which can be modified but which defaults to ``’StrLen’`