MRMS precipitation rates

This notebook illustrates how to download and open instantaneous precipitation rates from the Multi-Radar/Multi-Sensor System

Note: Since MRMS data is stored using grib2 format, loading the data into an xarray Dataset requires the cfgrib package and its dependencies to be installed.

Downloading the data

The MRMS instantaneous precipitation rate product is represented by the mrms_precip_rate attribute of the pansat.products.ground_based. After importing it, the object can be used to download data for an arbitrary time range. For this specific example, we will look at the instantaneous precipitation for one day of the 2021 February snow storms.

[1]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from datetime import datetime
from pansat.products.ground_based.mrms import mrms_precip_rate
[2]:
start_time = datetime(2021, 2, 15, 12, 0)
end_time = datetime(2021, 2, 15, 12, 1)
files = mrms_precip_rate.download(start_time, end_time)

Loading the data

If the cfgrib package is available on your system, the data can be read directly into an xarray Dataset.

[26]:
data = mrms_precip_rate.open(files[0])
display(data)
<xarray.Dataset>
Dimensions:         (latitude: 3500, longitude: 7000)
Coordinates:
    time            datetime64[ns] 2021-02-15T12:00:00
    step            timedelta64[ns] 00:00:00
    heightAboveSea  int64 0
  * latitude        (latitude) float64 54.99 54.98 54.98 ... 20.03 20.02 20.01
  * longitude       (longitude) float64 230.0 230.0 230.0 ... 300.0 300.0 300.0
    valid_time      datetime64[ns] 2021-02-15T12:00:00
Data variables:
    precip_rate     (latitude, longitude) float32 -3.0 -3.0 -3.0 ... -3.0 -3.0
Attributes:
    GRIB_edition:            2
    GRIB_centre:             161
    GRIB_centreDescription:  161
    GRIB_subCentre:          0
    Conventions:             CF-1.7
    institution:             161
    history:                 2021-03-03T10:50:37 GRIB to CDM+CF via cfgrib-0....

Displaying the data

To display the data, we replace 0 values with small positive values so that we can distinguish them from the missing values, which are negative. We also subsample the data slightly to make the plotting faster.

[25]:
from copy import copy
from matplotlib.gridspec import GridSpec
from matplotlib.colors import LogNorm
from matplotlib.cm import get_cmap
import cartopy.crs as ccrs

gs = GridSpec(1, 2, width_ratios=[1.0, 0.05])
f = plt.figure(figsize=(10, 5))
ax = plt.subplot(gs[0, 0], projection=ccrs.PlateCarree())

lats = data["latitude"].data[::3]
lons = data["longitude"].data[::3]
precip_rate = data["precip_rate"].data[::3, ::3]
# Set zero values to small value so that they can be distinguished
# from missing data.
precip_rate[precip_rate == 0.0] = 1e-6

norm = LogNorm(1e-2, 1e2)
cmap = copy(get_cmap("plasma"))
cmap.set_under([0.0, 0.0, 0.0, 0.0])
cmap.set_bad([0.5, 0.5, 0.5, 0.5])
m = ax.pcolormesh(lons, lats, precip_rate.data, norm=norm, cmap=cmap)
ax.coastlines()
ax.set_title("MRMS Precipitation rate", pad=20)
ax.set_xlabel(r"Longitude [$^\deg$ W]")
ax.set_ylabel(r"Latitude [$^\deg$ N]")
ax.gridlines(draw_labels=True)

ax = plt.subplot(gs[0, 1])
plt.colorbar(m, cax=ax, label="Precipitation rate [mm/h]")

f.canvas.draw()
plt.tight_layout()
../../_images/notebooks_products_mrms_8_0.png