Skip to content

Commit

Permalink
ADD: Extra examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Clyde Jackson committed Jun 19, 2019
1 parent f6b507a commit 26ebfa1
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 10 deletions.
Binary file added doc/source/arm_figure.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/source/hrrr_figure.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/source/sydney_tornado.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 12 additions & 5 deletions examples/hurricane_florence.py
Expand Up @@ -4,7 +4,12 @@
This is an example of how to retrieve winds in Hurricane Florence.
In this example, we use data from 2 NEXRAD radars as well as from
the HRRR to retrieve the winds.
the HRRR to retrieve the winds
Grided netCDF files are downloadable from:
https://drive.google.com/drive/u/1/folders/1pcQxWRJV78xuJePTZnlXPPpMe1qut0ie
.. image:: ../../hrrr_figure.png
Author: Robert C. Jackson
"""
Expand All @@ -14,6 +19,7 @@
import pydda
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import numpy as np

hrrr_url = ('https://pando-rgw01.chpc.utah.edu/hrrr/prs/20180914/' +
'hrrr.t06z.wrfprsf00.grib2')
Expand All @@ -27,15 +33,16 @@
u_init, v_init, w_init = pydda.initialization.make_constant_wind_field(
grid_mhx, (0.0, 0.0, 0.0))
out_grids = pydda.retrieval.get_dd_wind_field(
[grid_mhx, grid_ltx], u_init, v_init, w_init, Co=1.0, Cm=1000.0, Cmod=1e-3,
[grid_mhx, grid_ltx], u_init, v_init, w_init, Co=0.1, Cm=1000.0, Cmod=1e-3,
mask_outside_opt=True, vel_name='corrected_velocity',
model_fields=["hrrr"])

fig = plt.figure(figsize=(15, 10))
fig = plt.figure(figsize=(25, 15))
ax = plt.axes(projection=ccrs.PlateCarree())
ax = pydda.vis.plot_horiz_xsection_barbs_map(
out_grids, ax=ax, bg_grid_no=-1, level=1, barb_spacing_x_km=20.0,
barb_spacing_y_km=20.0)

barb_spacing_y_km=20.0, cmap='pyart_HomeyerRainbow')
ax.set_xticks(np.arange(-80, -75, 0.5))
ax.set_yticks(np.arange(33., 35.5, 0.5))
plt.title(out_grids[0].time['units'][13:] + ' winds at 0.5 km')
plt.show()
48 changes: 48 additions & 0 deletions examples/oklahoma_example.py
@@ -0,0 +1,48 @@
"""
Example of a wind retrieval from KVNX and 2 XSAPRs in Oklahoma
--------------------------------------------------------------
This shows an example of how to combine data from 3 radars and HRRR in
the vicinity of the SGP site in North Central Oklahoma.
Grided netCDF files are downloadable from:
https://drive.google.com/drive/u/1/folders/1pcQxWRJV78xuJePTZnlXPPpMe1qut0ie
.. image:: ../../arm_figure.png
"""

import pyart
import pydda
import matplotlib.pyplot as plt
import numpy as np
import urllib

hrrr_url = ('https://pando-rgw01.chpc.utah.edu/hrrr/prs/20181004/' +
'hrrr.t10z.wrfprsf00.grib2')
grid0 = pyart.io.read_grid('grid0.20171004.095021.nc')
grid1 = pyart.io.read_grid('grid1.20171004.095021.nc')
grid2 = pyart.io.read_grid('grid2.20171004.095021.nc')

urllib.request.urlretrieve(hrrr_url, 'test.grib2')
grid_mhx = pydda.constraints.add_hrrr_constraint_to_grid(grid0,
'test.grib2')

# Set initialization and do retrieval
u_init, v_init, w_init = pydda.initialization.make_constant_wind_field(grid1)
new_grids = pydda.retrieval.get_dd_wind_field([grid0, grid1, grid2],
u_init, v_init, w_init, Co=0.1, Cm=100.0,
model_fields=["hrrr"],
mask_outside_opt=True)
# Make a neat plot
fig = plt.figure(figsize=(10,10))
ax = pydda.vis.plot_horiz_xsection_quiver(new_grids, background_field='reflectivity', level=3,
show_lobes=False, bg_grid_no=0, vmin=0, vmax=60,
quiverkey_len=10.0,
quiver_spacing_x_km=2.0, quiver_spacing_y_km=2.0,
quiverkey_loc='top', colorbar_contour_flag=True,
cmap='pyart_HomeyerRainbow')
ax.set_xlim([-20, 40])
ax.set_ylim([-20, 40])
plt.show(ax)
2 changes: 1 addition & 1 deletion examples/plot_examples.py
Expand Up @@ -28,7 +28,7 @@
# Start the wind retrieval. This example only uses the mass continuity
# and data weighting constraints.
Grids = pydda.retrieval.get_dd_wind_field([berr_grid, cpol_grid], u_init,
v_init, w_init, Co=10.0, Cm=1500.0,
v_init, w_init, Co=1.0, Cm=1500.0,
Cz=0,
frz=5000.0, filt_iterations=2,
mask_outside_opt=True, upper_bc=1)
Expand Down
2 changes: 1 addition & 1 deletion examples/plot_examples_nested.py
Expand Up @@ -38,7 +38,7 @@
# Start the wind retrieval. This example only uses the mass continuity
# and data weighting constraints.
Grids = pydda.retrieval.get_dd_wind_field_nested(
[berr_grid, cpol_grid], u_init, v_init, w_init, client, Co=10.0,
[berr_grid, cpol_grid], u_init, v_init, w_init, client, Co=1.0,
Cm=1500.0, Cz=0, frz=5000.0,
filt_iterations=2, mask_outside_opt=True, upper_bc=1)

Expand Down
6 changes: 3 additions & 3 deletions examples/plot_fun_with_constraints.py
Expand Up @@ -40,7 +40,7 @@
new_grids = pydda.retrieval.get_dd_wind_field([cpol_grid, berr_grid],
u_init, v_init, w_init,
Co=1.0, Cm=1500.0, frz=5000.0,
mask_outside_opt=True)
mask_outside_opt=False)

fig = plt.figure(figsize=(7, 7))
ax = plt.axes(projection=ccrs.PlateCarree())
Expand All @@ -52,8 +52,8 @@
# Or, let's make the radar data more important!
new_grids = pydda.retrieval.get_dd_wind_field([cpol_grid, berr_grid],
u_init, v_init, w_init,
Co=10.0, Cm=1500.0, frz=5000.0,
mask_outside_opt=True)
Co=1.0, Cm=1500.0, frz=5000.0,
mask_outside_opt=False)
fig = plt.figure(figsize=(7, 7))
ax = plt.axes(projection=ccrs.PlateCarree())

Expand Down
43 changes: 43 additions & 0 deletions examples/sydney_tornado.py
@@ -0,0 +1,43 @@
"""
Example of a wind retrieval in a tornado over Sydney
----------------------------------------------------
This shows an example of how to retrieve winds from 4 radars over Sydney.
Grided netCDF files are downloadable from:
https://drive.google.com/drive/u/1/folders/1pcQxWRJV78xuJePTZnlXPPpMe1qut0ie
.. image:: ../../sydney_tornado.png
"""

import pyart
import pydda
import matplotlib.pyplot as plt
import numpy as np

grid1 = pyart.io.read_grid('grid1_sydney.nc')
grid2 = pyart.io.read_grid('grid2_sydney.nc')
grid3 = pyart.io.read_grid('grid3_sydney.nc')
grid4 = pyart.io.read_grid('grid4_sydney.nc')

# Set initialization and do retrieval
u_init, v_init, w_init = pydda.initialization.make_constant_wind_field(grid1, vel_field='VRADH_corr')
new_grids = pydda.retrieval.get_dd_wind_field([grid1, grid2, grid3, grid4],
u_init, v_init, w_init,
vel_name='VRADH_corr', refl_field='DBZH',
mask_outside_opt=True)
# Make a neat plot
fig = plt.figure(figsize=(10,7))
ax = pydda.vis.plot_horiz_xsection_quiver_map(new_grids, background_field='DBZH', level=3,
show_lobes=False, bg_grid_no=3, vmin=0, vmax=60,
quiverkey_len=40.0,
quiver_spacing_x_km=2.0, quiver_spacing_y_km=2.0,
quiverkey_loc='top', colorbar_contour_flag=True,
cmap='pyart_HomeyerRainbow')
ax.set_xticks(np.arange(150.5, 153, 0.1))
ax.set_yticks(np.arange(-36, -32.0, 0.1))
ax.set_xlim([151.0, 151.35])
ax.set_ylim([-34.15, -33.9])
plt.show(ax)

0 comments on commit 26ebfa1

Please sign in to comment.