.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/xradar/plot_dealias_xradar.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_xradar_plot_dealias_xradar.py: ================================================= Dealias Radial Velocities Using Xradar and Py-ART ================================================= An example which uses xradar and Py-ART to dealias radial velocities. .. GENERATED FROM PYTHON SOURCE LINES 9-38 .. code-block:: Python # Author: Max Grover (mgrover@anl.gov) # License: BSD 3 clause import cartopy.crs as ccrs import matplotlib.pyplot as plt import xradar as xd import pyart from pyart.testing import get_test_data # Locate the test data and read in using xradar filename = get_test_data("swx_20120520_0641.nc") tree = xd.io.open_cfradial1_datatree(filename) # Give the tree Py-ART radar methods radar = pyart.xradar.Xradar(tree) # Determine the nyquist velocity using the maximum radial velocity from the first sweep nyq = radar["sweep_0"]["mean_doppler_velocity"].max().values # Set the nyquist to what we captured above # Calculate the velocity texture vel_texture = pyart.retrieve.calculate_velocity_texture( radar, vel_field="mean_doppler_velocity", nyq=nyq ) radar.add_field("velocity_texture", vel_texture, replace_existing=True) .. GENERATED FROM PYTHON SOURCE LINES 39-41 **Visualize our velocity texture field** Let's use the RadarMapDisplay to visualize the texture field .. GENERATED FROM PYTHON SOURCE LINES 41-55 .. code-block:: Python fig = plt.figure(figsize=[8, 8]) display = pyart.graph.RadarMapDisplay(radar) display.plot_ppi_map( "velocity_texture", sweep=2, resolution="50m", vmin=0, vmax=10, projection=ccrs.PlateCarree(), cmap="pyart_balance", ) plt.show() .. image-sg:: /examples/xradar/images/sphx_glr_plot_dealias_xradar_001.png :alt: xsapr-sg 0.5 Deg. 2011-05-20T06:42:42Z Texture of radial velocity of scatters away from instrument :srcset: /examples/xradar/images/sphx_glr_plot_dealias_xradar_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 56-59 **Determine a Velocity Texture Threshold Value** We can use the xradar/xarray plotting functionality here .. GENERATED FROM PYTHON SOURCE LINES 59-62 .. code-block:: Python radar["sweep_0"]["velocity_texture"].plot.hist() plt.show() .. image-sg:: /examples/xradar/images/sphx_glr_plot_dealias_xradar_002.png :alt: latitude = 36.49 [degrees_north], longitude = -... :srcset: /examples/xradar/images/sphx_glr_plot_dealias_xradar_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 63-67 **Apply a Gatefilter Mask** We now apply this threshold, along with a reflectivity threshold, and make use of the region-based dealiasing algorithm .. GENERATED FROM PYTHON SOURCE LINES 67-84 .. code-block:: Python # Configure the gatefilter gatefilter = pyart.filters.GateFilter(radar) gatefilter.exclude_above("velocity_texture", 4) gatefilter.exclude_below("corrected_reflectivity_horizontal", 0) # At this point, we can simply used dealias_region_based to dealias the velocities # and then add the new field to the radar. velocity_dealiased = pyart.correct.dealias_region_based( radar, vel_field="mean_doppler_velocity", nyquist_vel=nyq, centered=True, gatefilter=gatefilter, ) radar.add_field("corrected_velocity", velocity_dealiased, replace_existing=True) .. GENERATED FROM PYTHON SOURCE LINES 85-88 **Visualize the Cleaned Radial Velocities** We can visualize the uncorrected and corrected radial velocity fields .. GENERATED FROM PYTHON SOURCE LINES 88-109 .. code-block:: Python fig = plt.figure(figsize=(14, 5)) display = pyart.graph.RadarMapDisplay(radar) ax1 = plt.subplot(121) display.plot_ppi( "mean_doppler_velocity", cmap="twilight_shifted", vmin=-40, vmax=40, colorbar_label="Uncorrected Radial Velocity (m/s)", ax=ax1, ) ax2 = plt.subplot(122) display.plot_ppi( "corrected_velocity", cmap="twilight_shifted", vmin=-40, vmax=40, colorbar_label="Corrected Radial Velocity (m/s)", ax=ax2, ) plt.show() .. image-sg:: /examples/xradar/images/sphx_glr_plot_dealias_xradar_003.png :alt: xsapr-sg 0.5 Deg. 2011-05-20T06:42:11Z Radial velocity of scatterers away from instrument, xsapr-sg 0.5 Deg. 2011-05-20T06:42:11Z Corrected radial velocity of scatterers away from instrument :srcset: /examples/xradar/images/sphx_glr_plot_dealias_xradar_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 10.379 seconds) .. _sphx_glr_download_examples_xradar_plot_dealias_xradar.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_dealias_xradar.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_dealias_xradar.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_