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.

variable name error in pydap 3.2.2

See original GitHub issue

I’m having trouble accessing a dataset with pydap 3.2.2 that worked fine in 3.2.1. I think 3.2.2 mangles the variable name. I briefly looked at the source, but it wasn’t clear to me where the problem was.

pydap 3.2.1

>>> from pydap.client import open_url
>>> dataset = open_url('https://nomads.ncdc.noaa.gov/thredds/dodsC/gfs-004/201612/20161201/gfs_4_20161201_0000_003.grb2')
>>> tsurf = dataset['Temperature_surface']
>>> tsurf[0, 0, 0]
<GridType with array 'Temperature_surface' and maps 'time', 'lat', 'lon'>

pydap 3.2.2

>>> from pydap.client import open_url
>>> dataset = open_url('https://nomads.ncdc.noaa.gov/thredds/dodsC/gfs-004/201612/20161201/gfs_4_20161201_0000_003.grb2')
>>> tsurf = dataset['Temperature_surface']
>>> tsurf[0, 0, 0]
Traceback (most recent call last):
  File "/Users/holmgren/miniconda3/envs/pydap322/lib/python3.6/site-packages/pydap/model.py", line 404, in _getitem_string
    return self._dict[quote(key)]
KeyError: 'Temperature_surface%2ETemperature_surface'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/holmgren/miniconda3/envs/pydap322/lib/python3.6/site-packages/pydap/model.py", line 740, in __getitem__
    var.data = self[var.name].data[slice_]
  File "/Users/holmgren/miniconda3/envs/pydap322/lib/python3.6/site-packages/pydap/handlers/dap.py", line 149, in __getitem__
    return dataset[self.id].data
  File "/Users/holmgren/miniconda3/envs/pydap322/lib/python3.6/site-packages/pydap/model.py", line 425, in __getitem__
    return self._getitem_string(key)
  File "/Users/holmgren/miniconda3/envs/pydap322/lib/python3.6/site-packages/pydap/model.py", line 409, in _getitem_string
    return self[splitted[0]]['.'.join(splitted[1:])]
  File "/Users/holmgren/miniconda3/envs/pydap322/lib/python3.6/site-packages/pydap/model.py", line 320, in __getitem__
    out.data = self._get_data_index(index)
  File "/Users/holmgren/miniconda3/envs/pydap322/lib/python3.6/site-packages/pydap/model.py", line 349, in _get_data_index
    return self._data[index]
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
jalbert10NJcommented, Jun 28, 2020

Apparently the above issue is due to the fact that one needs to fully pip uninstall Pydap before doing a pip install from a git repository, e.g. python -m pip install git+https://github.com/pydap/pydap.git@fc0dd0e6f180e455dbb68a06a85f84b1eca6754f (or just pip install git+https://github.com/pydap/pydap.git@fc0dd0e6f180e455dbb68a06a85f84b1eca6754f ), since if one already has Pydap 3.2.2 installed, then the pip install git+https://github.com/pydap/pydap.git@fc0dd0e6f180e455dbb68a06a85f84b1eca6754f does not install the update (likely due to a completely separate bug in pip – at least in the pip in the anaconda install of python 3.7 on MacOS Mojave – and despite the fact that the pip install does properly create the wheel, it does not properly install it if Pydap 3.2.2 has already been installed). (The wheel just rolls away 😉

Anyway, IMO there is no reason that this bug should still remain in the default version of Pydap, and require people to pip install from github, rather than from the default PyPI. If Pydap maintainers are waiting for other fixes before releasing 3.2.3, as is apparently the case, then IMO a 3.2.2.1 with this fix should be released to PyPI in the meantime. Additional people should not have to waste weeks re-debugging this issue. I am thus opening this issue back up (and request that it not be closed until the default version of Pydap from PyPI contains this fix).

1reaction
ghostcommented, Jan 26, 2018

I’m having similar trouble when using xarray and pydap. Why the variable name (key) gets doubled like above: ‘Temperature_surface.Temperature_surface’?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pydap Documentation - Read the Docs
Pydap is a pure Python library implementing the Data Access Protocol, ... We can check the names of the store variables like we...
Read more >
Developer documentation — Pydap 3.2 documentation
Note that there's a difference between the variable name (the local name a ) and its attribute name ; in this example they...
Read more >
Pydap - PyPI
An implementation of the Data Access Protocol.
Read more >
What's New - Xarray
Include the variable name in the error message when CF decoding fails to allow for ... Support for engine='pydap' with recent releases of...
Read more >
whats-new.rst.txt - Xarray - PyData |
Xarray now does a better job rendering variable names that are long LaTeX ... A clearer error is now raised if a user...
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