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
APSIMusing Jupyter/CLI/scripts; outputs land inpandas DataFramesfor downstream analysis, plotting, and reporting.Full model manipulation. A modular,
object-orienteddesign supports inspection, editing, experiments, and custom reports without manual GUI interface.Version resilience. rather than tying
apsimNGpyto a fixed APSIM version,apsimNGpyis developed with forward- and backward-compatibility in mind and is actively synchronized with upstream APSIM.Open and extensible.
Apache-2.0licensing, 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
Discussion and Community Support
Users who wish to ask questions, report issues, request new features, or engage in general discussion about apsimNGpy are encouraged to visit the project’s official GitHub Discussions page.
This forum serves as the preferred place for:
Troubleshooting and “how-to” questions
Sharing workflows or examples
Feature proposals and use-case discussions
Clarification on model editing, optimization, and calibration
Community-driven enhancements
Collaboration with other APSIM users
If your question is not answered in the documentation, feel free to start a new discussion thread and tag it appropriately.
For reporting reproducible bugs or contributing code, please use the GitHub Issues tracker.
Table of Contents
RELEASE NOTES
Getting Started
VERSION CONTROL
EDITING & INSPECTION
- Inspect Model
- Whole Model inspection
- Model Preview in GUI
- Inspect Model Parameters
- Editing model parameters
- More examples about
edit_model_by_path - Editing nested simulation models
- Quick and Simple Way to Run Factorial Experiments
- Quick Overview
- Getting Started
- Adding Input Factors
- Finalizing the Experiment
- API Summary
- Further Reading
- Weather Data Replacement.
DISTRIBUTED COMPUTING
OPTIMIZATION & TRADE-OFF ANALYSIS
- Parameter calibration
- 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
Sensitivity Analysis
CHEATSHEET
SIMULATED DATA PLOTTING & VISUALIZATION
- Plotting and Visualizing Simulated Output
- Moving average plots
- Categorical Plots
- Box plots
- Maize yield variability by population density (mva plot).
- Maize yield variability by population density and nitrogen fertilizer (box plot).
- Bar Plots
- Maize yield variability by population density (bar plot).
- Maize yield variability by population density (bar plot, estimator =sum).
- Maize yield variability by population density in Mg (bar plot, estimator =sum).
- Tidy up the plots for reporting
- Passing a custom dataset
- Meta info
API REFERENCE
- apsimNGpy: API Reference
- apsimNGpy.core.apsim
- apsimNGpy.core.config
- apsimNGpy.core.experimentmanager
- apsimNGpy.core.mult_cores
- apsimNGpy.core.pythonet_config
- apsimNGpy.core.runner
- apsimNGpy.core.senstivitymanager
- apsimNGpy.core_utils.database_utils
- apsimNGpy.exceptions
- apsimNGpy.optimizer.minimize.single_mixed
- apsimNGpy.optimizer.moo
- apsimNGpy.optimizer.problems.back_end
- apsimNGpy.optimizer.problems.smp
- apsimNGpy.parallel.process
- apsimNGpy.validation.evaluator