
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "examples/correct/plot_dealias.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_examples_correct_plot_dealias.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_examples_correct_plot_dealias.py:


===========================================================
Dealias doppler velocities using the Region Based Algorithm
===========================================================

In this example doppler velocities are dealiased using the ial condition of the dealiasing,
using the region-based dealiasing algorithm in Py-ART.

.. GENERATED FROM PYTHON SOURCE LINES 9-89



.. image-sg:: /examples/correct/images/sphx_glr_plot_dealias_001.png
   :alt: Velocity dealiasing using Py-ART, Raw Doppler Velocity, First Sweep, Corrected Doppler Velocity, First Sweep, Raw Doppler Velocity, Sixth Sweep, Corrected Doppler Velocity, Sixth Sweep
   :srcset: /examples/correct/images/sphx_glr_plot_dealias_001.png
   :class: sphx-glr-single-img





.. code-block:: Python


    print(__doc__)

    # Author: Jonathan J. Helmus (jhelmus@anl.gov)
    # License: BSD 3 clause

    import matplotlib.pyplot as plt

    import pyart
    from pyart.testing import get_test_data

    radar_file = get_test_data("095636.mdv")
    sonde_file = get_test_data("sgpinterpolatedsondeC1.c1.20110510.000000.cdf")

    # read in the data
    radar = pyart.io.read_mdv(radar_file)

    # read in sonde data
    dt, profile = pyart.io.read_arm_sonde_vap(sonde_file, radar=radar)

    # create a gate filter which specifies gates to exclude from dealiasing
    gatefilter = pyart.filters.GateFilter(radar)
    gatefilter.exclude_transition()
    gatefilter.exclude_invalid("velocity")
    gatefilter.exclude_invalid("reflectivity")
    gatefilter.exclude_outside("reflectivity", 0, 80)

    # perform dealiasing
    dealias_data = pyart.correct.dealias_region_based(radar, gatefilter=gatefilter)
    radar.add_field("corrected_velocity", dealias_data)

    # create a plot of the first and sixth sweeps
    fig = plt.figure(figsize=(15, 10))
    ax1 = fig.add_subplot(221)
    display = pyart.graph.RadarDisplay(radar)
    display.plot(
        "velocity",
        0,
        vmin=-16,
        vmax=16,
        ax=ax1,
        colorbar_label="",
        title="Raw Doppler Velocity, First Sweep",
    )

    ax2 = fig.add_subplot(222)
    display.plot(
        "corrected_velocity",
        0,
        vmin=-40,
        vmax=40,
        colorbar_label="",
        ax=ax2,
        title="Corrected Doppler Velocity, First Sweep",
    )

    ax3 = fig.add_subplot(223)
    display = pyart.graph.RadarDisplay(radar)
    display.plot(
        "velocity",
        5,
        vmin=-16,
        vmax=16,
        colorbar_label="",
        ax=ax3,
        title="Raw Doppler Velocity, Sixth Sweep",
    )

    ax4 = fig.add_subplot(224)
    display.plot_ppi(
        "corrected_velocity",
        5,
        vmin=-40,
        vmax=40,
        colorbar_label="",
        ax=ax4,
        title="Corrected Doppler Velocity, Sixth Sweep",
    )
    plt.suptitle("Velocity dealiasing using Py-ART", fontsize=16)
    plt.show()


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (1 minutes 19.145 seconds)


.. _sphx_glr_download_examples_correct_plot_dealias.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.ipynb <plot_dealias.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: plot_dealias.py <plot_dealias.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: plot_dealias.zip <plot_dealias.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
