Slicing bug with xarray
See original GitHub issueI found a subtle bug when slicing Images created with xarray, where an incorrect position is returned. Unfortunately, I am unable to demonstrate this with synthetic data, but the following notebook illustrates the problem:
https://gist.github.com/drs251/f97801aa7d6f92b11c9c71c6a7c4085a
EDIT: I found out how to reproduce it: the key is that the frames have to be non-square:
import numpy as np
import xarray as xr
import holoviews as hv
hv.notebook_extension()
x = np.linspace(-3, 7, 533)
y = np.linspace(-5, 8, 894)
z = np.exp(-1*(x**2 + y[:, np.newaxis]**2))
p = np.arange(5)
zz = np.dstack([z, z, z, z, z])
array = xr.DataArray(zz, coords=[y, x, p], dims=['x', 'y', 'p'])
array.name = "intensity"
image = hv.Dataset(array).to(hv.Image, kdims=["x", "y"])
image[0, -1:1, -1:1]
The slice should be nicely centered on the maximum, but it’s not.
Issue Analytics
- State:
- Created 6 years ago
- Comments:36 (36 by maintainers)
Top Results From Across the Web
slice in xarray gives error 'float' object cannot be interpreted as ...
I am trying to slice data by longtitude using xarray . The data is in a netcdf file I created from measurements I...
Read more >What's New — xray 0.5.0 documentation - Xarray
Fixed a bug where data netCDF variables read from disk with engine='scipy' could still be associated with the file on disk, even after...
Read more >What's New — xarray 0.8.0 documentation - PyData |
Fix a bug where xarray.ufuncs that take two arguments would incorrectly use to ... Silenced spurious warnings about all-NaN slices when using nan-aware ......
Read more >Introduction to cf_xarray - CF Xarray - Read the Docs
Slicing works will expand a single key like X to multiple dimensions if those ... coarsen works but everything later will break because...
Read more >pydata/xarray - Gitter
How can I do an indexing with a slice between two dataarrays? Deepak Cherian. @dcherian ... I haven't used it much so bugs...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Great you figured it out!
No, I’d say that’s a real issue and as you show for xarray we should ignore the matplotlibrc and specify an explicit origin. If you’re up for contributing, adding an explicit origin=‘upper’ here https://github.com/ioam/holoviews/blob/master/holoviews/plotting/mpl/raster.py#L160 would be appreciated otherwise I’ll try to get around to it soon.
I’ve opened an issue for the matplotlib origin thing, and the original bug mentioned in this issue has been fixed.