In [1]:
import requests
def get(param):
# Define the API endpoint URL
url = 'http://es-vocab.ipsl.fr/'
try:
# Make a GET request to the API endpoint using requests.get()
response = requests.get(url+param, headers = {'accept': 'application/json'}, verify=False)
# Check if the request waµs successful (status code 200)
if response.status_code == 200:
posts = response.json()
return posts
else:
print('Error:', response.status_code)
return None
except Exception as e:
print(e)
Exploring the CV Universe :¶
Datadescriptor¶
In [2]:
DD_names = get("api/universe/datadescriptor")
DD_names
Out[2]:
['forcing_index', 'initialization_index', 'institution', 'physic_index', 'realization_index', 'variant_label']
In [3]:
for dd in DD_names:
print(get("api/universe/datadescriptor/"+dd))
None None None None None None
Terms¶
In [4]:
for dd in DD_names:
terms = get("api/universe/datadescriptor/"+dd+"/term")
print(terms)
[{'id': 'multiple_digit', 'validation_method': 'regex', 'regex': '^f\\d*$', 'description': None}, {'id': 'forcing_index:one_digit', 'validation_method': 'regex', 'regex': '^f\\d$', 'description': None}] [{'id': 'initialization_index:one_digit', 'validation_method': 'regex', 'regex': '^i\\d$', 'description': None}] [{'id': 'dkrz', 'validation_method': 'list', 'acronyms': ['DKRZ'], 'aliases': [], 'established': 1987, 'type': 'Facility', 'labels': [], 'location': {'id': '03ztgj037', 'lat': 53.55073, 'lon': 9.99302, 'city': 'Hamburg', 'country': ['Germany', 'DE']}, 'name': 'German Climate Computing Centre', 'rorIdentifier': '03ztgj037', 'cmip_acronym': 'DKRZ', 'url': ['https://www.dkrz.de/']}, {'id': 'ipsl', 'validation_method': 'list', 'acronyms': ['IPSL'], 'aliases': ['Ipsl'], 'established': 1991, 'type': 'Facility', 'labels': [], 'location': {'id': '02haar591', 'lat': 48.855675, 'lon': 2.332105, 'city': 'Paris', 'country': ['France', 'FR']}, 'name': 'Institut Pierre-Simon Laplace', 'rorIdentifier': '02haar591', 'cmip_acronym': 'IPSL', 'url': ['https://www.ipsl.fr/en/']}, {'id': 'llnl', 'validation_method': 'list', 'acronyms': ['LLNL', 'LLL'], 'aliases': ['United States Department of Energy National Nuclear Security Administration Lawrence Livermore National Laboratory', 'U.S. Department of Energy National Nuclear Security Administration Los Alamos National Laboratory', 'United States Department of Energy Los Alamos National Laboratory', 'U.S. Department of Energy Los Alamos National Laboratory'], 'established': 1952, 'type': 'Facility', 'labels': [], 'location': {'id': '041nk4h53', 'lat': 37.68187, 'lon': -121.76801, 'city': 'Livermore', 'country': ['United States', 'US'], 'type': 'location'}, 'name': 'Lawrence Livermore National Laboratory', 'rorIdentifier': '041nk4h53', 'cmip_acronym': 'LLNL', 'url': ['https://www.llnl.gov/']}] [{'id': 'physic_index:one_digit', 'validation_method': 'regex', 'regex': '^p\\d$', 'description': None}] [{'id': 'realization_index:one_digit', 'validation_method': 'regex', 'regex': '^r\\d$', 'description': None}, {'id': 'run', 'validation_method': 'regex', 'regex': '^run\\d$', 'description': None}] [{'id': 'rip', 'validation_method': 'composite', 'separator': '', 'parts': [{'is_required': True, 'id': 'realization_index:one_digit'}, {'is_required': True, 'id': 'initialization_index:one_digit'}, {'is_required': True, 'id': 'physic_index:one_digit'}], 'description': 'TODO IMPROVE THIS'}, {'id': 'ripf', 'validation_method': 'composite', 'separator': '', 'parts': [{'is_required': True, 'id': 'realization_index:one_digit'}, {'is_required': True, 'id': 'initialization_index:one_digit'}, {'is_required': True, 'id': 'physic_index:one_digit'}, {'is_required': True, 'id': 'forcing_index:multiple_digit'}], 'description': 'TODO IMPROVE THIS'}, {'id': 'run', 'validation_method': 'composite', 'separator': '', 'parts': [{'is_required': True, 'id': 'realization:run'}], 'description': 'TODO IMPROVE THIS'}]
In [5]:
for dd in DD_names:
print("")
terms = get("api/universe/datadescriptor/"+dd+"/term")
for term in terms:
t = get("api/universe/datadescriptor/"+dd+"/term/"+term['id'])
print(dd," ",t)
forcing_index {'id': 'multiple_digit', 'validation_method': 'regex', 'regex': '^f\\d*$', 'description': None} forcing_index {'id': 'forcing_index:one_digit', 'validation_method': 'regex', 'regex': '^f\\d$', 'description': None} initialization_index {'id': 'initialization_index:one_digit', 'validation_method': 'regex', 'regex': '^i\\d$', 'description': None} institution {'id': 'dkrz', 'validation_method': 'list', 'acronyms': ['DKRZ'], 'aliases': [], 'established': 1987, 'type': 'Facility', 'labels': [], 'location': {'id': '03ztgj037', 'lat': 53.55073, 'lon': 9.99302, 'city': 'Hamburg', 'country': ['Germany', 'DE']}, 'name': 'German Climate Computing Centre', 'rorIdentifier': '03ztgj037', 'cmip_acronym': 'DKRZ', 'url': ['https://www.dkrz.de/']} institution {'id': 'ipsl', 'validation_method': 'list', 'acronyms': ['IPSL'], 'aliases': ['Ipsl'], 'established': 1991, 'type': 'Facility', 'labels': [], 'location': {'id': '02haar591', 'lat': 48.855675, 'lon': 2.332105, 'city': 'Paris', 'country': ['France', 'FR']}, 'name': 'Institut Pierre-Simon Laplace', 'rorIdentifier': '02haar591', 'cmip_acronym': 'IPSL', 'url': ['https://www.ipsl.fr/en/']} institution {'id': 'llnl', 'validation_method': 'list', 'acronyms': ['LLNL', 'LLL'], 'aliases': ['United States Department of Energy National Nuclear Security Administration Lawrence Livermore National Laboratory', 'U.S. Department of Energy National Nuclear Security Administration Los Alamos National Laboratory', 'United States Department of Energy Los Alamos National Laboratory', 'U.S. Department of Energy Los Alamos National Laboratory'], 'established': 1952, 'type': 'Facility', 'labels': [], 'location': {'id': '041nk4h53', 'lat': 37.68187, 'lon': -121.76801, 'city': 'Livermore', 'country': ['United States', 'US'], 'type': 'location'}, 'name': 'Lawrence Livermore National Laboratory', 'rorIdentifier': '041nk4h53', 'cmip_acronym': 'LLNL', 'url': ['https://www.llnl.gov/']} physic_index {'id': 'physic_index:one_digit', 'validation_method': 'regex', 'regex': '^p\\d$', 'description': None} realization_index {'id': 'realization_index:one_digit', 'validation_method': 'regex', 'regex': '^r\\d$', 'description': None} realization_index {'id': 'run', 'validation_method': 'regex', 'regex': '^run\\d$', 'description': None} variant_label {'id': 'rip', 'validation_method': 'composite', 'separator': '', 'parts': [{'is_required': True, 'id': 'realization_index:one_digit'}, {'is_required': True, 'id': 'initialization_index:one_digit'}, {'is_required': True, 'id': 'physic_index:one_digit'}], 'description': 'TODO IMPROVE THIS'} variant_label {'id': 'ripf', 'validation_method': 'composite', 'separator': '', 'parts': [{'is_required': True, 'id': 'realization_index:one_digit'}, {'is_required': True, 'id': 'initialization_index:one_digit'}, {'is_required': True, 'id': 'physic_index:one_digit'}, {'is_required': True, 'id': 'forcing_index:multiple_digit'}], 'description': 'TODO IMPROVE THIS'} variant_label {'id': 'run', 'validation_method': 'composite', 'separator': '', 'parts': [{'is_required': True, 'id': 'realization:run'}], 'description': 'TODO IMPROVE THIS'}
Exploring known projects¶
In [19]:
known_projects = get("api/project")
known_projects
Out[19]:
['CMIP6Plus_CVs']
In [ ]:
In [20]:
for proj in known_projects:
print(get("api/project/"+proj))
None
In [8]:
col_names = get("api/project/CMIP6Plus_CVs/collection")
col_names
Out[8]:
['institution_id', 'member_id']
In [9]:
for col in col_names:
print(get("api/project/CMIP6Plus_CVs/collection/"+col))
None None
In [10]:
for col in col_names:
print(col," ",get("api/project/CMIP6Plus_CVs/collection/"+col+"/term"))
institution_id ['ipsl', 'llnl'] member_id ['ripf']
In [11]:
for col in col_names:
term_ids = get("api/project/CMIP6Plus_CVs/collection/"+col+"/term")
for term in term_ids:
t = get("api/project/CMIP6Plus_CVs/collection/"+col+"/term/"+term)
print(col," ",t)
institution_id {'id': 'ipsl', 'validation_method': 'list', 'acronyms': ['IPSL'], 'aliases': ['Ipsl'], 'established': 1991, 'type': 'Facility', 'labels': [], 'location': {'city': 'Paris5'}, 'name': 'Institut Pierre-Simon Laplace modified', 'rorIdentifier': '02haar591', 'cmip_acronym': 'IPSL', 'url': ['https://www.ipsl.fr/en/'], 'myprop': '42'} institution_id {'id': 'llnl', 'validation_method': 'list', 'acronyms': ['LLNL', 'LLL'], 'aliases': ['United States Department of Energy National Nuclear Security Administration Lawrence Livermore National Laboratory', 'U.S. Department of Energy National Nuclear Security Administration Los Alamos National Laboratory', 'United States Department of Energy Los Alamos National Laboratory', 'U.S. Department of Energy Los Alamos National Laboratory'], 'established': 1952, 'type': 'Facility', 'labels': [], 'location': {'id': '041nk4h53', 'lat': 37.68187, 'lon': -121.76801, 'city': 'Livermore', 'country': ['United States', 'US'], 'type': 'location'}, 'name': 'Lawrence Livermore National Laboratory', 'rorIdentifier': '041nk4h53', 'cmip_acronym': 'LLNL', 'url': ['https://www.llnl.gov/']} member_id {'id': 'ripf', 'validation_method': 'composite', 'separator': '', 'parts': [{'is_required': True, 'id': 'realization_index:one_digit'}, {'is_required': True, 'id': 'initialization_index:one_digit'}, {'is_required': True, 'id': 'physic_index:one_digit'}, {'is_required': True, 'id': 'forcing_index:multiple_digit'}], 'description': 'TODO IMPROVE THIS'}
Some shortcuts¶
In [12]:
print(get("api/universe/datadescriptor/institution/term/ipsl"))
print(get("api/universe/term/ipsl"))
{'id': 'ipsl', 'validation_method': 'list', 'acronyms': ['IPSL'], 'aliases': ['Ipsl'], 'established': 1991, 'type': 'Facility', 'labels': [], 'location': {'id': '02haar591', 'lat': 48.855675, 'lon': 2.332105, 'city': 'Paris', 'country': ['France', 'FR']}, 'name': 'Institut Pierre-Simon Laplace', 'rorIdentifier': '02haar591', 'cmip_acronym': 'IPSL', 'url': ['https://www.ipsl.fr/en/']} [{'term': {'id': 'ipsl', 'validation_method': 'list', 'acronyms': ['IPSL'], 'aliases': ['Ipsl'], 'established': 1991, 'type': 'Facility', 'labels': [], 'location': {'id': '02haar591', 'lat': 48.855675, 'lon': 2.332105, 'city': 'Paris', 'country': ['France', 'FR']}, 'name': 'Institut Pierre-Simon Laplace', 'rorIdentifier': '02haar591', 'cmip_acronym': 'IPSL', 'url': ['https://www.ipsl.fr/en/']}, 'path': '/universe/datadescriptor/institution/term/ipsl'}]
In [13]:
print(get("api/project/CMIP6Plus_CVs/collection/"+"institution_id"+"/term/"+"ipsl"))
print("")
print(get("api/project/term/ipsl")[0]["term"]) # WHY [0]["term"] ????
{'id': 'ipsl', 'validation_method': 'list', 'acronyms': ['IPSL'], 'aliases': ['Ipsl'], 'established': 1991, 'type': 'Facility', 'labels': [], 'location': {'city': 'Paris5'}, 'name': 'Institut Pierre-Simon Laplace modified', 'rorIdentifier': '02haar591', 'cmip_acronym': 'IPSL', 'url': ['https://www.ipsl.fr/en/'], 'myprop': '42'} {'id': 'ipsl', 'validation_method': 'list', 'acronyms': ['IPSL'], 'aliases': ['Ipsl'], 'established': 1991, 'type': 'Facility', 'labels': [], 'location': {'city': 'Paris5'}, 'name': 'Institut Pierre-Simon Laplace modified', 'rorIdentifier': '02haar591', 'cmip_acronym': 'IPSL', 'url': ['https://www.ipsl.fr/en/'], 'myprop': '42'}
Explore all (Universe and projects) in one call¶
In [14]:
ipsl_insts = get("api/term/"+"ipsl")
for inst in ipsl_insts:
print(inst["path"])
print( " ", inst)
/universe/datadescriptor/institution/term/ipsl {'term': {'id': 'ipsl', 'validation_method': 'list', 'acronyms': ['IPSL'], 'aliases': ['Ipsl'], 'established': 1991, 'type': 'Facility', 'labels': [], 'location': {'id': '02haar591', 'lat': 48.855675, 'lon': 2.332105, 'city': 'Paris', 'country': ['France', 'FR']}, 'name': 'Institut Pierre-Simon Laplace', 'rorIdentifier': '02haar591', 'cmip_acronym': 'IPSL', 'url': ['https://www.ipsl.fr/en/']}, 'path': '/universe/datadescriptor/institution/term/ipsl'} /project/CMIP6Plus_CVs/collection/institution_id/term/ipsl {'term': {'id': 'ipsl', 'validation_method': 'list', 'acronyms': ['IPSL'], 'aliases': ['Ipsl'], 'established': 1991, 'type': 'Facility', 'labels': [], 'location': {'city': 'Paris5'}, 'name': 'Institut Pierre-Simon Laplace modified', 'rorIdentifier': '02haar591', 'cmip_acronym': 'IPSL', 'url': ['https://www.ipsl.fr/en/'], 'myprop': '42'}, 'path': '/project/CMIP6Plus_CVs/collection/institution_id/term/ipsl'}
In [15]:
get("api/collection/institution_id")
Out[15]:
[{'collection_id': 'institution_id', 'path': '/project/CMIP6Plus_CVs/collection/institution_id'}]
In [ ]:
In [ ]: