diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1489148a..87cdfb94 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/render_notebooks.yml b/.github/workflows/render_notebooks.yml index a346d2f9..d7084e99 100644 --- a/.github/workflows/render_notebooks.yml +++ b/.github/workflows/render_notebooks.yml @@ -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 diff --git a/notebooks/visualisation/wradlib_plot_scan_strategy.ipynb b/notebooks/visualisation/wradlib_plot_scan_strategy.ipynb index ebceb278..59f045af 100644 --- a/notebooks/visualisation/wradlib_plot_scan_strategy.ipynb +++ b/notebooks/visualisation/wradlib_plot_scan_strategy.ipynb @@ -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" ] }, @@ -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", ")" ] @@ -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." ] }, { @@ -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)" ] }, { @@ -204,7 +204,7 @@ "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", " )" ] }, @@ -212,8 +212,28 @@ "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", + ")" ] }, { @@ -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", " )" @@ -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", @@ -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", @@ -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", @@ -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()" @@ -319,7 +336,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "if has_data:\n", @@ -341,7 +360,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.0" + "version": "3.10.5" } }, "nbformat": 4,