Skip to content

Commit fd0b694

Browse files
committed
FIX: realign plot_scan_strategy notebook with recent wradlib, adapt CI
1 parent 5d86d81 commit fd0b694

File tree

3 files changed

+44
-29
lines changed

3 files changed

+44
-29
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ jobs:
5656
python -c "import wradlib; print(wradlib.show_versions())"
5757
- name: Render with pytest
5858
env:
59-
WRADLIB_EARTHDATA_USER: ${{ secrets.WRADLIB_EARTHDATA_USER }}
60-
WRADLIB_EARTHDATA_PASS: ${{ secrets.WRADLIB_EARTHDATA_PASS }}
59+
WRADLIB_EARTHDATA_BEARER_TOKEN: ${{ secrets.WRADLIB_EARTHDATA_BEARER_TOKEN }}
6160
run: |
6261
export WRADLIB_DATA=`realpath $WRADLIB_DATA`
6362
pytest -n auto --verbose --durations=15 --pyargs notebooks
@@ -122,8 +121,7 @@ jobs:
122121
python -c "import wradlib; print(wradlib.show_versions())"
123122
- name: Render with pytest
124123
env:
125-
WRADLIB_EARTHDATA_USER: ${{ secrets.WRADLIB_EARTHDATA_USER }}
126-
WRADLIB_EARTHDATA_PASS: ${{ secrets.WRADLIB_EARTHDATA_PASS }}
124+
WRADLIB_EARTHDATA_BEARER_TOKEN: ${{ secrets.WRADLIB_EARTHDATA_BEARER_TOKEN }}
127125
run: |
128126
export WRADLIB_DATA=`python -c "import os, sys; print(os.path.realpath(sys.argv[1]))" $WRADLIB_DATA`
129127
pytest -n auto --verbose --doctest-modules --durations=15 --cov-report xml:coverage.xml --cov=wradlib --pyargs notebooks
@@ -170,8 +168,7 @@ jobs:
170168
python -c "import wradlib; print(wradlib.show_versions())"
171169
- name: Test with pytest
172170
env:
173-
WRADLIB_EARTHDATA_USER: ${{ secrets.WRADLIB_EARTHDATA_USER }}
174-
WRADLIB_EARTHDATA_PASS: ${{ secrets.WRADLIB_EARTHDATA_PASS }}
171+
WRADLIB_EARTHDATA_BEARER_TOKEN: ${{ secrets.WRADLIB_EARTHDATA_BEARER_TOKEN }}
175172
run: |
176173
export WRADLIB_DATA=`python -c "import os, sys; print(os.path.realpath(sys.argv[1]))" $WRADLIB_DATA`
177174
pytest -n auto --verbose --doctest-modules --durations=15 --cov-report xml:coverage.xml --cov=wradlib --pyargs notebooks

.github/workflows/render_notebooks.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ jobs:
4848
python -c "import wradlib; print(wradlib.show_versions())"
4949
- name: Render with pytest
5050
env:
51-
WRADLIB_EARTHDATA_USER: ${{ secrets.WRADLIB_EARTHDATA_USER }}
52-
WRADLIB_EARTHDATA_PASS: ${{ secrets.WRADLIB_EARTHDATA_PASS }}
51+
WRADLIB_EARTHDATA_BEARER_TOKEN: ${{ secrets.WRADLIB_EARTHDATA_BEARER_TOKEN }}
5352
run: |
5453
export WRADLIB_DATA=`realpath $WRADLIB_DATA`
5554
pytest -n auto --verbose --durations=15 --pyargs notebooks

notebooks/visualisation/wradlib_plot_scan_strategy.ipynb

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@
5555
"source": [
5656
"nrays = 360\n",
5757
"nbins = 150\n",
58-
"range_res = 1000.0\n",
58+
"range_res = 500.0\n",
5959
"ranges = np.arange(nbins) * range_res\n",
6060
"elevs = [28.0, 18.0, 14.0, 11.0, 8.2, 6.0, 4.5, 3.1, 2.0, 1.0]\n",
61-
"sitecoords = (7.07, 50.73, 100.0)\n",
61+
"sitecoords = (-28.1, 38.42, 450.0)\n",
6262
"beamwidth = 1.0"
6363
]
6464
},
@@ -132,7 +132,7 @@
132132
" vert_res=1000.0,\n",
133133
" maxalt=15000.0,\n",
134134
" range_res=5000.0,\n",
135-
" maxrange=200000.0,\n",
135+
" maxrange=75000.0,\n",
136136
" units=\"km\",\n",
137137
")"
138138
]
@@ -181,7 +181,7 @@
181181
"\n",
182182
"A terrain profile can be added to the plot by specifying keyword argument `terrain=True` which automatically downloads neccessary SRTM DEM data and calculates the terrain profile. Additionally the azimuth angle need to be set via keyword argument `az` (it would default to `0`, pointing due north).\n",
183183
"\n",
184-
"For this to work the `WRADLIB_DATA` environment variable has to point a writable folder."
184+
"For this to work the `WRADLIB_DATA` environment variable has to point a writable folder. Aditionally users need an [earthdata account](https://urs.earthdata.nasa.gov/) with bearer token."
185185
]
186186
},
187187
{
@@ -193,7 +193,7 @@
193193
"# only run if environment variables are set\n",
194194
"import os\n",
195195
"\n",
196-
"has_data = os.environ.get(\"WRADLIB_EARTHDATA_USER\", False)"
196+
"has_data = os.environ.get(\"WRADLIB_EARTHDATA_BEARER_TOKEN\", False)"
197197
]
198198
},
199199
{
@@ -204,16 +204,36 @@
204204
"source": [
205205
"if has_data:\n",
206206
" ax = wrl.vis.plot_scan_strategy(\n",
207-
" ranges, elevs, sitecoords, units=\"km\", terrain=True, az=165\n",
207+
" ranges, elevs, sitecoords, units=\"km\", terrain=True, az=10\n",
208208
" )"
209209
]
210210
},
211211
{
212212
"cell_type": "markdown",
213213
"metadata": {},
214214
"source": [
215-
"Instead of downloading the SRTM data a precomputed terrain profile can be plotted. Just for the purpose to show this, the data is extracted from the previous axes.\n",
216-
"The profile should be fed via the same keyword argument `terrain`."
215+
"Instead of downloading the SRTM data a precomputed terrain profile can be plotted. Just for the purpose to show this, the terrain data is calculated via the same mechanism as in plot_scan_strategy. The profile should be fed via the same keyword argument `terrain`."
216+
]
217+
},
218+
{
219+
"cell_type": "code",
220+
"execution_count": null,
221+
"metadata": {},
222+
"outputs": [],
223+
"source": [
224+
"xyz, rad = wrl.georef.spherical_to_xyz(ranges, [10.0], elevs, sitecoords, squeeze=True)\n",
225+
"ll = wrl.georef.reproject(xyz, projection_source=rad)\n",
226+
"# (down-)load srtm data\n",
227+
"ds = wrl.io.get_srtm(\n",
228+
" [ll[..., 0].min(), ll[..., 0].max(), ll[..., 1].min(), ll[..., 1].max()],\n",
229+
")\n",
230+
"rastervalues, rastercoords, proj = wrl.georef.extract_raster_dataset(\n",
231+
" ds, nodata=-32768.0\n",
232+
")\n",
233+
"# map rastervalues to polar grid points\n",
234+
"terrain = wrl.ipol.cart_to_irregular_spline(\n",
235+
" rastercoords, rastervalues, ll[-1, ..., :2], order=3, prefilter=False\n",
236+
")"
217237
]
218238
},
219239
{
@@ -223,9 +243,6 @@
223243
"outputs": [],
224244
"source": [
225245
"if has_data:\n",
226-
" terrain = np.ma.masked_equal(\n",
227-
" ax.collections[0].get_paths()[0].vertices[..., 1], 0\n",
228-
" ).compressed()[2:-1][::-1]\n",
229246
" ax = wrl.vis.plot_scan_strategy(\n",
230247
" ranges, elevs, sitecoords, units=\"km\", terrain=terrain\n",
231248
" )"
@@ -256,7 +273,7 @@
256273
" beamwidth=1.0,\n",
257274
" vert_res=500.0,\n",
258275
" range_res=5000.0,\n",
259-
" maxrange=100000.0,\n",
276+
" maxrange=75000.0,\n",
260277
" units=\"km\",\n",
261278
" terrain=None,\n",
262279
" ax=ax1,\n",
@@ -269,8 +286,8 @@
269286
" beamwidth=1.0,\n",
270287
" vert_res=100.0,\n",
271288
" maxalt=1000.0,\n",
272-
" range_res=500.0,\n",
273-
" maxrange=10000.0,\n",
289+
" range_res=1000.0,\n",
290+
" maxrange=30000.0,\n",
274291
" units=\"km\",\n",
275292
" terrain=None,\n",
276293
" ax=ax2,\n",
@@ -283,10 +300,10 @@
283300
" beamwidth=1.0,\n",
284301
" vert_res=500.0,\n",
285302
" range_res=5000.0,\n",
286-
" maxrange=100000.0,\n",
303+
" maxrange=75000.0,\n",
287304
" units=\"km\",\n",
288305
" terrain=True,\n",
289-
" az=165,\n",
306+
" az=10,\n",
290307
" ax=ax3,\n",
291308
" )\n",
292309
" ax4 = 224\n",
@@ -297,11 +314,11 @@
297314
" beamwidth=1.0,\n",
298315
" vert_res=100.0,\n",
299316
" maxalt=1000.0,\n",
300-
" range_res=500.0,\n",
301-
" maxrange=10000.0,\n",
317+
" range_res=1000.0,\n",
318+
" maxrange=30000.0,\n",
302319
" units=\"km\",\n",
303320
" terrain=True,\n",
304-
" az=165,\n",
321+
" az=10,\n",
305322
" ax=ax4,\n",
306323
" )\n",
307324
" pl.tight_layout()"
@@ -319,7 +336,9 @@
319336
{
320337
"cell_type": "code",
321338
"execution_count": null,
322-
"metadata": {},
339+
"metadata": {
340+
"tags": []
341+
},
323342
"outputs": [],
324343
"source": [
325344
"if has_data:\n",
@@ -341,7 +360,7 @@
341360
"name": "python",
342361
"nbconvert_exporter": "python",
343362
"pygments_lexer": "ipython3",
344-
"version": "3.9.0"
363+
"version": "3.10.5"
345364
}
346365
},
347366
"nbformat": 4,

0 commit comments

Comments
 (0)