1 Model
Model()A model of inland water resources systems.
1.1 Attributes
| Name | Description |
|---|---|
| allocation | |
| basin | |
| continuous_control | |
| crs | |
| discrete_control | |
| endtime | |
| experimental | |
| filepath | |
| flow_boundary | |
| flow_demand | |
| input_dir | |
| interpolation | |
| junction | |
| level_boundary | |
| level_demand | |
| linear_resistance | |
| link | |
| logging | |
| manning_resistance | |
| model_config | |
| outlet | |
| pid_control | |
| pump | |
| results | |
| results_dir | |
| results_path | Get the path to the results directory if it exists. |
| ribasim_version | |
| solver | |
| starttime | |
| tabulated_rating_curve | |
| terminal | |
| toml_path | Get the path to the TOML file if it exists. |
| use_validation | |
| user_demand |
1.2 Methods
| Name | Description |
|---|---|
| diff | Compare two instances of a BaseModel. |
| model_dump | |
| model_post_init | |
| node_table | Compute the full sorted NodeTable from all node types. |
| plot | Plot the nodes, links and allocation networks of the model. |
| plot_control_listen | Plot the implicit listen links of the model. |
| read | Read a model from a TOML file. |
| set_crs | Set the coordinate reference system of the data in the model. |
| set_filepath | Set the filepath of this instance. |
| to_crs | |
| to_fews | Write the model network and results into files used by Delft-FEWS. |
| to_xugrid | Convert the network to a xugrid.UgridDataset. |
| write | Write the contents of the model to disk and save it as a TOML configuration file. |
1.2.1 diff
Model.diff(other, ignore_meta=False)Compare two instances of a BaseModel.
** Warning: This method is experimental and is likely to change. **
If they are equal, return None. Otherwise, return a nested dictionary with the differences. When the differences are not a DataFrame (like the toml config), the dict has self and other as key. For DataFrames we return a dict with diff as key, and a datacompy Comparison object.
When ignore_meta is set to True, the meta_* columns in the DataFrames are ignored. Note that in that case the key will still be returned and the value will be None.
1.2.1.1 Examples
>>> nbasic == basic
False
>>> x = nbasic.diff(basic)
{'basin': {'node': {'diff': <datacompy.core.Compare object at 0x16e5a45c0>},
'static': {'diff': <datacompy.core.Compare object at 0x16eb90080>}},
'solver': {'saveat': {'other': 86400.0, 'self': 0.0}}}
>>> x["basin"]["static"]["diff"].report()
DataComPy Comparison
--------------------
...1.2.2 model_dump
Model.model_dump(**kwargs)1.2.3 model_post_init
Model.model_post_init(__context)1.2.4 node_table
Model.node_table()Compute the full sorted NodeTable from all node types.
1.2.5 plot
Model.plot(ax=None, indicate_subnetworks=True, aspect_ratio_bound=0.33)Plot the nodes, links and allocation networks of the model.
1.2.5.1 Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| ax | matplotlib.pyplot.Artist | Axes on which to draw the plot. | None |
| indicate_subnetworks | bool | Whether to indicate subnetworks with a convex hull backdrop. | True |
| aspect_ratio_bound | float | The maximal aspect ratio in (0,1). The smaller this number, the further the figure shape is allowed to be from a square | 0.33 |
1.2.5.2 Returns
| Name | Type | Description |
|---|---|---|
| ax | matplotlib.pyplot.Artist | Axis on which the plot is drawn. |
1.2.6 plot_control_listen
Model.plot_control_listen(ax)Plot the implicit listen links of the model.
1.2.7 read
Model.read(filepath)Read a model from a TOML file.
1.2.7.1 Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| filepath | str | PathLike[str] | The path to the TOML file. | required |
1.2.8 set_crs
Model.set_crs(crs)Set the coordinate reference system of the data in the model.
1.2.8.1 Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| crs | str | Coordinate reference system, like “EPSG:4326” for WGS84 latitude longitude. | required |
1.2.9 set_filepath
Model.set_filepath(filepath)Set the filepath of this instance.
Args: filepath (Path): The filepath to set.
1.2.10 to_crs
Model.to_crs(crs)1.2.11 to_fews
Model.to_fews(region_home, add_network=True, add_results=True)Write the model network and results into files used by Delft-FEWS.
** Warning: This method is experimental and is likely to change. **
To run this method, the model needs to be written to disk, and have results. The Node, Link and Basin / area tables are written to shapefiles in the REGION_HOME/Config directory. The results are written to NetCDF files in the REGION_HOME/Modules directory. The netCDF files are NetCDF4 with CF-conventions.
1.2.11.1 Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| region_home | str | PathLike[str] | Path to the Delft-FEWS REGION_HOME directory. | required |
| add_network | bool | Write shapefiles representing the network, enabled by default. | True |
| add_results | bool | Write the results to NetCDF files, enabled by default. | True |
1.2.12 to_xugrid
Model.to_xugrid(add_flow=False, add_allocation=False)Convert the network to a xugrid.UgridDataset.
Either the flow or the allocation data can be added, but not both simultaneously. This method will throw ImportError if the optional dependency xugrid isn’t installed.
1.2.12.1 Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| add_flow | bool | add flow results (Optional, defaults to False) | False |
| add_allocation | bool | add allocation results (Optional, defaults to False) | False |
1.2.13 write
Model.write(filepath)Write the contents of the model to disk and save it as a TOML configuration file.
If filepath.parent does not exist, it is created before writing.
1.2.13.1 Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| filepath | str | PathLike[str] | A file path with .toml extension. | required |