README: refresh Space metadata
Browse files
README.md
CHANGED
|
@@ -1,117 +1,82 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
##
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
-
|
| 37 |
-
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
-
|
| 41 |
-
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
``
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
``
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
``
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
``
|
| 82 |
-
|
| 83 |
-
```
|
| 84 |
-
|
| 85 |
-
See [ims_api_documentation.md](ims_api_documentation.md) for token registration.
|
| 86 |
-
|
| 87 |
-
## Usage
|
| 88 |
-
|
| 89 |
-
### Download IMS weather data
|
| 90 |
-
|
| 91 |
-
```bash
|
| 92 |
-
python -m scripts.download_ims_data --list-channels # show available channels
|
| 93 |
-
python -m scripts.download_ims_data --from 2024-01-01 --to 2024-12-31
|
| 94 |
-
```
|
| 95 |
-
|
| 96 |
-
### Run the pipeline
|
| 97 |
-
|
| 98 |
-
```bash
|
| 99 |
-
python -m scripts.run_pipeline
|
| 100 |
-
```
|
| 101 |
-
|
| 102 |
-
Stage 1: load sensors β filter daytime β keep growing season (MayβSep) β compute Farquhar *A* β save labels.
|
| 103 |
-
Stage 2: load IMS + labels β merge on timestamp β add time features β temporal train/test split β train & evaluate models β save metrics and plots to `outputs/`.
|
| 104 |
-
|
| 105 |
-
### Launch the app
|
| 106 |
-
|
| 107 |
-
```bash
|
| 108 |
-
streamlit run app.py
|
| 109 |
-
```
|
| 110 |
-
|
| 111 |
-
## Key dependencies
|
| 112 |
-
|
| 113 |
-
pandas, numpy, scikit-learn, xgboost, pvlib, matplotlib, seaborn, plotly, streamlit, requests, python-dotenv
|
| 114 |
-
|
| 115 |
-
## Deployment
|
| 116 |
-
|
| 117 |
-
See [DEPLOY.md](DEPLOY.md) for Streamlit Community Cloud deployment instructions. A trimmed sensor sample (`sensors_wide_sample.csv`) is included for cloud use where the full 982 MB dataset is not available.
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: SolarWine API
|
| 3 |
+
emoji: πΏ
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: yellow
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
+
private: true
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# SolarWine API
|
| 12 |
+
|
| 13 |
+
FastAPI backend for the SolarWine agrivoltaic vineyard control system.
|
| 14 |
+
|
| 15 |
+
## Endpoints
|
| 16 |
+
|
| 17 |
+
### Health & Monitoring
|
| 18 |
+
- `GET|HEAD /api/health` β system health (uptime, Redis, TB, IMS, Gemini status)
|
| 19 |
+
- `GET /api/health/data` β data freshness per source (age, ok/degraded)
|
| 20 |
+
- `GET /api/health/data-sources` β per-source green/yellow/red status with thresholds
|
| 21 |
+
|
| 22 |
+
### Weather (IMS Station 43)
|
| 23 |
+
- `GET /api/weather/current` β latest weather readings + data age
|
| 24 |
+
- `GET /api/weather/history?start_date&end_date&format` β historical weather (hourly)
|
| 25 |
+
- `GET /api/weather/forecast` β weather forecast
|
| 26 |
+
|
| 27 |
+
### Vine Sensors (ThingsBoard)
|
| 28 |
+
- `GET /api/sensors/snapshot` β latest readings (treatment vs reference)
|
| 29 |
+
- `GET /api/sensors/history?type&area&hours` β sensor time-series
|
| 30 |
+
- `GET /api/sensors/soil-moisture?hours` β soil moisture history
|
| 31 |
+
- `GET /api/sensors/rain?hours` β rainfall history
|
| 32 |
+
|
| 33 |
+
### Energy
|
| 34 |
+
- `GET /api/energy/current` β current power output (kW)
|
| 35 |
+
- `GET /api/energy/daily/{date}` β daily production + hourly profile
|
| 36 |
+
- `GET /api/energy/history` β energy generation time-series
|
| 37 |
+
- `GET /api/energy/predict/{date}` β predicted daily generation
|
| 38 |
+
|
| 39 |
+
### Photosynthesis
|
| 40 |
+
- `GET /api/photosynthesis/current?model` β current A rate (FvCB or ML)
|
| 41 |
+
- `GET /api/photosynthesis/forecast` β 24h predicted A profile
|
| 42 |
+
|
| 43 |
+
### Control System
|
| 44 |
+
- `GET /api/control/status` β last control loop tick
|
| 45 |
+
- `GET /api/control/plan` β current day-ahead plan
|
| 46 |
+
- `GET /api/control/budget` β energy budget status
|
| 47 |
+
- `GET /api/control/trackers` β tracker angles and modes
|
| 48 |
+
|
| 49 |
+
### Chatbot (Gemini AI)
|
| 50 |
+
- `POST /api/chatbot/message` β send message to vineyard advisor
|
| 51 |
+
- `POST /api/chatbot/feedback` β submit feedback on response
|
| 52 |
+
- `GET /api/chatbot/briefing` β current system status briefing
|
| 53 |
+
|
| 54 |
+
### Biology
|
| 55 |
+
- `GET /api/biology/phenology` β current growth stage
|
| 56 |
+
- `GET /api/biology/rules` β all biology rules
|
| 57 |
+
- `GET /api/biology/rules/{name}` β single rule detail
|
| 58 |
+
- `GET /api/biology/chill-units?season_start` β accumulated chill units
|
| 59 |
+
|
| 60 |
+
### Auth
|
| 61 |
+
- `POST /api/auth/login` β JWT token (guest mode when JWT_SECRET unset)
|
| 62 |
+
|
| 63 |
+
### Events
|
| 64 |
+
- `GET /api/events/stream` β SSE stream for live frontend updates
|
| 65 |
+
|
| 66 |
+
Interactive docs at `/docs`.
|
| 67 |
+
|
| 68 |
+
## Environment Variables
|
| 69 |
+
|
| 70 |
+
| Variable | Required | Description |
|
| 71 |
+
|----------|----------|-------------|
|
| 72 |
+
| `IMS_API_TOKEN` | Yes | IMS weather API token |
|
| 73 |
+
| `THINGSBOARD_HOST` | Yes | ThingsBoard server URL |
|
| 74 |
+
| `THINGSBOARD_USERNAME` | Yes | ThingsBoard login |
|
| 75 |
+
| `THINGSBOARD_PASSWORD` | Yes | ThingsBoard password |
|
| 76 |
+
| `GOOGLE_API_KEY` | No | Gemini AI for chatbot/advisor |
|
| 77 |
+
| `JWT_SECRET` | No | JWT signing key (guest mode if unset) |
|
| 78 |
+
| `ADMIN_PASSWORD` | No | Login password |
|
| 79 |
+
| `REDIS_URL` | No | Upstash Redis for shared cache |
|
| 80 |
+
| `SENTRY_DSN` | No | Sentry error tracking |
|
| 81 |
+
| `SMTP_HOST` | No | Email alerts (with ALERT_EMAIL_TO) |
|
| 82 |
+
| `ALERT_EMAIL_TO` | No | Alert recipient email(s) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|