Skip to main content

Python wrapper for Aquimod 2

Project description

aquimodpy

PyPI version Python versions CI status License

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 optimization.
  • 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

Quick Start

import pandas as pd
from aquimodpy import Model, FAO, Weibull, Q3K3S1, Observations, EvaluationRunner

# 1. Initialize the model
model = Model(
    model_name="MySimulation",
    executable_path="~/Documents/AquiMod2/AquiMod2.exe",
    working_directory="./simulation_results",
    exec_prefix=["wine"],  # Use ["wine"] for Linux
    spinup_time=24, # Number of time steps in spinup period
)

# 2. Add components using named arguments
FAO(
    model,
    theta_fc=0.4,
    theta_wp=0.1,
    Z_r=1000,
    p=0.5,
    BFI=0.8
)

Weibull(
    model,
    k=2.0,
    lambda_=5.0 # Use lambda_ as 'lambda' is a Python keyword
)

Q3K3S1(
    model,
    dx=1000,
    K3=10,
    K2=5,
    K1=1,
    S=0.01,
    z3=50,
    z2=40,
    z1=30,
    alpha=1
)

# 3. Add observations and map column names
df = pd.read_csv("my_data.csv")
Observations(model, df, {
    "DATE": "date_col",
    "RAIN": "rainfall_mm",
    "PET": "pet_mm",
    "GWL": "gw_level_m"
})

# 4. Configure and run
model.set_runner(EvaluationRunner(model))
model.setup()
model.run()

# 5. Analyze results
results = model.get_results()
print(results['Sat'].head())

Calibration and Optimization

Monte Carlo Calibration

Provide [min, max] lists for parameters you wish to calibrate.

from aquimodpy import CalibrationRunner
model.set_runner(CalibrationRunner(model))
model.set_simulation_mode('m', n_runs=10000, threshold=0.5, variable='g')

# Calibrate Z_r and BFI, keep others fixed
FAO(
    model,
    theta_fc=0.35,
    theta_wp=0.1,
    Z_r=[500, 3000],
    p=0.5,
    BFI=[0.1, 0.99]
)

SCE-UA Optimization

model.set_simulation_mode('s', n_loops=100, n_complexes=50, variable='g')

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

aquimodpy-1.1.0.tar.gz (93.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aquimodpy-1.1.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file aquimodpy-1.1.0.tar.gz.

File metadata

  • Download URL: aquimodpy-1.1.0.tar.gz
  • Upload date:
  • Size: 93.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for aquimodpy-1.1.0.tar.gz
Algorithm Hash digest
SHA256 7bc2a8d50f5bf63925e110e121dea41d9e6824a1e8e193f70f7249153ed93259
MD5 3b0ea9be4023807dda468efed2be7b3f
BLAKE2b-256 872dad56f23c1209d057303e15486d04f6c5e9255fe72f946b957089cb0b2f2c

See more details on using hashes here.

File details

Details for the file aquimodpy-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: aquimodpy-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for aquimodpy-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6fc4ec4182c48c511cfda26711a3cb690c5433f7a9b5e21b189faee786177268
MD5 4e3d869c06fe7459e2a72efb941a29cc
BLAKE2b-256 949ebf4c7b83cb94b41bd1fbe5e85f8c53c0c763df1a7f9cb8afa129ad4b8627

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page