Change the future

ApsimRegions: A Gridded Modeling Framework for the APSIM Crop Model

David Stack

Audience level:


This poster demonstrates how Python can be used in the Environmental and Earth Systems Sciences to create a framework for automating the process of preparing input, running in parallel, and processing output from existing computer models. The framework discussed, ApsimRegions, uses many built-in and third-party Python packages to accomplish these tasks specifically for the APSIM crop growth model.


Over the past few decades, there have been many process-based crop models developed with the goal of better understanding the impacts of climate, soils, and management decisions on crop yields. Traditionally, process-based crop models have been run at the individual farm level for yield optimization and management scenario testing. Few previous studies have used these models over broader geographic regions, largely due to the lack of gridded high-resolution meteorological and soil datasets required as inputs for these data intensive process-based models. With the growing availability of such datasets, and the desire to analyze spatial and temporal yield changes at the regional scale, the ApsimRegions modeling framework was developed to fill this need. By using Python, an automated pipeline was created to link gridded Regional Climate Model (RCM) output (rain, temperature, etc.) with the point-specific Agricultural Production Systems sIMulator (APSIM) crop model. This one-way nested modeling framework is capable of creating APSIM XML files using the lxml package, running thousands of simulations in parallel by using Python’s built-in multiprocessing and subprocess capabilities, saving the output of each APSIM simulation to a SQLite database through the use of Python’s native sqlite3 support, conducting a statistical analysis on the output using StatsModels package, and generating maps, timeseries, and figures by using the NumPy, Basemap, matplotlib, and pandas packages. Python is one of the few programming languages flexible and adaptable enough to combine all of this functionality into a streamlined, integrated, modeling framework. ApsimRegions has already been successfully applied in a U.S. Department of Agriculture funded study to better understand the relationship between climate variability and crop yield in the Southwestern United States. Encouraging results from this study have led to the further development of ApsimRegions and planned increasing community involvement. Because of the widespread use of the APSIM crop model throughout the world, and the growing demand for regional scale crop simulation capabilities, ApsimRegions not only has the potential to be widely adopted to meet this need, but is one of the first gridded modeling frameworks to extend a process-based crop model for use at the regional scale.