{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Plot a Cross Section from a Grid\n\nThis is an example of how to plot a cross section\nof your radar grid using the GridMapDisplay\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print(__doc__)\n\n# Author: Max Grover (mgrover@anl.gov)\n# License: BSD 3 clause\n\nimport cartopy.crs as ccrs\nimport matplotlib.pyplot as plt\n\nimport pyart\nfrom pyart.testing import get_test_data\n\n# Read in the data from two XSAPR radars\nxsapr_sw_file = get_test_data(\"swx_20120520_0641.nc\")\nxsapr_se_file = get_test_data(\"sex_20120520_0641.nc\")\nradar_sw = pyart.io.read_cfradial(xsapr_sw_file)\nradar_se = pyart.io.read_cfradial(xsapr_se_file)\n\n# Filter out gates with reflectivity > 100 from both radars\ngatefilter_se = pyart.filters.GateFilter(radar_se)\ngatefilter_se.exclude_transition()\ngatefilter_se.exclude_above(\"corrected_reflectivity_horizontal\", 100)\ngatefilter_sw = pyart.filters.GateFilter(radar_sw)\ngatefilter_sw.exclude_transition()\ngatefilter_sw.exclude_above(\"corrected_reflectivity_horizontal\", 100)\n\n# perform Cartesian mapping, limit to the reflectivity field.\ngrid = pyart.map.grid_from_radars(\n (radar_se, radar_sw),\n gatefilters=(gatefilter_se, gatefilter_sw),\n grid_shape=(20, 181, 181),\n grid_limits=((500, 10000), (-50000, 40000), (-60000, 40000)),\n grid_origin=(36.57861, -97.363611),\n fields=[\"corrected_reflectivity_horizontal\"],\n)\n\n# Define some start and end points, using (latitude, longitude)\nstart = (36.7, -97.7)\nend = (36.2, -97.8)\n\n# Setup the figure, and plot our x/y view of the radar\nfig = plt.figure(figsize=(18, 6))\nax1 = plt.subplot(121, projection=ccrs.PlateCarree())\ndisplay = pyart.graph.GridMapDisplay(grid)\ndisplay.plot_grid(\n \"corrected_reflectivity_horizontal\",\n ax=ax1,\n cmap=\"pyart_HomeyerRainbow\",\n vmin=-20,\n vmax=70,\n)\n\n# Plot our start and end points, as well as a line in between the two\nax1.scatter(start[1], start[0], color=\"tab:blue\", label=\"Start\")\nax1.scatter(end[1], end[0], color=\"black\", label=\"End\")\nax1.plot([start[1], end[1]], [start[0], end[0]], color=\"k\", linestyle=\":\")\nplt.legend(loc=\"upper right\")\n\n# Add a cross section, using our start and end points, and set our x-axis as latitude (lat)\nax2 = plt.subplot(122)\ndisplay.plot_cross_section(\n \"corrected_reflectivity_horizontal\",\n start,\n end,\n x_axis=\"lat\",\n cmap=\"pyart_HomeyerRainbow\",\n vmin=-20,\n vmax=70,\n)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.0" } }, "nbformat": 4, "nbformat_minor": 0 }