holoviz / holoviews

With Holoviews, your data visualizes itself.
https://holoviews.org
BSD 3-Clause "New" or "Revised" License
2.67k stars 400 forks source link

Misjudge about gridded data or not #6317

Open arafune opened 2 weeks ago

arafune commented 2 weeks ago

ALL software version info

OS: Mac OS Bokeh : 3.4.2 / 3.5.0

Description of expected behavior and the observed behavior

Clearly, xr.DataArray is regular grid from its definition. but I met the problem as follows:


DataError Traceback (most recent call last) Cell In[12], line 1 ----> 1 hv.Image(cut2_band)

File ~/env/py311/lib/python3.11/site-packages/holoviews/element/raster.py:281, in Image.init(self, data, kdims, vdims, bounds, extents, xdensity, ydensity, rtol, params) 279 Dataset.init(self, data, kdims=kdims, vdims=vdims, extents=extents, params) 280 if not self.interface.gridded: --> 281 raise DataError( 282 f"{type(self).name} type expects gridded data, " 283 f"{self.interface.name} is columnar. " 284 "To display columnar data as gridded use the HeatMap " 285 "element or aggregate the data (e.g. using np.histogram2d)." 286 ) 288 dim2, dim1 = self.interface.shape(self, gridded=True)[:2] 289 if bounds is None:

DataError: Image type expects gridded data, DictInterface is columnar. To display columnar data as gridded use the HeatMap element or aggregate the data (e.g. using np.histogram2d).

This problem does not occur not always.

I have confirmed that this problematic xr.DataArray is 2-dimensional.

スクリーンショット 2024-07-09 16 30 32

Therefore, I cannot figure out why this problem occurs. I believe the issue may lie in the process that determines whether the data is gridded or not. If you need more information about this problematic xr.DataArray to fix the code, please let me know.

arafune commented 2 weeks ago

hv.Image((cut2_band.coords["kp"].values, cut2_band.coords["eV"], cut2_band.values))

The above code works well. So I believe the problem should lie in the process for determining the gridded.