ewatercycle.base.parameter_set
Parameter set module for eWaterCycle.
Module Contents
- ewatercycle.base.parameter_set.logger
- ewatercycle.base.parameter_set.download_github_repo(org: str, repo: str, branch: str, download_dir: pathlib.Path, subfolder: str | None = None) None
Download a Github repository .zip file, and extract (a subfolder) to a directory.
- Parameters:
org – Github organization (e.g., “eWaterCycle”)
repo – Repository name (e.g, “ewatercycle”)
branch – Branch name (e.g., “main”)
download_dir – Path towards the directory where the data should be downloaded to.
subfolder – Optional subfolder within the github repo to extract. For example “src/ewatercycle/base”. If not set then downloads the entire repository.
- Raises:
ConnectionError – If the HTTP return code is not 200.
- class ewatercycle.base.parameter_set.GitHubDownloader
Bases:
pydantic.BaseModel
Download and extract a Github repository.
Examples
See https://github.com/ec-jrc/lisflood-usecases/tree/master/LF_lat_lon_UseCase
- class ewatercycle.base.parameter_set.ZenodoDownloader
Bases:
pydantic.BaseModel
Download and extract a Zenodo archive.
- Parameters:
doi – DOI of Zenodo record. For example ‘10.5281/zenodo.1045339’.
- class ewatercycle.base.parameter_set.ArchiveDownloader
Bases:
pydantic.BaseModel
Download and unpack a parameter set from an archive file.
- url: pydantic.HttpUrl
- class ewatercycle.base.parameter_set.ParameterSet
Bases:
pydantic.BaseModel
Container object for parameter set options.
Is directory containing data that does not change over time. Should be passed to a models constructor like
eWaterCycleModel
.Example
>>> from ewatercycle.base import ParameterSet >>> parameter_set = ParameterSet(name='test', >>> directory='test_dir', >>> config='test_dir/config.yaml') >>> from ewatercycle.models import Wflow >>> model = Wflow(parameter_set=parameter_set)
- directory: pathlib.Path
Location on disk where files of parameter set are stored.
If Path is relative then relative to CFG.parameterset_dir.
- config: pathlib.Path
Model configuration file which uses files from
directory
.If Path is relative then relative to
directory
.
- supported_model_versions: set[str]
Set of model versions that are compatible with this parameter set.
If not set then parameter set compability check silently passes.
- downloader: GitHubDownloader | ZenodoDownloader | ArchiveDownloader | None = None
Method to download parameter set from somewhere.
- model_config
- download(download_dir: pathlib.Path, force: bool = False) None
Download parameter set to directory.
- Parameters:
download_dir – Directory where parameter set should be downloaded to.
force – If True then download even if directory already exists.
- Raises:
ValueError – If no downloader is defined.
- classmethod from_github(org: str, repo: str, branch: str, subfolder: str | None = None, **kwargs)
Create a parameter set from a GitHub repository.
- Parameters:
org – GitHub organization (e.g., ‘UU-Hydro’)
repo – Repository name (e.g, ‘PCR-GLOBWB_input_example’)
branch – Branch name (e.g., ‘master’)
subfolder – Subfolder within the github repo to extract. E.g. ‘pcrglobwb_rhinemeuse_30min’. If not given then downloads the entire repository.
**kwargs – See
ParameterSet
for other arguments.
The example Github arguments would download all files from https://github.com/UU-Hydro/PCR-GLOBWB_input_example/tree/master/RhineMeuse30min
- classmethod from_zenodo(doi: str, **kwargs) ParameterSet
Download a parameter set from Zenodo.
- Parameters:
doi – DOI of Zenodo record. E.g. ‘10.5281/zenodo.1045339’.
**kwargs – See
ParameterSet
for other arguments.
- classmethod from_archive_url(url: str, **kwargs) ParameterSet
Download a parameter set from an archive file on the Internet.
- Parameters:
url – Link to archive file.
**kwargs – See
ParameterSet
for other arguments.
Example
>>> from ewatercycle.base import ParameterSet >>> url = '' >>> parameter_set = ParameterSet.from_archive_url(url)
- make_absolute(parameterset_dir: pathlib.Path) ParameterSet
Make self.directory and self.config absolute paths.
- Parameters:
parameterset_dir – Directory to which relative paths should be made absolute.
- Returns:
self