Skip to content

Commit 9da4386

Browse files
Initial commit
1 parent 0a109f9 commit 9da4386

15 files changed

Lines changed: 13737 additions & 1 deletion

.github/workflows/book.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: deploy-book
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: pages
10+
cancel-in-progress: true
11+
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
jobs:
18+
deploy-book:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v6
23+
24+
- name: Set up Python 3.11
25+
uses: actions/setup-python@v6
26+
with:
27+
python-version: 3.11
28+
cache: pip
29+
30+
- name: Install dependencies
31+
run: |
32+
python -m pip install --upgrade pip
33+
pip install -r requirements.txt
34+
pip show jupyter-book
35+
jupyter-book --version
36+
37+
- name: Build the book
38+
run: |
39+
jupyter book build
40+
ls -la _build/html
41+
42+
- name: Upload artifact
43+
uses: actions/upload-pages-artifact@v4
44+
with:
45+
path: "_build/html"
46+
47+
- name: Deploy to GitHub Pages
48+
id: deployment
49+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*.pyo
5+
*.pyd
6+
.Python
7+
8+
# Virtual environment
9+
.venv/
10+
11+
# Jupyter
12+
.ipynb_checkpoints/
13+
*.ipynb_checkpoints
14+
15+
# Jupyter Book v2 build output
16+
_build/
17+
18+
# Trained model artifacts
19+
*.pt
20+
*.pt.ckpt
21+
*.pkl
22+
23+
# Data files
24+
data/
25+
26+
# Environment variables
27+
.env
28+
29+
# macOS
30+
.DS_Store
31+
32+
# Editor
33+
.vscode/
34+
.idea/

00_load-dwd-data.ipynb

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"id": "c93fb23f",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"# Wetterdienst: https://pypi.org/project/wetterdienst/\n",
11+
"from wetterdienst import Settings\n",
12+
"from wetterdienst.provider.dwd.observation import DwdObservationRequest, DwdObservationMetadata"
13+
]
14+
},
15+
{
16+
"cell_type": "markdown",
17+
"id": "6906bc4d",
18+
"metadata": {},
19+
"source": [
20+
"DWD - Stations with station IDs: https://www.dwd.de/DE/leistungen/klimadatendeutschland/stationsuebersicht.html\n"
21+
]
22+
},
23+
{
24+
"cell_type": "code",
25+
"execution_count": 2,
26+
"id": "c15656a2",
27+
"metadata": {},
28+
"outputs": [
29+
{
30+
"name": "stdout",
31+
"output_type": "stream",
32+
"text": [
33+
"<class 'pandas.core.frame.DataFrame'>\n",
34+
"DatetimeIndex: 91315 entries, 1975-01-01 to 2024-12-31\n",
35+
"Data columns (total 15 columns):\n",
36+
" # Column Non-Null Count Dtype \n",
37+
"--- ------ -------------- ----- \n",
38+
" 0 station_id 91315 non-null object \n",
39+
" 1 wind_gust_max 86857 non-null float64\n",
40+
" 2 wind_speed 90284 non-null float64\n",
41+
" 3 precipitation_height 90913 non-null float64\n",
42+
" 4 precipitation_form 91086 non-null float64\n",
43+
" 5 sunshine_duration 91054 non-null float64\n",
44+
" 6 snow_depth 89281 non-null float64\n",
45+
" 7 cloud_cover_total 91179 non-null float64\n",
46+
" 8 pressure_vapor 91260 non-null float64\n",
47+
" 9 pressure_air_site 91289 non-null float64\n",
48+
" 10 temperature_air_mean_2m 91304 non-null float64\n",
49+
" 11 humidity 91260 non-null float64\n",
50+
" 12 temperature_air_max_2m 91304 non-null float64\n",
51+
" 13 temperature_air_min_2m 91304 non-null float64\n",
52+
" 14 temperature_air_min_0_05m 72718 non-null float64\n",
53+
"dtypes: float64(14), object(1)\n",
54+
"memory usage: 11.1+ MB\n"
55+
]
56+
}
57+
],
58+
"source": [
59+
"# Load daily climate summary data from ...\n",
60+
"# 183 - Arkona\n",
61+
"# 722 - Brocken\n",
62+
"# 2667 - Köln-Bonn\n",
63+
"# 2932 - Leipzig\n",
64+
"# 5792 - Zugspitze\n",
65+
"# ... for years 1975-2024 \n",
66+
"request = DwdObservationRequest(\n",
67+
" parameters=DwdObservationMetadata.daily.climate_summary,\n",
68+
" start_date=\"1975-01-01\",\n",
69+
" end_date=\"2024-12-31\",\n",
70+
" settings=Settings(\n",
71+
" ts_shape=\"wide\", # tidy data\n",
72+
" ts_humanize=True, # humanized parameters\n",
73+
" ts_convert_units=False # do not convert values to SI units\n",
74+
" )\n",
75+
").filter_by_station_id([183, 722, 2667, 2932, 5792])\n",
76+
"\n",
77+
"# Load values\n",
78+
"df = request.values.all().df.to_pandas().set_index(\"date\")\n",
79+
"# Drop columns with quality flags and just on distinct value\n",
80+
"df_selected = df.loc[:, ~df.columns.str.startswith(\"qn_\") & (df.nunique() != 1)]\n",
81+
"# Remove timezone from datetime index, this triggers warnings in some tsa libraries\n",
82+
"df_selected.index = df_selected.index.tz_convert(None)\n",
83+
"df_selected.info()"
84+
]
85+
},
86+
{
87+
"cell_type": "code",
88+
"execution_count": 4,
89+
"id": "0d5d838c",
90+
"metadata": {},
91+
"outputs": [],
92+
"source": [
93+
"# Save data station-wise\n",
94+
"for station_id in df_selected.station_id.unique():\n",
95+
" station_data = df_selected[df_selected.station_id == station_id]\n",
96+
" station_data = station_data.drop(columns=[\"station_id\"])\n",
97+
" station_data.to_csv(f\"data/dwd_{station_id}_climate.csv\", sep=';', index=True)"
98+
]
99+
}
100+
],
101+
"metadata": {
102+
"kernelspec": {
103+
"display_name": "tsa-overview (3.14.0)",
104+
"language": "python",
105+
"name": "python3"
106+
},
107+
"language_info": {
108+
"codemirror_mode": {
109+
"name": "ipython",
110+
"version": 3
111+
},
112+
"file_extension": ".py",
113+
"mimetype": "text/x-python",
114+
"name": "python",
115+
"nbconvert_exporter": "python",
116+
"pygments_lexer": "ipython3",
117+
"version": "3.13.0"
118+
}
119+
},
120+
"nbformat": 4,
121+
"nbformat_minor": 5
122+
}

01_time-series-properties.ipynb

Lines changed: 980 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)