#!/usr/bin/env python # coding: utf-8 # # HRRR forecast best timeseries # Read from kerchunked GRIB2 files, write to Zarr # In[1]: import xarray as xr import fsspec import hvplot.xarray from kerchunk.grib2 import scan_grib # needed here only for grib compression codec # #### HRRR latest forecast best time series # In[2]: rpath = 's3://esip-qhub-public/noaa/hrrr/hrrr_best.json' s_opts = {'requester_pays':True, 'skip_instance_cache':True} r_opts = {'anon':True} fs = fsspec.filesystem("reference", fo=rpath, ref_storage_args=s_opts, remote_protocol='s3', remote_options=r_opts) m = fs.get_mapper("") ds = xr.open_dataset(m, engine="zarr", backend_kwargs=dict(consolidated=False), chunks={'valid_time':1}) # In[3]: ds # In[4]: da = ds['u10'].isel(valid_time=slice(-3,-1)).load() # In[5]: da.hvplot.quadmesh(x='longitude', y='latitude', geo=True, rasterize=True, cmap='turbo', tiles='OSM') # In[6]: ds.isel(valid_time=slice(-3,-1)).to_zarr('foo.zarr', 'w')