GDPS π ±#
BETA Requires MetPy >=1.6
This demonstrates using data from Canadaβs GEM Global or Global Deterministic Prediction System (GDPS).
Data Sources
|
Data source |
Archive Duration |
---|---|---|
|
Last 24 hours |
Model Initialization
Model cyles every twelve hours.
Forecast Hour
For the most recent version of GDPSβ¦
|
Forecast lead time |
---|---|
|
3-hourly forecasts available |
Products
|
Product Description |
---|---|
|
Global 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=TGL_2
will give you the filename that containsTMP_TGL_2
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 toolbox import EasyMap, pc
import cartopy.crs as ccrs
import cartopy.feature as feature
import pandas as pd
recent = pd.Timestamp("now").floor("12h") - pd.Timedelta("12h")
[2]:
recent
[2]:
Timestamp('2024-04-11 00:00:00')
[3]:
# Some examples
H = Herbie(
recent, # Datetime
model="gdps",
fxx=30,
variable="TMP",
level="TGL_2",
)
H.grib
β
Found β model=gdps β product=15km/grib2/lat_lon β 2024-Apr-11 00:00 UTC F30 β GRIB2 @ msc β IDX @ None
[3]:
'https://dd.weather.gc.ca/model_gem_global/15km/grib2/lat_lon/00/030/CMC_glb_TMP_TGL_2_latlon.15x.15_2024041100_P030.grib2'
[4]:
H = Herbie(
recent, # Datetime
model="gdps",
fxx=12,
variable="HGT",
level="ISBL_500",
)
H.grib
β
Found β model=gdps β product=15km/grib2/lat_lon β 2024-Apr-11 00:00 UTC F12 β GRIB2 @ msc β IDX @ None
[4]:
'https://dd.weather.gc.ca/model_gem_global/15km/grib2/lat_lon/00/012/CMC_glb_HGT_ISBL_500_latlon.15x.15_2024041100_P012.grib2'
Get the 2-metre temperature#
[5]:
H = Herbie(
recent,
model="gdps",
fxx=0,
variable="TMP",
level="TGL_2",
)
ds = H.xarray()
ds
β
Found β model=gdps β product=15km/grib2/lat_lon β 2024-Apr-11 00:00 UTC F00 β GRIB2 @ local β IDX @ None
/p/home/blaylock/BB_python/Herbie/herbie/core.py:1100: UserWarning: Will not remove GRIB file because it previously existed.
warnings.warn("Will not remove GRIB file because it previously existed.")
[5]:
<xarray.Dataset> Size: 12MB Dimensions: (latitude: 1201, longitude: 2400) Coordinates: time datetime64[ns] 8B 2024-04-11 step timedelta64[ns] 8B 00:00:00 heightAboveGround float64 8B 2.0 * latitude (latitude) float64 10kB -90.0 -89.85 ... 89.85 90.0 * longitude (longitude) float64 19kB -180.0 -179.8 ... 179.7 179.8 valid_time datetime64[ns] 8B ... Data variables: t2m (latitude, longitude) float32 12MB ... gribfile_projection object 8B 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: gdps product: 15km/grib2/lat_lon description: Canada's Global Deterministic Prediction System ... remote_grib: /p/cwfs/blaylock/data/gdps/20240411/CMC_glb_TMP_... local_grib: /p/cwfs/blaylock/data/gdps/20240411/CMC_glb_TMP_... search: None
[6]:
ds.valid_time.dt.strftime("%Y-%m-%d %H:%M").item()
[6]:
'2024-04-11 00:00'
[ ]:
Plot data on Plate Carree projection#
[7]:
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()
[7]:
<cartopy.mpl.gridliner.Gridliner at 0x2b335baf5690>
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"], ["TGL_10", "TGL_10"]):
_ds = Herbie(
recent,
model="gdps",
fxx=0,
product="15km/grib2/lat_lon",
variable=var,
level=lev,
).xarray()
store.append(_ds)
ds = xr.merge(store)
ds
β
Found β model=gdps β product=15km/grib2/lat_lon β 2024-Apr-11 00:00 UTC F00 β GRIB2 @ local β IDX @ None
/p/home/blaylock/BB_python/Herbie/herbie/core.py:1100: UserWarning: Will not remove GRIB file because it previously existed.
warnings.warn("Will not remove GRIB file because it previously existed.")
β
Found β model=gdps β product=15km/grib2/lat_lon β 2024-Apr-11 00:00 UTC F00 β GRIB2 @ local β IDX @ None
/p/home/blaylock/BB_python/Herbie/herbie/core.py:1100: UserWarning: Will not remove GRIB file because it previously existed.
warnings.warn("Will not remove GRIB file because it previously existed.")
[8]:
<xarray.Dataset> Size: 23MB Dimensions: (latitude: 1201, longitude: 2400) Coordinates: time datetime64[ns] 8B 2024-04-11 step timedelta64[ns] 8B 00:00:00 heightAboveGround float64 8B 10.0 * latitude (latitude) float64 10kB -90.0 -89.85 ... 89.85 90.0 * longitude (longitude) float64 19kB -180.0 -179.8 ... 179.7 179.8 valid_time datetime64[ns] 8B 2024-04-11 Data variables: u10 (latitude, longitude) float32 12MB ... gribfile_projection object 8B None v10 (latitude, longitude) float32 12MB ... 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: gdps product: 15km/grib2/lat_lon description: Canada's Global Deterministic Prediction System ... remote_grib: /p/cwfs/blaylock/data/gdps/20240411/CMC_glb_UGRD... local_grib: /p/cwfs/blaylock/data/gdps/20240411/CMC_glb_UGRD... search: None
[9]:
# MetPy version >= 1.6 is required to parse the map projection
ds.herbie.crs
[9]:
<cartopy.crs.PlateCarree object at 0x2b334b583d50>
[10]:
ax = (
EasyMap("50m", crs=ds.herbie.crs, figsize=8, linewidth=1)
.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")
[10]:
Text(0.0, 1.0, 'GDPS')
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_500", "ISBL_500"]):
_ds = Herbie(
recent,
model="gdps",
fxx=0,
product="15km/grib2/lat_lon",
variable=var,
level=lev,
).xarray()
store.append(_ds)
ds = xr.merge(store)
ds
β
Found β model=gdps β product=15km/grib2/lat_lon β 2024-Apr-11 00:00 UTC F00 β GRIB2 @ local β IDX @ None
/p/home/blaylock/BB_python/Herbie/herbie/core.py:1100: UserWarning: Will not remove GRIB file because it previously existed.
warnings.warn("Will not remove GRIB file because it previously existed.")
β
Found β model=gdps β product=15km/grib2/lat_lon β 2024-Apr-11 00:00 UTC F00 β GRIB2 @ local β IDX @ None
/p/home/blaylock/BB_python/Herbie/herbie/core.py:1100: UserWarning: Will not remove GRIB file because it previously existed.
warnings.warn("Will not remove GRIB file because it previously existed.")
[11]:
<xarray.Dataset> Size: 23MB Dimensions: (latitude: 1201, longitude: 2400) Coordinates: time datetime64[ns] 8B 2024-04-11 step timedelta64[ns] 8B 00:00:00 isobaricInhPa float64 8B 500.0 * latitude (latitude) float64 10kB -90.0 -89.85 ... 89.85 90.0 * longitude (longitude) float64 19kB -180.0 -179.8 ... 179.7 179.8 valid_time datetime64[ns] 8B 2024-04-11 Data variables: gh (latitude, longitude) float32 12MB ... gribfile_projection object 8B None r (latitude, longitude) float32 12MB ... 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: gdps product: 15km/grib2/lat_lon description: Canada's Global Deterministic Prediction System ... remote_grib: /p/cwfs/blaylock/data/gdps/20240411/CMC_glb_HGT_... local_grib: /p/cwfs/blaylock/data/gdps/20240411/CMC_glb_HGT_... search: None
[12]:
ax = (
EasyMap("50m", crs=ds.herbie.crs, figsize=8, linewidth=1, dark=True)
.BORDERS()
.STATES(alpha=0.5)
.ax
)
# Draw Relative Humidity
p = ax.pcolormesh(
ds.longitude, ds.latitude, ds.r * 100, 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, 'GDPS')