0

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

  1. 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 only omega is kept non-equidistant?

I can construct a QuadMesh for a specific angle using hv.QuadMesh( (...), kdim=[..]) and hence essentially unwrapping the original object.

  1. (an extra) Why does an aggregation along the, e.g., time dimension using subset.reduce(timeDim, np.sum) work, but subset.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.
Nox
  • 324
  • 3
  • 18
  • Welcome to stack overflow! Please see the guide to [ask], and try to simplify your example and provide setup code as a [mre]. Please only ask one question at a time - you’re welcome to post more than one question, but tailor your setup and explanation to only include the information and code for each. Thanks! – Michael Delgado Jan 05 '22 at 16:25
  • Right; tough to follow without complete, runnable code, ideally boiled down to a very specific issue. The HoloViews community typically discusses such issues at https://discourse.holoviz.org/c/holoviews/6 ... – James A. Bednar Jan 05 '22 at 19:42

0 Answers0