Changeset 530 for CMIP6dreqbuild/trunk/src
- Timestamp:
- 18/12/15 13:50:34 (6 years ago)
- Location:
- CMIP6dreqbuild/trunk/src/workbook
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
CMIP6dreqbuild/trunk/src/workbook/importShDreq2.py
r527 r530 8 8 """ 9 9 10 ### # experiment group dictionary added, and experiment set of named tuples -- making it possible to identify experiments in each mip and group.11 ### # should be able to use this in review to make refernce groups ...10 ### Experiment group dictionary added, and experiment set of named tuples -- making it possible to identify experiments in each mip and group. 11 ### Should be able to use this in review to make reference groups ... 12 12 13 13 ### 14 14 ### Appear to be getting core variables into a clean format 15 15 ### Some filtering to avoit duplicates arising from two approaches to OMIP, flagged as ERROR.090 in standard output. 16 ### corrected by omitting 2nd reference16 ### Corrected by omitting 2nd reference 17 17 ### 18 18 19 import xlrd, xml, os, sys, string, shelve 19 20 import utils_wb, uuid … … 26 27 reload(ivg) 27 28 29 WbMods = importWbMods.run() 30 28 31 nt__trace = collections.namedtuple( 'trace', ['GROUPITEM_ta','SPATIALSHAPE_01'] ) 29 32 trace = nt__trace( False, False ) … … 97 100 fok = [test(os.path.isfile(src),'%s not found' % src), ] 98 101 assert all( fok), 'Required input file(s) missing' 99 self.fx = importWbMods.fx100 self.spsh = importWbMods.ls101 self.cmDims = importWbMods.cm102 self.importWbMods = importWbMods102 self.fx = WbMods.fx 103 self.spsh = WbMods.ls 104 self.cmDims = WbMods.cm 105 self.importWbMods = WbMods 103 106 104 107 for sh in [rq.expt,rq.exgp,rq.objec,rq.refti, rq.revti, rq.vars, rq.grps, rq.rqvg, rq.rqli, rq.rqit, rq.rqsect]: … … 137 140 'requestvargroup':rq.rqvg, 'tablesection':rq.rqsect, 'requestvar':rq.revti} 138 141 142 self.newImport = False 143 self.prepVar() 139 144 self.writeTimeSlice() 140 145 self.writeMip() … … 145 150 self.prep01() 146 151 self.prepRequestVarGroup() 147 self.newImport = False148 152 self.prep(rq) 153 self.addAerChem() 149 154 self.prepRequestItem() 150 155 self.reviewExpt() … … 337 342 assert nsev < 20, 'Multiple duplicate labels in variable groups: %s' % nsev 338 343 339 def prepRequestItem(self): 340 thissh = self.skey['requestitem'] 341 for k in thissh: 342 if k[0] != '_': 343 ll = thissh[k][:] 344 ku = str(ll[2]) 345 ## 346 self.exptPnt[ku].append( str(k) ) 347 344 def prepVar(self): 345 thissh = self.skey['var'] 346 self.varsxx = None 348 347 if self.newImport: 349 #['label', 'title', 'sn', 'units', 'description', 'procnote', 'procComment', 'prov', 'priority0'] 350 thissh = self.skey['var'] 348 #['label', 'title', 'sn', 'units', 'description', 'procnote', 'procComment', 'prov', 'priority0', 'rlm0'] 351 349 self.vars = collections.defaultdict( list ) 352 350 self.vars1 = collections.defaultdict( list ) … … 357 355 self.vars[thisl].append( k ) 358 356 self.vars1[str( ll[0] )].append( k ) 357 else: 358 self.varsxx = collections.defaultdict( list ) 359 for k in thissh: 360 if k[0] != '_': 361 ll = thissh[k][:] 362 thisl = str( ll[2] ) 363 self.varsxx[str( ll[0] )].append( k ) 364 365 366 def prepRequestItem(self): 367 thissh = self.skey['requestitem'] 368 for k in thissh: 369 if k[0] != '_': 370 ll = thissh[k][:] 371 ku = str(ll[2]) 372 ## 373 self.exptPnt[ku].append( str(k) ) 374 359 375 360 376 thissh = self.skey['experiment'] … … 593 609 ### request variables 594 610 self.rqv = [] 611 self.realmByVar = collections.defaultdict( list ) 595 612 for ksect in [ 'ovar','groupitem']: 596 613 thissh = self.skey[ksect] … … 680 697 tt.deflate, tt.valid_min, tt.flag_values, tt.modeling_realm, tt.valid_max, tt.positive, tt.mipTable, \ 681 698 prov, tt.ssect, fr, tt.rowIndex, '',int(tt.priority)) ) 699 self.realmByVar[ lab ].append( tt.modeling_realm ) 682 700 if string.strip( tt.gpid ) == '': 683 701 print 'ERROR.090.0990: blank gpid: ',lab,tt.mipTable … … 816 834 for tt in gi: 817 835 gr = 'a' 818 if tt.mip == 'OMIP' or any( [string.find(tt.table,i) != -1 for i in ['Omon','Oyr','Oclim','OImon' ] ] ):836 if tt.mip == 'OMIP' or any( [string.find(tt.table,i) != -1 for i in ['Omon','Oyr','Oclim','OImon','Ocean'] ] ): 819 837 gr = 'o' 838 if self.varsxx != None: 839 if tt.cmorv in self.varsxx: 840 sss = set() 841 for k in self.varsxx[tt.cmorv]: 842 sss.add(self.skey['var'][k][-1] ) 843 sss = list(sss) 844 if len(sss) == 1: 845 if sss[0] == 'ocean': 846 gr = 'o' 847 elif sss[0] == 'atmos': 848 gr = 'a' 849 print 'INFO:lllw:', tt.cmorv, sss, gr 850 if tt.cmorv == 'sltbasin': 851 print 'INFO.llll: ',tt,gr 820 852 ## 821 853 ## adding label for mip here messes up referencing later ... … … 848 880 else: 849 881 p = int(tt1.priority) 882 thisrealm = tt1.modeling_realm 883 if gr == 'o' and thisrealm == 'atmos': 884 thisrealm = 'ocean' 850 885 thiscmv = (tt.uid, (tt.shape,tt.levels,tt.tstyle,gr,smdd[tt.mask],tt1.flag_values,tt1.flag_meanings), lab, '__from %s' % tt.table, tt.descriptionEx, tt1.vid, \ 851 886 tt1.deflate_level, tt1.shuffle, tt1.ok_max_mean_abs, tt1.flag_meanings, tt1.type, tt1.ok_min_mean_abs, \ 852 tt1.deflate, tt1.valid_min, tt1.flag_values, t t1.modeling_realm, tt1.valid_max, tt1.positive, ntab, \887 tt1.deflate, tt1.valid_min, tt1.flag_values, thisrealm, tt1.valid_max, tt1.positive, ntab, \ 853 888 prov, provNote, tt.freq, tt.rowIndex, '', int(p)) 889 self.realmByVar[ lab ].append( thisrealm ) 854 890 thisrqv = [str( uuid.uuid1() ),lab, tt.uid, tt.gpid, p, tt.mip, tt.group] 855 891 nov += 1 … … 860 896 else: 861 897 print 'WARN:070.00001: realm not found for %s,%s' % (lab,prov) 898 if gr == 'o' and thisrealm == 'atmos': 899 thisrealm = 'ocean' 862 900 863 901 if thisrealm == 'seaIce': … … 875 913 0,0,0, thisrealm, 0, '', ntab, \ 876 914 prov, provNote, tt.freq, tt.rowIndex, '', str(p)) 915 self.realmByVar[ lab ].append( thisrealm ) 877 916 878 917 thisrqv = [str( uuid.uuid1() ),lab, tt.uid, tt.gpid, p, tt.mip, tt.group] … … 891 930 ## Variables marked with shape '?' from PMIP are actually defined by OMIP .... 892 931 if tt.shape == '?': 893 print ' WARN: shape not set: %s, %s, %s' % ( tt.shape,tt.mip,tt.var)932 print 'ERROR.801.00001: shape not set: %s, %s, %s' % ( tt.shape,tt.mip,tt.var) 894 933 895 934 ##['', u'none', u'land', u'grounded ice sheet', u'floating ice sheet', u'floating ice shelf', u'ocean', u'ice sheet', u'sea', u'Southern hemisphere', u'Northern hemisphere'] … … 911 950 tshp = { 'time':['time-mean','Temporal mean'], 'time1':['time-point','Instantaneous value (i.e. synoptic or time-step value)'], \ 912 951 'time2':['climatoglogy','Climatological mean'], \ 913 '':['None','No spatial dimensions ... fixed field'], 'xxxx':['unknown','dimension not recognised'] }952 '':['None','No temporal dimensions ... fixed field'], 'xxxx':['unknown','dimension not recognised'] } 914 953 915 954 for ksect in [ 'ovar','groupitem']: … … 935 974 esd[s] = (u,lab,description,d,lfl,nl) 936 975 976 esd['Y-na'] = (str( uuid.uuid1() ),'extra','extra','latitude','false',1) 937 977 self.dimsTime = etd 938 978 self.dimsTimeInfo = ['uid','label','title','dimensions'] … … 943 983 eshp = set() 944 984 ll = [] 985 lls = ivg.structureList() 945 986 nt_dims = collections.namedtuple( 'dims', ['uid','label','spid','tmid','odims','coords','cell_methods','cell_measures','flag_values','flag_meanings','description','procNote','prov'] ) 946 987 kk = 0 947 988 strdd = {} 989 ee3 = {} 948 990 for dims,cmet,cmea,flgv, flgm in ds2: 949 991 tdim, tt = self.dsort_u1( self.dsortdd['ovar'][0][dims], self.dsortdd['ovar'][1] ) … … 959 1001 desc = '' 960 1002 print 'INFO.zzz01: ',dims 961 strdd[(dims,cmet,cmea,flgv,flgm)] = u1003 t0 = (dims,cmet,cmea,flgv,flgm) 962 1004 if cmet == 'None': 963 1005 cmet = '' … … 968 1010 if flgm == 'None': 969 1011 flgm = '' 970 strdd[(dims,cmet,cmea,flgv,flgm)] = u 1012 t1 = (dims,cmet,cmea,flgv,flgm) 1013 u = lls.add( [u,label,spid,tmid, odim, crd, cmet, cmea, flgv, flgm, desc, proc, prov] ) 971 1014 self.structInfo[u] = (label,cmet) 972 ll.append( nt_dims._make( [u,label,spid,tmid, odim, crd, cmet, cmea, flgv, flgm, desc, proc, prov] ) ) 1015 strdd[t0] = u 1016 strdd[t1] = u 1017 1018 ##nt = nt_dims._make( [u,label,spid,tmid, odim, crd, cmet, cmea, flgv, flgm, desc, proc, prov] ) 1019 ##tt = tuple( [nt.__dict__[k] for k in ['spid','tmid','odims','coords','cell_methods','cell_measures','flag_values','flag_meanings','procNote','prov']] ) 1020 ##if ee3.has_key( tt ): 1021 ##u = ee3[tt] 1022 ##else: 1023 ##ee3[tt] = u 1024 ##ll.append( nt ) 1025 ##ll.append( nt_dims._make( [u,label,spid,tmid, odim, crd, cmet, cmea, flgv, flgm, desc, proc, prov] ) ) 973 1026 974 1027 ttt = [ {u'Instantaneous (end of year)', 'instantaneous', 'point', 'Synoptic', u'synoptic', u'time: point'}, … … 1011 1064 else: 1012 1065 print 'INFO.zzz02: ',tt, tdim 1066 u = lls.add( [u,label,spid,tmid, odim, crd, cmet, cmea, '', '', desc, proc, prov] ) 1067 ##nt = nt_dims._make( [u,label,spid,tmid, odim, crd, cmet, cmea, '', '', desc, proc, prov] ) 1068 ##tt = tuple( [nt.__dict__[k] for k in ['spid','tmid','odims','coords','cell_methods','cell_measures','flag_values','flag_meanings','procNote','prov']] ) 1069 ##if ee3.has_key( tt ): 1070 ##u = ee3[tt] 1071 ##else: 1072 ##ee3[tt] = u 1073 ##ll.append( nt ) 1074 1013 1075 ee1[(tmid, spid, odim, cmet, cmea, crd)] = u 1014 ll.append( nt_dims._make( [u,label,spid,tmid, odim, crd, cmet, cmea, '', '', desc, proc, prov] ) )1015 1076 strdd[(shp,lvls,sty,gr,tmsk,flgv,flgm)] = u 1016 1077 self.structInfo[u] = (label,cmet) 1017 1078 1018 self.structList = ll 1079 ##nt_dims = collections.namedtuple( 'dims', ['uid','label','spid','tmid','odims','coords','cell_methods','cell_measures','flag_values','flag_meanings','description','procNote','prov'] ) 1080 cc = collections.defaultdict( list ) 1081 for nt in lls.ll: 1082 tt = tuple( [nt.__dict__[k] for k in ['spid','tmid','odims','coords','cell_methods','cell_measures','flag_values','flag_meanings','procNote','prov']] ) 1083 cc[tt].append( nt.uid ) 1084 ks = [k for k in cc.keys() if len( cc[k] ) > 1] 1085 if len( ks ) > 0: 1086 print 'DUPLICATE STRUCTURES' 1087 for k in ks: 1088 print 'DUPLICATE: ',k,len(cc[k]) 1089 1090 self.structList = lls.ll 1019 1091 self.strdd = strdd 1020 1092 oo = open( 'test.csv', 'w' ) … … 1023 1095 oo.write( '%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,\n' % l ) 1024 1096 oo.close() 1097 1098 def addAerChem(self): 1099 import importExtra 1100 lc = importExtra.loadAerChem() 1101 es = {} 1102 et = {} 1103 for l in self.dimsSpace.keys(): 1104 print self.dimsSpace[l] 1105 assert self.dimsSpace[l][1] not in es, 'Duplicate spatial dimension label: %s' % self.dimsSpace[l][1] 1106 es[self.dimsSpace[l][1]] = l 1107 for l in self.dimsTime.keys(): 1108 print self.dimsTime[l] 1109 assert self.dimsTime[l][1] not in et, 'Duplicate spatial dimension label: %s' % self.dimsTime[l][1] 1110 et[self.dimsTime[l][1]] = l 1111 nt_acv = collections.namedtuple( 'acv', ['sn','title','label', 'units', 'description', 'subsect', 'freq', 'splab', 'tm' ] ) 1112 for t in lc.cc2.keys(): 1113 nn = 0 1114 for v in lc.cc2[t].a: 1115 if v not in self.vars1: 1116 print 'INFO.kkkkk: AerChem Var missing: %s, %s' % (t,v) 1117 else: 1118 nn += 1 1119 tt = nt_acv._make( lc.cc2[t].a[v][0] ) 1120 thisrealm = 'unset' 1121 thiscmv = (uuid.uuid1(), (tt.splab,tt.tm), tt.label, 'AerChemMIP', tt.description, self.vars1[v][0], '','','','','float','','','','',"aero",'','','','AerChemMIP','',tt.freq, 0, '', 1) 1122 self.cmv.append( thiscmv ) 1123 print 'INFO.kkkkk: AerChem Vars found: %s: %s' % (t,nn) 1124 ##thiscmv = (tt.uid, (tt.shape,tt.levels,tt.tstyle,gr,smdd[tt.mask],tt1.flag_values,tt1.flag_meanings), lab, '__from %s' % tt.table, tt.descriptionEx, tt1.vid, \ 1125 ##tt1.deflate_level, tt1.shuffle, tt1.ok_max_mean_abs, tt1.flag_meanings, tt1.type, tt1.ok_min_mean_abs, \ 1126 ##tt1.deflate, tt1.valid_min, tt1.flag_values, thisrealm, tt1.valid_max, tt1.positive, ntab, \ 1127 ##prov, provNote, tt.freq, tt.rowIndex, '', int(p)) 1025 1128 1026 1129 def dsort_u1(self,eed,sde): … … 1061 1164 bb = string.split(bits[0],'|') 1062 1165 if bb[-1] in odims: 1063 if bb[-1] == 'tau ':1166 if bb[-1] == 'tauxxx': 1064 1167 b0 = bits[0][:-4] 1065 1168 ts = 'tau|time' … … 1148 1251 ls1.add( d[1] ) 1149 1252 1150 lset = {'soil levels':'s level', 'all model levels above 400hPa':'aslevel'}1253 lset = {'soil levels':'sdepth', 'all model levels above 400hPa':'alevel'} 1151 1254 lsdd = {} 1152 1255 for l in ls1: … … 1166 1269 this = 'alt%s' % ii 1167 1270 elif ii > 1.5: 1271 if ii > 35: 1272 ii = 39 1168 1273 this = 'plev%s' % ii 1169 1274 else: … … 1193 1298 else: 1194 1299 n = -2 1300 1195 1301 lcount[sc] = n 1196 1302 if n == -1 and sc == 'latitude|basin': … … 1559 1665 def write2(self): 1560 1666 """write sections for cmor variable, request variable, structure, spatial and temporal dimensions""" 1561 for ksect in [ u'cmorvar', u'spatialshape', u'temporalshape', u'structure', u'requestvar', u'requestlink']: 1667 spsResets = collections.defaultdict(list) 1668 self.spLab2Uid = {} 1669 for ksect in [ u'spatialshape', u'temporalshape', u'cmorvar', u'structure', u'requestvar', u'requestlink']: 1562 1670 ##for ksect in [ u'cmorvar', u'spatialshape', u'temporalshape', u'structure']: 1563 1671 dil = self.ff[ksect][0].getElementsByTagName('item') … … 1574 1682 print 'ERROR.090.09005: duplicate key at ',r 1575 1683 s1.add( r[0] ) 1576 try: 1577 stid = self.strdd[r[1]] 1578 except: 1579 print 'ERROR.999.00099: strdd key not found: %s' % str(r[1]) 1580 for k in self.strdd.keys(): 1581 if k[0] == r[1][0]: 1582 print '*** ',k 1583 raise 1684 if len( r[1] ) == 2: 1685 spid = self.spLab2Uid[r[1][0]] 1686 print 'INFO.klklkl: AerChemMIP structure .... ',r[1] 1687 else: 1688 try: 1689 stid = self.strdd[r[1]] 1690 except: 1691 print 'ERROR.999.00099: strdd key not found: %s' % str(r[1]) 1692 for k in self.strdd.keys(): 1693 if k[0] == r[1][0]: 1694 print '*** ',k 1695 raise 1584 1696 1585 1697 if r[0] in self.fx.d2: … … 1657 1769 self.ff[ksect][0].appendChild( item ) 1658 1770 elif ksect == u'structure': 1771 ers = {} 1772 for kk in spsResets: 1773 if len( spsResets[kk] ) > 0: 1774 utarg = spsResets[kk][0][0] 1775 for r in spsResets[kk][1:]: 1776 ers[r[0]] = utarg 1659 1777 flds = self.structList[0]._fields 1660 1778 for nt in self.structList: 1661 1779 item = self.doc.createElement( 'item' ) 1662 1780 for f in flds: 1663 item.setAttribute( f, str( nt.__dict__[f] ) ) 1781 if f == 'spid' and nt.__dict__[f] in ers: 1782 item.setAttribute( f, ers[ nt.__dict__[f] ] ) 1783 print 'INFO.801.00011: updating target spid .... ' 1784 else: 1785 item.setAttribute( f, str( nt.__dict__[f] ) ) 1664 1786 self.ff[ksect][0].appendChild( item ) 1665 1787 elif ksect == u'spatialshape': 1788 1789 ## self.dimsSpaceInfo = ['uid','label','title','dimensions','levelFlag','levels'] 1666 1790 for k in self.dimsSpace.keys(): 1667 1791 rr = self.dimsSpace[k] 1668 item = self.doc.createElement( 'item' ) 1669 for i in range(len(self.dimsSpaceInfo)): 1670 item.setAttribute( self.dimsSpaceInfo[i], str( rr[i] ) ) 1671 if rr[3] in self.spsh.ss: 1672 lab,ttl = self.spsh.ss[rr[3]] 1673 if trace.SPATIALSHAPE_01: 1674 print 'INFO.035.0001: new spatial shape label: %s, %s' % (lab, ttl) 1675 if ttl[:4] != 'ssd.': 1676 item.setAttribute( 'title', ttl ) 1677 if len(lab) < 4 or lab[:4] != 'ssd-': 1678 item.setAttribute( 'label', lab ) 1679 1680 self.ff[ksect][0].appendChild( item ) 1792 kk = rr[3] 1793 if kk == '': 1794 kk = 'scalar' 1795 rr = list(rr) 1796 rr[3] = 'scalar' 1797 elif kk == 'longitude|latitude|plev': 1798 kk = 'longitude|latitude|plev4' 1799 rr = list(rr) 1800 rr[3] = kk 1801 if kk not in spsResets: 1802 item = self.doc.createElement( 'item' ) 1803 for i in range(len(self.dimsSpaceInfo)): 1804 item.setAttribute( self.dimsSpaceInfo[i], str( rr[i] ) ) 1805 if rr[3] in self.spsh.ss: 1806 lab,ttl,lf,li = self.spsh.ss[rr[3]] 1807 if trace.SPATIALSHAPE_01: 1808 print 'INFO.035.0001: new spatial shape label: %s, %s' % (lab, ttl) 1809 if ttl[:4] != 'ssd.': 1810 item.setAttribute( 'title', ttl ) 1811 if len(lab) < 4 or lab[:4] != 'ssd-': 1812 item.setAttribute( 'label', lab ) 1813 item.setAttribute( 'levels', li ) 1814 item.setAttribute( 'levelFlag', string.lower(lf) ) 1815 else: 1816 print 'ERROR.055.00001: spatial shape record not recognised: %s' % str(rr) 1817 print 'INFO.801.00120: new shape for %s' % str(rr) 1818 thisl = item.getAttribute( 'label' ) 1819 assert thisl not in self.spLab2Uid.keys(), 'Duplicate spatial shape label: %s' % thisl 1820 self.spLab2Uid[thisl] = item.getAttribute( 'uid' ) 1821 self.ff[ksect][0].appendChild( item ) 1822 else: 1823 print 'INFO.801.00121: duplicate shape for %s' % str(rr) 1824 spsResets[kk].append( rr ) 1825 1681 1826 elif ksect == u'temporalshape': 1682 1827 for k in self.dimsTime.keys(): -
CMIP6dreqbuild/trunk/src/workbook/importWbMods.py
r526 r530 20 20 21 21 class loadVars(object): 22 def __init__(self): 23 wb = workbook( 'inputs/var.xls' ) 24 x = ['label', 'title', 'description', 'procComment', 'procnote', 'prov', 'provmip', 'sn', 'units', 'uid','defaultp'] 25 nt_var = collections.namedtuple( 'var', x ) 26 22 def __init__(self,opt=1): 23 if opt == 0: 24 wb = workbook( 'inputs/var.xls' ) 25 else: 26 wb = workbook( 'inputs/vars_20151201.xls' ) 27 #x = ['label', 'title', 'description', 'procComment', 'procnote', 'prov', 'provmip', 'sn', 'units', 'uid','defaultp','tags','alias'] 28 #nt_var = collections.namedtuple( 'var', x ) 27 29 28 30 self.d1 = {} … … 30 32 s1 = wb.book.sheet_by_name(u'var') 31 33 for i in range(1,s1.nrows): 32 rr = [x.value for x in s1.row(i)] 33 uid = rr[-2] 34 assert uid not in self.d1, 'Duplicate uid in var.xls: %s, %s' % (uid,str(rr) ) 35 rr[-1] = int( rr[-1] ) 36 self.d1[uid] = rr 37 self.c1[rr[0]].append( uid ) 34 try: 35 rr = [x.value for x in s1.row(i)] 36 uid = rr[9] 37 assert uid not in self.d1, 'Duplicate uid in var.xls: %s, %s' % (uid,str(rr) ) 38 rr[10] = int( rr[10] ) 39 self.d1[uid] = [str(x) for x in rr] 40 self.c1[rr[0]].append( uid ) 41 except: 42 print rr 43 raise 38 44 39 45 class loadFixes(object): … … 79 85 for i in range(s1.nrows): 80 86 rr = [x.value for x in s1.row(i)] 81 assert rr[2] not in self.ss, 'Duplicate dimension set in spatial shape sheet: %s' % rr[2] 82 a,b,k = tuple( [string.strip(x) for x in rr[:3] ] ) 83 self.ss[ k ] = (a,b) 87 if rr[0] != 'label': 88 assert rr[2] not in self.ss, 'Duplicate dimension set in spatial shape sheet: %s' % rr[2] 89 a,b,k,lf = tuple( [string.strip(x) for x in rr[:4] ] ) 90 li = str( int( rr[4] ) ) 91 self.ss[ k ] = (a,b,lf,li) 84 92 85 fx = loadFixes() 86 vars = loadVars() 87 ls = loadSpatial() 88 cm = loadCmorDims() 89 mmsi = loadMipMaps( 'SIMIP' ) 93 class run(object): 94 def __init__(self): 95 self.fx = loadFixes() 96 self.vars = loadVars() 97 self.ls = loadSpatial() 98 self.cm = loadCmorDims() 99 self.mmsi = loadMipMaps( 'SIMIP' ) -
CMIP6dreqbuild/trunk/src/workbook/ivg.py
r457 r530 4 4 5 5 cmip5GrpLk = collections.defaultdict( dict ) 6 7 class cellMethodCheck(object): 8 def __init__(self): 9 pass 10 def check(self,cm): 11 if string.find( cm, "area: where" ) != -1: 12 return ( string.replace( cm, "area: where", "area: mean where" ), 1) 13 elif string.find( cm, "time:mean" ) != -1: 14 return ( string.replace( cm, "time:mean", "time: mean" ), 1) 15 elif string.find( cm, "weighted b " ) != -1: 16 return ( string.replace( cm, "weighted b ", "weighted by " ), 1) 17 else: 18 return (cm,0) 19 20 class structureList(object): 21 def __init__(self): 22 self.ll = [] 23 self.nt_dims = collections.namedtuple( 'dims', ['uid','label','spid','tmid','odims','coords','cell_methods','cell_measures','flag_values','flag_meanings','description','procNote','prov'] ) 24 self.ee3 = {} 25 self.cmch = cellMethodCheck() 26 27 def add(self,cand): 28 29 cm, fl = self.cmch.check( cand[6] ) 30 if fl == 1: 31 cand[6] = cm 32 nt = self.nt_dims._make( cand ) 33 tt = tuple( [nt.__dict__[k] for k in ['spid','tmid','odims','coords','cell_methods','cell_measures','flag_values','flag_meanings','procNote','prov']] ) 34 if self.ee3.has_key( tt ): 35 u = self.ee3[tt] 36 else: 37 u = nt.uid 38 self.ee3[tt] = nt.uid 39 self.ll.append( nt ) 40 return u 6 41 7 42 freqmap = {'daily':'day', 'Annual':'yr', 'Timestep':'subhr', '1day':'day', '1mon':'mon', 'month':'mon', 'year':'yr', 'monthly':'mon', 'Day':'day', '6h':'6hr', '3 hourly':'3hr', '3 Hourly':'3hr' }
Note: See TracChangeset
for help on using the changeset viewer.