geost.read_model_from_opendap#

geost.read_model_from_opendap(url: str, data_vars: str | list[str] | None = None, bbox: tuple[float, float, float, float] | None = None, load: bool = False, **xr_kwargs) → Dataset | DataArray[source]#

Read NetCDF data from an OpenDAP server of a voxelmodel or layermodel data into an xarray Dataset or DataArray. Note that this function is a wrapper around the geost.read_model_netcdf() function and uses it to read the data.

Parameters:
  • url (str) – URL to the OpenDAP NetCDF file of the voxelmodel or layermodel.

  • data_vars (str | list[str] | None, optional) – List of data variable names or a single data variable name specifying which data variables to return. If None, all data variables are returned.

  • bbox (tuple[float, float, float, float] | None, optional) – Specify a bounding box (xmin, ymin, xmax, ymax) to return a selected area. The default is None. If bbox is None and the dataset is large, it is recommended to use lazy loading (load=False) and specify chunks (see examples below) to avoid memory issues.

  • load (bool, optional) – If True, the netcdf file is loaded into memory immediately. This will improve the speed of several analyses but will cause higher memory usage or memory error if the dataset is too large. Use False for lazy loading, which allows to process data that does not fit into memory. The default is False. Note that if load=True is used and chunks are specified in xr_kwargs, the chunks will be ignored and the entire dataset will be loaded into memory as Numpy Arrays.

  • **xr_kwargs – Additional keyword arguments xarray.open_dataset. See relevant documentation for details.

Returns:

xarray Dataset instance of the netcdf file or DataArray if a single variable is selected.

Return type:

xr.Dataset | xr.DataArray

Examples

Read all model data from an OpenDAP server in chunks:

>>> import geost
>>> model = geost.read_model_from_opendap(
...     "https://opendap.example.org/data/model.nc",
...     chunks={"x": 100, "y": 100, "z": -1}, # -1 takes the entire "z" dimension in a chunk
... )