Skip to content

Commit

Permalink
FIX: realign plot_scan_strategy notebook with recent wradlib, adapt CI
Browse files Browse the repository at this point in the history
  • Loading branch information
kmuehlbauer committed Aug 11, 2022
1 parent 5d86d81 commit fd0b694
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 29 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ jobs:
python -c "import wradlib; print(wradlib.show_versions())"
- name: Render with pytest
env:
WRADLIB_EARTHDATA_USER: ${{ secrets.WRADLIB_EARTHDATA_USER }}
WRADLIB_EARTHDATA_PASS: ${{ secrets.WRADLIB_EARTHDATA_PASS }}
WRADLIB_EARTHDATA_BEARER_TOKEN: ${{ secrets.WRADLIB_EARTHDATA_BEARER_TOKEN }}
run: |
export WRADLIB_DATA=`realpath $WRADLIB_DATA`
pytest -n auto --verbose --durations=15 --pyargs notebooks
Expand Down Expand Up @@ -122,8 +121,7 @@ jobs:
python -c "import wradlib; print(wradlib.show_versions())"
- name: Render with pytest
env:
WRADLIB_EARTHDATA_USER: ${{ secrets.WRADLIB_EARTHDATA_USER }}
WRADLIB_EARTHDATA_PASS: ${{ secrets.WRADLIB_EARTHDATA_PASS }}
WRADLIB_EARTHDATA_BEARER_TOKEN: ${{ secrets.WRADLIB_EARTHDATA_BEARER_TOKEN }}
run: |
export WRADLIB_DATA=`python -c "import os, sys; print(os.path.realpath(sys.argv[1]))" $WRADLIB_DATA`
pytest -n auto --verbose --doctest-modules --durations=15 --cov-report xml:coverage.xml --cov=wradlib --pyargs notebooks
Expand Down Expand Up @@ -170,8 +168,7 @@ jobs:
python -c "import wradlib; print(wradlib.show_versions())"
- name: Test with pytest
env:
WRADLIB_EARTHDATA_USER: ${{ secrets.WRADLIB_EARTHDATA_USER }}
WRADLIB_EARTHDATA_PASS: ${{ secrets.WRADLIB_EARTHDATA_PASS }}
WRADLIB_EARTHDATA_BEARER_TOKEN: ${{ secrets.WRADLIB_EARTHDATA_BEARER_TOKEN }}
run: |
export WRADLIB_DATA=`python -c "import os, sys; print(os.path.realpath(sys.argv[1]))" $WRADLIB_DATA`
pytest -n auto --verbose --doctest-modules --durations=15 --cov-report xml:coverage.xml --cov=wradlib --pyargs notebooks
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/render_notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ jobs:
python -c "import wradlib; print(wradlib.show_versions())"
- name: Render with pytest
env:
WRADLIB_EARTHDATA_USER: ${{ secrets.WRADLIB_EARTHDATA_USER }}
WRADLIB_EARTHDATA_PASS: ${{ secrets.WRADLIB_EARTHDATA_PASS }}
WRADLIB_EARTHDATA_BEARER_TOKEN: ${{ secrets.WRADLIB_EARTHDATA_BEARER_TOKEN }}
run: |
export WRADLIB_DATA=`realpath $WRADLIB_DATA`
pytest -n auto --verbose --durations=15 --pyargs notebooks
Expand Down
61 changes: 40 additions & 21 deletions notebooks/visualisation/wradlib_plot_scan_strategy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@
"source": [
"nrays = 360\n",
"nbins = 150\n",
"range_res = 1000.0\n",
"range_res = 500.0\n",
"ranges = np.arange(nbins) * range_res\n",
"elevs = [28.0, 18.0, 14.0, 11.0, 8.2, 6.0, 4.5, 3.1, 2.0, 1.0]\n",
"sitecoords = (7.07, 50.73, 100.0)\n",
"sitecoords = (-28.1, 38.42, 450.0)\n",
"beamwidth = 1.0"
]
},
Expand Down Expand Up @@ -132,7 +132,7 @@
" vert_res=1000.0,\n",
" maxalt=15000.0,\n",
" range_res=5000.0,\n",
" maxrange=200000.0,\n",
" maxrange=75000.0,\n",
" units=\"km\",\n",
")"
]
Expand Down Expand Up @@ -181,7 +181,7 @@
"\n",
"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",
"\n",
"For this to work the `WRADLIB_DATA` environment variable has to point a writable folder."
"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."
]
},
{
Expand All @@ -193,7 +193,7 @@
"# only run if environment variables are set\n",
"import os\n",
"\n",
"has_data = os.environ.get(\"WRADLIB_EARTHDATA_USER\", False)"
"has_data = os.environ.get(\"WRADLIB_EARTHDATA_BEARER_TOKEN\", False)"
]
},
{
Expand All @@ -204,16 +204,36 @@
"source": [
"if has_data:\n",
" ax = wrl.vis.plot_scan_strategy(\n",
" ranges, elevs, sitecoords, units=\"km\", terrain=True, az=165\n",
" ranges, elevs, sitecoords, units=\"km\", terrain=True, az=10\n",
" )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"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",
"The profile should be fed via the same keyword argument `terrain`."
"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`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"xyz, rad = wrl.georef.spherical_to_xyz(ranges, [10.0], elevs, sitecoords, squeeze=True)\n",
"ll = wrl.georef.reproject(xyz, projection_source=rad)\n",
"# (down-)load srtm data\n",
"ds = wrl.io.get_srtm(\n",
" [ll[..., 0].min(), ll[..., 0].max(), ll[..., 1].min(), ll[..., 1].max()],\n",
")\n",
"rastervalues, rastercoords, proj = wrl.georef.extract_raster_dataset(\n",
" ds, nodata=-32768.0\n",
")\n",
"# map rastervalues to polar grid points\n",
"terrain = wrl.ipol.cart_to_irregular_spline(\n",
" rastercoords, rastervalues, ll[-1, ..., :2], order=3, prefilter=False\n",
")"
]
},
{
Expand All @@ -223,9 +243,6 @@
"outputs": [],
"source": [
"if has_data:\n",
" terrain = np.ma.masked_equal(\n",
" ax.collections[0].get_paths()[0].vertices[..., 1], 0\n",
" ).compressed()[2:-1][::-1]\n",
" ax = wrl.vis.plot_scan_strategy(\n",
" ranges, elevs, sitecoords, units=\"km\", terrain=terrain\n",
" )"
Expand Down Expand Up @@ -256,7 +273,7 @@
" beamwidth=1.0,\n",
" vert_res=500.0,\n",
" range_res=5000.0,\n",
" maxrange=100000.0,\n",
" maxrange=75000.0,\n",
" units=\"km\",\n",
" terrain=None,\n",
" ax=ax1,\n",
Expand All @@ -269,8 +286,8 @@
" beamwidth=1.0,\n",
" vert_res=100.0,\n",
" maxalt=1000.0,\n",
" range_res=500.0,\n",
" maxrange=10000.0,\n",
" range_res=1000.0,\n",
" maxrange=30000.0,\n",
" units=\"km\",\n",
" terrain=None,\n",
" ax=ax2,\n",
Expand All @@ -283,10 +300,10 @@
" beamwidth=1.0,\n",
" vert_res=500.0,\n",
" range_res=5000.0,\n",
" maxrange=100000.0,\n",
" maxrange=75000.0,\n",
" units=\"km\",\n",
" terrain=True,\n",
" az=165,\n",
" az=10,\n",
" ax=ax3,\n",
" )\n",
" ax4 = 224\n",
Expand All @@ -297,11 +314,11 @@
" beamwidth=1.0,\n",
" vert_res=100.0,\n",
" maxalt=1000.0,\n",
" range_res=500.0,\n",
" maxrange=10000.0,\n",
" range_res=1000.0,\n",
" maxrange=30000.0,\n",
" units=\"km\",\n",
" terrain=True,\n",
" az=165,\n",
" az=10,\n",
" ax=ax4,\n",
" )\n",
" pl.tight_layout()"
Expand All @@ -319,7 +336,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"if has_data:\n",
Expand All @@ -341,7 +360,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.0"
"version": "3.10.5"
}
},
"nbformat": 4,
Expand Down

0 comments on commit fd0b694

Please sign in to comment.