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

.. only:: html

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

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

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

.. _sphx_glr_examples_retrieve_plot_composite_reflectivity.py:


=========================================
Calculate and Plot Composite Reflectivity
=========================================

Calculates and plots the composite reflectivity, or the
maximum reflectivity across all of the elevations.

.. GENERATED FROM PYTHON SOURCE LINES 9-43



.. image-sg:: /examples/retrieve/images/sphx_glr_plot_composite_reflectivity_001.png
   :alt: xsapr-sg 0.5 Deg. 2011-05-20T06:42:11Z  Equivalent reflectivity factor, xsapr-sg 0.0 Deg. 2011-05-20T06:42:11.039436Z  Composite reflectivity
   :srcset: /examples/retrieve/images/sphx_glr_plot_composite_reflectivity_001.png
   :class: sphx-glr-single-img





.. code-block:: Python


    # Author: Maxwell Grover (mgrover@anl.gov)
    # License: BSD 3 clause

    import matplotlib.pyplot as plt

    import pyart
    from pyart.testing import get_test_data

    # Read in a sample file
    filename = get_test_data("swx_20120520_0641.nc")
    radar = pyart.io.read(filename)

    # Configure a gatefilter to filter out copolar correlation coefficient values > 0.9
    gatefilter = pyart.filters.GateFilter(radar)
    gatefilter.exclude_transition()
    gatefilter.exclude_below("copol_coeff", 0.9)

    # Calculate composite reflectivity, or the maximum reflectivity across all elevation levels
    compz = pyart.retrieve.composite_reflectivity(
        radar, field="reflectivity_horizontal", gatefilter=gatefilter
    )

    # Plot the original reflectivity field and the composite field
    fig = plt.figure(figsize=(16, 6))
    ax = plt.subplot(121)
    display = pyart.graph.RadarDisplay(radar)
    display.plot("reflectivity_horizontal", ax=ax, vmin=-20, vmax=80)

    ax2 = plt.subplot(122)
    composite_display = pyart.graph.RadarDisplay(compz)
    composite_display.plot(
        "composite_reflectivity", ax=ax2, vmin=-20, vmax=80, cmap="pyart_HomeyerRainbow"
    )


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

   **Total running time of the script:** (0 minutes 5.891 seconds)


.. _sphx_glr_download_examples_retrieve_plot_composite_reflectivity.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: plot_composite_reflectivity.ipynb <plot_composite_reflectivity.ipynb>`

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

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

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

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


.. only:: html

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

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