landlab.io.netcdf.load

from_netcdf(filename_or_obj, include='*', exclude=None)[source]

Create a ModelGrid from a netcdf file.

Create a new ModelGrid from the netcdf file, nc_file. If the netcdf file also contains data, add that data to the grid’s fields. To create a new grid without any associated data from the netcdf file, use include=None.

Parameters:
  • filename_or_obj (str, Path, or file) – Strings and Path objects are interpreted as a path to a netCDF file or an OpenDAP URL and opened with python-netCDF4, unless the filename ends with .gz, in which case the file is gunzipped and opened with scipy.io.netcdf (only netCDF3 supported). Byte-strings or file-like objects are opened by scipy.io.netcdf (netCDF3) or h5py (netCDF4/HDF).

  • include (str or iterable of str, optional) – A list of unix-style glob patterns of field names to include. Fully qualified field names that match any of these patterns will be written to the output file. A fully qualified field name is one that that has a prefix that indicates what grid element is defined on (e.g. “at_node:topographic__elevation”). The default is to include all fields.

  • exclude (str or iterable of str, optional) – Like the include keyword but, instead, fields matching these patterns will be excluded from the output file.

Returns:

A newly-created ModelGrid.

Return type:

ModelGrid