|
| 1 | +# Met Office Global Spot Forecast Publisher |
| 2 | + |
| 3 | +Status: initial implementation for the access-gated Met Office Weather DataHub Site-Specific Forecast / Global Spot product. Live validation requires a `MET_OFFICE_GLOBAL_SPOT_API_KEY` subscription key. |
| 4 | + |
| 5 | +This publisher is separate from `publishers/met_office_datahub`, which publishes observed Land Observations station telemetry. Global Spot values are deterministic forecasts for configured points, not readings from physical sensors. |
| 6 | + |
| 7 | +## Source |
| 8 | + |
| 9 | +- Weather DataHub landing page: https://datahub.metoffice.gov.uk/ |
| 10 | +- Site-specific forecast overview: https://datahub.metoffice.gov.uk/docs/g/category/site-specific/overview |
| 11 | +- Site-specific pricing: https://datahub.metoffice.gov.uk/pricing/site-specific |
| 12 | +- Weather DataHub docs: https://datahub.metoffice.gov.uk/docs |
| 13 | + |
| 14 | +The subscribed product context from planning notes is `/sitespecific/v0`, API name `SiteSpecificForecast`, with a free-plan allowance of 360 calls/day. |
| 15 | + |
| 16 | +## CSAPI Model |
| 17 | + |
| 18 | +- One procedure for Met Office Global Spot hourly forecast retrieval. |
| 19 | +- One virtual forecast-point system per curated location. |
| 20 | +- One datastream per selected forecast parameter. |
| 21 | +- One deployment group for curated Global Spot forecast points. |
| 22 | +- Each published observation uses forecast valid time as `phenomenonTime` and preserves issued time, valid time, lead time, parameter, unit, source URL, and forecast type in the result payload. |
| 23 | + |
| 24 | +These resources intentionally avoid claiming the forecast points are physical stations. |
| 25 | + |
| 26 | +## Configuration |
| 27 | + |
| 28 | +Store the API key outside git. In this workspace the preferred local file is `publishers/.env`, which is ignored by git. |
| 29 | + |
| 30 | +```text |
| 31 | +MET_OFFICE_GLOBAL_SPOT_API_KEY=... |
| 32 | +``` |
| 33 | + |
| 34 | +On live hosts, prefer a service environment variable or a root-owned secret file: |
| 35 | + |
| 36 | +```text |
| 37 | +MET_OFFICE_GLOBAL_SPOT_API_KEY_FILE=/etc/os4csapi/secrets/met-office-global-spot.key |
| 38 | +``` |
| 39 | + |
| 40 | +The key file may contain the raw key on the first non-comment line, or one of these assignments: |
| 41 | + |
| 42 | +```text |
| 43 | +MET_OFFICE_GLOBAL_SPOT_API_KEY=... |
| 44 | +MET_OFFICE_SITE_SPECIFIC_FORECAST_API_KEY=... |
| 45 | +MET_OFFICE_DATAHUB_API_KEY=... |
| 46 | +``` |
| 47 | + |
| 48 | +Optional overrides: |
| 49 | + |
| 50 | +```text |
| 51 | +MET_OFFICE_GLOBAL_SPOT_BASE_URL=https://data.hub.api.metoffice.gov.uk/sitespecific/v0 |
| 52 | +MET_OFFICE_GLOBAL_SPOT_HOURLY_PATH=/point/hourly |
| 53 | +MET_OFFICE_GLOBAL_SPOT_FORECAST_HOURS=24 |
| 54 | +MET_OFFICE_DATAHUB_API_KEY_HEADER=apikey |
| 55 | +MET_OFFICE_GLOBAL_SPOT_REQUEST_DELAY=1.0 |
| 56 | +MET_OFFICE_GLOBAL_SPOT_429_BACKOFF=3600 |
| 57 | +``` |
| 58 | + |
| 59 | +`MET_OFFICE_GLOBAL_SPOT_HOURLY_PATH` may be an absolute URL, a path under the base URL, or a format string containing `{lat}`, `{lon}`, `{latitude}`, and `{longitude}`. |
| 60 | + |
| 61 | +## Commands |
| 62 | + |
| 63 | +Probe the authenticated API and inspect response shape: |
| 64 | + |
| 65 | +```bash |
| 66 | +python -m publishers.met_office_global_spot.met_office_global_spot_publisher --probe --locations london-heathrow-area |
| 67 | +``` |
| 68 | + |
| 69 | +Run a dry publisher cycle without POSTing to OSH: |
| 70 | + |
| 71 | +```bash |
| 72 | +python -m publishers.met_office_global_spot.met_office_global_spot_publisher --dry-run --once |
| 73 | +``` |
| 74 | + |
| 75 | +Bootstrap CSAPI resources: |
| 76 | + |
| 77 | +```bash |
| 78 | +python -m publishers.met_office_global_spot.bootstrap_met_office_global_spot |
| 79 | +``` |
| 80 | + |
| 81 | +Run one live publish cycle: |
| 82 | + |
| 83 | +```bash |
| 84 | +python -m publishers.met_office_global_spot.met_office_global_spot_publisher --once |
| 85 | +``` |
| 86 | + |
| 87 | +## Implementation Notes |
| 88 | + |
| 89 | +The initial curated points mirror the Met Office Land Observations demo geography: London Heathrow, Stornoway, and Cairngorm. At one hourly API request per point per cycle, a one-hour cadence uses 72 calls/day, comfortably below the 360 calls/day free-plan allowance. |
| 90 | + |
| 91 | +The runtime client has a configurable endpoint path because public DataHub pages confirm the Site-Specific Forecast / Global Spot product and `/sitespecific/v0` context, but the exact hourly endpoint path should be validated with the live subscribed API before production service installation. |
0 commit comments