<jupyter_start><jupyter_text>intialize the logon manager<jupyter_code>lm = LogonManager()
if not lm.is_logged_on():
    lm.logon(hostname="esgf-data.dkrz.de", bootstrap=True, interactive=True)

lm.is_logged_on()
def print_context_info(ctx):
    print('Hits:', ctx.hit_count)
    print('Experiments:', ctx.facet_counts['experiment'])
    print('Ensembles:', ctx.facet_counts['ensemble'])<jupyter_output><empty_output><jupyter_text>search for some data<jupyter_code>conn = SearchConnection('http://esgf-data.dkrz.de/esg-search', distrib=True)
ctx = conn.new_context(project='CORDEX', institute='MPI-CSC', experiment='historical', time_frequency='day')
ctx = ctx.constrain(ensemble='r1i1p1', variable='tasmax')<jupyter_output><empty_output><jupyter_text>print a summary of what we found<jupyter_code>print_context_info(ctx)<jupyter_output>('Hits:', 6)
('Experiments:', {u'historical': 6})
('Ensembles:', {u'r1i1p1': 6})<jupyter_text>aggregate results<jupyter_code>result = ctx.search()[0]
agg_ctx = result.aggregation_context()<jupyter_output><empty_output><jupyter_text>get a list of opendap urls<jupyter_code>x = list(a.opendap_url for a in agg_ctx.search() if a.opendap_url)
print(x)<jupyter_output>[u'http://esgf1.dkrz.de/thredds/dodsC/cordex.output.AFR-44.MPI-CSC.MPI-M-MPI-ESM-LR.historical.r1i1p1.REMO2009.v1.day.tasmax.tasmax.20160412.aggregation']<jupyter_text>try opening one of the opendap datasets<jupyter_code>from netCDF4 import Dataset
ds = Dataset(x[0], 'r')
ds.ncattrs()
ds.getncattr('experiment')

ds.variables.keys()
ds.variables['time']
ds.variables['tasmax']
import matplotlib.pyplot as plt
from cartopy import config
import cartopy.crs as ccrs

timestep = 0

tasmax = ds.variables['tasmax'][timestep, :, :]
lats = ds.variables['lat'][:]
lons = ds.variables['lon'][:]

ax = plt.axes(projection=ccrs.PlateCarree())
ax.coastlines()
ax.set_global()

fig = plt.contourf(lons, lats, tasmax, 60, transform=ccrs.PlateCarree())
#plt.show()<jupyter_output><empty_output><jupyter_text>using pydap:https://pydap.readthedocs.io/en/latest/client.html?highlight=esgf<jupyter_code>openid='https://esgf-data.dkrz.de/esgf-idp/openid/pingutest1'
password='<PASSWORD>'

from pydap.client import open_url
from pydap.cas.esgf import setup_session
dataset_url = x[0]
session = setup_session(openid, password, check_url=dataset_url, verify=True)
dataset = open_url(dataset_url, session=session)

xr.open_dataset(x[0], engine='pydap')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15744507729861676, 'fraction_numerical': 0.015052888527257934, 'mean_word_length': 8.279245283018868, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '60030', 'license': 'Apache-2.0', 'n_tokens_mistral': 1034, 'n_tokens_neox': 994, 'n_words': 133, 'path': 'esgf-examples/esgf-pydap.ipynb', 'repo_name': 'cehbrecht/jupyterlab-notebooks', 'size': '2454'}