
Overview¶
During the 2022 Prediction of Rainfall Extremes Campaign In the Pacific (PRECIP),
NCAR’s S-Pol radar scanned precipitating systems over the western Pacific. GDEX
hosts the radar moments as the ARCO dataset d694517,
converted to analysis-ready Zarr stores following the CfRadial2 convention
and served over OSDF.
S-Pol scans in two geometries: vertical Range–Height Indicator (RHI) slices and horizontal Plan Position Indicator (PPI) surveillance sweeps. We open one of each and plot reflectivity.
Open S-Pol radar Zarr stores as a hierarchical
DataTreeExtract a single sweep
Plot an RHI (vertical) reflectivity cross-section
Georeference and map a PPI (horizontal) sweep
Prerequisites¶
| Concepts | Importance | Notes |
|---|---|---|
| Introduction to ARCO/Zarr on GDEX | Helpful | Opening Zarr stores on GDEX |
| xarray | Necessary | DataTree for hierarchical sweeps |
| xradar | Necessary | Radar data structures & georeferencing |
| cmweather | Necessary | Weather colormaps |
| Cartopy | Necessary | Mapping |
Time to learn: 30 minutes
System requirements:
zarr ≥ 3.1.6and a recentxarraywithDataTreesupport
Imports¶
import numpy as np
import xarray as xr
import xradar as xd
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cmweather Locating the data¶
S-Pol stores one Zarr per scan. We use two scans from 25 May 2022 — an RHI (vertical) scan and a PPI (horizontal surveillance) scan — streamed from GDEX over the OSDF director.
base = "https://osdf-director.osg-htc.org/ncar-gdex/d694517/v2.0_zarr"
#base = 'osdf:///ncar-gdex/d694517/v2.0_zarr' #Doesn't work. PelicanFS needs to be updated
rhi_url = f"{base}/cfrad.20220525_015443.665_to_20220525_015709.985_SPOL_PrecipRhi2_RHI.zarr"
ppi_url = f"{base}/cfrad.20220525_030910.927_to_20220525_031137.777_SPOL_PrecipSur2_SUR.zarr"
print(rhi_url)https://osdf-director.osg-htc.org/ncar-gdex/d694517/v2.0_zarr/cfrad.20220525_015443.665_to_20220525_015709.985_SPOL_PrecipRhi2_RHI.zarr
Opening the data¶
CfRadial2 organizes each scan’s sweeps as a hierarchy, so we open the stores with
xr.open_datatree — every sweep (sweep_0, sweep_1, …) is a node in the tree.
dt_rhi = xr.open_datatree(rhi_url, engine="zarr", decode_timedelta=False)
dt_ppi = xr.open_datatree(ppi_url, engine="zarr", decode_timedelta=False)
dt_rhiVisualizing the RHI (vertical) scan¶
We extract the first sweep, compute each gate’s altitude from its range and elevation angle (accounting for Earth’s curvature), and plot reflectivity as a range–altitude cross-section.
ds_rhi = dt_rhi["sweep_0"].to_dataset()
def rhi_altitude(r, elevation_deg):
"""Beam altitude (km) from range (m) and elevation angle (deg), with Earth curvature."""
r_earth = 6_371_000.0
e = np.deg2rad(elevation_deg)
return (np.sqrt(r**2 + r_earth**2 + 2 * r * r_earth * np.sin(e)) - r_earth) / 1000.0
ds_rhi["rhi_alt"] = rhi_altitude(ds_rhi["range"], ds_rhi["elevation"]).compute()
ds_rhi = ds_rhi.set_coords("rhi_alt")
ds_rhi["range"] = ds_rhi["range"] / 1000.0
ds_rhi["rhi_alt"].attrs = {"long_name": "RHI altitude", "units": "km"}
ds_rhi["range"].attrs["units"] = "km"fig, ax = plt.subplots(figsize=(16, 4))
ds_rhi["DBZ"].plot.pcolormesh(
x="range",
y="rhi_alt",
cmap="ChaseSpectral",
levels=np.arange(-10, 55, 1),
ax=ax,
cbar_kwargs={"label": "Reflectivity (dBZ)"},
)
ax.set_xlabel("Range (km)")
ax.set_ylabel("Altitude (km)")
ax.set_xlim(0, 150)
ax.set_ylim(0, 15)
ax.set_title(
f"S-Pol RHI reflectivity — 2022-05-25 "
f"(lon {ds_rhi.longitude.values:.2f}, lat {ds_rhi.latitude.values:.2f})"
)
plt.show()
Visualizing the PPI (horizontal) scan¶
For the surveillance scan we use xradar to georeference the polar coordinates into
Cartesian x/y/z, then map reflectivity onto a Cartopy projection for
geographic context.
dt_ppi = dt_ppi.xradar.georeference()
dt_ppi = xd.georeference.get_x_y_z_tree(dt_ppi)
ds_ppi = dt_ppi["sweep_0"].to_dataset()
da_dbz = ds_ppi["DBZ"]radar_crs = ccrs.Projection(xd.georeference.get_crs(ds_ppi))
fig = plt.figure(figsize=(10, 10))
ax = fig.add_subplot(111, projection=ccrs.PlateCarree())
da_dbz.plot(
x="x",
y="y",
transform=radar_crs,
cmap="ChaseSpectral",
levels=np.arange(-10, 55, 1),
cbar_kwargs={"label": "Reflectivity (dBZ)", "shrink": 0.75, "pad": 0.075},
)
ax.coastlines()
ax.gridlines(draw_labels=True)
ax.set_title(f"S-Pol PPI reflectivity — sweep 0 (elevation {ds_ppi.elevation.values[0]:.2f}°)")
plt.show()/home/runner/micromamba/envs/gdex-cookbook/lib/python3.12/site-packages/cartopy/mpl/geoaxes.py:1769: UserWarning: The input coordinates to pcolormesh are interpreted as cell centers, but are not monotonically increasing or decreasing. This may lead to incorrectly calculated cell edges, in which case, please supply explicit cell edges to pcolormesh.
result = super().pcolormesh(*args, **kwargs)
/home/runner/micromamba/envs/gdex-cookbook/lib/python3.12/site-packages/cartopy/io/__init__.py:263: DownloadWarning: Downloading: https://naturalearth.s3.amazonaws.com/10m_physical/ne_10m_coastline.zip
warnings.warn(f'Downloading: {url}', DownloadWarning)

Summary¶
We opened NCAR S-Pol radar scans from the PRECIP campaign as CfRadial2 Zarr
DataTrees over OSDF, extracted single sweeps, and plotted reflectivity as a
vertical RHI cross-section and a georeferenced horizontal PPI map.
What’s next?¶
Continue to Data Fusion to combine multiple GDEX datasets in a single analysis.