|
| 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 | +``` |
0 commit comments