Workshop Africa: Choose Region & Calibrate Model#

Welcome to the eWaterCycle Africa workshop!

Since I am working on a CAMEL dataset, I made the data I already have available for you today. I would, of course, love the opportunity to gather more data via your network.

Here you can choose a GRDC station from Ghana, Kenya or Zimbabwe that we have downloaded, with which we can do HBV modelling! This notebook will help you choose a certain region with the station ID. After that you can manually calibrate the the model to fit your region and maybe even calibrate it for the research you want to do already! Later on we will also use algorithms to calibrate our model.

Please keep in mind that I am looking for ways to improve our platform, if you found something hard to understand, let me know! Also, what models do you want to see implemented so you can use the platform in your hydrological research?

Importing modules#

Starting with all the libraries and utility functions. We have some general Python packages that we use. And then the eWaterCycle packages, this is where we import our ‘interface’, models & our way of loading generalised forcings for all supported models. Also I import some utility functions just for this notebook that I made to make it easier.

NOTE geopandas and folium will be installed, as they are not installed by default. But you will need to restart the kernel! Do this by going to the top-left “Kernel” –> “Restart Kernel…” OR click the “rewind” icon left of the “forward” icon, which is left of “Markdown”.

# General python
import warnings
warnings.filterwarnings("ignore", category=UserWarning)

import importlib
import subprocess
import sys
import numpy as np
from pathlib import Path
import pandas as pd
import matplotlib.pyplot as plt
import xarray as xr
import os
from IPython.display import display
import json

# Niceties
from rich import print

# General eWaterCycle
import ewatercycle
import ewatercycle.models
import ewatercycle.forcing

# Check and install geopandas and folium
def install_if_missing(package_name):
    try:
        importlib.import_module(package_name)
        print(f"'{package_name}' is already installed.")
    except ImportError:
        print(f"'{package_name}' not found. Installing...")
        subprocess.check_call([sys.executable, "-m", "pip", "install", package_name])
        print(f"PLEASE RESTART KERNEL")

install_if_missing("geopandas")
install_if_missing("folium")

import geopandas as gpd
import folium

# Utility functions
from util_functions import *
'geopandas' is already installed.
'folium' is already installed.

Select your region#

First we need to specify the country we want to look at.

country = "Zimbabwe"  # Ghana, Kenya or Zimbabwe
# Make a settings file to store our settings
settings = dict()

settings["country"] = country

Choosing your station#

I am working on a CAMELS dataset for Zimbabwe, Kenya and Ghana. I have uploaded the data I have available for Africa which you can use. The markers represent the GRDC stations and the areas their shapefiles/catchments.

You can choose the station id from the interactive map! Click on the shapefile are or the marker to copy the ID.

stations_dict = get_station_names(country)
stations_map(stations_dict, country)
Make this Notebook Trusted to load map: File -> Trust Notebook