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

.. only:: html

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

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

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

.. _sphx_glr_examples_mapping_plot_map_one_radar_to_grid.py:


======================================
Map a single radar to a Cartesian grid
======================================

Map the reflectivity field of a single radar from Antenna coordinates to a
Cartesian grid.

.. GENERATED FROM PYTHON SOURCE LINES 10-48



.. image-sg:: /examples/mapping/images/sphx_glr_plot_map_one_radar_to_grid_001.png
   :alt: plot map one radar to grid
   :srcset: /examples/mapping/images/sphx_glr_plot_map_one_radar_to_grid_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 numpy as np

    import pyart
    from pyart.testing import get_test_data

    # read in the data
    file = get_test_data("110635.mdv")
    radar = pyart.io.read_mdv(file)

    # mask out last 10 gates of each ray, this removes the "ring" around the radar.
    radar.fields["reflectivity"]["data"][:, -10:] = np.ma.masked

    # exclude masked gates from the gridding
    gatefilter = pyart.filters.GateFilter(radar)
    gatefilter.exclude_transition()
    gatefilter.exclude_masked("reflectivity")

    # perform Cartesian mapping, limit to the reflectivity field.
    grid = pyart.map.grid_from_radars(
        (radar,),
        gatefilters=(gatefilter,),
        grid_shape=(1, 241, 241),
        grid_limits=((2000, 2000), (-123000.0, 123000.0), (-123000.0, 123000.0)),
        fields=["reflectivity"],
    )

    # create the plot
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.imshow(grid.fields["reflectivity"]["data"][0], origin="lower")
    plt.show()


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

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


.. _sphx_glr_download_examples_mapping_plot_map_one_radar_to_grid.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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