-
Notifications
You must be signed in to change notification settings - Fork 10
/
CMIP6_studies_list.py
72 lines (63 loc) · 2.44 KB
/
CMIP6_studies_list.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import glob
import YamlStudies as ys
import yaml
import sys
CORDEX_DOMAIN = sys.argv[1]
with open('CMIP6_studies_config.yaml') as fp:
config = yaml.load(fp, Loader=yaml.FullLoader)
alldata = []
for fname in glob.glob('CMIP6_studies/*.yaml'):
with open(fname) as fp:
entrylist = yaml.load(fp, Loader=yaml.FullLoader)
for x in entrylist:
x['file'] = fname
alldata.extend(entrylist)
alldata = [x for x in alldata if x['spatial_scope'] in config['spatial_scope_filter'][CORDEX_DOMAIN]]
def is_incomplete(dic):
try:
return(dic['disabled']['cause'] == 'incomplete')
except:
return(False)
print(f'## Incomplete entries\n')
for x in alldata:
if is_incomplete(x):
print(f' * [{x["key"]}]({x["file"]})')
print(f'## Globally disabled entries\n')
preferred = {}
for x in alldata:
if 'disabled' in x:
print(f' · [{x["key"]}]({x["file"]})')
if x['disabled']['cause'] == 'preferred_source' and x['disabled']['preferred']:
preferred.setdefault(x['disabled']['preferred'], []).append(x['key'])
print(f'## Entries disabled in {CORDEX_DOMAIN}\n')
preferred = {}
for x in alldata:
if f'disabled_{CORDEX_DOMAIN}' in x:
print(f' · [{x["key"]}]({x["file"]})')
if x[f'disabled_{CORDEX_DOMAIN}']['cause'] == 'preferred_source' and x[f'disabled_{CORDEX_DOMAIN}']['preferred']:
preferred.setdefault(x[f'disabled_{CORDEX_DOMAIN}']['preferred'], []).append(x['key'])
enabled_data = ys.load_from_files('CMIP6_studies/*.yaml', resolve_doi = False, skip_disabled = True, skip_disabled_domain = CORDEX_DOMAIN)
# filter and sort
enabled_data = [x for x in enabled_data if x.spatial_scope in config['spatial_scope_filter'][CORDEX_DOMAIN]]
enabled_data.sort(key=lambda x: config['spatial_scope_filter'][CORDEX_DOMAIN].index(x.spatial_scope))
typenames = dict(
performance = 'Plausibility',
future_spread = 'Spread of future outcomes',
other = 'Other criteria'
)
print(f'## Available entries ({CORDEX_DOMAIN} scope)')
for t in typenames:
print(f'### {typenames[t]}')
for x in enabled_data:
if x.type == t:
print(f'#### {x.key}\n')
print(f'Located in [{x.file}](../{x.file})\n')
if x.key in preferred:
pref_list = []
for item in preferred[x.key]:
pref_list.extend([x['file'] for x in alldata if x['key']==item])
print(f'Preferred to ', end='')
[print(f'[{y}](../{y})') for y in pref_list]
print()
print(f'{x.reference}\n')
print(f'```\n{x.__str__()}\n```\n')