Hide code cell content
# Suppress distracting outputs in these examples
# Note: this cell should be hidden with the tag "hide-cell"
import logging
import warnings

warnings.filterwarnings("ignore", category=UserWarning)
logger = logging.getLogger("esmvalcore")
logger.setLevel(logging.WARNING)

Parameter sets

Parameter sets are an essential part of many hydrological models, and for the eWaterCycle package as well.

import ewatercycle.parameter_sets

The default system setup includes a number of example parameter sets that can be used directly. System administrators can also add available parameter sets that are globally availble to all users. In the future, we’re hoping to add functionality to fetch new parameter sets using a DOI as well.

To see the available parameter sets:

sets = ewatercycle.parameter_sets.available_parameter_sets()
print(sets)
{
    'pcrglobwb_rhinemeuse_30min': ParameterSet(
        name='pcrglobwb_rhinemeuse_30min',
        directory=PosixPath('/home/bart/ewatercycle/parameter-sets/pcrglobwb_rhinemeuse_30min'),
        config=PosixPath('/home/bart/ewatercycle/parameter-sets/pcrglobwb_rhinemeuse_30min/ini_and_batch_files/delt
ares_laptop/setup_natural_test.ini'),
        doi='https://doi.org/10.5281/zenodo.1045339',
        target_model='pcrglobwb',
        supported_model_versions={'setters'},
        downloader=GitHubDownloader(
            org='UU-Hydro',
            repo='PCR-GLOBWB_input_example',
            branch='master',
            subfolder='RhineMeuse30min'
        )
    ),
    'wflow_rhine_sbm_nc': ParameterSet(
        name='wflow_rhine_sbm_nc',
        directory=PosixPath('/home/bart/ewatercycle/parameter-sets/wflow_rhine_sbm_nc'),
        config=PosixPath('/home/bart/ewatercycle/parameter-sets/wflow_rhine_sbm_nc/wflow_sbm_NC.ini'),
        doi='N/A',
        target_model='wflow',
        supported_model_versions={'2020.1.2', '2020.1.3', '2020.1.1'},
        downloader=GitHubDownloader(
            org='openstreams',
            repo='wflow',
            branch='master',
            subfolder='examples/wflow_rhine_sbm_nc'
        )
    )
}

Since most parameter sets are model specific, you can filter the results as well:

sets = ewatercycle.parameter_sets.available_parameter_sets(target_model="wflow")
print(sets)
{
    'wflow_rhine_sbm_nc': ParameterSet(
        name='wflow_rhine_sbm_nc',
        directory=PosixPath('/home/bart/ewatercycle/parameter-sets/wflow_rhine_sbm_nc'),
        config=PosixPath('/home/bart/ewatercycle/parameter-sets/wflow_rhine_sbm_nc/wflow_sbm_NC.ini'),
        doi='N/A',
        target_model='wflow',
        supported_model_versions={'2020.1.2', '2020.1.3', '2020.1.1'},
        downloader=GitHubDownloader(
            org='openstreams',
            repo='wflow',
            branch='master',
            subfolder='examples/wflow_rhine_sbm_nc'
        )
    )
}

Once you have found a suitable parameter set, you can load it and see some more details:

parameter_set = sets["wflow_rhine_sbm_nc"]
print(parameter_set)
ParameterSet(
    name='wflow_rhine_sbm_nc',
    directory=PosixPath('/home/bart/ewatercycle/parameter-sets/wflow_rhine_sbm_nc'),
    config=PosixPath('/home/bart/ewatercycle/parameter-sets/wflow_rhine_sbm_nc/wflow_sbm_NC.ini'),
    doi='N/A',
    target_model='wflow',
    supported_model_versions={'2020.1.2', '2020.1.3', '2020.1.1'},
    downloader=GitHubDownloader(
        org='openstreams',
        repo='wflow',
        branch='master',
        subfolder='examples/wflow_rhine_sbm_nc'
    )
)

or you can access individual attributes of the parameter sets

parameter_set.supported_model_versions
{'2020.1.1', '2020.1.2', '2020.1.3'}

Should you wish to configure your own parameter set (e.g. for PCRGlobWB in this case), this is also possible:

custom_parameter_set = ewatercycle.parameter_sets.ParameterSet(
    name="custom_parameter_set",
    directory="~/ewatercycle/docs/examples/parameter-sets/pcrglobwb_rhinemeuse_30min",
    config="~/ewatercycle/docs/examples/parameter-sets/pcrglobwb_rhinemeuse_30min/setup_natural_test.ini",
    target_model="pcrglobwb",
    doi="https://doi.org/10.5281/zenodo.1045339",
    supported_model_versions={"setters"},
)

As you can see, an eWaterCycle parameter set is defined fully by a directory and a configuration file. The configuration file typically informs the model about the structure of the parameter set (e.g. “what is the filename of the land use data”). It is possible to change these settings later, when setting up the model.