Example on integrating radar and HRRR data#
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
This example has been updated to use _Herbie to retrieve the HRRR data. In addition, _pooch is used to retrieve the gridded data for the example. Herbie is not required to run PyDDA, but must be installed to run this example.
Author: Robert C. Jackson
import pydda
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import numpy as np
from herbie import Herbie
H = Herbie("2018-09-14 06:00", model="hrrr", product="prs", fxx=0)
H.download()
grid_mhx_path = pydda.tests.get_sample_file("grid_mhx.nc")
grid_ltx_path = pydda.tests.get_sample_file("grid_ltx.nc")
grid_mhx = pydda.io.read_grid(grid_mhx_path)
grid_ltx = pydda.io.read_grid(grid_ltx_path)
grid_mhx = pydda.constraints.add_hrrr_constraint_to_grid(grid_mhx, H.grib)
grid_mhx = 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],
Co=1e-2,
Cm=128.0,
Cmod=1e-4,
Cx=1e-4,
Cy=1e-4,
Cz=1e-4,
max_iterations=100,
mask_outside_opt=True,
vel_name="corrected_velocity",
engine="scipy",
model_fields=["hrrr"],
)
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=3,
barb_spacing_x_km=20.0,
barb_spacing_y_km=20.0,
cmap="ChaseSpectral",
)
ax.set_xticks(np.arange(-80, -75, 0.5))
ax.set_yticks(np.arange(33.0, 35.5, 0.5))
plt.title(out_grids[0].time.attrs["units"][13:] + " winds at 0.5 km")
plt.show()
## You are using the Python ARM Radar Toolkit (Py-ART), an open source
## library for working with weather radar data. Py-ART is partly supported
## by the U.S. Department of Energy Office of Science as part of
## the Atmospheric Radiation Measurement (ARM) User Facility.
##
## If you use this software to prepare a publication, please cite:
##
## JJ Helmus and SM Collis, JORS 2016, doi: 10.5334/jors.119
Welcome to PyDDA 2.4.1
If you are using PyDDA in your publications, please cite:
Jackson et al. (2020) Journal of Open Research Science
Detecting Jax...
Jax/JaxOpt are not installed on your system, unable to use Jax engine.
Detecting TensorFlow...
Unable to load both TensorFlow and tensorflow-probability. TensorFlow engine disabled.
No module named 'tensorflow'
✅ Found ┊ model=hrrr ┊ product=prs ┊ 2018-Sep-14 06:00 UTC F00 ┊ GRIB2 @ local ┊ IDX @ aws
False
Calculating weights for radars 0 and 1
Calculating weights for radars 1 and 0
Calculating weights for models...
Starting solver
rmsVR = 21.58818045293143
Total points: 1284618
The max of w_init is 0.0
---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
Cell In[1], line 19
15 grid_ltx = pydda.io.read_grid(grid_ltx_path)
16
17 grid_mhx = pydda.constraints.add_hrrr_constraint_to_grid(grid_mhx, H.grib)
18 grid_mhx = pydda.initialization.make_constant_wind_field(grid_mhx, (0.0, 0.0, 0.0))
---> 19 out_grids, _ = pydda.retrieval.get_dd_wind_field(
20 [grid_mhx, grid_ltx],
21 Co=1e-2,
22 Cm=128.0,
File ~/work/PyDDA/PyDDA/pydda/retrieval/wind_retrieve.py:1502, in get_dd_wind_field(Grids, u_init, v_init, w_init, engine, **kwargs)
1495 w_init = new_grids[0]["w"].values.squeeze()
1497 if (
1498 engine.lower() == "scipy"
1499 or engine.lower() == "jax"
1500 or engine.lower() == "auglag"
1501 ):
-> 1502 return _get_dd_wind_field_scipy(
1503 new_grids, u_init, v_init, w_init, engine, **kwargs
1504 )
1505 elif engine.lower() == "tensorflow":
1506 return _get_dd_wind_field_tensorflow(
1507 new_grids, u_init, v_init, w_init, **kwargs
1508 )
File ~/work/PyDDA/PyDDA/pydda/retrieval/wind_retrieve.py:538, in _get_dd_wind_field_scipy(Grids, u_init, v_init, w_init, engine, points, vel_name, refl_field, u_back, v_back, z_back, frz, Co, Cm, Cx, Cy, Cz, Cb, Cv, Cmod, Cpoint, cvtol, gtol, Jveltol, Ut, Vt, low_pass_filter, mask_outside_opt, weights_obs, weights_model, weights_bg, max_iterations, mask_w_outside_opt, filter_window, filter_order, min_bca, max_bca, upper_bc, model_fields, output_cost_functions, roi, wind_tol, tolerance, const_boundary_cond, max_wind_mag, parallel)
536 print("The max of w_init is", wcurrmax)
537 iterations = 0
--> 538 bounds = [(-x, x) for x in max_wind_mag * np.ones(winds.shape)]
540 if model_fields is not None:
541 for i, the_field in enumerate(model_fields):
KeyboardInterrupt: