ewatercycle.base.parameter_set ============================== .. py:module:: ewatercycle.base.parameter_set .. autoapi-nested-parse:: Parameter set module for eWaterCycle. Module Contents --------------- .. py:data:: logger .. py:function:: 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. :param org: Github organization (e.g., "eWaterCycle") :param repo: Repository name (e.g, "ewatercycle") :param branch: Branch name (e.g., "main") :param download_dir: Path towards the directory where the data should be downloaded to. :param 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. .. py:class:: GitHubDownloader Bases: :py:obj:`pydantic.BaseModel` Download and extract a Github repository. .. rubric:: Examples See https://github.com/ec-jrc/lisflood-usecases/tree/master/LF_lat_lon_UseCase .. py:attribute:: org :type: str Github organization (e.g., 'eWaterCycle') .. py:attribute:: repo :type: str Repository name (e.g, 'ewatercycle') .. py:attribute:: branch :type: str Branch name (e.g., 'main') .. py:attribute:: subfolder :type: str | None :value: None Subfolder within the github repo to extract. E.g. 'src/ewatercycle/base'. .. py:class:: ZenodoDownloader Bases: :py:obj:`pydantic.BaseModel` Download and extract a Zenodo archive. :param doi: DOI of Zenodo record. For example '10.5281/zenodo.1045339'. .. py:attribute:: doi :type: str .. py:class:: ArchiveDownloader Bases: :py:obj:`pydantic.BaseModel` Download and unpack a parameter set from an archive file. .. py:attribute:: url :type: pydantic.HttpUrl .. py:class:: ParameterSet Bases: :py:obj:`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 :py:class:`~ewatercycle.base.model.eWaterCycleModel`. .. rubric:: 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) .. py:attribute:: name :type: str :value: '' Name of parameter set .. py:attribute:: directory :type: pathlib.Path Location on disk where files of parameter set are stored. If Path is relative then relative to CFG.parameterset_dir. .. py:attribute:: config :type: pathlib.Path Model configuration file which uses files from :py:attr:`~directory`. If Path is relative then relative to :py:attr:`~directory`. .. py:attribute:: doi :type: str :value: 'N/A' Persistent identifier of parameter set. For a example a DOI for a Zenodo record. .. py:attribute:: target_model :type: str :value: 'generic' Name of model that parameter set can work with. .. py:attribute:: supported_model_versions :type: set[str] Set of model versions that are compatible with this parameter set. If not set then parameter set compability check silently passes. .. py:attribute:: downloader :type: GitHubDownloader | ZenodoDownloader | ArchiveDownloader | None :value: None Method to download parameter set from somewhere. .. py:attribute:: model_config .. py:method:: download(download_dir: pathlib.Path, force: bool = False) -> None Download parameter set to directory. :param download_dir: Directory where parameter set should be downloaded to. :param force: If True then download even if directory already exists. :raises ValueError: If no downloader is defined. .. py:method:: from_github(org: str, repo: str, branch: str, subfolder: str | None = None, **kwargs) :classmethod: Create a parameter set from a GitHub repository. :param org: GitHub organization (e.g., 'UU-Hydro') :param repo: Repository name (e.g, 'PCR-GLOBWB_input_example') :param branch: Branch name (e.g., 'master') :param subfolder: Subfolder within the github repo to extract. E.g. 'pcrglobwb_rhinemeuse_30min'. If not given then downloads the entire repository. :param \*\*kwargs: See :py:class:`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 .. py:method:: from_zenodo(doi: str, **kwargs) -> ParameterSet :classmethod: Download a parameter set from Zenodo. :param doi: DOI of Zenodo record. E.g. '10.5281/zenodo.1045339'. :param \*\*kwargs: See :py:class:`ParameterSet` for other arguments. .. py:method:: from_archive_url(url: str, **kwargs) -> ParameterSet :classmethod: Download a parameter set from an archive file on the Internet. :param url: Link to archive file. :param \*\*kwargs: See :py:class:`ParameterSet` for other arguments. .. rubric:: Example >>> from ewatercycle.base import ParameterSet >>> url = '' >>> parameter_set = ParameterSet.from_archive_url(url) .. py:method:: make_absolute(parameterset_dir: pathlib.Path) -> ParameterSet Make self.directory and self.config absolute paths. :param parameterset_dir: Directory to which relative paths should be made absolute. :returns: self