Python wrapper for Aquimod 2
Project description
aquimodpy
A Python wrapper for the British Geological Survey's AquiMod 2, a lumped parameter groundwater model.
Features
- IDE Support: Full autocompletion and parameter validation in modern editors.
- Modular Design: Support for all Soil Zone (FAO, NSSS, SMAP), Unsaturated Zone (Weibull), and Saturated Zone (Q3K3S1, VKD, SA1D, etc.) components.
- Automated Configuration: Generates all required input files (
Input.txt,Observations.txt, and component-specific parameter files) with correct Windows-style formatting for Wine compatibility. - Simulation Modes: Full support for Evaluation, Monte Carlo calibration, and SCE-UA global optimisation.
- Cross-Platform: Flexible execution support; specify your preferred command prefix (e.g.,
["wine"],["box86"]) for running the Windows binary on non-Windows systems. - Data Integration: Seamless integration with Pandas for observation input and result parsing.
Installation
# Using pip
pip install aquimodpy
# Using uv
uv add aquimodpy
Documentation
Workflow Example: Calibration to Evaluation
This example demonstrates a complete real-world workflow: defining parameter ranges, running a Monte Carlo calibration, selecting the best parameter set, and performing a final evaluation.
import pandas as pd
import matplotlib.pyplot as plt
from aquimodpy import Model, FAO, Weibull, Q3K3S1, Observations, CalibrationRunner, EvaluationRunner
# 1. Initialise Model & Define Components
# We specify ranges [min, max] for parameters we want to calibrate
model = Model(
model_name="MySimulation",
executable_path="~/AquiMod2/AquiMod2.exe",
working_directory="./sim_results",
spinup_time=12,
exec_prefix=["wine"] # Required for Linux
)
FAO(model, theta_fc=0.3, theta_wp=0.1, Z_r=[500, 2500], p=0.5, BFI=[0.1, 0.9])
Weibull(model, k=[0.5, 5.0], lambda_=10.0)
Q3K3S1(model, dx=1000, K3=10, K2=5, K1=1, S=[1e-4, 1e-2], z3=50, z2=40, z1=30, alpha=1)
# 2. Load Forcing Data and Observations
df = pd.read_csv("my_data.csv", parse_dates=["date"])
Observations(model, df, {
"DATE": "date",
"RAIN": "rainfall_mm",
"PET": "pet_mm",
"GWL": "observed_gwl_m"
})
# 3. Step 1: Run Monte Carlo Calibration
model.set_runner(CalibrationRunner(model))
model.set_simulation_mode('m', n_runs=10000)
model.setup()
model.run()
# 4. Step 2: Load the Best Parameter Set
# Find the run with the highest Nash-Sutcliffe Efficiency (NSE)
calib_results = model.get_results()
best_run_idx = calib_results['Fit']['NSE'].idxmax()
model.load_parameters(calib_results, index=best_run_idx)
# 5. Step 3: Run Final Evaluation (Historical Simulation)
model.set_runner(EvaluationRunner(model))
model.set_simulation_mode('e')
model.setup()
model.run()
# 6. Analyse and Plot Results
results = model.get_results()
sim_gwl = results['Sat'] # Saturated zone time series
print(f"Optimal parameters loaded. NSE: {calib_results['Fit']['NSE'].max():.2f}")
print(sim_gwl.head())
# Optional: Plotting with Matplotlib
# plt.plot(df['date'], df['observed_gwl_m'], 'k.', label='Observed')
# plt.plot(df['date'], sim_gwl['Head(m)'], 'r-', label='Simulated')
# plt.show()
License and Attribution
This library is licensed under the MIT License.
This project provides a wrapper for AquiMod 2, which is owned by the British Geological Survey (BGS) and is licensed under the Open Government Licence v3.0.
Please note that this library does not include the AquiMod 2 binary. You can download the AquiMod 2 software from the official BGS website. Users are responsible for obtaining the binary independently and complying with the terms of the Open Government Licence as specified by the BGS.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aquimodpy-1.1.1.tar.gz.
File metadata
- Download URL: aquimodpy-1.1.1.tar.gz
- Upload date:
- Size: 112.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84ea8663c7d091d7acf87bdef0968e8f7bf96170ded71fe1a5e3c0d141c25451
|
|
| MD5 |
613f28f1a6854349c6a2e8e643e43782
|
|
| BLAKE2b-256 |
3e3d5a8379e187cd2a205e7942bdda0ab039e32f614f14e46cde496f216e199f
|
File details
Details for the file aquimodpy-1.1.1-py3-none-any.whl.
File metadata
- Download URL: aquimodpy-1.1.1-py3-none-any.whl
- Upload date:
- Size: 14.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
728738359048f5f97ee792994cb4c8d6e0b53bfb287b2b7675e0422d8f4f6beb
|
|
| MD5 |
5bb3386ed5a492e00cc5a684e16613b4
|
|
| BLAKE2b-256 |
e9c40d09d00254ba7bce332f914653dcaa283706f3fc9d528254aa35da05d0c9
|