nctoolkit.open_data

nctoolkit.open_data(x=[], suppress_messages=False, checks=False, \*\*kwargs)

Read netcdf data as a DataSet object

Parameters
  • x (str or list) – A string or list of netcdf files or a single url. The function will check the files exist. If x is not a list, but an iterable it will be converted to a list. If a *.nc style wildcard is supplied, open_data will use all files available. By default an empty dataset is created, ie. using open_data() will create an empty dataset that can then be expanded using append.

  • thredds (boolean) – Are you accessing a thredds server? Must end with .nc.

  • checks (boolean) – Do you want basic checks to ensure cdo can read files?

Examples

If you want to open a single file as a dataset, do the following:

>>> import nctoolkit as nc
>>> data = nc.open_data("example.nc")

If you want to open a list of files as a multi-file dataset, you would do something like this:

>>> import nctoolkit as nc
>>> data = nc.open_data(["file1.nc", "file2.nc", "file3.nc"])

If you wanted to open all files in a directory “data” as a multi-file dataset, you can use a wildcard:

>>> import nctoolkit as nc
>>> data = nc.open_data("data/*.nc")