HRDPS π ±#
BETA Requires MetPy >=1.6
This demonstrates using data from Canadaβs High Resolution Deterministic Prediction System (HRDPS).
Data Sources
|
Data source |
Archive Duration |
---|---|---|
|
Last 24 hours |
Model Initialization
Model cyles every hour.
Forecast Hour
For the most recent version of HRRRβ¦
|
Forecast lead time |
---|---|
|
hourly forecasts available |
Products
|
Product Description |
---|---|
|
Continental domain |
Variable and Level
You will need to specify the variable and level for each request.
NOTE: The organization of these files is different than other NWP products.
There are no index files provided.
Each GRIB2 file only contains one message. The variable name and level is in the fileβs name.
Herbie requires you provide a keyword argument for both
variable
andlevel
. Pay special attention to model description (linked above) to understand how the model data is organized. If you donβt provide input forvariable
orlevel
, Herbie will give you some ideas. For example,variable=TMP
andlevel=AGL-2m
will give you the filename that containsTMP_AGL-2m
Note: This requires MetPy version 1.6 or greater which has the capability to parse the rotated latitude longitude map projection type (see MetPy/#3123).
[1]:
from herbie import Herbie
import xarray as xr
import numpy as np
import matplotlib.pyplot as plt
from herbie.toolbox import EasyMap, pc
import cartopy.crs as ccrs
import cartopy.feature as feature
import pandas as pd
recent = pd.Timestamp("now").floor("6H") - pd.Timedelta("6H")
/home/blaylock/GITHUB/Carpenter_Workshop/paint/radar2.py:86: SyntaxWarning: invalid escape sequence '\m'
self.units = "m s$\mathregular{^{-1}}$"
/home/blaylock/GITHUB/Carpenter_Workshop/paint/standard2.py:153: SyntaxWarning: invalid escape sequence '\d'
self.units = f"$\degree${units}"
/home/blaylock/GITHUB/Carpenter_Workshop/paint/standard2.py:160: SyntaxWarning: invalid escape sequence '\d'
self.units = f"$\degree${units}"
/home/blaylock/GITHUB/Carpenter_Workshop/paint/standard2.py:309: SyntaxWarning: invalid escape sequence '\d'
self.units = f"$\degree${units}"
/home/blaylock/GITHUB/Carpenter_Workshop/paint/standard2.py:316: SyntaxWarning: invalid escape sequence '\d'
self.units = f"$\degree${units}"
/home/blaylock/GITHUB/Carpenter_Workshop/toolbox/stock.py:126: SyntaxWarning: invalid escape sequence '\*'
"""
/home/blaylock/GITHUB/Carpenter_Workshop/toolbox/stock.py:879: SyntaxWarning: invalid escape sequence '\*'
'''
[2]:
# Some examples
H = Herbie(
recent, # Datetime
model="hrdps",
fxx=32,
product="continental/2.5km",
variable="TMP",
level="AGL-2m",
)
H.grib
β
Found β model=hrdps β product=continental/2.5km β 2023-Dec-29 00:00 UTC F32 β GRIB2 @ msc β IDX @ None
[2]:
'https://dd.weather.gc.ca/model_hrdps/continental/2.5km/00/032/20231229T00Z_MSC_HRDPS_TMP_AGL-2m_RLatLon0.0225_PT032H.grib2'
[3]:
H = Herbie(
recent, # Datetime
model="hrdps",
fxx=12,
product="continental/2.5km",
variable="HGT",
level="ISBL_0500",
)
H.grib
β
Found β model=hrdps β product=continental/2.5km β 2023-Dec-29 00:00 UTC F12 β GRIB2 @ msc β IDX @ None
[3]:
'https://dd.weather.gc.ca/model_hrdps/continental/2.5km/00/012/20231229T00Z_MSC_HRDPS_HGT_ISBL_0500_RLatLon0.0225_PT012H.grib2'
Get the 2-metre temperature#
[4]:
H = Herbie(
recent,
model="hrdps",
fxx=0,
product="continental/2.5km",
variable="TMP",
level="AGL-2m",
)
ds = H.xarray()
ds
β
Found β model=hrdps β product=continental/2.5km β 2023-Dec-29 00:00 UTC F00 β GRIB2 @ msc β IDX @ None
π¨π»βπ Created directory: [/home/blaylock/data/hrdps/20231229]
/home/blaylock/GITHUB/Herbie/herbie/core.py:1065: UserWarning: Will not remove GRIB file because Herbie will only remove subsetted files (not full files).
warnings.warn(
[4]:
<xarray.Dataset> Dimensions: (y: 1290, x: 2540) Coordinates: time datetime64[ns] 2023-12-29 step timedelta64[ns] 00:00:00 heightAboveGround float64 2.0 latitude (y, x) float64 ... longitude (y, x) float64 ... valid_time datetime64[ns] ... Dimensions without coordinates: y, x Data variables: t2m (y, x) float32 ... gribfile_projection object None Attributes: GRIB_edition: 2 GRIB_centre: cwao GRIB_centreDescription: Canadian Meteorological Service - Montreal GRIB_subCentre: 0 Conventions: CF-1.7 institution: Canadian Meteorological Service - Montreal model: hrdps product: continental/2.5km description: Canada's High Resolution Deterministic Predictio... remote_grib: /home/blaylock/data/hrdps/20231229/20231229T00Z_... local_grib: /home/blaylock/data/hrdps/20231229/20231229T00Z_... search: None
[5]:
ds.valid_time.dt.strftime("%Y-%m-%d %H:%M").item()
[5]:
'2023-12-29 00:00'
[ ]:
Plot data on Plate Carree projection#
[6]:
ax = EasyMap("50m").BORDERS().STATES(alpha=0.5).ax
p = ax.pcolormesh(ds.longitude, ds.latitude, ds.t2m, transform=pc, cmap="Spectral_r")
plt.colorbar(p, ax=ax, orientation="horizontal", pad=0.01, shrink=0.8)
ax.set_title(
f"2-m Temperature\nValid {ds.valid_time.dt.strftime('%Y-%m-%d %H:%M').item()} UTC",
loc="right",
fontsize=10,
)
ax.set_title(f"{ds.model.upper()}: {H.product_description}", loc="left")
ax.gridlines()
[6]:
<cartopy.mpl.gridliner.Gridliner at 0x7f9e3bdaa480>
Plot data on model grid projection - rotated latitude longitude#
Requires Metpy >=1.6.0
[7]:
ax = EasyMap("50m", crs=ds.herbie.crs).BORDERS().STATES(alpha=0.5).ax
p = ax.pcolormesh(ds.longitude, ds.latitude, ds.t2m, transform=pc, cmap="Spectral_r")
plt.colorbar(p, ax=ax, orientation="horizontal", pad=0.01, shrink=0.8)
ax.set_title(
f"2-m Temperature\nValid {ds.valid_time.dt.strftime('%Y-%m-%d %H:%M').item()} UTC",
loc="right",
fontsize=10,
)
ax.set_title(f"{ds.model.upper()}: {H.product_description}", loc="left")
ax.gridlines()
[7]:
<cartopy.mpl.gridliner.Gridliner at 0x7f9e3b961490>
Get 10-m U and 10-m V wind#
[8]:
# loading more than one variable requires a loop, because the
# data is stored in multiple files (and a Herbie object only
# represents a single file).
store = []
for var, lev in zip(["UGRD", "VGRD"], ["AGL-10m", "AGL-10m"]):
_ds = Herbie(
recent,
model="hrdps",
fxx=0,
product="continental/2.5km",
variable=var,
level=lev,
).xarray()
store.append(_ds)
ds = xr.merge(store)
ds
β
Found β model=hrdps β product=continental/2.5km β 2023-Dec-29 00:00 UTC F00 β GRIB2 @ msc β IDX @ None
/home/blaylock/GITHUB/Herbie/herbie/core.py:1065: UserWarning: Will not remove GRIB file because Herbie will only remove subsetted files (not full files).
warnings.warn(
β
Found β model=hrdps β product=continental/2.5km β 2023-Dec-29 00:00 UTC F00 β GRIB2 @ msc β IDX @ None
/home/blaylock/GITHUB/Herbie/herbie/core.py:1065: UserWarning: Will not remove GRIB file because Herbie will only remove subsetted files (not full files).
warnings.warn(
[8]:
<xarray.Dataset> Dimensions: (y: 1290, x: 2540) Coordinates: time datetime64[ns] 2023-12-29 step timedelta64[ns] 00:00:00 heightAboveGround float64 10.0 latitude (y, x) float64 39.63 39.63 39.64 ... 47.91 47.89 47.88 longitude (y, x) float64 -133.6 -133.6 -133.6 ... -40.73 -40.71 valid_time datetime64[ns] 2023-12-29 Dimensions without coordinates: y, x Data variables: u10 (y, x) float32 ... gribfile_projection object None v10 (y, x) float32 ... Attributes: GRIB_edition: 2 GRIB_centre: cwao GRIB_centreDescription: Canadian Meteorological Service - Montreal GRIB_subCentre: 0 Conventions: CF-1.7 institution: Canadian Meteorological Service - Montreal model: hrdps product: continental/2.5km description: Canada's High Resolution Deterministic Predictio... remote_grib: /home/blaylock/data/hrdps/20231229/20231229T00Z_... local_grib: /home/blaylock/data/hrdps/20231229/20231229T00Z_... search: None
[9]:
# MetPy version >= 1.6 is required to parse the map projection
ds.herbie.crs
[9]:
<cartopy.crs.RotatedPole object at 0x7f9e3bbc9010>
[10]:
ax = (
EasyMap("50m", crs=ds.herbie.crs, figsize=8, linewidth=1, theme="dark")
.BORDERS()
.STATES(alpha=0.5)
.ax
)
p = ax.pcolormesh(
ds.longitude,
ds.latitude,
np.hypot(ds.u10, ds.v10), # Wind Speed
transform=pc,
)
plt.colorbar(
p, ax=ax, orientation="horizontal", pad=0.01, shrink=0.8, label="Wind speed (m/s)"
)
ax.set_title(
f"10-m Wind Speed\nValid {ds.valid_time.dt.strftime('%Y-%m-%d %H:%M').item()} UTC",
loc="center",
fontsize=10,
)
ax.set_title(f"{ds.model.upper()}", loc="left")
ax.EasyMap.INSET_GLOBE()
[10]:
<GeoAxes: >
500 hPa Humidity and Geopotential Height#
[11]:
# loading more than one variable requires a loop, because the
# data is stored in multiple files (and a Herbie object only
# represents a single file).
store = []
for var, lev in zip(["HGT", "RH"], ["ISBL_0500", "ISBL_0500"]):
_ds = Herbie(
recent,
model="hrdps",
fxx=0,
product="continental/2.5km",
variable=var,
level=lev,
).xarray()
store.append(_ds)
ds = xr.merge(store)
ds
β
Found β model=hrdps β product=continental/2.5km β 2023-Dec-29 00:00 UTC F00 β GRIB2 @ msc β IDX @ None
/home/blaylock/GITHUB/Herbie/herbie/core.py:1065: UserWarning: Will not remove GRIB file because Herbie will only remove subsetted files (not full files).
warnings.warn(
β
Found β model=hrdps β product=continental/2.5km β 2023-Dec-29 00:00 UTC F00 β GRIB2 @ msc β IDX @ None
/home/blaylock/GITHUB/Herbie/herbie/core.py:1065: UserWarning: Will not remove GRIB file because Herbie will only remove subsetted files (not full files).
warnings.warn(
[11]:
<xarray.Dataset> Dimensions: (y: 1290, x: 2540) Coordinates: time datetime64[ns] 2023-12-29 step timedelta64[ns] 00:00:00 isobaricInhPa float64 500.0 latitude (y, x) float64 39.63 39.63 39.64 ... 47.91 47.89 47.88 longitude (y, x) float64 -133.6 -133.6 -133.6 ... -40.73 -40.71 valid_time datetime64[ns] 2023-12-29 Dimensions without coordinates: y, x Data variables: gh (y, x) float32 ... gribfile_projection object None r (y, x) float32 ... Attributes: GRIB_edition: 2 GRIB_centre: cwao GRIB_centreDescription: Canadian Meteorological Service - Montreal GRIB_subCentre: 0 Conventions: CF-1.7 institution: Canadian Meteorological Service - Montreal model: hrdps product: continental/2.5km description: Canada's High Resolution Deterministic Predictio... remote_grib: /home/blaylock/data/hrdps/20231229/20231229T00Z_... local_grib: /home/blaylock/data/hrdps/20231229/20231229T00Z_... search: None
[12]:
ax = (
EasyMap("50m", crs=ds.herbie.crs, figsize=8, linewidth=1, theme="dark")
.BORDERS()
.STATES(alpha=0.5)
.ax
)
# Draw Relative Humidity
p = ax.pcolormesh(
ds.longitude, ds.latitude, ds.r, transform=pc, cmap="BrBG", vmin=0, vmax=100
)
plt.colorbar(
p,
ax=ax,
orientation="horizontal",
pad=0.01,
shrink=0.8,
label="Relative Humidity (%)",
)
# Draw Geopential Height Contours
ax.contour(
ds.longitude,
ds.latitude,
ds.gh,
colors="k",
transform=pc,
levels=range(0, 6000, 40),
)
ax.set_title(
f"500 hPa RH and Geopotential height\nValid {ds.valid_time.dt.strftime('%Y-%m-%d %H:%M').item()} UTC",
loc="center",
fontsize=10,
)
ax.set_title(f"{ds.model.upper()}", loc="left")
[12]:
Text(0.0, 1.0, 'HRDPS')
HRDPS North domain (experimental)#
[13]:
H = Herbie(
recent.floor("12H"), # only run every 00 anc 12 UTC
model="hrdps_north",
fxx=0,
product="north/grib2",
variable="TMP",
level="TGL_2",
)
ds = H.xarray()
ds
β
Found β model=hrdps_north β product=north/grib2 β 2023-Dec-29 00:00 UTC F00 β GRIB2 @ msc β IDX @ None
π¨π»βπ Created directory: [/home/blaylock/data/hrdps_north/20231229]
/home/blaylock/GITHUB/Herbie/herbie/core.py:1065: UserWarning: Will not remove GRIB file because Herbie will only remove subsetted files (not full files).
warnings.warn(
[13]:
<xarray.Dataset> Dimensions: (y: 825, x: 1465) Coordinates: time datetime64[ns] 2023-12-29 step timedelta64[ns] 00:00:00 heightAboveGround float64 2.0 latitude (y, x) float64 ... longitude (y, x) float64 ... valid_time datetime64[ns] ... Dimensions without coordinates: y, x Data variables: t2m (y, x) float32 ... gribfile_projection object None Attributes: GRIB_edition: 2 GRIB_centre: cwao GRIB_centreDescription: Canadian Meteorological Service - Montreal GRIB_subCentre: 0 Conventions: CF-1.7 institution: Canadian Meteorological Service - Montreal model: hrdps_north product: north/grib2 description: Canada's High Resolution Deterministic Predictio... remote_grib: /home/blaylock/data/hrdps_north/20231229/CMC_hrd... local_grib: /home/blaylock/data/hrdps_north/20231229/CMC_hrd... search: None
[14]:
# This domain is run on a polar stereographic projection
ds.herbie.crs
[14]:
<cartopy.crs.Stereographic object at 0x7f9e3bbca060>
[15]:
ax = EasyMap("50m", crs=ds.herbie.crs).BORDERS().STATES(alpha=0.5).ax
p = ax.pcolormesh(
ds.longitude, ds.latitude, ds.t2m - 273.15, transform=pc, cmap="Spectral_r"
)
plt.colorbar(
p,
ax=ax,
orientation="horizontal",
pad=0.01,
shrink=0.8,
label="2-m Temperature (C)",
)
ax.set_title(f"{ds.model.upper()}", loc="left")
ax.set_title(
f"2-m Temperature\nValid {ds.valid_time.dt.strftime('%Y-%m-%d %H:%M').item()} UTC",
loc="center",
fontsize=10,
)
ax.gridlines()
ax.EasyMap.INSET_GLOBE()
[15]:
<GeoAxes: >
[ ]: