Skip to main content

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 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

# Clone the repository
git clone https://github.com/your-repo/aquimodpy.git
cd aquimodpy

# Install dependencies (using uv)
uv pip install -e .

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 or [] for native Windows
)

# 2. Add components using named arguments
# Units and special characters are handled automatically!
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.0.0.tar.gz (73.9 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.0.0-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for aquimodpy-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ad78d6aefe6abc6ed8cf5b01f24d072f99a1ad7fbe2e1667585c0f3e15dfe226
MD5 ae3b112b2e6ef98a2ded1e9ef61cafb8
BLAKE2b-256 c86c8487074af32c764069a0b4527339c9fe6a6622d7b0c335c6eb115b169003

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for aquimodpy-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2407b1a4afdb3063e1700d1e87f48e60c79041ab2b9c618ffd2fe1f81942c584
MD5 a9a9b4af8ba69b2aea08e9dd9d81ba73
BLAKE2b-256 c6a898cc7c00818b6cbd3437e293c503a49f2fc99cd9354aec5605c29346cb9d

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