Okay, I think this works
import h5py
import numpy as np
import panel as pn
import xarray as xr
import holoviews as hv
import dask.array as da
from holoviews.operation.datashader import rasterize, shade
hv.extension('bokeh', logo=False)
f = h5py.File('data.h5', "r")
full_data = da.from_array(f['data'], chunks=(60*60, 2401), name=False)
da = xr.DataArray(
full_data,
dims=("x", "y"),
coords={"x": np.arange(full_data.shape[0]), "y": np.arange(full_data.shape[1])},
)
class BigSpectrogram():
def points(self, x_range, y_range):
print(x_range, y_range)
data = da.sel(x=slice(*x_range), y=slice(*y_range)).compute()
image = hv.Image(data)
return image
def view(self,**kwargs):
range_xy = hv.streams.RangeXY(x_range=(0, 3600), y_range=(0, 2401))
points = hv.DynamicMap(self.points, streams=[range_xy])
agg = rasterize(points)
return agg
spectrogram = BigSpectrogram()
pn.Row(spectrogram.view()).servable()