nctoolkit.open_data

nctoolkit.open_data(x=[], checks=True, \*\*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.

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

  • **kwargs (kwargs) – Optional arguments for internal use by open_thredds and open_url.

Returns

open_data

Return type

nctoolkit.DataSet

Examples

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

>>> import nctoolkit as nc
>>> ds = 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
>>> ds = 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
>>> ds = nc.open_data("data/*.nc")