cropemu
Fast emulators of process-based crop models, usable anywhere on the globe without installing the models. An emulator is a neural network trained on ~118,000 simulated seasons at ~2,000 points of the soybean area of the world. It predicts a whole season (phenology dates, yield, biomass, water balance) in about 10 µs instead of the 0.1–1 s of the crop model.
| Emulator | Crop model | Inputs | Outputs |
|---|---|---|---|
dssat-soybean-v1 |
DSSAT 4.8 CROPGRO-Soybean (official executable) | weather, soil, sowing date, 14 cultivar coefficients, water regime, CO₂ | 41 |
aquacrop-soybean-v1 |
FAO AquaCrop 7.3 (official executable) | weather, soil, sowing date, 13 crop parameters, water regime, CO₂ | 44 |
Both emulators ship inside the package (~1.3 MB each) and run with onnxruntime only.
Install
pip install cropemu # emulators + NASA POWER weather
pip install "cropemu[soil]" # + SoilGrids soil profiles (rasterio)
On Intel Macs, add --prefer-binary (the newest rasterio has no wheel for them).
Quick start
import cropemu
from cropemu.weather import fetch, fill_gaps
from cropemu.soil import soilgrids
lat, lon = -23.19, -51.18 # Londrina, Brazil
weather = fill_gaps(fetch(lat, lon, "2000-01-01", "2024-12-31")) # NASA POWER, cached
soil = soilgrids.fetch(lat, lon) # SoilGrids 2.0 profile, cached
emu = cropemu.load("dssat-soybean-v1")
emu.describe() # outputs, units, validation error, level
res = emu.predict(weather, lat=lat, elev=600, soil=soil,
sowing=["2020-10-15", "2021-10-15", "2022-10-15"],
cultivar=emu.cultivar(mg=6.5))
res.outputs[["MDAT_dap", "HWAM", "ETCM"]] # maturity (days after sowing), yield (kg/ha), ET (mm)
res.recommended("caution") # only outputs that passed validation
res.out_of_domain, res.rare_inputs # inputs outside the training data
Climate scenarios as in training: emu.predict(..., dt=2.0, rain_factor=0.9, co2=550).
Irrigated (no water stress): irrigated=True.
What every prediction tells you
- Acceptance level of each output, from a 5-fold cross-validation by 5° spatial blocks
(the emulator never saw the region it is tested on):
- recommended: dates with RMSE ≤ 5 days; other outputs with RMSE < 0.25 of the within-site standard deviation;
- caution: relative error < 0.5;
- not recommended: everything else.
out_of_domain: inputs outside the range of the training data (do not trust).rare_inputs: inputs outside the 0.5–99.5 % range of the training data (less trust).
Validation, by spatial blocks:
| Maturity date | Yield | Evapotranspiration | |
|---|---|---|---|
| DSSAT | 3.3 d (R² 0.98) | 454 kg/ha (R² 0.94) | 32 mm (R² 0.96) |
| AquaCrop | 4.4 d (R² 0.99) | 0.58 t/ha (R² 0.91) | 52 mm (R² 0.90) |
Inputs, as in training
- Weather: NASA POWER daily data, gaps filled. The emulator summarises it in windows from 30 days before to 130 days after sowing.
- Soil: SoilGrids 2.0 (1 km, 3 × 3 km median, 6 layers to 2 m). Water retention: Reichert et al. (2009) with field capacity at 10 kPa up to 30° latitude, Saxton & Rawls (2006) from 40°, and a linear blend in between.
- Cultivar:
emu.cultivar(mg=...)gives the DSSAT default coefficients of a maturity group.- For AquaCrop it gives the middle of the training range of every crop parameter. The cycle
length comes from the local climate:
emu.cultivar(weather=..., sowing=..., cycle_days=...). - Any value can be overridden:
emu.cultivar(mg=6, LFMAX=1.1).
- Fixed in training: 30 plants/m², 50 cm rows, no nitrogen stress, 50 % of the available water at the start of the simulation (30 days before sowing).
Your own data
- Weather station: any daily table with the columns
srad,tmax,tmin,rain(and optionallydewp,rhum,wind) andattrslat,lon,elev. Check it withcropemu.weather.checkand complete missing days or columns from NASA POWER withcropemu.weather.fill_from(station, power). - Measured soil: a profile with your
llanddulis used as it is (cut at 2 m, the depth of the training profiles); missing properties can be taken from SoilGrids withcropemu.soil.fill_from(profile, soilgrids.fetch(lat, lon)). - DSSAT files:
cropemu.ioreads weather (read_wth), soil (read_sol), cultivar (read_cul), experiment (read_experiment) and observed data (read_observed).emu.cultivar_from_dssat(read_cul(...))gives the emulator cultivar, andemu.cultivar_domain(cultivar)shows which coefficients fall outside the training range. - AquaCrop cycle from an observation:
emu.cultivar(gdd_maturity=cropemu.gdd_between(weather, sowing, maturity)). - Calibration: compute the inputs once (
emu.inputs), change the cultivar columns and callemu.predict_inputs: thousands of candidate cultivars × seasons per second, inside the domain.
The example notebooks show all of this with published field trials from the DSSAT example data.
Limitations
- An emulator reproduces its crop model, not the field: model errors are inherited.
- Soybean only (maize planned).
- Pre-alpha: the output names follow the crop models and may change.
License
MIT. Data sources: NASA POWER, SoilGrids 2.0 (CC-BY 4.0), GGCMI Phase 3 crop calendar.
Metadata
Release files for cropemu 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cropemu-0.2.0.tar.gz | 2.4 MB | Without provenance | Details for cropemu-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cropemu-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for cropemu-0.2.0-py3-none-any.whl |
Total release size: 4.8 MB
Release files / cropemu-0.2.0.tar.gz
| Download URL | cropemu-0.2.0.tar.gz |
|---|---|
| Size | 2.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c3f6967103839b3af31360637a86c52ae8a12e5b9d4e88d43131d3ebe493a05c
|
|
BLAKE2b-256 checksum How to use checksums |
b40ea34010e8828b325a756e18547cb5040149bd64ac062fe567476063330931
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.13
|
Release files / cropemu-0.2.0-py3-none-any.whl
| Download URL | cropemu-0.2.0-py3-none-any.whl |
|---|---|
| Size | 2.4 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
62651ab2f87d5a51860cccd9c589929c304497374d56154b44d62a9b7a48a7cf
|
|
BLAKE2b-256 checksum How to use checksums |
1e25b085575329b14e815db38839a61700ea132860a3bd9e5c174862d826fced
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.13
|
Security for cropemu 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.