MATILDA: Modeling wATer resources In gLacierizeD cAtchments

July 17, 2025 · View on GitHub

DOI Documentation Status

MATILDA is a Python-based modeling framework for simulating water resources in glacierized catchments. This repository contains the core routines of the comprehensive MATILDA-Online workflow:

  1. The matilda.core module combines a temperature-index melt model with the HBV model for hydrological simulations.
  2. The matilda.mspot_glacier module provides a parameter optimization routine using the spotpy library.

While MATILDA can be used as a stand-alone model, the MATILDA-Online workflow provides comprehensive tools for data acquisition, pre- and post-processing with detailed documentation.


Repository Structure

.
├── Example
│   ├── example_workflow.py           # Example script for running MATILDA
│   ├── forcing_data.csv              # Input data for example workflow
│   └── runoff_data.csv               # Observed runoff data
├── matilda
│   ├── core.py                       # MATILDA core routines
│   └── mspot_glacier.py              # Parameter optimization routines
...

Installation

The tool's dependencies are set to integrate with MATILDA-Online. It requires Python 3.11 and the following libraries:

- xarray
- numpy
- pandas
- matplotlib
- scipy
- datetime
- hydroeval
- HydroErr
- plotly
- spotpy
- pyyaml

The MATILDA package and it's dependencies can be installed on your local machine using pip or a similar package manager. You can either install the package by using the link to this repository:

pip install git+https://github.com/cryotools/matilda.git

...or clone this repository to your local machine, navigate to the top-level directory and use it:

pip install .

Usage

A detailed walkthrough of the proposed modeling workflow and calibration strategy can be found at the MATILDA Online Webpage. For a quick start to the stand-alone model, see the application example and use the following guidelines.

Forcing Data

The minimum input is a CSV file containing time series of air temperature (°C or K), total precipitation (mm), and (if available) evapotranspiration (mm) data in the format shown below. If evapotranspiration is not provided, it is estimated from air temperature according to Oudin et.al. 2010. A series of discharge observations (mm) is used to calibrate the model. If no discharge data are provided, the model runs with default parameters. All datasets require daily resolution.

TIMESTAMPT2RRRPE
2011-01-01 00:00:00-18.20.000.00
2011-01-01 01:00:00-18.30.10.00
2011-01-01 02:00:00-18.20.10.00
............
DateQobs
2011-01-010.17
2011-01-010.19
......

The forcing data are scaled to the mean elevations of the glacierized and ice-free subcatchments, respectively, using linear lapse rates. Reference elevations must be provided for the input data, the entire catchment, and the glacierized fraction. Automated routines for catchment delineation and public data download can be found in the MATILDA Online workflow.

Glacier Data

To apply the Δh parameterization of Huss and Hock 2015 within the DDM routine to calculate glacier evolution over the study period, you need to provide data on the initial glacier cover. The routine requires an initial glacier profile containing the spatial distribution of ice over elevation bands at the beginning of the study period in the form of a dataframe:

ElevationAreaWEEleZone
37200.00510786.0613700
37300.00113687.8013700
37400.00112571.2533700
37500.00212357.9873800
...........
  • Elevation - elevation of each band (10 m intervals recommended)
  • Area - glacierized area in each band as a fraction of the total catchment area (column sum is the glacierized fraction of the total catchment)
  • WE - ice thickness in mm w.e.
  • EleZone - combined bands across 100-200 m.

Parameter List

MATILDA has 21 non-optional parameters, most of which are HBV standard parameters.

ParameterDescriptionUnitDefault Value
lrtemp\text{lr}_{\text{temp}}Temperature lapse rate°C m⁻¹-0.006
lrprec\text{lr}_{\text{prec}}Precipitation lapse ratemm m⁻¹0
PCORR\text{PCORR}Precipitation correction factor-1.0
TTsnow\text{TT}_{\text{snow}}Threshold temperature for snow°C0
TTdiff\text{TT}_{\text{diff}}Temperature range for rain-snow transition°C2
SFCF\text{SFCF}Snowfall correction factor-0.7
CFMAXsnow\text{CFMAX}_{\text{snow}}Melt factor for snowmm °C⁻¹ day⁻¹5
CFMAXrel\text{CFMAX}_{\text{rel}}Melt factor for ice relative to snow-2
CWH\text{CWH}Water holding capacity of snowpack-0.1
CFR\text{CFR}Refreezing coefficient-0.15
AG\text{AG}Control parameter of the glacier storage-release scheme-0.7
BETA\text{BETA}Shape coefficient for soil moisture routine-1.0
CET\text{CET}Correction factor for evapotranspiration-0.15
FC\text{FC}Field capacity of soilmm250
LP\text{LP}Fraction of field capacity for maximum evapotranspiration-0.7
K0\text{K}_0Recession coefficient for surface flowday⁻¹0.055
K1\text{K}_1Recession coefficient for intermediate groundwater flowday⁻¹0.055
K2\text{K}_2Recession coefficient for deep groundwater flowday⁻¹0.04
PERC\text{PERC}Percolation rate from upper to lower groundwater reservoirmm day⁻¹1.5
UZL\text{UZL}Threshold for quick flow from upper zonemm120
MAXBAS\text{MAXBAS}Length of triangular routing functionday3.0

Authors

See also the list of contributors who participated in the initial project funded by the GIZ.

License

This project is licensed under the MIT License.


References

The development of MATILDA integrated several well-established hydrological and glacier modeling tools. References for the primary methods and libraries used in the model are listed below:

PyPDD (Temperature-Index Model):

LHMP and HBV Models:

Δh (delta-h) Parametrization:

SPOTPY (Parameter Optimization):