🌐 Cartopy CRS#

Herbie can help you get the Cartopy Coordinate Reference System (CRS) for the model domain. Just use the Herbie accessor on a returned xarray Dataset.

crs = ds.herbie.crs

This is helpful if you want to plot the data on the map.

This feature requires Metpy and Pygrib

[8]:
from herbie import Herbie
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
[2]:
H = Herbie("2022-12-05 06:00", fxx=6, model="hrrr")
ds = H.xarray("TMP:2 m")
βœ… Found β”Š model=hrrr β”Š product=sfc β”Š 2022-Dec-05 06:00 UTC F06 β”Š GRIB2 @ aws β”Š IDX @ aws
[11]:
# Herbie xarray accessor to get CRS
ds.herbie.crs
[11]:
2024-04-06T15:41:43.696563 image/svg+xml Matplotlib v3.8.3, https://matplotlib.org/
<cartopy.crs.LambertConformal object at 0x7f8187e67ce0>
[10]:
ax = plt.subplot(projection=ds.herbie.crs)
ax.coastlines()
ax.pcolormesh(ds.longitude, ds.latitude, ds.t2m, transform=ccrs.PlateCarree())
[10]:
<cartopy.mpl.geocollection.GeoQuadMesh at 0x7f817d4e4440>
../../../_images/user_guide_tutorial_accessor_notebooks_cartopy_crs_4_1.png