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
[2]:
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 = rx.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:283: 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)
INFO:botocore.httpchecksum:Skipping checksum validation. Response did not contain one of the following algorithms: ['crc32', 'sha1', 'sha256'].
INFO:botocore.httpchecksum:Skipping checksum validation. Response did not contain one of the following algorithms: ['crc32', 'sha1', 'sha256'].
INFO:botocore.httpchecksum:Skipping checksum validation. Response did not contain one of the following algorithms: ['crc32', 'sha1', 'sha256'].
INFO:botocore.httpchecksum:Skipping checksum validation. Response did not contain one of the following algorithms: ['crc32', 'sha1', 'sha256'].
INFO:botocore.httpchecksum:Skipping checksum validation. Response did not contain one of the following algorithms: ['crc32', 'sha1', 'sha256'].
[3]:
dtree.groups
[3]:
('/',
'/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')
[4]:
def filter_radar(ds):
ds = ds.where((ds.DBZH > -10) & (ds.DBZH < 75))
return ds
[5]:
dtree = dtree.xradar.map_over_sweeps(filter_radar)
[6]:
# 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="NWSRef",
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()
[7]:
%%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,
)
CPU times: user 8.55 s, sys: 1.69 s, total: 10.2 s
Wall time: 11.2 s
[8]:
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.
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.
[8]:
[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,
)
CPU times: user 5.23 s, sys: 600 ms, total: 5.83 s
Wall time: 5.83 s
[10]:
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.
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.
[10]: