π 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]:
<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>