source: CMIP6dreqbuild/trunk/src/framework/exports.py @ 744

Subversion URL: http://proj.badc.rl.ac.uk/svn/exarch/CMIP6dreqbuild/trunk/src/framework/exports.py@1291
Revision 744, 1.2 KB checked in by mjuckes, 3 years ago (diff)

bug in scope_utils

Line 
1
2from dreqPy import dreq
3import collections, json, time
4
5dq = dreq.loadDreq()
6rvgUsage = collections.defaultdict( set )
7rvUsage = {}
8cmvUsage = collections.defaultdict( set )
9vUsage = collections.defaultdict( set )
10for i in dq.coll['requestVarGroup'].items:
11  for u in dq.inx.iref_by_sect[i.uid].a['requestLink']:
12    rl = dq.inx.uid[u]
13    rvgUsage[i.uid].add( rl.mip )
14
15for i in dq.coll['requestVar'].items:
16  rvUsage[i.uid] = rvgUsage[i.vgid]
17
18for i in dq.coll['CMORvar'].items:
19  for u in dq.inx.iref_by_sect[i.uid].a['requestVar']:
20    if u in rvUsage:
21      for x in rvUsage[u]:
22        cmvUsage[i.uid].add(x)
23
24for i in dq.coll['var'].items:
25  for u in dq.inx.iref_by_sect[i.uid].a['CMORvar']:
26    if u in cmvUsage:
27      for x in cmvUsage[u]:
28        vUsage[i.uid].add(x)
29
30vars = {i.label: {'long_name':i.title, 'standard_name':i.sn, 'units':i.units, 'usage':sorted(list(vUsage[i.uid])), 'prov':'%s {%s}' % (i.prov,i.provmip)} for i in dq.coll['var'].items if i.uid in vUsage }
31info = {'version':dq.version, 'source':'Data Request', 'author':'Martin Juckes (martin.juckes@stfc.ac.uk)', 'creation_date':time.ctime()}
32oo = open( 'CV_var.json', 'w' )
33json.dump( {'info':info, 'variable':vars}, oo, indent=4, sort_keys=True )
34oo.close()
Note: See TracBrowser for help on using the repository browser.