Comments (6)
@jenfly
Simply replace the line
session = setup_session(username, password)
by
session = setup_session(username, password, check_url=url2)
This is explained in the updated documentation but unfortunately the readthedocs version was not updated after the last commit so there was no way for you to find out. @jameshiebert any chance the online documentation could be updated?
The reason is that the NASA URS authentication only gives you the right cookies when you actually query some data..
from pydap.
Perfect! Thanks so much, @laliberte.
from pydap.
Re: readthedocs: readthedocs automatically builds the docs from GitHub every time we tag a release (not on every commit, I think), so one should be able to read the updated docs now that a release has been tagged.
from pydap.
Yes, it is working! Good to know that a release has to be tagged :)
from pydap.
I'm also trying to access this data. Using
from pydap.client import open_url
from pydap.cas.urs import setup_session
url2 = ('https://goldsmr4.gesdisc.eosdis.nasa.gov/opendap/MERRA2/'
'M2I1NXASM.5.12.4/2015/08/MERRA2_400.inst1_2d_asm_Nx.20150802.nc4')
url3 = ('https://goldsmr5.gesdisc.eosdis.nasa.gov/opendap/hyrax/MERRA2/'
'M2I3NVASM.5.12.4/2015/08/MERRA2_400.inst3_3d_asm_Nv.20150802.nc4')
session = setup_session(username, password, check_url=url2)
ds2 = open_url(url2, session=session)
ds3 = open_url(url3, session=session)
print(ds2['TS'].shape)
print(ds2['TS'][0, 0, 0])
print(ds3['T'].shape)
print(ds3['T'][0, 0, 0, 0])
I get :
(24, 361, 576)
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
<ipython-input-37-a6a3022d846a> in <module>()
12
13 print(ds2['TS'].shape)
---> 14 print(ds2['TS'][0, 0, 0])
15 print(ds3['T'].shape)
16 print(ds3['T'][0, 0, 0, 0])
/home/mpubatman/anaconda3/lib/python3.6/site-packages/pydap/model.py in __getitem__(self, index)
318 def __getitem__(self, index):
319 out = copy.copy(self)
--> 320 out.data = self._get_data_index(index)
321 return out
322
/home/mpubatman/anaconda3/lib/python3.6/site-packages/pydap/model.py in _get_data_index(self, index)
347 return np.vectorize(decode_np_strings)(self._data[index])
348 else:
--> 349 return self._data[index]
350
351 def _get_data(self):
/home/mpubatman/anaconda3/lib/python3.6/site-packages/pydap/handlers/dap.py in __getitem__(self, index)
140 logger.info("Fetching URL: %s" % url)
141 r = GET(url, self.application, self.session, timeout=self.timeout)
--> 142 raise_for_status(r)
143 dds, data = r.body.split(b'\nData:\n', 1)
144 dds = dds.decode(r.content_encoding or 'ascii')
/home/mpubatman/anaconda3/lib/python3.6/site-packages/pydap/net.py in raise_for_status(response)
34 detail=response.status+'\n'+response.text,
35 headers=response.headers,
---> 36 comment=response.body
37 )
38
HTTPError: 302 Found
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="https://urs.earthdata.nasa.gov/oauth/authorize/?scope=uid&app_type=401&client_id=e2WVk8Pw6weeLUKZYOxvTQ&response_type=code&redirect_uri=https%3A%2F%2Fgoldsmr4.gesdisc.eosdis.nasa.gov%2Fdata-redirect&state=aHR0cHM6Ly9nb2xkc21yNC5nZXNkaXNjLmVvc2Rpcy5uYXNhLmdvdi9vcGVuZGFwL01FUlJBMi9NMkkxTlhBU00uNS4xMi40LzIwMTUvMDgvTUVSUkEyXzQwMC5pbnN0MV8yZF9hc21fTnguMjAxNTA4MDIubmM0LmRvZHM%2FVFNbMDoxOjBdWzA6MTowXVswOjE6MF0">here</a>.</p>
</body></html>
Help much appreciated.
Incidentally, I get the same thing if I enter a random username and password. I'm quite sure I got those right. I'm not sure how to debug this one... Thanks!
from pydap.
Wow, nevermind. I followed the link and just followed the instructions. Turns out I had to authorize the NASA GESDISC DATA ARCHIVE applications as part of my Earthdata account.
from pydap.
Related Issues (20)
- AttributeError: '<class 'pydap.model.DatasetType'>' object has no attribute 'decode'
- Documentation for proxy use HOT 2
- namespace_packages deprecated HOT 1
- "This is redirect error" when accessing NASA OPeNDAP HDF5 files (3.3.0) HOT 7
- Pydap handlers not found during installation HOT 4
- Can't access attributes/coordinates HOT 2
- Include verify=self.verify within add_dap4_proxies() and add_dap2_proxies() HOT 3
- Solve pkg_resources DeprecationWarning HOT 1
- rename `master` branch to `main`
- TypeError: cannot pickle '_thread.lock' object on OSX (and potentially Win32) for python > 3.8
- update readme + documentation HOT 1
- Modernize pydap for newer python practices HOT 1
- Diagnose xarray-with-pydap errors described below HOT 5
- Extend PyDAP to support EDL tokens HOT 1
- Support for DAP4 objects in PyDAP python library HOT 4
- HTTPError 401 when using pydap + EDL tokens to access EarthData. HOT 1
- remove six dependency HOT 1
- add project.toml file HOT 1
- URL escaping: Does PyDAP escape characters in URLs?
- improve debuging with pre-commit
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pydap.