{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Extract a radar column above a point\n\nGiven a radar and a point, extract the column of radar data values above\na point\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Author: Maxwell Grover (mgrover@anl.gov)\n# License: BSD 3 clause\n\nimport cartopy.crs as ccrs\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nimport pyart\nfrom pyart.testing import get_test_data\n\n# Read in some test data\nfilename = get_test_data(\"swx_20120520_0641.nc\")\nradar = pyart.io.read(filename)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Plot the first sweep and our desired point**\n\nLet's visualize our radar data from a single sweep, and plot\nthe location of our desired point on a map.\nThis will provide some context as to where we are extracting our\ncolumn of values.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "site_lon = -97.73 # longitude in degrees\nsite_lat = 36.41 # latitdue in degrees\n\n# Setup the RadarMapDisplay and add our projection\ndisplay = pyart.graph.RadarMapDisplay(radar)\nax = plt.subplot(111, projection=ccrs.PlateCarree())\n\n# Visualize the reflectivity field, using the lowest sweep with\n# latitude and longitude lines\ndisplay.plot_ppi_map(\n \"reflectivity_horizontal\",\n 0,\n ax=ax,\n vmin=-32,\n vmax=64.0,\n lon_lines=np.arange(-98, -97, 0.2),\n lat_lines=np.arange(36, 37, 0.2),\n)\n\n# Plot our site location on top of the radar image\nax.scatter(site_lon, site_lat, color=\"black\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now that we have our point defined, and our radar object, we can use the following\nutility function in Py-ART to subset a column\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "ds = pyart.util.columnsect.get_field_location(radar, site_lat, site_lon)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This function returns an xarray dataset, with all of our data fields!\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print(ds)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Visualize the Reflectivity Values in the Column**\n\nLet's visualize the reflectivity values in the column\nabove our point, which is stored in our new dataset\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "ds.corrected_reflectivity_horizontal.plot(y=\"height\")" ] } ], "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.14.3" } }, "nbformat": 4, "nbformat_minor": 0 }