Brian Blaylock
July 20, 2021
RRFS Data#
The Rapid Refresh Forecast System is undergoing rapid development. There are prototype products available on the cloud on AWS. Some files have an index file, others do not.
[1]:
from herbie.archive import Herbie
from toolbox.cartopy_tools import common_features, pc
from paint.standard2 import cm_tmp
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
/p/home/blaylock/BB_python/Carpenter_Workshop/toolbox/cartopy_tools_OLD.py:37: UserWarning: Migrate to new `cartopy_tools` for latest updates and features.
warnings.warn("Migrate to new `cartopy_tools` for latest updates and features.")
/p/home/blaylock/BB_python/Carpenter_Workshop/toolbox/cartopy_tools.py:38: UserWarning: Migrate to `cartopy_tools2` for latest updates and features.
warnings.warn("Migrate to `cartopy_tools2` for latest updates and features.")
/p/home/blaylock/BB_python/Carpenter_Workshop/toolbox/cartopy_tools.py:994: AccessorRegistrationWarning: registration of accessor <class 'toolbox.cartopy_tools.xr_to_cartopy'> under name 'xmap' for type <class 'xarray.core.dataset.Dataset'> is overriding a preexisting attribute with the same name.
class xr_to_cartopy:
[2]:
H = Herbie("2021-07-23", model="rrfs", fxx=1)
/p/home/blaylock/BB_python/Herbie/herbie/archive.py:205: UserWarning: `product` not specified. Will use ["mean"].
warnings.warn(f'`product` not specified. Will use ["{self.product}"].')
ππ»ββοΈ Found 2021-Jul-23 00:00 UTC F01 [RRFS] [product=mean] GRIB2 file from aws and index file from aws.
[3]:
H.SOURCES
[3]:
{'aws': 'https://noaa-rrfs-pds.s3.amazonaws.com/rrfs.20210723/00/ensprod/rrfsce.t00z.conus.mean.f01.grib2',
'aws-mem': 'https://noaa-rrfs-pds.s3.amazonaws.com/rrfs.20210723/00/mem01/rrfs.t00z.mem01.meanf001.grib2'}
[4]:
x = H.xarray("TMP:2 m")
π¨π»βπ Created directory: [/p/cwfs/blaylock/data/rrfs/20210723/mem01]
π Download subset: [RRFS] model [mean] product run at 2021-Jul-23 00:00 UTC F01
cURL from https://noaa-rrfs-pds.s3.amazonaws.com/rrfs.20210723/00/ensprod/rrfsce.t00z.conus.mean.f01.grib2
1: GRIB_message=14 TMP:2 m above ground:1 hour fcst:wt ens mean
[6]:
ax = common_features(crs=x.herbie.crs, figsize=[8, 8]).ax
p = ax.pcolormesh(
x.longitude, x.latitude, x.t2m, transform=pc, **cm_tmp(units="K").cmap_kwargs
)
plt.colorbar(
p, ax=ax, orientation="horizontal", pad=0.05, **cm_tmp(units="K").cbar_kwargs
)
ax.set_title(x.t2m.GRIB_name, loc="right")
ax.set_title(f"{H.model.upper()}: {H.product_description}", loc="left")
/p/home/blaylock/anaconda3/envs/herbie/lib/python3.8/site-packages/cartopy/mpl/geoaxes.py:1702: UserWarning: The input coordinates to pcolormesh are interpreted as cell centers, but are not monotonically increasing or decreasing. This may lead to incorrectly calculated cell edges, in which case, please supply explicit cell edges to pcolormesh.
X, Y, C, shading = self._pcolorargs('pcolormesh', *args,
[6]:
Text(0.0, 1.0, 'RRFS: ensemble mean')

What about when there isnβt an index file available?#
We have to download the full file.
[ ]:
H = Herbie(
"2021-07-23", model="rrfs", product="testbed.conus", member=1, priority="aws-mem"
)
ππ»ββοΈ Found 2021-Jul-23 00:00 UTC F00 [RRFS] [product=testbed.conus] GRIB2 file from aws-mem and index file from None.
[ ]:
# no index file available. Have to download the full file.
H.download()
β
Success! Downloaded RRFS from aws-mem
src: https://noaa-rrfs-pds.s3.amazonaws.com/rrfs.20210723/00/mem01/rrfs.t00z.mem01.testbed.conusf000.grib2
dst: /p/cwfs/blaylock/data/rrfs/20210723/mem01/rrfsce.t00z.conus.testbed.conus.f00.grib2
[ ]:
import xarray
[ ]:
# Since we have the full file, we need to filter by keys to open the
# variable we want with cfgrib
x = xarray.open_dataset(
H.get_localFilePath(),
engine="cfgrib",
backend_kwargs={
"filter_by_keys": {"shortName": "2t", "typeOfLevel": "heightAboveGround"}
},
)
[ ]:
ax = common_features(crs=x.herbie.crs, figsize=[8, 8]).ax
p = ax.pcolormesh(
x.longitude, x.latitude, x.t2m, transform=pc, **cm_tmp(units="K").cmap_kwargs
)
plt.colorbar(
p, ax=ax, orientation="horizontal", pad=0.05, **cm_tmp(units="K").cbar_kwargs
)
ax.set_title(x.t2m.GRIB_name, loc="right")
ax.set_title(f"{H.model.upper()}: member {H.member}", loc="left")
Text(0.0, 1.0, 'RRFS: member 1')

Grid Mapping#
Herbie attempts to parse the CF grid mapping from the GRIB data if it is available. This can be parsed by metpy.
[10]:
import metpy
[13]:
crs_info = x.metpy.parse_cf().metpy_crs.item()
crs_info.to_cartopy()
[13]:
<cartopy.crs.LambertConformal object at 0x2ab37c61ccc0>
[14]:
crs_info.to_pyproj()
[14]:
<Projected CRS: {"$schema": "https://proj.org/schemas/v0.2/projjso ...>
Name: undefined
Axis Info [cartesian]:
- E[east]: Easting (metre)
- N[north]: Northing (metre)
Area of Use:
- undefined
Coordinate Operation:
- name: unknown
- method: Lambert Conic Conformal (2SP)
Datum: World Geodetic System 1984
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich
[ ]: