Skip to content

Commit 540df8f

Browse files
committed
Add Applications section with Ag Forecasting API docs
1 parent 03d3017 commit 540df8f

3 files changed

Lines changed: 164 additions & 1 deletion

File tree

_toc.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@
44
format: jb-book
55
root: index
66
chapters:
7-
- file: worker
7+
- file: worker
8+
- file: applications/index
9+
title: Applications
10+
sections:
11+
- file: applications/ag-forecasting-api

applications/ag-forecasting-api.md

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# 🌾 Agricultural Forecasting API
2+
3+
FastAPI-based service for **crop disease risk forecasting** and **winter rye biomass estimation** using multi-source weather data.
4+
Developed by the University of Wisconsin–Madison Data Science Institute.
5+
6+
---
7+
8+
## Overview
9+
10+
The API provides geospatial agricultural intelligence for Wisconsin, combining weather data with validated agronomic models.
11+
12+
### Key Features
13+
- 🌽 Crop disease risk forecasting (corn & soybean)
14+
- 🌱 Winter rye biomass estimation
15+
- 🌦 Multi-source weather integration (IBM EIS, WiscoNet, NOAA)
16+
- 📍 Coordinate and station-based queries
17+
- 🗺 GeoJSON outputs for GIS applications
18+
- ⚡ Async batch processing for multi-station analysis
19+
20+
---
21+
22+
## System Architecture
23+
24+
The system is structured into four main layers:
25+
26+
- **API Layer (FastAPI)**
27+
Handles incoming requests and routing (`/ibm`, `/wisconet_g`, `/models`)
28+
29+
- **Data Layer**
30+
- IBM EIS: high-resolution global weather API
31+
- WiscoNet: Wisconsin mesonet station network
32+
33+
- **Processing Layer**
34+
Weather normalization, unit conversion, GDD calculation, rolling features
35+
36+
- **Model Layer**
37+
Disease risk models and winter rye biomass model
38+
39+
---
40+
41+
## Core Modules
42+
43+
- Weather ingestion (IBM + WiscoNet)
44+
- Disease risk modeling
45+
- Winter rye biomass estimation
46+
- Async pipeline orchestration
47+
- GeoJSON response formatting
48+
49+
---
50+
51+
## API Endpoints
52+
53+
### IBM Forecasting (Coordinates)
54+
`GET /v2/ag_models_wrappers/ibm`
55+
56+
Returns disease risk + biomass using IBM weather data.
57+
58+
---
59+
60+
### WiscoNet Forecasting (Stations)
61+
`GET /v2/ag_models_wrappers/wisconet_g`
62+
63+
Returns station-based time-series disease risk and biomass.
64+
65+
---
66+
67+
### Model Metadata
68+
`GET /v2/ag_models_wrappers/models`
69+
70+
Returns available disease and biomass models.
71+
72+
---
73+
74+
## Disease Models
75+
76+
- **Tarspot (corn)** – humidity and temperature-based risk
77+
- **Gray Leaf Spot (corn)** – temperature + dew point model
78+
- **Frogeye Leaf Spot (soybean)** – GDD + rainfall model
79+
- **White Mold (soybean)** – precipitation and soil moisture model
80+
81+
---
82+
83+
## Winter Rye Biomass Model
84+
85+
Predicts dry biomass (lb/acre) using:
86+
87+
- Growing Degree Days (0°C base)
88+
- Planting date (day-of-year)
89+
- Fall precipitation
90+
- Logistic growth curve
91+
92+
### Outputs
93+
- Biomass (lb/acre)
94+
- Color class (gray / yellow / green)
95+
- Interpretation message
96+
97+
---
98+
99+
## Data Sources
100+
101+
### IBM Environmental Intelligence Suite (EIS)
102+
- High-resolution global weather data
103+
- Hourly forecasts and historical data
104+
- Requires authentication
105+
106+
### WiscoNet
107+
- Wisconsin mesonet (~100 stations)
108+
- Daily weather observations
109+
- Public API access
110+
111+
---
112+
113+
## Response Format
114+
115+
All outputs are returned as **GeoJSON FeatureCollections**, including:
116+
117+
- Weather variables
118+
- Disease risk scores
119+
- Biomass predictions
120+
- Station metadata
121+
122+
---
123+
124+
## Performance Features
125+
126+
- Async multi-station processing
127+
- Cached weather and station data (6h–7d TTL)
128+
- Parallel risk computation
129+
- Optimized data aggregation pipeline
130+
131+
---
132+
133+
## Setup
134+
135+
```bash
136+
git clone <repo>
137+
cd ag_forecasting_api
138+
139+
python -m venv .venv
140+
source .venv/bin/activate
141+
142+
pip install -r requirements.txt
143+
144+
uvicorn app:app --reload
145+
```

applications/index.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Applications
2+
3+
We are building OL to support a wide range of applications with minimal changes required from those applications. Our approach is to port more real-world workloads and let their needs drive incremental improvements to the platform.
4+
5+
## Want to deploy FastAPI apps on OpenLambda? Just ASGI us how.
6+
7+
In this post, we look at an agricultural forecasting application and an ASGI-based web service. The ag app is a natural fit for serverless because it is fundamentally stateless: results can be regenerated on demand from underlying data rather than relying on persistent runtime state. This also influenced the choice of FastAPI for a modern, async-friendly interface.
8+
To situate ASGI, it builds on the long history of WSGI-based Python web serving, where earlier work (including Jaime’s contributions) helped shape synchronous server patterns. ASGI extends this model with native async support, enabling higher concurrency and better I/O utilization, but requiring deeper runtime integration.
9+
A broader design question is whether it is beneficial to consolidate multiple functions into a single Lambda-like unit. We believe it is: co-locating functions enables opportunistic state reuse, faster warm starts, and reduced overhead.
10+
On the implementation side, OL removes its dependency on Tornado and adds optional support for both WSGI and ASGI applications. The ag forecasting app also surfaced practical issues, including /dev/shm constraints when using process pools, which required targeted adjustments.
11+
Looking ahead, improved visibility into execution—such as detecting when applications are blocked on I/O—opens the door to new billing models that distinguish compute from idle waiting time, addressing a longstanding serverless concern.
12+
More broadly, expanding the set of supported applications continues to drive OL’s evolution, alongside features like environment variables and GitHub-based deployments that further reduce friction for onboarding new workloads.
13+
14+
- [Ag Forecasting API](ag-forecasting-api.md)

0 commit comments

Comments
 (0)