nctoolkit.DataSet.to_nc

Contents

nctoolkit.DataSet.to_nc#

DataSet.to_nc(out, zip=True, overwrite=False, **kwargs)#

to_nc: Save a dataset to a named file.

This will only work with single file datasets.

Parameters:
  • out (str) – Output file name.

  • zip (boolean) – True/False depending on whether you want to zip the file. Default is True.

  • overwrite (boolean) – If out file exists, do you want to overwrite it? Default is False.

  • **kwargs (kwargs) – Optional arguments to be sent to subset.

Examples

If you want to export a dataset to a netCDF file, do the following:

>>> ds.to_nc("out.nc")

By default this file will be zipped. If you do not want it zipped, do this:

>>> ds.to_nc("out.nc", zip = False)

By default this cannot overwrite files. If the output file exists, do the following:

>>> ds.to_nc("out.nc", overwrite = True)

If you only want to export a subset of the data, you can use optional arguments that will be sent to subset. For example, if you only wanted the year 2000, you would do this:

>>> ds.to_nc("out.nc", year = 2000)