Skip to content
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

Unlimit the vdims for a variety of elements #253

Merged
merged 3 commits into from Jan 14, 2019

Conversation

@ahuang11
Copy link
Collaborator

ahuang11 commented Nov 27, 2018

image

Still working on making quadmesh work (can't seem to figure it out)...

<xarray.Dataset>
Dimensions:  (lat: 25, lon: 53)
Coordinates:
  * lat      (lat) float32 75.0 72.5 70.0 67.5 65.0 ... 25.0 22.5 20.0 17.5 15.0
  * lon      (lon) float32 200.0 202.5 205.0 207.5 ... 322.5 325.0 327.5 330.0
    time     datetime64[ns] 2013-01-01
Data variables:
    air      (lat, lon) float32 241.2 242.5 243.5 244.0 ... 296.9 296.79 296.6
    air2     (lat, lon) float32 482.4 485.0 487.0 488.0 ... 593.8 593.58 593.2
Attributes:
    Conventions:  COARDS
    title:        4x daily NMC reanalysis (1948)
    description:  Data is from NMC initialized reanalysis\n(4x/day).  These a...
    platform:     Model
    references:   http://www.esrl.noaa.gov/psd/data/gridded/data.ncep.reanaly...
['lon', 'lat']
['air', 'air2']
<xarray.Dataset>
Dimensions:  (lat: 25, lon: 53)
Coordinates:
  * lat      (lat) float32 75.0 72.5 70.0 67.5 65.0 ... 25.0 22.5 20.0 17.5 15.0
  * lon      (lon) float32 200.0 202.5 205.0 207.5 ... 322.5 325.0 327.5 330.0
    time     datetime64[ns] 2013-01-01
Data variables:
    air      (lat, lon) float32 241.2 242.5 243.5 244.0 ... 296.9 296.79 296.6
    air2     (lat, lon) float32 482.4 485.0 487.0 488.0 ... 593.8 593.58 593.2
Attributes:
    Conventions:  COARDS
    title:        4x daily NMC reanalysis (1948)
    description:  Data is from NMC initialized reanalysis\n(4x/day).  These a...
    platform:     Model
    references:   http://www.esrl.noaa.gov/psd/data/gridded/data.ncep.reanaly...
[Dimension('lon'), Dimension('lat')]
[Dimension('air'), Dimension('air2')]
(array([[-160. , -157.5, -155. , ...,  -35. ,  -32.5,  -30. ],
       [-160. , -157.5, -155. , ...,  -35. ,  -32.5,  -30. ],
       [-160. , -157.5, -155. , ...,  -35. ,  -32.5,  -30. ],
       ...,
       [-160. , -157.5, -155. , ...,  -35. ,  -32.5,  -30. ],
       [-160. , -157.5, -155. , ...,  -35. ,  -32.5,  -30. ],
       [-160. , -157.5, -155. , ...,  -35. ,  -32.5,  -30. ]]), array([[15. , 15. , 15. , ..., 15. , 15. , 15. ],
       [17.5, 17.5, 17.5, ..., 17.5, 17.5, 17.5],
       [20. , 20. , 20. , ..., 20. , 20. , 20. ],
       ...,
       [70. , 70. , 70. , ..., 70. , 70. , 70. ],
       [72.5, 72.5, 72.5, ..., 72.5, 72.5, 72.5],
       [75. , 75. , 75. , ..., 75. , 75. , 75. ]]), array([[296.29   , 296.79   , 297.1    , ..., 296.9    , 296.79   ,
        296.6    ],
       [295.9    , 296.19998, 296.79   , ..., 295.9    , 295.9    ,
        295.19998],
       [296.6    , 296.19998, 296.4    , ..., 295.4    , 295.1    ,
        294.69998],
       ...,
       [250.     , 249.79999, 248.89   , ..., 233.2    , 236.39   ,
        241.7    ],
       [243.79999, 244.5    , 244.7    , ..., 232.79999, 235.29999,
        239.29999],
       [241.2    , 242.5    , 243.5    , ..., 232.79999, 235.5    ,
        238.59999]], dtype=float32))
[Dimension('lon'), Dimension('lat')]
[Dimension('air'), Dimension('air2')]
---------------------------------------------------------------------------
DataError                                 Traceback (most recent call last)
~/anaconda3/lib/python3.6/site-packages/IPython/core/formatters.py in __call__(self, obj, include, exclude)
    968 
    969             if method is not None:
--> 970                 return method(include=include, exclude=exclude)
    971             return None
    972         else:

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/core/dimension.py in _repr_mimebundle_(self, include, exclude)
   1289         combined and returned.
   1290         """
-> 1291         return Store.render(self)
   1292 
   1293 

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/core/options.py in render(cls, obj)
   1311         data, metadata = {}, {}
   1312         for hook in hooks:
-> 1313             ret = hook(obj)
   1314             if ret is None:
   1315                 continue

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/ipython/display_hooks.py in pprint_display(obj)
    270     if not ip.display_formatter.formatters['text/plain'].pprint:
    271         return None
--> 272     return display(obj, raw_output=True)
    273 
    274 

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/ipython/display_hooks.py in display(obj, raw_output, **kwargs)
    240     elif isinstance(obj, (CompositeOverlay, ViewableElement)):
    241         with option_state(obj):
--> 242             output = element_display(obj)
    243     elif isinstance(obj, (Layout, NdLayout, AdjointLayout)):
    244         with option_state(obj):

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/ipython/display_hooks.py in wrapped(element)
    140         try:
    141             max_frames = OutputSettings.options['max_frames']
--> 142             mimebundle = fn(element, max_frames=max_frames)
    143             if mimebundle is None:
    144                 return {}, {}

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/ipython/display_hooks.py in element_display(element, max_frames)
    186         return None
    187 
--> 188     return render(element)
    189 
    190 

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/ipython/display_hooks.py in render(obj, **kwargs)
     63         renderer = renderer.instance(fig='png')
     64 
---> 65     return renderer.components(obj, **kwargs)
     66 
     67 

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/plotting/bokeh/renderer.py in components(self, obj, fmt, comm, **kwargs)
    276         # Bokeh has to handle comms directly in <0.12.15
    277         comm = False if bokeh_version < '0.12.15' else comm
--> 278         return super(BokehRenderer, self).components(obj,fmt, comm, **kwargs)
    279 
    280 

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/plotting/renderer.py in components(self, obj, fmt, comm, **kwargs)
    319             plot = obj
    320         else:
--> 321             plot, fmt = self._validate(obj, fmt)
    322 
    323         widget_id = None

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/plotting/renderer.py in _validate(self, obj, fmt, **kwargs)
    218         if isinstance(obj, tuple(self.widgets.values())):
    219             return obj, 'html'
--> 220         plot = self.get_plot(obj, renderer=self, **kwargs)
    221 
    222         fig_formats = self.mode_formats['fig'][self.mode]

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/plotting/bokeh/renderer.py in get_plot(self_or_cls, obj, doc, renderer, **kwargs)
    161             curdoc().theme = self_or_cls.theme
    162         doc.theme = self_or_cls.theme
--> 163         plot = super(BokehRenderer, self_or_cls).get_plot(obj, renderer, **kwargs)
    164         plot.document = doc
    165         return plot

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/plotting/renderer.py in get_plot(self_or_cls, obj, renderer, **kwargs)
    205             init_key = tuple(v if d is None else d for v, d in
    206                              zip(plot.keys[0], defaults))
--> 207             plot.update(init_key)
    208         else:
    209             plot = obj

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/plotting/plot.py in update(self, key)
    589     def update(self, key):
    590         if len(self) == 1 and ((key == 0) or (key == self.keys[0])) and not self.drawn:
--> 591             return self.initialize_plot()
    592         item = self.__getitem__(key)
    593         self.traverse(lambda x: setattr(x, '_updated', True))

/mnt/c/Users/sephi/GOOGLE~1/Bash/geoviews/geoviews/plotting/bokeh/plot.py in initialize_plot(self, ranges, plot, plots, source)
     86     def initialize_plot(self, ranges=None, plot=None, plots=None, source=None):
     87         opts = {} if isinstance(self, HvOverlayPlot) else {'source': source}
---> 88         fig = super(GeoPlot, self).initialize_plot(ranges, plot, plots, **opts)
     89         if self.geographic and self.show_bounds and not self.overlaid:
     90             from . import GeoShapePlot

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/plotting/bokeh/element.py in initialize_plot(self, ranges, plot, plots, source)
    948         self.handles['plot'] = plot
    949 
--> 950         self._init_glyphs(plot, element, ranges, source)
    951         if not self.overlaid:
    952             self._update_plot(key, plot, style_element)

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/plotting/bokeh/element.py in _init_glyphs(self, plot, element, ranges, source)
    899         else:
    900             style = self.style[self.cyclic_index]
--> 901             data, mapping, style = self.get_data(element, ranges, style)
    902             current_id = element._plot_id
    903         if source is None:

/mnt/c/Users/sephi/GOOGLE~1/Bash/geoviews/geoviews/plotting/bokeh/plot.py in get_data(self, element, ranges, style)
    130         proj = self.projection
    131         if self._project_operation and self.geographic:
--> 132             element = self._project_operation(element, projection=proj)
    133         return super(GeoPlot, self).get_data(element, ranges, style)
    134 

~/anaconda3/lib/python3.6/site-packages/param/parameterized.py in __new__(class_, *args, **params)
   2029         inst = class_.instance()
   2030         inst.param._set_name(class_.__name__)
-> 2031         return inst.__call__(*args,**params)
   2032 
   2033     def __call__(self,*args,**kw):

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/core/operation.py in __call__(self, element, **params)
    161                                 operation=self, kwargs=params)
    162         elif isinstance(element, ViewableElement):
--> 163             processed = self._apply(element)
    164         elif isinstance(element, DynamicMap):
    165             if any((not d.values) for d in element.kdims):

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/core/operation.py in _apply(self, element, key)
    119         for hook in self._preprocess_hooks:
    120             kwargs.update(hook(self, element))
--> 121         ret = self._process(element, key)
    122         for hook in self._postprocess_hooks:
    123             ret = hook(self, ret, **kwargs)

/mnt/c/Users/sephi/GOOGLE~1/Bash/geoviews/geoviews/operation/projection.py in _process(self, element, key)
     38 
     39     def _process(self, element, key=None):
---> 40         return element.map(self._process_element, self.supported_types)
     41 
     42 

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/core/dimension.py in map(self, map_fn, specs, clone)
    733             return deep_mapped
    734         else:
--> 735             return map_fn(self) if applies else self
    736 
    737 

/mnt/c/Users/sephi/GOOGLE~1/Bash/geoviews/geoviews/operation/projection.py in _process_element(self, element)
    271 
    272         params = get_param_values(element)
--> 273         return QuadMesh((PX, PY, zs), crs=self.projection, **params)
    274 
    275 

/mnt/c/Users/sephi/GOOGLE~1/Bash/geoviews/geoviews/element/geo.py in __init__(self, data, kdims, vdims, **kwargs)
    101 
    102 
--> 103     def clone(self, data=None, shared_data=True, new_type=None,
    104               *args, **overrides):
    105         if 'crs' not in overrides and (not new_type or isinstance(new_type, _Element)):

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/element/raster.py in __init__(self, data, kdims, vdims, **params)
    807 
    808     def __init__(self, data, kdims=None, vdims=None, **params):
--> 809         super(QuadMesh, self).__init__(data, kdims, vdims, **params)
    810         if not self.interface.gridded:
    811             raise DataError("%s type expects gridded data, %s is columnar."

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/core/data/__init__.py in __init__(self, data, kdims, vdims, **kwargs)
    217         validate_vdims = kwargs.pop('_validate_vdims', True)
    218         initialized = Interface.initialize(type(self), data, kdims, vdims,
--> 219                                            datatype=kwargs.get('datatype'))
    220         (data, self.interface, dims, extra_kws) = initialized
    221         super(Dataset, self).__init__(data, **dict(kwargs, **dict(dims, **extra_kws)))

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/core/data/interface.py in initialize(cls, eltype, data, kdims, vdims, datatype)
    249                                   % (intfc.__name__, e))
    250                 error = ' '.join([error, priority_error])
--> 251             raise DataError(error)
    252 
    253         return data, interface, dims, extra_kws

DataError: None of the available storage backends were able to support the supplied data format.
@ahuang11 ahuang11 mentioned this pull request Nov 27, 2018
@philippjfr

This comment has been minimized.

Copy link
Member

philippjfr commented Nov 27, 2018

What happens with additional vdims on RGB/HSV elements?

@jbednar

This comment has been minimized.

Copy link
Member

jbednar commented Nov 27, 2018

Would be nice if those worked with hover but I suspect @jlstevens didn't support RGB for hovering at the Bokeh level.

@ahuang11

This comment has been minimized.

Copy link
Collaborator Author

ahuang11 commented Nov 28, 2018

Yes, hover doesn't do anything on RGB/HSV so I limited it back.

Also still don't really understand how to fix quadmesh geo=True with additional vdims:

import hvplot.xarray
import cartopy.crs as ccrs
import geoviews as gv
ds = xr.tutorial.load_dataset('air_temperature').isel(time=0)
ds['air2'] = ds['air'] * 2

# this doesn't work
ds.hvplot.quadmesh('lon', 'lat', z='air', hover_cols=['air2'], geo=True).options(projection=ccrs.PlateCarree())

# this works
ds.hvplot.quadmesh('lon', 'lat', z='air', geo=True).options(projection=ccrs.PlateCarree())

particularly I don't really get why/how
super(_Element, self).__init__(data, kdims=kdims, vdims=vdims, **kwargs) gets called three separate times, the second time converting ['lon', 'lat'] ['air', 'air2'] to [Dimension('lon'), Dimension('lat')] [Dimension('air'), Dimension('air2')] and third time retains that.

@philippjfr

This comment has been minimized.

Copy link
Member

philippjfr commented Jan 14, 2019

I'll merge for now, but you're right that QuadMesh likely needs further fixes.

@philippjfr philippjfr merged commit badcfff into holoviz:master Jan 14, 2019
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.