-
-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KeyError: Dimension not found, even though dimension exists #72
Comments
Thanks for reporting this @madHatter106. Could you tell me the versions of holoviews, geoviews and xarray of when it was working and what versions you have now? |
Certainly: currently, When it was working: |
This may have been fixed in holoviz/holoviews#1467 but I can't be sure. We'll have a dev release later tonight at which point you can get it with |
sure, conda reports the master is what I have. I'll wait for the dev then . thanks @philippjfr |
Looks like the dev release will happen tomorrow. Any chance you could provide me with a small slice of your dataset containing just a few lats/lons so I can test it? |
Sure, thanks. I have a sub-sampled scene, about 1.3 MB. What's the best way to get it to you? |
Great! At that size email should be okay, could you mail it to |
Done. Thanks! |
I made a fix just before the 1.8dev2 release was out. Unfortunately I now think the fix was incorrect and have submitted a PR for the correct fix here: holoviz/holoviews#1526 |
Fix has now been merged into holoviews and will be part of the holoviews release early next week. |
hi @philippjfr ,
Below is the error
bokeh version: 1.0.4 |
Hi,
the code below used to work but has ceased to do so.
For context, working with the following geoviews dataset:
gvDataset.dimensions()
[Dimension('lon'),
Dimension('lat'),
Dimension('experiment'),
Dimension('rrs_unc')]
where
gvDataset['experiment']
array(['O3', 'Pressure', 'WindSpeed', ..., 'Lt', 'All', 'RH'], dtype=object)
then...
image = gvDataset.to(gv.Image, ['lat', 'lon'] ) * gf.land(style=dict(facecolor='gray'))
yields...
KeyError Traceback (most recent call last)
in ()
3 ancMin, ancMax = 1e-6, 1e-4
4 gvDataset = MakeGvDS(band)
----> 5 image = gvDataset.to(gv.Image, geodims) * gf.land(style=dict(facecolor='gray'))
6 layout = hv.NdLayout(image)
7 layout.cols(2)
~/anaconda3/lib/python3.5/site-packages/geoviews/element/init.py in call(self, *args, **kwargs)
24 if 'crs' not in kwargs and issubclass(group_type, _Element):
25 kwargs['crs'] = self._element.crs
---> 26 return super(GeoConversion, self).call(*args, **kwargs)
27
28 def linecontours(self, kdims=None, vdims=None, mdims=None, **kwargs):
~/anaconda3/lib/python3.5/site-packages/holoviews/core/data/init.py in call(self, new_type, kdims, vdims, groupby, sort, **kwargs)
132 return element.sort() if sort else element
133 group = selected.groupby(groupby, container_type=HoloMap,
--> 134 group_type=new_type, **params)
135 if sort:
136 return group.map(lambda x: x.sort(), [new_type])
~/anaconda3/lib/python3.5/site-packages/holoviews/core/data/init.py in groupby(self, dimensions, container_type, group_type, dynamic, **kwargs)
549
550 return self.interface.groupby(self, dim_names, container_type,
--> 551 group_type, **kwargs)
552
553 def len(self):
~/anaconda3/lib/python3.5/site-packages/holoviews/core/data/xarray.py in groupby(cls, dataset, dimensions, container_type, group_type, **kwargs)
123 if drop_dim:
124 v = v.to_dataframe().reset_index()
--> 125 data.append((k, group_type(v, **group_kwargs)))
126 else:
127 unique_iters = [cls.values(dataset, d, False) for d in group_by]
~/anaconda3/lib/python3.5/site-packages/geoviews/element/geo.py in init(self, data, **kwargs)
81 elif crs:
82 kwargs['crs'] = crs
---> 83 super(_Element, self).init(data, **kwargs)
84
85
~/anaconda3/lib/python3.5/site-packages/holoviews/element/raster.py in init(self, data, bounds, extents, xdensity, ydensity, **params)
257 SheetCoordinateSystem.init(self, bounds, xdensity, ydensity)
258
--> 259 if len(self.shape) == 3:
260 if self.shape[2] != len(self.vdims):
261 raise ValueError("Input array has shape %r but %d value dimensions defined"
~/anaconda3/lib/python3.5/site-packages/holoviews/core/data/init.py in shape(self)
565 def shape(self):
566 "Returns the shape of the data."
--> 567 return self.interface.shape(self)
568
569
~/anaconda3/lib/python3.5/site-packages/holoviews/core/data/grid.py in shape(cls, dataset, gridded)
101 return dataset.data[dataset.vdims[0].name].shape
102 else:
--> 103 return (cls.length(dataset), len(dataset.dimensions()))
104
105
~/anaconda3/lib/python3.5/site-packages/holoviews/core/data/xarray.py in length(cls, dataset)
249 @classmethod
250 def length(cls, dataset):
--> 251 return np.product(dataset[dataset.vdims[0].name].shape)
252
253 @classmethod
~/anaconda3/lib/python3.5/site-packages/holoviews/core/data/init.py in getitem(self, slices)
377 value_select = None
378 if len(slices) == 1 and slices[0] in self.dimensions():
--> 379 return self.dimension_values(slices[0])
380 elif len(slices) == self.ndims+1 and slices[self.ndims] in self.dimensions():
381 selection = dict(zip(self.dimensions('key', label=True), slices))
~/anaconda3/lib/python3.5/site-packages/holoviews/core/data/init.py in dimension_values(self, dim, expanded, flat)
574 """
575 dim = self.get_dimension(dim, strict=True)
--> 576 return self.interface.values(self, dim, expanded, flat)
577
578
~/anaconda3/lib/python3.5/site-packages/holoviews/core/data/xarray.py in values(cls, dataset, dim, expanded, flat)
157 if dim in dataset.vdims:
158 coord_dims = dataset.data[dim.name].dims
--> 159 data = cls.canonicalize(dataset, data, coord_dims=coord_dims)
160 return data.T.flatten() if flat else data
161 elif expanded:
~/anaconda3/lib/python3.5/site-packages/holoviews/core/data/grid.py in canonicalize(cls, dataset, data, coord_dims)
143 slices = []
144 for d in coord_dims:
--> 145 coords = cls.coords(dataset, d)
146 if np.all(coords[1:] < coords[:-1]):
147 slices.append(slice(None, None, -1))
~/anaconda3/lib/python3.5/site-packages/holoviews/core/data/xarray.py in coords(cls, dataset, dim, ordered, expanded)
142 @classmethod
143 def coords(cls, dataset, dim, ordered=False, expanded=False):
--> 144 dim = dataset.get_dimension(dim, strict=True).name
145 if expanded:
146 return util.expand_grid_coords(dataset, dim)
~/anaconda3/lib/python3.5/site-packages/holoviews/core/dimension.py in get_dimension(self, dimension, default, strict)
892 name_map.update({dimension_sanitizer(dim.name): dim for dim in all_dims})
893 if strict and dimension not in name_map:
--> 894 raise KeyError("Dimension %s not found" % dimension)
895 else:
896 return name_map.get(dimension, default)
KeyError: 'Dimension experiment not found'
The text was updated successfully, but these errors were encountered: