hydromt.Model.read_nc#

Model.read_nc(fn: str | Path, mask_and_scale: bool = False, single_var_as_array: bool = True, load: bool = False, **kwargs) Dict[str, Dataset]#

Read netcdf files at <root>/<fn> and return as dict of xarray.Dataset.

NOTE: Unless single_var_as_array is set to False a single-variable data source will be returned as xarray.DataArray rather than xarray.Dataset. key-word arguments are passed to xarray.open_dataset().

Parameters:
  • fn (str) – filename relative to model root, may contain wildcards

  • mask_and_scale (bool, optional) – If True, replace array values equal to _FillValue with NA and scale values according to the formula original_values * scale_factor + add_offset, where _FillValue, scale_factor and add_offset are taken from variable attributes (if they exist).

  • single_var_as_array (bool, optional) – If True, return a DataArray if the dataset consists of a single variable. If False, always return a Dataset. By default True.

  • load (bool, optional) – If True, the data is loaded into memory. By default False.

  • **kwargs – Additional keyword arguments that are passed to the xr.open_dataset function.

Returns:

dict of xarray.Dataset

Return type:

Dict[str, xr.Dataset]