This repository contains the simple water balance model (SWBM) used in the Earth System Modelling course.
It is designed to demonstrate the most basic version of the model.
- 🧹 Preprocessing of input data for the water balance model
- 💧 Simulation of soil moisture, runoff, and evapotranspiration
- ⏱ Easy-to-run time series simulations
- 📈 Plotting of results
- 📊 Correlation analysis between model output and observed data
The model requires an input CSV file with the following variables:
📅 time: Date or timestamp
🌐 latitude and longitude
☔ tp_[mm]: Precipitation in mm
☀️ snr_[MJ/m2]: Surface net radiation
Optional: (used for correlation with observations):
🌱 sm_[m3/m3]: Soil moisture
🌊 ro_[m]: Runoff
🔥 le_[W/m2]: Latent heat flux
An example file is provided in the data/ folder:
📊 Data_swbm_Germany.csv
The model uses a configuration dictionary with these example parameters:
| Parameter | Description | Example |
|---|---|---|
c_s |
Soil water holding capacity (mm) | 420 |
a |
Runoff function shape (α) | 4 |
g |
ET function shape (γ) | 0.5 |
b0 |
Maximum of ET function (β) | 0.8 |
Python example:
config = {
'c_s': 420,
'a': 4,
'g': 0.5,
'b0': 0.8
}Follow these steps to set up the environment and run the model.
If you do not have Git installed on your system, download and install Git for your system:
git clone https://github.com/Motzemoere/Earth-System-Modelling.git
cd Earth-System-ModellingIf you do not have Conda installed, download and install Miniforge for your system:
You should now have access to the Miniforge prompt command terminal
The easiest way is to just create the environment manually by runnning these commands in the miniforge prompt:
conda create -n esm python pandas numpy matplotlib -y
conda activate esmAlternatively:
Use the provided environment.yml file to create a Python environment with all dependencies in one go:
(this is how its normally done with bigger envs)
Run and confirm this in your miniforge prompt:
cd Earth-System-Modelling
conda env create -f environment.yml
conda activate esmOpen the cloned repository folder in you prefered IDE, select the esm env as your Python interpreter and start playing around.
You can find a complete example workflow, including how to run the SWBM model, plot the results, and compute correlations with observed data, in the following file:
➡️ run_swbm.py
from google.colab import drive
drive.mount('/content/drive')
# Follow the instruction to allow access to your google driveOpen up a terminal in Google Colab (bottom left corner) and run the following commands:
cd drive/MyDrive
git clone https://github.com/Motzemoere/Earth-System-Modelling.git
cd Earth-System-ModellingAlternatively you could also just clone the repository to your local machine (see above) and then upload it to Google Drive.
In the repository, there is a complete example flow for running the SWBM: run_swbm_colab.ipynb.
However, to open the script in Colab, you need to go back to Google Drive, navigate to the GitHub repository that you just cloned, and open the script from there using the Open with option, selecting Google Colaboratory.
If you have any questions, feel free to reach out:
✉️ mattis.pfenning@email.uni-freiburg.de
Koster, R. D., and S. P. P. Mahanama, 2012: Land surface controls on hydroclimatic means and variability. J. Hydrometeor., 13, 1604 1620, doi:10.1175/JHM-D-12-050.1.