Why can I not access ESGF data via OPeNDAP, despite my valid credentials?

209 Views Asked by At

I would like to access climate (CORDEX) data through ESGF's OPeNDAP service via Python (xarray looks like a great option).

This dataset is an example of one I cannot access: https://esg-dn1.nsc.liu.se/thredds/dodsC/esg_dataroot7/cordexdata/cordex/output/CAS-44/BOUN/MOHC-HadGEM2-ES/rcp45/r1i1p1/BOUN-RegCM4-3/v5/day/tas/v2019116/tas_CAS-44_MOHC-HadGEM2-ES_rcp45_r1i1p1_BOUN-RegCM4-3_v5_day_20060201-20101230.nc.html

I have saved credentials in a credentials.pem file, and I have a .dodsrc file in my home directory, which referms to my credentials.pem file, like so:

HTTP.VERBOSE=0
HTTP.COOKIEJAR=C:\\Users\\tsh371/.esg.dods_cookies
HTTP.SSL.VALIDATE=0
HTTP.SSL.CERTIFICATE=C:\\Users\\tsh371/.esg\\credentials.pem
HTTP.SSL.KEY=C:\\Users\\tsh371/.esg\\credentials.pem
HTTP.SSL.CAPATH=C:\\Users\\tsh371/.esg\\ca-trustroots

But when accessing the dataset, for example through xarray.open_dataset() on the dataset above, I get. [Errno -77] NetCDF: Access failure

I have tried to verify my credentials.pem is valid by accessing a tiny slice of the data. For example with

url = 'https://esg-dn1.nsc.liu.se/thredds/dodsC/esg_dataroot7/cordexdata/cordex/output/CAS-44/BOUN/MOHC-HadGEM2-ES/rcp45/r1i1p1/BOUN-RegCM4-3/v5/day/tas/v2019116/tas_CAS-44_MOHC-HadGEM2-ES_rcp45_r1i1p1_BOUN-RegCM4-3_v5_day_20060201-20101230.nc.ascii?tas%5B0:1:0%5D%5B0:1:0%5D%5B0:1:0%5D'

Then getting the data while explicitly pointing at the credentials like this, gets me the data:

import requests
requests.get(url, cert = 'C:/Users/tsh371/.esg/credentials.pem')

But while running the same request without including the cert argument, gives response 401. Note that with other climate data (fx https://dap.ceda.ac.uk/), after correctly setting up .dodsrc, I don't have to include a cert argument.

Is there something wrong with my .dodsrc file? Or is there some way to tell xarray where to look for the certificate?

Reproducible code that generates the error:

import pyesgf

import xarray as xa
import os

os.environ['HOME'] = os.environ['USERPROFILE'] # pyesgf refers to HOME, which should be equivalent to USERPROFILE on Windows
from pyesgf.logon import LogonManager

lm = LogonManager()

lm.logon(username = None, password = None, hostname = 'esgf-node.ipsl.upmc.fr', bootstrap=True)

opendapurl = 'https://esg-dn1.nsc.liu.se/thredds/dodsC/esg_dataroot7/cordexdata/cordex/output/CAS-44/BOUN/MOHC-HadGEM2-ES/rcp45/r1i1p1/BOUN-RegCM4-3/v5/day/tas/v2019116/tas_CAS-44_MOHC-HadGEM2-ES_rcp45_r1i1p1_BOUN-RegCM4-3_v5_day_20060201-20101230.nc'

xa.open_dataset(opendapurl)
0

There are 0 best solutions below