Case description
I have a set of spectral maps (intensity dependent on time and frequency) for a set of detectors which can be fit into a 3D array BlockDataset
of size M x N x K
(here: M
= number of frequencies, N
number of time steps and K
is the number of detectors).
The M
frequencies are log-spaced and the K
detectors are normally indexed by a tuple consiting of 2 angles but for brevity I'm considering only one angle. The N
time values are equidistant.
Creating a HoloViews dataset from BlockDataset
with appropriate value arrays for all of the dimensions is possible, but requires me to switch from a simple hv.Image
display to a hv.QuadMesh
display.
Problem description
If the dataset is created with actual angle values, instead of just detector numbers, a conversion to a HoloMap
fails with the following error:
DataError: The shape of the intensity value array does not match the expected dimensionality indicated by the key dimensions. Expected 2-D array, found 3-D array.
If detector numbers (integers) are used instead of angles (floating point numbers) there's no problem.
Code
timeDim = hv.Dimension("time", label="Time", unit="sec", values=times)
freqDim = hv.Dimension("frequency", label = "Angular frequency", unit="$\\frac{rad}{s}", values=omega)
polarAngleDim = hv.Dimension("angle", label=" $\varphi$", unit="rad", values=angles[:,0])
intensityDim = hv.Dimension("intensity", label="Intensity $\\frac{d^2 W}{d\Omega d\omega}(t,\vartheta,\varphi)", unit="J/(s srad)")
hvDatasetNatural = hv.Dataset((times, angles[:,0], omega, BlockDataset.transpose()), [timeDim, polarAngleDim, freqDim], intensityDim)
subset = hvDatasetNatural.select( angle=list(angles[selectedIndices,0]) )
img = subset.to( new_type=hv.QuadMesh, kdims=[timeDim, freqDim])
The selection of a subset
appears to work properly, but neither the conversion of the subset, nor of the entire dataset to QuadMesh
works.
Note again: times
are lin-spaced float values, angles
are nonlinearly spaced floats and omega
are log-spaced float values.
Query
- What may be the problem here? I.e., why doesn't
.to()
work on the dataset when 2 of the 3 dimensions are non-equidistant, non-integer values but it works well if onlyomega
is kept non-equidistant?
I can construct a QuadMesh
for a specific angle using hv.QuadMesh( (...), kdim=[..])
and hence essentially unwrapping the original object.
- (an extra) Why does an aggregation along the, e.g., time dimension using
subset.reduce(timeDim, np.sum)
work, butsubset.reduce(timeDim, np.trapz)
fails with:
DataError: None of the available storage backends were able to support the supplied data format. GridInterface raised following error:
GridInterface interface requires at least one value dimension.