Overview¶
The remnants of Hurricane Ida produced extreme rainfall and flash flooding across the northeastern United States on 1–2 September 2021. In this notebook, we use MPAS-Viewer to access and visualize MPAS-A output from a 3 km simulation over the New York City region. The goal is to demonstrate how MPAS-Viewer can be used to explore the evolution of a high-impact precipitation event using remotely hosted model output.
Objectives¶
Access MPAS-A output directly from a THREDDS server.
Load selected meteorological variables using MPAS-Viewer.
Visualize the evolution of rainfall, reflectivity, cloud-top structure, and near-surface temperature.
Demonstrate interactive exploration of MPAS-A output using MPAS-Viewer.
Imports¶
from mpasviewer import scvtmesh
from datetime import datetime
from earthcmap import escmap
from ipywidgets import interact, Dropdown, SelectionSlider
import matplotlib.pyplot as plt
import pandas as pd---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[1], line 4
2 from datetime import datetime
3 from earthcmap import escmap
----> 4 from ipywidgets import interact, Dropdown, SelectionSlider
5 import matplotlib.pyplot as plt
6 import pandas as pd
ModuleNotFoundError: No module named 'ipywidgets'Remote data¶
url_thredds = "https://thredds.hydroshare.org/thredds/catalog/hydroshare/resources/6be754bf29cb488b815810c35f3f0ac9/data/contents/nyc_out/catalog.html"
inidt = datetime(2021, 9, 1, 13)
enddt = datetime(2021, 9, 2, 12)
list_files = scvtmesh.get_thredds_list(
url_thredds,
date_start=inidt,
date_end=enddt
)
list_files[:3]# Initalizing MPAS-Viewer
grid_file = "http://thredds.hydroshare.org/thredds/dodsC/hydroshare/resources/6be754bf29cb488b815810c35f3f0ac9/data/contents/nyc_static/nyc.static.nc"
mpasd = scvtmesh(
grid_file=grid_file,
diag_list=list_files
)# Loading in necessary variables
load_vars = ["rainnc", "rainc", "t2m", "olrtoa", "refl10cm_max"]
mpasd.dataset(load_variables=load_vars)
mpasd.rain_rate()
dta = mpasd.load()# double checking times and dates
print(dta)
print(dta["time"].values)for i, t in enumerate(dta["time"].values):
max_rain = dta["rain_rate"].isel(time=i).max().compute().values
print(i, t, max_rain)# Rain rate
subd = mpasd.get_subset(
dta,
lon=(-75, -71),
lat=(39, 42.5)
)from earthcmap import escmap
cmap, norm = escmap("nwps_qpe", units="mm")
mpasd.show(
dta,
var_name="rain_rate",
time_index=8,
figsize=(8,8),
cmap=cmap,
norm=norm,
)
plt.title(
"Rain Rate at 2100 UTC",
pad=30,
x=0.57 #shifts the title to the center of the plot
)Rain rate is used to identify the location and intensity of the heaviest precipitation associated with the remnants of Hurricane Ida.
Reflectivity¶
cmap, norm = escmap("mrms_cref")
mpasd.show(
dta,
var_name="refl10cm_max",
time_index=8,
figsize=(8,8),
cmap=cmap,
norm=norm,
)
plt.title(
"Maximum 10-cm Reflectivity at 2100 UTC",
pad=30,
x=0.57
)Simulated maximum reflectivity highlights regions of organized precipitation and convective structures during the event.
Outgoing Longwave Radiation¶
# importing for colormap usage
import matplotlib.colors as colors
cmap = plt.get_cmap("gray_r")
norm = colors.Normalize(vmin=100, vmax=320)\
mpasd.show(
dta,
var_name="olrtoa",
time_index=8,
figsize=(8, 5),
cmap=cmap,
norm=norm,
)
plt.title(
"OLR at 2100 UTC",
pad=30,
x=0.73
)Outgoing longwave radiation (OLR) provides information about cloud-top characteristics, with lower values generally associated with deeper convection and colder cloud tops.
Evolution of Rainfall During Hurricane Ida¶
To better understand the temporal evolution of the event, we create an animation of simulated rain rate from 13 UTC 1 September through 12 UTC 2 September 2021. This animation highlights the development, intensification, and movement of precipitation associated with the remnants of Hurricane Ida.
Install Imageio to make a gif¶
!pip install imageioPlotting 3 time frames before peak, during peak and after peak¶
# NWS Color QPE colormaps
cmap, norm = escmap("nwps_qpe", units="mm")
# Select representative times showing the evolution of rainfall: before peak intensity, during peak intensity, and after the event begins to weaken.
times = [6, 8, 15]
for idx in times:
mpasd.show(
dta,
var_name="rain_rate",
time_index=idx,
figsize=(5,5),
cmap=cmap,
norm=norm,
)
# Add timestamp to each frame
timestamp = pd.to_datetime(dta.time.values[idx])
timestr = timestamp.strftime("%d %b %Y, %H:%M UTC")
ax = plt.gca()
plt.title(
f"\n{timestr}",
pad=40,
x=0.61
)
plt.savefig(
f"rain_rate_{idx:02d}.png",
dpi=150,
bbox_inches="tight"
)
plt.close()# NWS map colors
cmap, norm = escmap("nwps_qpe", units="mm")
times = [6, 8, 15]
for idx in times:
mpasd.show(
dta,
var_name="rain_rate",
time_index=idx,
figsize=(5, 5),
cmap=cmap,
norm=norm,
)
timestamp = pd.to_datetime(dta.time.values[idx])
timestr = timestamp.strftime("%d %b %Y, %H:%M UTC")
ax = plt.gca()
ax.set_title(
f"Rain Rate\n{timestr}",
pad=40,
x=0.61
)
plt.show()Making all 24 time steps into a GIF¶
# NWS map colors
cmap, norm = escmap("nwps_qpe", units="mm")
# Save each hourly rain-rate map as an image
for idx in range(len(dta.time)):
mpasd.show(
dta,
var_name="rain_rate",
time_index=idx,
figsize=(5, 5),
cmap=cmap,
norm=norm,
)
# Add timestamp to each frame
timestamp = pd.to_datetime(dta.time.values[idx])
timestr = timestamp.strftime("%d %b %Y, %H:%M UTC")
plt.title(
f"\n{timestr}",
pad=40,
x=0.61
)
plt.savefig(
f"rain_rate_{idx:02d}.png",
dpi=150,
bbox_inches="tight"
)
plt.close()# Making the GIF
from PIL import Image
files = [f"rain_rate_{i:02d}.png" for i in range(len(dta.time))]
frames = [Image.open(f).convert("RGB") for f in files]
frames[0].save(
"ida_rainfall_evolution_24hr.gif",
save_all=True,
append_images=frames[1:],
duration=500,
loop=0
)# displaying the GIF
from IPython.display import Image as IPImage
IPImage(filename="ida_rainfall_evolution_24hr.gif")Figure: Animation of MPAS-A simulated rain rate during the remnants of Hurricane Ida from 13 UTC 1 September to 12 UTC 2 September 2021. The animation highlights the evolution and movement of heavy precipitation bands across the northeastern United States, with peak rainfall occurring during the evening hours of 1 September.