In [1]:
import xarray as xr
import fsspec
In [2]:
fs = fsspec.filesystem('s3', anon=True)
In [3]:
url = 's3://noaa-hrrr-bdp-pds/hrrr.20210902/conus/hrrr.t12z.wrfsfcf01.grib2'
In [4]:
_ = fs.download(url, 'test.grib2')
In [5]:
ds = xr.open_dataset('test.grib2', engine='cfgrib', 
               backend_kwargs={'filter_by_keys': {'typeOfLevel': 'heightAboveGround', 'level': 2}})   
Ignoring index file 'test.grib2.9810b.idx' older than GRIB file
In [6]:
ds.data_vars
Out[6]:
Data variables:
    unknown  (y, x) float32 ...
    t2m      (y, x) float32 ...
    pt       (y, x) float32 ...
    sh2      (y, x) float32 ...
    d2m      (y, x) float32 ...
    r2       (y, x) float32 ...
In [7]:
ds1 = xr.open_dataset('test.grib2', engine='cfgrib', 
               backend_kwargs={'filter_by_keys': {'typeOfLevel': 'heightAboveGround', 'level': 10}})   
ds1.data_vars
Ignoring index file 'test.grib2.9810b.idx' older than GRIB file
Out[7]:
Data variables:
    u10      (y, x) float32 ...
    v10      (y, x) float32 ...
    si10     (y, x) float32 ...
    unknown  (y, x) float32 ...
In [ ]: