- Jupyter Notebook 98.2%
- Python 1.8%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .github/workflows | ||
| images | ||
| notebooks | ||
| scripts | ||
| .gitignore | ||
| AUTHORS.txt | ||
| LICENSE.txt | ||
| poetry.lock | ||
| pyproject.toml | ||
| README.md | ||
🌤️ MeteoSwiss Open Data: Local Forecast Demos
This repository provides Jupyter notebook examples for accessing and visualizing local weather forecasts from MeteoSwiss, released through Switzerland's Open Government Data (OGD) initiative.
Access high-resolution forecasts for ~5,600 points across Switzerland — including weather stations, towns, and postal code areas (PLZ).
🌤️ The Meteogram Notebook
notebooks/Meteogram.ipynb walks you through the full workflow of accessing MeteoSwiss OGD forecast data, from location discovery to visualization. It is structured as a story with one concept per section:
| Section | What you learn |
|---|---|
| 1 · Choose your location | How forecast data is organised by point of interest (POI) |
| 2 · Explore parameters | What MeteoSwiss publishes and how parameters are grouped |
| 3 · Download the data | How to query the STAC API and parse the CSV files |
| 4 · Visualise | How to render a 9-day meteogram |
| 5 · Daily summary | How pictogram codes map to weather descriptions |
Key features:
- Integrated POI search — find your location by name or ZIP code directly in the notebook
- 9-day forecast horizon — hourly data combined with daily summaries
- Metadata-driven — units, labels, and panel groupings resolved automatically from OGD metadata
- Accurate day/night shading — sunrise and sunset computed per location using astronomical calculations
What the meteogram shows
The chart is divided into up to six panels, each covering a different aspect of the forecast:
| Panel | What is shown |
|---|---|
| Temperature | Hourly median temperature at 2 m (°C) with a Q10–Q90 uncertainty band; daily minimum and maximum markers; freezing-level altitude (m a.s.l.) on a secondary axis |
| Precipitation (hourly) | Hourly precipitation amounts (mm) as bars with a Q10–Q90 uncertainty band; precipitation probability (%) as a dashed line on a secondary axis |
| Precipitation (daily) | Daily total precipitation (mm) as bars with Q10–Q90 whiskers |
| Wind | 10-minute mean wind speed and gusts (km/h) with Q10–Q90 uncertainty bands; wind direction shown as arrows every 3 hours |
| Sunshine | Hourly sunshine duration (min) |
| Radiation | Global and diffuse solar radiation (W/m²) |
| Clouds | Low, mid, and high cloud cover (%) as a stacked area chart |
All hourly panels share the same time axis with day/night shading. You can display any subset of panels by setting PANELS = ["Temperature", "Wind"] in the configuration cell.
The plotting code lives in meteogram_plot.py, alongside the notebook. The notebook itself focuses on the data and the API; open the module only if you want to customise the chart.
Daily Weather Summary Table (example output):
| Date | Weather | T min (°C) | T max (°C) | Precip. (mm) |
|---|---|---|---|---|
| Mon 19.05 | partly sunny, thick passing clouds | 12.3 | 22.1 | 0–2 |
| Tue 20.05 | very cloudy, light rain | 10.8 | 19.5 | 3–15 |
| Wed 21.05 | high clouds | 11.1 | 21.3 | 0 |
| Thu 22.05 | mostly sunny, some clouds | 12.5 | 23.0 | 0 |
| Fri 23.05 | overcast, some rain showers | 11.0 | 18.7 | 5–20 |
| Sat 24.05 | sunny | 10.2 | 24.1 | 0 |
| Sun 25.05 | mostly sunny, some clouds | 11.8 | 25.3 | 0 |
| Mon 26.05 | partly sunny, thick passing clouds | 12.0 | 22.8 | 0–3 |
| Tue 27.05 | mostly sunny, some clouds | 13.0 | 24.2 | 0 |
☀️ The Solar Production Notebook
notebooks/SolarProduction.ipynb shows a practical downstream use case for the same OGD data: estimating expected PV (solar panel) output from the 9-day radiation forecast. It reuses the fetch/parse pipeline from the Meteogram notebook, then feeds gre000h0 (global radiation), ods000h0 (diffuse radiation), and tre200h0 (2m temperature) into a pvlib-based model: solar position and panel tilt/azimuth determine plane-of-array irradiance, panel temperature derates the output, and pvlib.pvsystem.pvwatts_dc() converts that into DC power for an illustrative rooftop system.
Note: the system itself is illustrative (a generic capacity/tilt/azimuth, not a real module datasheet), but the underlying physics — solar position, irradiance transposition onto the panel plane, and temperature-dependent PVWatts output — is handled by pvlib rather than a flat radiation-ratio approximation.
The plotting code lives in notebooks/solar_plot.py, following the same notebook/plotting-module split as the Meteogram demo.
🚀 Quick Start
Try it instantly — no installation needed
-
Click the badge
(ctrl/cmd-click to open it in a new tab) to open the notebook in a ready-to-use cloud environment. Wait for the session to start (1–5 minutes).
-
In the file browser on the left, navigate to
opendata-local-weatherforecast-demos/notebooks/ -
Open
Meteogram.ipynb(orSolarProduction.ipynbfor the PV output demo) -
Follow the steps in the notebook you chose.
New to Jupyter notebooks? See the Jupyter documentation for an introduction.
🛠️ Technical Details
Data source
Forecast data is fetched directly from the Federal Geodata Infrastructure STAC API.
- Collection:
ch.meteoschweiz.ogd-local-forecasting - Update cycle: Updated hourly
- Horizon: 9 days (D+0 to D+8)
Repository structure
notebooks/
Meteogram.ipynb # Main notebook — data access and API walkthrough
meteogram_plot.py # Plotting module — all matplotlib code lives here
SolarProduction.ipynb # Downstream demo — PV output estimate from the radiation forecast
solar_plot.py # Plotting module for the Solar Production notebook
Architecture
The notebook is metadata-driven: it reads the OGD parameter CSV at runtime to resolve parameter units, panel groupings, and hourly vs. daily granularity — no hardcoded labels.
The plotting module (meteogram_plot.py) is intentionally separate so the notebook stays focused on explaining the data. It exposes a single entry point:
from meteogram_plot import plot_meteogram
plot_meteogram(df_hourly, df_daily, ...)
💻 Local Installation
git clone https://github.com/MeteoSwiss/opendata-localforecast-demos.git
cd opendata-localforecast-demos
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install poetry
poetry install
poetry run jupyter lab




