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

hvplot expects xarray coordinate variable and dimension name to be the same? #329

Closed
rsignell-usgs opened this issue Oct 9, 2019 · 1 comment · Fixed by #450
Closed
Labels
Milestone

Comments

@rsignell-usgs
Copy link

rsignell-usgs commented Oct 9, 2019

This fails:

import xarray as xr
import hvplot.xarray

url = 'http://tds.glos.us/thredds/dodsC/glos/glcfs/huron/fcfmrc-3d/Lake_Huron_-_3D_best.ncd'
ds  = xr.open_dataset(url)
ds.temp.hvplot.quadmesh(x='lon', y='lat', rasterize=True)

with a cryptic error:

ValueError: can only convert an array of size 1 to a Python scalar

By trial and error, I discovered that the vertical coordinate name is sigma, but the dimension name of sigma is nsigma: sigma(nsigma).

If I simply rename the dimension nsigma to sigma, everything works as expected:

ds = ds.rename({'nsigma':'sigma'})

See https://nbviewer.jupyter.org/gist/rsignell-usgs/d5eee45716933297c978318e2a147fb6

@philippjfr
Copy link
Member

I think the correct way to handle this is to set sigma as an index: .set_index({'nsigma': 'sigma'}). I'll see if we can automate that though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants