source: CMIP6dreqbuild/trunk/src/framework/ing02/purgeVarGroups.py @ 1084

Subversion URL: http://proj.badc.rl.ac.uk/svn/exarch/CMIP6dreqbuild/trunk/src/framework/ing02/purgeVarGroups.py@1206
Revision 1084, 1.6 KB checked in by mjuckes, 2 years ago (diff)

add missing file

Line 
1import shelve, collections
2
3
4ii = open( 'purgeRqvGroup.csv', 'r' )
5
6vgdel = set()
7vgmap = dict()
8
9for l in ii.readlines():
10  bits = [x.strip() for x in l.split( '\t' )]
11  ##bits = l.split( '\t' )
12  if bits[0] == 'DEL':
13    vgdel.add( bits[4] )
14  elif bits[0] == 'MAP':
15    vgmap[bits[1]] = bits[2]
16
17for k in vgmap:
18  assert k in vgdel
19
20flag = 'w'
21sh = shelve.open( 'exports/l1sh/requestVar', flag )
22cols = sh['__cols__']
23iu = cols.index( 'uid' )
24ig = cols.index( 'vgid' )
25nm = nd = 0
26for k in sh.keys():
27  if k[0] != '_':
28##    if sh[k][ig] in vgmap:
29      ##nm += 1
30      ##if flag == 'w':
31        ##rec = sh[k]
32        ##rec[ig] = vgmap[sh[k][ig]]
33        ##sh[k] = rec[:]
34    if sh[k][ig] in vgdel:
35      nd += 1
36      if flag == 'w':
37        del sh[k]
38print 'VG map in request vars: %s' % nm
39print 'deleted request vars: %s' % nd
40sh.close()
41
42shg = shelve.open( 'exports/l1sh/requestVarGroup', flag )
43for k in vgmap:
44  assert vgmap[k] in shg
45cols = shg['__cols__']
46iu = cols.index( 'uid' )
47nd = 0
48for k in shg.keys():
49  if k[0] != '_':
50    if k in vgdel or k in vgmap:
51      nd += 1
52      if flag == 'w':
53        del shg[k]
54print 'deleted request var groups: %s' % nd
55shg.close()
56
57shl = shelve.open( 'exports/l1sh/requestLink', flag )
58cols = shl['__cols__']
59ir = cols.index( 'refid' )
60nm = ne = 0
61for k in shl.keys():
62  if k[0] != '_':
63    if shl[k][ir] in vgmap:
64      nm += 1
65      if flag == 'w':
66        rec = shl[k]
67        rec[ir] = vgmap[shl[k][ir]]
68        shl[k] = rec[:]
69    elif shl[k][ir] in vgdel:
70      ne += 1
71print 'VG maps in links: %s' % nm
72if ne > 0:
73  print 'SEVERE: VG in links deleted: %s' % ne
74shl.close()   
75
Note: See TracBrowser for help on using the repository browser.