2

I would like to access several MODIS products through OPeNDAP as an xarray.Dataset, for example the MOD13Q1 tiles found here. However I'm running into some problems, which I think are somehow related to the authentication. For data sources that do not require authentication, things work fine. For example:

data = xr.open_dataset('https://dods.ndbc.noaa.gov/thredds/dodsC/data/stdmet/44065/44065.ncml')

runs without a problem. For NASA Earthdata however, I need to provide a username and password. XArray documentation points to a function provided by pydap called setup_session which, as they explain in their documentation, is provided specially for NASA Earthdata:

from pydap.client import open_url
from pydap.cas.urs import setup_session
dataset_url = 'https://opendap.cr.usgs.gov/opendap/hyrax/MOD13Q1.061/h01v10.ncml'
session = setup_session('my_username', 'my_password', check_url=dataset_url)
dataset = open_url(dataset_url, session=session)

This gives the following error on the setup_session line:

UserWarning: Navigate to https://opendap.cr.usgs.gov/opendap/hyrax/MOD13Q1.061/h01v10.ncml, login and follow instructions. It is likely that you have to perform some one-time registration steps before acessing this data.

Navigating to the given url doesn't solve anything unfortunately. I'm also quite confident that I've approved the correct apps on my NASA Earthdata profile page (e.g. I have approved LP DAAC OPeNDAP).

Any suggestions/solutions would be very much appreciated!

1 Answer 1

2

The ncml data page doesn't challenge you to login until you fill in the form and request some data. I tried a login url which requests a minimal slice of the data in ASCII. It seemed to work then.

login_url = "https://opendap.cr.usgs.gov/opendap/hyrax/MOD13Q1.061/h01v10.ncml.ascii?YDim[0],XDim[0],time[0]"
dataset_url = 'https://opendap.cr.usgs.gov/opendap/hyrax/MOD13Q1.061/h01v10.ncml'
session = setup_session('my_username', 'my_password', check_url=login_url)
dataset = open_url(dataset_url, session=session)
Sign up to request clarification or add additional context in comments.

2 Comments

Just for reference, then to open the dataset in XArray, do this: store = xr.backends.PydapDataStore.open(dataset_url, session=session) ds = xr.open_dataset(store)
@BertCoerver Can I ask what Pydap version are you using? After trying your trick I get a KeyError: 'int8' in pydap open_url. The URL I'm trying to access is opendap.earthdata.nasa.gov/collections/C1996881146-POCLOUD/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.