Skip to content

Commit b1f696a

Browse files
egoudenkmuehlbauer
andauthored
NEW: compositing examples with new default binning transformation (#101)
* NEW: compositing examples with new default binning transformation * MIN: lint and clean * FIX: ubuntu version in CI --------- Co-authored-by: Edouard Goudenhoofdt <egouden@outlook.com> Co-authored-by: Kai Mühlbauer <kmuehlbauer@wradlib.org>
1 parent cd99f6e commit b1f696a

5 files changed

Lines changed: 493 additions & 2 deletions

File tree

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ concurrency:
1818
jobs:
1919
build_0:
2020
name: wradlib notebooks - linux
21-
runs-on: ubuntu-20.04
21+
runs-on: ubuntu-latest
2222
defaults:
2323
run:
2424
shell: bash -l {0}

notebooks/compositing.ipynb

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {
6+
"nbsphinx": "hidden"
7+
},
8+
"source": [
9+
"This notebook is part of the $\\omega radlib$ documentation: https://docs.wradlib.org.\n",
10+
"\n",
11+
"Copyright (c) $\\omega radlib$ developers.\n",
12+
"Distributed under the MIT License. See LICENSE.txt for more info."
13+
]
14+
},
15+
{
16+
"cell_type": "markdown",
17+
"metadata": {},
18+
"source": [
19+
"# Compositing"
20+
]
21+
},
22+
{
23+
"cell_type": "markdown",
24+
"metadata": {},
25+
"source": [
26+
"This section provides a collection of examples related to the compositing of radar data.\n"
27+
]
28+
},
29+
{
30+
"cell_type": "markdown",
31+
"metadata": {
32+
"nbsphinx-toctree": {
33+
"hidden": true,
34+
"maxdepth": 2
35+
}
36+
},
37+
"source": [
38+
"- [Production of a maximum reflectivity composite](compositing/max_reflectivity.ipynb)"
39+
]
40+
},
41+
{
42+
"cell_type": "markdown",
43+
"metadata": {
44+
"nbsphinx-toctree": {
45+
"hidden": true,
46+
"maxdepth": 2
47+
}
48+
},
49+
"source": [
50+
"- [Comparison of transformation methods](compositing/transform.ipynb)"
51+
]
52+
},
53+
{
54+
"cell_type": "code",
55+
"execution_count": null,
56+
"metadata": {},
57+
"outputs": [],
58+
"source": []
59+
}
60+
],
61+
"metadata": {
62+
"celltoolbar": "Edit Metadata",
63+
"language_info": {
64+
"codemirror_mode": {
65+
"name": "ipython",
66+
"version": 3
67+
},
68+
"file_extension": ".py",
69+
"mimetype": "text/x-python",
70+
"name": "python",
71+
"nbconvert_exporter": "python",
72+
"pygments_lexer": "ipython3",
73+
"version": "3.13.3"
74+
},
75+
"toc": {
76+
"colors": {
77+
"hover_highlight": "#DAA520",
78+
"navigate_num": "#000000",
79+
"navigate_text": "#333333",
80+
"running_highlight": "#FF0000",
81+
"selected_highlight": "#FFD700",
82+
"sidebar_border": "#EEEEEE",
83+
"wrapper_background": "#FFFFFF"
84+
},
85+
"moveMenuLeft": true,
86+
"nav_menu": {
87+
"height": "49px",
88+
"width": "252px"
89+
},
90+
"navigate_menu": true,
91+
"number_sections": false,
92+
"sideBar": true,
93+
"threshold": 4,
94+
"toc_cell": false,
95+
"toc_section_display": "block",
96+
"toc_window_display": false,
97+
"widenNotebook": false
98+
}
99+
},
100+
"nbformat": 4,
101+
"nbformat_minor": 4
102+
}
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {
6+
"nbsphinx": "hidden"
7+
},
8+
"source": [
9+
"This notebook is part of the $\\omega radlib$ documentation: https://docs.wradlib.org.\n",
10+
"\n",
11+
"Copyright (c) $\\omega radlib$ developers.\n",
12+
"Distributed under the MIT License. See LICENSE.txt for more info."
13+
]
14+
},
15+
{
16+
"cell_type": "markdown",
17+
"metadata": {},
18+
"source": [
19+
"# Production of a maximum reflectivity composite"
20+
]
21+
},
22+
{
23+
"cell_type": "code",
24+
"execution_count": null,
25+
"metadata": {},
26+
"outputs": [],
27+
"source": [
28+
"import os\n",
29+
"import numpy as np\n",
30+
"import wradlib\n",
31+
"import xarray\n",
32+
"import xradar\n",
33+
"import matplotlib.pyplot as plt"
34+
]
35+
},
36+
{
37+
"cell_type": "markdown",
38+
"metadata": {},
39+
"source": [
40+
"Read volume reflectivity measurements from the three belgian radars"
41+
]
42+
},
43+
{
44+
"cell_type": "code",
45+
"execution_count": null,
46+
"metadata": {},
47+
"outputs": [],
48+
"source": [
49+
"from wradlib_data import DATASETS\n",
50+
"\n",
51+
"filenames = [\"bejab.pvol.hdf\", \"bewid.pvol.hdf\", \"behel.pvol.hdf\"]\n",
52+
"paths = [DATASETS.fetch(f\"hdf5/{f}\") for f in filenames]\n",
53+
"volumes = [xradar.io.backends.odim.open_odim_datatree(p) for p in paths]"
54+
]
55+
},
56+
{
57+
"cell_type": "markdown",
58+
"metadata": {},
59+
"source": [
60+
"Define a raster dataset with a window including the 3 radars, a pixel size of 1km and the standard European projection."
61+
]
62+
},
63+
{
64+
"cell_type": "code",
65+
"execution_count": null,
66+
"metadata": {},
67+
"outputs": [],
68+
"source": [
69+
"crs = wradlib.georef.epsg_to_osr(3035)\n",
70+
"bounds = [0, 8, 48, 53]\n",
71+
"bounds = wradlib.georef.project_bounds(bounds, crs)\n",
72+
"print(bounds)\n",
73+
"size = 1000\n",
74+
"raster = wradlib.georef.create_raster_xarray(crs, bounds, size)"
75+
]
76+
},
77+
{
78+
"cell_type": "markdown",
79+
"metadata": {},
80+
"source": [
81+
"Define a geographic raster dataset with a window including the 3 radars, and an approximate pixel size of 1km. "
82+
]
83+
},
84+
{
85+
"cell_type": "code",
86+
"execution_count": null,
87+
"metadata": {},
88+
"outputs": [],
89+
"source": [
90+
"crs = wradlib.georef.epsg_to_osr(3035)\n",
91+
"bounds = [0, 8, 48, 53]\n",
92+
"size = 1000\n",
93+
"raster2 = wradlib.georef.create_raster_geographic(bounds, size, size_in_meters=True)"
94+
]
95+
},
96+
{
97+
"cell_type": "markdown",
98+
"metadata": {},
99+
"source": [
100+
"Combine lowest radar sweep into a raster image for each radar"
101+
]
102+
},
103+
{
104+
"cell_type": "code",
105+
"execution_count": null,
106+
"metadata": {},
107+
"outputs": [],
108+
"source": [
109+
"# raster = raster2\n",
110+
"metadata = xradar.model.required_sweep_metadata_vars\n",
111+
"rasters = []\n",
112+
"for volume in volumes:\n",
113+
" sweep = volume[\"sweep_0\"].to_dataset()\n",
114+
" sweep = sweep[[\"DBZH\"] + list(metadata)]\n",
115+
" sweep = sweep.sel(range=slice(0, 200e3))\n",
116+
" raster_sweep = wradlib.comp.sweep_to_raster(sweep, raster)\n",
117+
" rasters.append(raster_sweep)\n",
118+
"\n",
119+
"for raster in rasters:\n",
120+
" raster = raster.drop_vars(\"spatial_ref\")\n",
121+
" raster[\"DBZH\"].plot(vmin=0, vmax=50)\n",
122+
" plt.axis(\"equal\")\n",
123+
" plt.show()"
124+
]
125+
},
126+
{
127+
"cell_type": "markdown",
128+
"metadata": {},
129+
"source": [
130+
"Take the maximum value from the 3 rasters"
131+
]
132+
},
133+
{
134+
"cell_type": "code",
135+
"execution_count": null,
136+
"metadata": {},
137+
"outputs": [],
138+
"source": [
139+
"rasters_concat = xarray.concat(rasters, dim=\"sweep\")\n",
140+
"comp = rasters_concat.max(dim=\"sweep\", keep_attrs=True)\n",
141+
"comp[\"DBZH\"].plot(vmin=0, vmax=50)\n",
142+
"with open(\"comp.nc\", \"wb\") as f:\n",
143+
" comp.to_netcdf(f)\n",
144+
"!gdalinfo comp.nc\n",
145+
"ds = xarray.open_dataset(\"comp.nc\", engine=\"rasterio\")\n",
146+
"comp = comp.drop_vars(\"spatial_ref\")\n",
147+
"plt.axis(\"equal\")\n",
148+
"plt.show()"
149+
]
150+
},
151+
{
152+
"cell_type": "code",
153+
"execution_count": null,
154+
"metadata": {},
155+
"outputs": [],
156+
"source": []
157+
}
158+
],
159+
"metadata": {
160+
"language_info": {
161+
"codemirror_mode": {
162+
"name": "ipython",
163+
"version": 3
164+
},
165+
"file_extension": ".py",
166+
"mimetype": "text/x-python",
167+
"name": "python",
168+
"nbconvert_exporter": "python",
169+
"pygments_lexer": "ipython3",
170+
"version": "3.13.3"
171+
},
172+
"toc": {
173+
"colors": {
174+
"hover_highlight": "#DAA520",
175+
"navigate_num": "#000000",
176+
"navigate_text": "#333333",
177+
"running_highlight": "#FF0000",
178+
"selected_highlight": "#FFD700",
179+
"sidebar_border": "#EEEEEE",
180+
"wrapper_background": "#FFFFFF"
181+
},
182+
"moveMenuLeft": true,
183+
"nav_menu": {
184+
"height": "47px",
185+
"width": "252px"
186+
},
187+
"navigate_menu": true,
188+
"number_sections": false,
189+
"sideBar": true,
190+
"threshold": 4,
191+
"toc_cell": false,
192+
"toc_section_display": "block",
193+
"toc_window_display": false,
194+
"widenNotebook": false
195+
}
196+
},
197+
"nbformat": 4,
198+
"nbformat_minor": 4
199+
}

0 commit comments

Comments
 (0)