In [4]:
from pyesgf.logon import LogonManager
lm = LogonManager()
lm.logoff()
lm.is_logged_on()


Out[4]:
False

In [6]:
lm.logon(hostname="esgf-data.dkrz.de", bootstrap=True, interactive=True)


Enter myproxy username:pingutest1
Enter password for pingutest1: ········


In [8]:
lm.is_logged_on()


Out[8]:
True

In [9]:
import requests

In [10]:
file_url = 'http://esgf1.dkrz.de/thredds/fileServer/cordex/cordex/output/EUR-44/MPI-CSC/MPI-M-MPI-ESM-LR/historical/r1i1p1/MPI-CSC-REMO2009/v1/mon/tas/v20150609/tas_EUR-44_MPI-M-MPI-ESM-LR_historical_r1i1p1_MPI-CSC-REMO2009_v1_mon_200101-200512.nc'

In [11]:
headers = {
            'user-agent': 'requests',
            'connection': 'close'
}

See pydap example, requests_pydap/http.py:

https://pypi.python.org/pypi/netcdf4_pydap


In [12]:
"""
cmd = ["wget"]
cmd.extend(["--certificate", credentials])
cmd.extend(["--private-key", credentials])
cmd.extend(["--ca-certificate", credentials])
cmd.append("--no-check-certificate")
"""


Out[12]:
'\ncmd = ["wget"]\ncmd.extend(["--certificate", credentials])\ncmd.extend(["--private-key", credentials])\ncmd.extend(["--ca-certificate", credentials])\ncmd.append("--no-check-certificate")\n'

In [13]:
cert = '/Users/pingu/.esg/credentials.pem'
ca_certs = '/Users/pingu/.esg/certificates'

response = requests.get(
    file_url,
    cert=(cert, cert),
    verify=ca_certs,
    headers=headers,
    allow_redirects=True,
    timeout=120)

In [14]:
response.ok


Out[14]:
True

In [15]:
response.headers


Out[15]:
{'Content-Length': '1869282', 'Accept-Ranges': 'bytes', 'Last-Modified': 'Fri, 10 Apr 2015 12:23:32 GMT', 'Connection': 'close', 'Date': 'Fri, 17 Nov 2017 15:20:53 GMT', 'Content-Type': 'application/x-netcdf'}

In [ ]: