Panel is great at making simple dashboards to explore met/ocean forecast model output, like this HRRR explorer notebook, where I open an OPeNDAP Data URL from Unidata’s THREDDS server with xarray:
url = 'http://thredds.ucar.edu/thredds/dodsC/grib/NCEP/HRRR/CONUS_2p5km/Best'
ds = xr.open_dataset(url, chunks={'time':1})
load data and display fields using hvplot:
@pn.depends(var_select, base_map_select)
def plot(var, base_map):
extra_dims = list(ds[var].dims[:-2])
mesh = ds[var].hvplot.quadmesh(x='x', y='y', rasterize=True, crs=crs, title=var,
attr_labels=False, project=True,
groupby=extra_dims, cmap='rainbow',
width=600, height=400).opts(alpha=0.7,
data_aspect=None, active_tools=['wheel_zoom', 'pan'])
return pn.panel(mesh * base_map, widgets={k: pn.widgets.Select for k in extra_dims})
col = pn.Column(var_select, base_map_select, plot)
Here’s a snapshot of the dashboard:
The data available at the OPeNDAP endpoint changes each time a new forecast is available, but unless we reload the dataset, xarray won’t know about the new data. This isn’t a problem if the user just reruns the notebook, but when deployed as a web app that stays running, I guess I need a button that says “check for latest data” that reloads the dataset?
How best to accomplish that?