question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inconsistent xarray dimensions use between holoviews and geoviews

See original GitHub issue

The same data is being plotted differently into an Image using either holoviews or geoviews. Is this related to how geoviews uses boundaries, a mention I find in just one line of the docs of geoviews when comparing to the Iris library?

Here’s how I create the datasets:

kdims = ['simtime', 'lyr_mid', ('lon', 'Longitude'), ('lat','Latitude')]
vdims = ['wind_mag', 'wind_dir']
xr_dataset = gv.Dataset(xr_ensemble, kdims=kdims, vdims=vdims, crs=crs.PlateCarree())
hv_dataset = hv.Dataset(xr_ensemble, kdims=kdims, vdims=vdims)

Here’s the geoviews Image plot:

%%opts Image [aspect=1.5]
xr_dataset.select(simtime=(24096,24098)).to(gv.Image, ['lon', 'lat'], 'wind_mag')

screenshot 2017-07-29 16 12 08

and here the holoviews Image plot:

%%opts Image [aspect=1.5]
hv_dataset.select(simtime=(24096,24098)).to(hv.Image, ['lon', 'lat'], 'wind_mag')

screenshot 2017-07-29 16 13 24

As you can see the latitude has 4 bins, and all bins are shown in the holoviews Image plot, but the geoviews Image plot is using the value of the first latitude dimension, 70, as a boundary instead of centering the bin around that number, which is how this netCDF data was compiled.

How can I make geoviews treat the data the same way holoviews already does?

Here’s the .coords view of the xarray object:

Coordinates:
  * lyr_mid  (lyr_mid) float64 0.992 0.9975 0.9995
  * lon      (lon) float64 -180.0 -174.0 -168.0 -162.0 -156.0 -150.0 -144.0 ...
  * lat      (lat) float64 -85.0 -80.0 -75.0 -70.0
  * simtime  (simtime) float64 2.41e+04 2.41e+04 2.41e+04 2.41e+04 2.41e+04 ...

My system data:

  • macOS 10.12.5
  • python 3.6 using conda-forge, all current versions
  • geoviews via the ioam channel
  • Chrome Browser Version 59.0.3071.115 (Official Build) (64-bit)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
philippjfrcommented, Jan 8, 2018

The fix was merged in the referenced PR, closing.

1reaction
lukasbindreitercommented, Oct 25, 2017

Any updates on this?

This definetly looks like an issue in boundary calculation. If you look at the latitude axis, it ranges from -70 to -85 in geoviews and from -65 to -90 in holoviews.

X Array has images in their documentation which nicely illustrate the difference: Images taken from here

Without bounds calculation

Without bounds

With bounds calculation

With bounds

In X-Array you can change this behaviour by specifying the infer_intervals argument, which uses this underlying function: _infer_interval_breaks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Inconsistent xarray dimensions use between holoviews and ... - GitHub
The same data is being plotted differently into an Image using either holoviews or geoviews. Is this related to how geoviews uses boundaries, ......
Read more >
Hvplot reporting "inconsistent chunks" on Xarray dataarray
I extract a 2D DataArray from the dataset (and the 2D data has 300x300 size chunks). Although the Matplotlib quadmesh da.plot() command works ......
Read more >
FAQ — HoloViews v1.15.3
A: HoloViews typically uses pandas and xarray objects in its examples, but it can accept standard Python data structures as well. Whatever data...
Read more >
Gridded Datasets I - GeoViews
GeoViews is designed to make full use of multidimensional gridded datasets stored in netCDF or other common formats, via the xarray and iris...
Read more >
Highest scored 'geoviews' questions - Stack Overflow
I am trying to plot the Zillow dataset with Bokeh using Geoviews and Datashader ... Holoviews/Bokeh: # convert GeoDataFrame to xarray object xa_dataset...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found