hydromt.model.Model#
- class hydromt.model.Model(root: str | None = None, *, components: Dict[str, Any] | None = None, mode: str = 'w', data_libs: List | str | None = None, region_component: str | None = None, **catalog_keys)[source]#
General and basic API for models in HydroMT.
Initialize a model.
- Parameters:
root (
str
, optional) – Model root, by default Nonecomponents (
Dict[str
,Any]
, optional) –Dictionary of components to add to the model, by default None Every entry in this dictionary contains the name of the component as key, and the component object as value, or a dictionary with options passed to the component initializers. If a component is a dictionary, the key ‘type’ should be provided with the name of the component type.
{ "grid": { "type": "GridComponent", "filename": "path/to/grid.nc" } }
mode (
{'r','r+','w'}
, optional) – read/append/write mode, by default “w”data_libs (
List[str]
, optional) – List of data catalog configuration files, by default Noneregion_component (
str
, optional) – The name of the region component in the components dictionary. If None, the model will can automatically determine the region component if there is only one SpatialModelComponent. Otherwise it will raise an error. If there are no SpatialModelComponent it will raise a warning that region functionality will not work.logger – The logger to be used.
**catalog_keys – Additional keyword arguments to be passed down to the DataCatalog.
- __init__(root: str | None = None, *, components: Dict[str, Any] | None = None, mode: str = 'w', data_libs: List | str | None = None, region_component: str | None = None, **catalog_keys)[source]#
Initialize a model.
- Parameters:
root (
str
, optional) – Model root, by default Nonecomponents (
Dict[str
,Any]
, optional) –Dictionary of components to add to the model, by default None Every entry in this dictionary contains the name of the component as key, and the component object as value, or a dictionary with options passed to the component initializers. If a component is a dictionary, the key ‘type’ should be provided with the name of the component type.
{ "grid": { "type": "GridComponent", "filename": "path/to/grid.nc" } }
mode (
{'r','r+','w'}
, optional) – read/append/write mode, by default “w”data_libs (
List[str]
, optional) – List of data catalog configuration files, by default Noneregion_component (
str
, optional) – The name of the region component in the components dictionary. If None, the model will can automatically determine the region component if there is only one SpatialModelComponent. Otherwise it will raise an error. If there are no SpatialModelComponent it will raise a warning that region functionality will not work.logger – The logger to be used.
**catalog_keys – Additional keyword arguments to be passed down to the DataCatalog.
Methods
__init__
([root, components, mode, ...])Initialize a model.
add_component
(name, component)Add a component to the model.
build
(*[, write])Single method to build a model from scratch based on settings in steps.
from_dict
(model_dict)Construct a model with the components and other init arguments in the yaml file located at path.
from_yml
(path)Construct a model with the components and other init arguments in the yaml file located at path.
get_component
(name)Get a component from the model.
read
([components])Read provided components from disk.
test_equal
(other)Test if two models are equal, based on their components.
update
(*[, model_out, write, steps, ...])Single method to update a model based the settings in steps.
write
([components])Write provided components to disk with defaults.
write_data_catalog
([root, data_lib_path, ...])Write the data catalog to data_lib_path.
Attributes
Returns coordinate reference system embedded in region.
name
Return the model's region component.
DataCatalog for data access
Model root