Grid Radar -> Plot Max-CAPPI#

We are using fast-barnes-py to grid the radar data. Please cite if you use it in your research.

[1]:
import fsspec
import radarx as rx
import xradar as xd
import cmweather  # noqa
import matplotlib.pyplot as plt
from radarx.utils import combine_nexrad_sweeps
[2]:
print(rx.__version__)
0.2.6.dev6
[3]:
file = "s3://noaa-nexrad-level2/2022/03/30/KGWX/KGWX20220330_234639_V06"
local_file = fsspec.open_local(
    f"simplecache::s3://{file}",
    s3={"anon": True},
    filecache={"cache_storage": "."},
)
dtree = xd.io.open_nexradlevel2_datatree(local_file)
dtree = combine_nexrad_sweeps(dtree)
dtree = dtree.xradar.georeference()
/home/docs/checkouts/readthedocs.org/user_builds/radarx/conda/latest/lib/python3.12/site-packages/fsspec/registry.py:286: UserWarning: Your installed version of s3fs is very old and known to cause
severe performance issues, see also https://github.com/dask/dask/issues/10276

To fix, you should specify a lower version bound on s3fs, or
update the current installation.

  warnings.warn(s3_msg)
[4]:
display(dtree.groups)
('/',
 '/sweep_0',
 '/sweep_1',
 '/sweep_2',
 '/sweep_3',
 '/sweep_4',
 '/sweep_5',
 '/sweep_6',
 '/sweep_7',
 '/sweep_8',
 '/sweep_9',
 '/sweep_10',
 '/sweep_11',
 '/sweep_12',
 '/sweep_13',
 '/radar_parameters',
 '/georeferencing_correction',
 '/radar_calibration')
[5]:
def filter_radar(ds):
    ds = ds.where((ds.DBZH > -10) & (ds.DBZH < 75))
    return ds
[6]:
dtree = dtree.xradar.map_over_sweeps(filter_radar)
[7]:
# Create a figure and axis
fig, ax = plt.subplots(figsize=(7, 5))
dtree["sweep_2"]["DBZH"].plot.contourf(
    x="x",
    y="y",
    levels=range(-10, 75),
    cmap="ChaseSpectral",
    ylim=(-200e3, 300e3),  # Adjust y-axis limits
    xlim=(-200e3, 300e3),  # Adjust x-axis limits
    ax=ax,  # Use the created axis
)
# Set the title
ax.set_title(
    f"{dtree.attrs['instrument_name']} {dtree['sweep_0']['time'].min().values}"
)
# Show the plot
plt.show()
../_images/notebooks_Grid_Radar_8_0.png
[8]:
%%time
ds = dtree.radarx.to_grid(
    data_vars=["DBZH"],
    pseudo_cappi=True,
    x_lim=(-100000.0, 100000.0),
    y_lim=(-100000.0, 100000.0),
    z_lim=(0, 10000.0),
    x_step=1000,
    y_step=1000,
    z_step=250,
    x_smth=0.2,
    y_smth=0.2,
    z_smth=1,
)

ds.radarx.plot_max_cappi("DBZH", cmap="ChaseSpectral", add_slogan=True);
WARNING:matplotlib.font_manager:findfont: Font family 'Courier New' not found.
WARNING:matplotlib.font_manager:findfont: Font family 'Courier New' not found.
WARNING:matplotlib.font_manager:findfont: Font family 'Courier New' not found.
WARNING:matplotlib.font_manager:findfont: Font family 'Courier New' not found.
WARNING:matplotlib.font_manager:findfont: Font family 'Courier New' not found.
../_images/notebooks_Grid_Radar_9_1.png
CPU times: user 11.5 s, sys: 1.84 s, total: 13.4 s
Wall time: 15.8 s
[9]:
%%time
ds2 = dtree.radarx.to_grid(
    data_vars=["DBZH"],
    pseudo_cappi=False,
    x_lim=(-200000.0, 200000.0),
    y_lim=(-200000.0, 200000.0),
    z_lim=(0, 15000.0),
    x_step=1000,
    y_step=1000,
    z_step=250,
    x_smth=0.2,
    y_smth=0.2,
    z_smth=1,
)

ds2.radarx.plot_max_cappi("DBZH", cmap="ChaseSpectral", add_slogan=True);
WARNING:matplotlib.font_manager:findfont: Font family 'Courier New' not found.
WARNING:matplotlib.font_manager:findfont: Font family 'Courier New' not found.
WARNING:matplotlib.font_manager:findfont: Font family 'Courier New' not found.
WARNING:matplotlib.font_manager:findfont: Font family 'Courier New' not found.
WARNING:matplotlib.font_manager:findfont: Font family 'Courier New' not found.
../_images/notebooks_Grid_Radar_10_1.png
CPU times: user 4.31 s, sys: 444 ms, total: 4.76 s
Wall time: 4.76 s
[ ]: