<jupyter_start><jupyter_text>This notebook is part of the $\omega radlib$ documentation: https://docs.wradlib.org.Copyright (c) $\omega radlib$ developers.Distributed under the MIT License. See LICENSE.txt for more info.  Plotting Radar Scan StrategyThis notebook shows how to plot the scan strategy of a specific radar.<jupyter_code>import wradlib as wrl
import matplotlib.pyplot as pl
import matplotlib as mpl
import warnings
warnings.filterwarnings('ignore')
try:
    get_ipython().magic("matplotlib inline")
except:
    pl.ion()
import numpy as np<jupyter_output><empty_output><jupyter_text>Setup Radar details<jupyter_code>nrays = 360
nbins = 150
range_res = 1000.
ranges = np.arange(nbins) * range_res
elevs = [28.0, 18.0, 14.0, 11.0, 8.2, 6.0, 4.5, 3.1, 2.0, 1.0]
sitecoords = (7.07, 50.73, 100.0)
beamwidth = 1.0<jupyter_output><empty_output><jupyter_text>Standard PlotThis works with some assumptions:- beamwidth = 1.0- vert_res = 500.0- maxalt = 10000.0- units = 'm'<jupyter_code>ax = wrl.vis.plot_scan_strategy(ranges, elevs, sitecoords)<jupyter_output><empty_output><jupyter_text>Change Plot Style  Plot Axes in KilometerTo quickly change the Axes tickmarks and labels from meter to kilometer, just add keyword argument `units='km'`.<jupyter_code>ax = wrl.vis.plot_scan_strategy(ranges, elevs, sitecoords, units='km')<jupyter_output><empty_output><jupyter_text>Change Axes Resolution and RangeThe horizontal and vertical Axes Resolution and Range can be set by feeding keyword arguments `vert_res`, `maxalt`, `range_res`, `max_range` in meter.<jupyter_code>ax = wrl.vis.plot_scan_strategy(ranges, elevs, sitecoords, vert_res=1000., maxalt=15000., range_res=5000., maxrange=200000., units='km')<jupyter_output><empty_output><jupyter_text>Change BeamwidthThe beamwidth defaults to 1.0°. It can specified by keyword argument `beamwidth`.<jupyter_code>ax = wrl.vis.plot_scan_strategy(ranges, elevs, sitecoords, beamwidth=0.5, units='km')<jupyter_output><empty_output><jupyter_text>Change ColorsThe colorcycle can be changed from the default `tab10` to any colormap available in matplotlib. If the output is intended to be plotted as grey-scale, the use of the Perceptually Uniform Sequential colormaps (eg. `viridis`, `cividis`) is suggested.<jupyter_code>ax = wrl.vis.plot_scan_strategy(ranges, elevs, sitecoords, units='km', cmap='viridis')<jupyter_output><empty_output><jupyter_text>Plot TerrainA 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).For this to work the `WRADLIB_DATA` environment variable has to point a writable folder.<jupyter_code># only run if environment variables are set
import os
has_data = os.environ.get("WRADLIB_EARTHDATA_USER", False)
if has_data:
    ax = wrl.vis.plot_scan_strategy(ranges, elevs, sitecoords, units='km', terrain=True, az=165)<jupyter_output><empty_output><jupyter_text>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.The profile should be fed via the same keyword argument `terrain`.<jupyter_code>if has_data:
    terrain = np.ma.masked_equal(ax.collections[0].get_paths()[0].vertices[..., 1], 0).compressed()[2:-1][::-1]
    ax = wrl.vis.plot_scan_strategy(ranges, elevs, sitecoords, units='km', terrain=terrain)<jupyter_output><empty_output><jupyter_text>Plotting in gridsThe keyword argument `ax` can be used to specify the axes to plot in.<jupyter_code>if has_data:
    fig = pl.figure(figsize=(16, 8))
    ax1 = 221
    ax1 = wrl.vis.plot_scan_strategy(ranges, elevs, sitecoords, beamwidth=1.0, vert_res=500., range_res=5000., maxrange=100000., units='km', 
                                     terrain=None, ax=ax1)
    ax2 = 222
    ax2 = wrl.vis.plot_scan_strategy(ranges, elevs, sitecoords, beamwidth=1.0, vert_res=100., maxalt=1000., range_res=500., maxrange=10000., 
                                     units='km', terrain=None, ax=ax2)
    ax3 = 223
    ax3 = wrl.vis.plot_scan_strategy(ranges, elevs, sitecoords, beamwidth=1.0, vert_res=500., range_res=5000., maxrange=100000., units='km', 
                                     terrain=True, az=165, ax=ax3)
    ax4 = 224
    ax4 = wrl.vis.plot_scan_strategy(ranges, elevs, sitecoords, beamwidth=1.0, vert_res=100., maxalt=1000., range_res=500., maxrange=10000., 
                                     units='km', terrain=True, az=165, ax=ax4)
    pl.tight_layout()<jupyter_output><empty_output><jupyter_text>Plotting with curvelinear gridAll of the above shown plotting into a cartesian coordinate system is also possible with a curvelinear grid. Just set keyword argument `cg=True`. The thick black line denotes the earth mean sea level (MSL).<jupyter_code>if has_data:
    ax = wrl.vis.plot_scan_strategy(ranges, elevs, sitecoords, units='km', cg=True, terrain=terrain)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10741687979539642, 'fraction_numerical': 0.03777296871926028, 'mean_word_length': 5.052380952380952, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '391457', 'license': 'MIT', 'n_tokens_mistral': 1843, 'n_tokens_neox': 1682, 'n_words': 471, 'path': 'notebooks/visualisation/wradlib_plot_scan_strategy.ipynb', 'repo_name': 'wradlib/wradlib-notebooks', 'size': '5083'}