-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: Add column example to docs (#1263)
* add column example to docs * condense some lines
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.. _retrieve_examples: | ||
|
||
Retrieval Examples | ||
------------------ | ||
|
||
Retrievals from various radars, such as additional fields or subsets of the data. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
""" | ||
==================================== | ||
Extract a radar column above a point | ||
==================================== | ||
Given a radar and a point, extract the column of radar data values above | ||
a point | ||
""" | ||
|
||
# Author: Maxwell Grover ([email protected]) | ||
# License: BSD 3 clause | ||
|
||
import pyart | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
import cartopy.crs as ccrs | ||
from pyart.testing import get_test_data | ||
|
||
# Read in some test data | ||
filename = get_test_data('swx_20120520_0641.nc') | ||
radar = pyart.io.read(filename) | ||
|
||
###################################### | ||
# **Plot the first sweep and our desired point** | ||
# | ||
# Let's visualize our radar data from a single sweep, and plot | ||
# the location of our desired point on a map. | ||
# This will provide some context as to where we are extracting our | ||
# column of values. | ||
|
||
site_lon = -97.73 # longitude in degrees | ||
site_lat = 36.41 # latitdue in degrees | ||
|
||
# Setup the RadarMapDisplay and add our projection | ||
display = pyart.graph.RadarMapDisplay(radar) | ||
ax = plt.subplot(111, projection=ccrs.PlateCarree()) | ||
|
||
# Visualize the reflectivity field, using the lowest sweep with | ||
# latitude and longitude lines | ||
display.plot_ppi_map('reflectivity_horizontal', | ||
0, ax=ax,vmin=-32, vmax=64., | ||
lon_lines=np.arange(-98, -97, .2), | ||
lat_lines=np.arange(36, 37, .2)) | ||
|
||
# Plot our site location on top of the radar image | ||
ax.scatter(site_lon, | ||
site_lat, | ||
color='black'); | ||
|
||
###################################### | ||
# Now that we have our point defined, and our radar object, we can use the following | ||
# utility function in Py-ART to subset a column | ||
ds = pyart.util.columnsect.get_field_location(radar, site_lat, site_lon) | ||
|
||
###################################### | ||
# This function returns an xarray dataset, with all of our data fields! | ||
print(ds) | ||
|
||
###################################### | ||
# **Visualize the Reflectivity Values in the Column** | ||
# | ||
# Let's visualize the reflectivity values in the column | ||
# above our point, which is stored in our new dataset | ||
ds.corrected_reflectivity_horizontal.plot(y='height'); |