cropemu 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,16 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .venv/
5
+ build/
6
+ dist/
7
+ .pytest_cache/
8
+ .coverage
9
+ htmlcov/
10
+ .DS_Store
11
+
12
+ # local data and simulation outputs (published separately on Zenodo)
13
+ /data/
14
+ /runs/
15
+ /cache/
16
+ *.parquet
cropemu-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Fabrício Correia de Oliveira
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
cropemu-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,113 @@
1
+ Metadata-Version: 2.5
2
+ Name: cropemu
3
+ Version: 0.1.0
4
+ Summary: Fast, validated emulators of process-based crop models
5
+ Author: Fabrício Correia de Oliveira
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Classifier: Development Status :: 2 - Pre-Alpha
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Topic :: Scientific/Engineering :: Atmospheric Science
12
+ Requires-Python: >=3.10
13
+ Requires-Dist: numpy<2; sys_platform == 'darwin' and platform_machine == 'x86_64'
14
+ Requires-Dist: numpy>=1.24
15
+ Requires-Dist: onnxruntime>=1.16
16
+ Requires-Dist: pandas>=2.0
17
+ Provides-Extra: soil
18
+ Requires-Dist: rasterio>=1.3; extra == 'soil'
19
+ Provides-Extra: test
20
+ Requires-Dist: pytest>=7; extra == 'test'
21
+ Description-Content-Type: text/markdown
22
+
23
+ # cropemu
24
+
25
+ Fast emulators of process-based crop models, usable anywhere on the globe without
26
+ installing the models. An emulator is a neural network trained on ~118,000 simulated
27
+ seasons at ~2,000 points of the soybean area of the world. It predicts a whole season
28
+ (phenology dates, yield, biomass, water balance) in about 10 µs instead of the 0.1–1 s
29
+ of the crop model.
30
+
31
+ | Emulator | Crop model | Inputs | Outputs |
32
+ |---|---|---|---|
33
+ | `dssat-soybean-v1` | DSSAT 4.8 CROPGRO-Soybean (official executable) | weather, soil, sowing date, 14 cultivar coefficients, water regime, CO₂ | 41 |
34
+ | `aquacrop-soybean-v1` | FAO AquaCrop 7.3 (official executable) | weather, soil, sowing date, 13 crop parameters, water regime, CO₂ | 44 |
35
+
36
+ Both emulators ship inside the package (~1.3 MB each) and run with `onnxruntime` only.
37
+
38
+ ## Install
39
+
40
+ ```bash
41
+ pip install cropemu # emulators + NASA POWER weather
42
+ pip install "cropemu[soil]" # + SoilGrids soil profiles (rasterio)
43
+ ```
44
+
45
+ On Intel Macs, add `--prefer-binary` (the newest rasterio has no wheel for them).
46
+
47
+ ## Quick start
48
+
49
+ ```python
50
+ import cropemu
51
+ from cropemu.weather import fetch, fill_gaps
52
+ from cropemu.soil import soilgrids
53
+
54
+ lat, lon = -23.19, -51.18 # Londrina, Brazil
55
+ weather = fill_gaps(fetch(lat, lon, "2000-01-01", "2024-12-31")) # NASA POWER, cached
56
+ soil = soilgrids.fetch(lat, lon) # SoilGrids 2.0 profile, cached
57
+
58
+ emu = cropemu.load("dssat-soybean-v1")
59
+ emu.describe() # outputs, units, validation error, level
60
+
61
+ res = emu.predict(weather, lat=lat, elev=600, soil=soil,
62
+ sowing=["2020-10-15", "2021-10-15", "2022-10-15"],
63
+ cultivar=emu.cultivar(mg=6.5))
64
+ res.outputs[["MDAT_dap", "HWAM", "ETCM"]] # maturity (days after sowing), yield (kg/ha), ET (mm)
65
+ res.recommended("caution") # only outputs that passed validation
66
+ res.out_of_domain, res.rare_inputs # inputs outside the training data
67
+ ```
68
+
69
+ Climate scenarios as in training: `emu.predict(..., dt=2.0, rain_factor=0.9, co2=550)`.
70
+ Irrigated (no water stress): `irrigated=True`.
71
+
72
+ ## What every prediction tells you
73
+
74
+ - **Acceptance level of each output**, from a 5-fold cross-validation by 5° spatial blocks
75
+ (the emulator never saw the region it is tested on):
76
+ - *recommended*: dates with RMSE ≤ 5 days; other outputs with RMSE < 0.25 of the
77
+ within-site standard deviation;
78
+ - *caution*: relative error < 0.5;
79
+ - *not recommended*: everything else.
80
+ - **`out_of_domain`**: inputs outside the range of the training data (do not trust).
81
+ - **`rare_inputs`**: inputs outside the 0.5–99.5 % range of the training data (less trust).
82
+
83
+ Validation, by spatial blocks:
84
+
85
+ | | Maturity date | Yield | Evapotranspiration |
86
+ |---|---|---|---|
87
+ | DSSAT | 3.3 d (R² 0.98) | 454 kg/ha (R² 0.94) | 32 mm (R² 0.96) |
88
+ | AquaCrop | 4.4 d (R² 0.99) | 0.58 t/ha (R² 0.91) | 52 mm (R² 0.90) |
89
+
90
+ ## Inputs, as in training
91
+
92
+ - **Weather:** NASA POWER daily data, gaps filled. The emulator summarises it in windows from
93
+ 30 days before to 130 days after sowing.
94
+ - **Soil:** SoilGrids 2.0 (1 km, 3 × 3 km median, 6 layers to 2 m). Water retention:
95
+ Reichert et al. (2009) with field capacity at 10 kPa up to 30° latitude, Saxton & Rawls
96
+ (2006) from 40°, and a linear blend in between.
97
+ - **Cultivar:**
98
+ - `emu.cultivar(mg=...)` gives the DSSAT default coefficients of a maturity group.
99
+ - For AquaCrop it gives the middle of the training range of every crop parameter. The cycle
100
+ length comes from the local climate: `emu.cultivar(weather=..., sowing=..., cycle_days=...)`.
101
+ - Any value can be overridden: `emu.cultivar(mg=6, LFMAX=1.1)`.
102
+ - **Fixed in training:** 30 plants/m², 50 cm rows, no nitrogen stress, 50 % of the available
103
+ water at the start of the simulation (30 days before sowing).
104
+
105
+ ## Limitations
106
+
107
+ - An emulator reproduces its crop model, not the field: model errors are inherited.
108
+ - Soybean only (maize planned).
109
+ - Pre-alpha: the output names follow the crop models and may change.
110
+
111
+ ## License
112
+
113
+ MIT. Data sources: NASA POWER, SoilGrids 2.0 (CC-BY 4.0), GGCMI Phase 3 crop calendar.
@@ -0,0 +1,91 @@
1
+ # cropemu
2
+
3
+ Fast emulators of process-based crop models, usable anywhere on the globe without
4
+ installing the models. An emulator is a neural network trained on ~118,000 simulated
5
+ seasons at ~2,000 points of the soybean area of the world. It predicts a whole season
6
+ (phenology dates, yield, biomass, water balance) in about 10 µs instead of the 0.1–1 s
7
+ of the crop model.
8
+
9
+ | Emulator | Crop model | Inputs | Outputs |
10
+ |---|---|---|---|
11
+ | `dssat-soybean-v1` | DSSAT 4.8 CROPGRO-Soybean (official executable) | weather, soil, sowing date, 14 cultivar coefficients, water regime, CO₂ | 41 |
12
+ | `aquacrop-soybean-v1` | FAO AquaCrop 7.3 (official executable) | weather, soil, sowing date, 13 crop parameters, water regime, CO₂ | 44 |
13
+
14
+ Both emulators ship inside the package (~1.3 MB each) and run with `onnxruntime` only.
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ pip install cropemu # emulators + NASA POWER weather
20
+ pip install "cropemu[soil]" # + SoilGrids soil profiles (rasterio)
21
+ ```
22
+
23
+ On Intel Macs, add `--prefer-binary` (the newest rasterio has no wheel for them).
24
+
25
+ ## Quick start
26
+
27
+ ```python
28
+ import cropemu
29
+ from cropemu.weather import fetch, fill_gaps
30
+ from cropemu.soil import soilgrids
31
+
32
+ lat, lon = -23.19, -51.18 # Londrina, Brazil
33
+ weather = fill_gaps(fetch(lat, lon, "2000-01-01", "2024-12-31")) # NASA POWER, cached
34
+ soil = soilgrids.fetch(lat, lon) # SoilGrids 2.0 profile, cached
35
+
36
+ emu = cropemu.load("dssat-soybean-v1")
37
+ emu.describe() # outputs, units, validation error, level
38
+
39
+ res = emu.predict(weather, lat=lat, elev=600, soil=soil,
40
+ sowing=["2020-10-15", "2021-10-15", "2022-10-15"],
41
+ cultivar=emu.cultivar(mg=6.5))
42
+ res.outputs[["MDAT_dap", "HWAM", "ETCM"]] # maturity (days after sowing), yield (kg/ha), ET (mm)
43
+ res.recommended("caution") # only outputs that passed validation
44
+ res.out_of_domain, res.rare_inputs # inputs outside the training data
45
+ ```
46
+
47
+ Climate scenarios as in training: `emu.predict(..., dt=2.0, rain_factor=0.9, co2=550)`.
48
+ Irrigated (no water stress): `irrigated=True`.
49
+
50
+ ## What every prediction tells you
51
+
52
+ - **Acceptance level of each output**, from a 5-fold cross-validation by 5° spatial blocks
53
+ (the emulator never saw the region it is tested on):
54
+ - *recommended*: dates with RMSE ≤ 5 days; other outputs with RMSE < 0.25 of the
55
+ within-site standard deviation;
56
+ - *caution*: relative error < 0.5;
57
+ - *not recommended*: everything else.
58
+ - **`out_of_domain`**: inputs outside the range of the training data (do not trust).
59
+ - **`rare_inputs`**: inputs outside the 0.5–99.5 % range of the training data (less trust).
60
+
61
+ Validation, by spatial blocks:
62
+
63
+ | | Maturity date | Yield | Evapotranspiration |
64
+ |---|---|---|---|
65
+ | DSSAT | 3.3 d (R² 0.98) | 454 kg/ha (R² 0.94) | 32 mm (R² 0.96) |
66
+ | AquaCrop | 4.4 d (R² 0.99) | 0.58 t/ha (R² 0.91) | 52 mm (R² 0.90) |
67
+
68
+ ## Inputs, as in training
69
+
70
+ - **Weather:** NASA POWER daily data, gaps filled. The emulator summarises it in windows from
71
+ 30 days before to 130 days after sowing.
72
+ - **Soil:** SoilGrids 2.0 (1 km, 3 × 3 km median, 6 layers to 2 m). Water retention:
73
+ Reichert et al. (2009) with field capacity at 10 kPa up to 30° latitude, Saxton & Rawls
74
+ (2006) from 40°, and a linear blend in between.
75
+ - **Cultivar:**
76
+ - `emu.cultivar(mg=...)` gives the DSSAT default coefficients of a maturity group.
77
+ - For AquaCrop it gives the middle of the training range of every crop parameter. The cycle
78
+ length comes from the local climate: `emu.cultivar(weather=..., sowing=..., cycle_days=...)`.
79
+ - Any value can be overridden: `emu.cultivar(mg=6, LFMAX=1.1)`.
80
+ - **Fixed in training:** 30 plants/m², 50 cm rows, no nitrogen stress, 50 % of the available
81
+ water at the start of the simulation (30 days before sowing).
82
+
83
+ ## Limitations
84
+
85
+ - An emulator reproduces its crop model, not the field: model errors are inherited.
86
+ - Soybean only (maize planned).
87
+ - Pre-alpha: the output names follow the crop models and may change.
88
+
89
+ ## License
90
+
91
+ MIT. Data sources: NASA POWER, SoilGrids 2.0 (CC-BY 4.0), GGCMI Phase 3 crop calendar.
@@ -0,0 +1,32 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.24"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "cropemu"
7
+ version = "0.1.0"
8
+ description = "Fast, validated emulators of process-based crop models"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.10"
12
+ authors = [{ name = "Fabrício Correia de Oliveira" }]
13
+ dependencies = [
14
+ "numpy>=1.24",
15
+ # the last onnxruntime wheels for Intel Macs are built against numpy 1
16
+ "numpy<2; sys_platform == 'darwin' and platform_machine == 'x86_64'",
17
+ "pandas>=2.0",
18
+ "onnxruntime>=1.16",
19
+ ]
20
+ classifiers = [
21
+ "Development Status :: 2 - Pre-Alpha",
22
+ "Intended Audience :: Science/Research",
23
+ "Programming Language :: Python :: 3",
24
+ "Topic :: Scientific/Engineering :: Atmospheric Science",
25
+ ]
26
+
27
+ [project.optional-dependencies]
28
+ soil = ["rasterio>=1.3"]
29
+ test = ["pytest>=7"]
30
+
31
+ [tool.hatch.build.targets.wheel]
32
+ packages = ["src/cropemu"]
@@ -0,0 +1,16 @@
1
+ """cropemu: fast, validated emulators of process-based crop models.
2
+
3
+ >>> import cropemu
4
+ >>> cropemu.available()
5
+ ['aquacrop-soybean-v1', 'dssat-soybean-v1']
6
+ >>> emu = cropemu.load("dssat-soybean-v1")
7
+ >>> emu.describe() # outputs, units, acceptance levels
8
+
9
+ Weather (NASA POWER) and soil (SoilGrids) helpers are in ``cropemu.weather`` and ``cropemu.soil``.
10
+ """
11
+
12
+ from .emulator import Emulator, Prediction, available, load, season_gdd
13
+
14
+ __all__ = ["Emulator", "Prediction", "available", "load", "season_gdd"]
15
+
16
+ __version__ = "0.1.0"
@@ -0,0 +1 @@
1
+ """Data files shipped with cropemu."""