apsimNGpy: The Next-Generation Agro-ecosystem Simulation Library
Introduction
apsimNGpy is a cutting-edge, open-source Python framework designed for advanced modeling with APSIM process-based model. Built on object-oriented principles. apsimNGpy extends and augments APSIM Next Generation functionalities within the Python scientific ecosystem, turning GUI-centric workflows into scriptable, reproducible, and scalable pipelines. apsimNGpy functionalities include, but not limited to the following:
Scalable performance. Run large experiment sets efficiently via
multiprocessing/multithreading
(e.g., factorials, ensembles, calibrations) using a clean, high-level API.Spatial & data integration. Leverage Python’s geospatial stack and built-in helpers to fetch and manage soil/weather inputs, enabling landscape-scale analyses.
Optimization & calibration. Access multi-objective optimization and sensitivity analysis to quantify trade-offs (e.g., yield vs. nitrate loss/GHG) and calibrate parameters.
Reproducible automation. Run
APSIM
using Jupyter/CLI/scripts; outputs land inpandas DataFrames
for downstream analysis, plotting, and reporting.Full model manipulation. A modular,
object-oriented
design supports inspection, editing, experiments, and custom reports without manual GUI interface.Version resilience. rather than tying
apsimNGpy
to a fixed APSIM version,apsimNGpy
is developed with forward- and backward-compatibility in mind and is actively synchronized with upstream APSIM.Open and extensible.
Apache-2.0
licensing, clear abstractions, and a plug-friendly architecture make it easy to extend and integrate into existing research pipelines.Diverse model evaluation metrics. Built-in model prediction evaluation metrics: RMSE, RRMSE, Willmott’s Index of Agreement (WIA), Bias, MAE, Lin’s CCC, and R2
Table of Contents
Getting Started
VERSION CONTROL
EDITING & INSPECTION
DISTRIBUTED COMPUTING
OPTIMIZATION & TRADE-OFF ANALYSIS
- Single-Objective Optimization with apsimNGpy
- Mixed-Variable Optimization in apsimNGpy
- Multi-Objective Optimization with apsimNGpy
- Step 1: Import required modules
- Step 2: Initialize the APSIM model runner
- Step 3: Define Objective Functions
- Step 4a: Define decision variables (Approach 1 - direct List)
- Step 3b: Define decision variables (Approach 2 - using
add_control()
) - Step 5: Run the NSGA-II optimizer
- Step 6: Plot the Pareto Front
- Comparing objectives without mult-objective optimization
SUPPORT DEVELOPMENT
TUTORIALS
CHEATSHEET
API REFERENCE
- apsimNGpy: API Reference
- ApsimModel
- ContinuousVariable
- CoreModel
- ExperimentManager
- MixedVariable
- ModelTools
- MultiCoreManager
- MultiObjectiveProblem
- apsimNGpy.core.base_data
- apsimNGpy.core.load_model
- apsimNGpy.core.runner
- apsimNGpy.core_utils.database_utils
- apsimNGpy.exceptions
- apsimNGpy.manager.soilmanager
- apsimNGpy.manager.weathermanager
- apsimNGpy.parallel.process
- apsimNGpy.validation.evaluator