Ignore:
Timestamp:
20/01/17 10:10:15 (3 years ago)
Author:
mjuckes
Message:

stripped sx203.py from sx202.py

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CMIP6dreqbuild/trunk/srcMisc/sx202.py

    r876 r926  
    2828uidgen = collections.defaultdict( uid1 ) 
    2929 
    30 sh1 = shelve.open( '%s/cmip5Groups' % odir, 'n' ) 
     30if sx.doCmipVar: 
     31  sh1 = shelve.open( '%s/cmip5Groups' % odir, 'n' ) 
    3132## 
    3233## list of CMIP5 tables which have groups 
    3334## 
    34 cmip5GroupsIx = set() 
     35  cmip5GroupsIx = set() 
    3536## 
    3637## dictionary, specifying group for each variable in table 
    3738## 
    38 cmip5GroupsIVAR = collections.defaultdict( dict ) 
    39 for k in sx.cmip5so.sop.keys(): 
    40   sh1[k] = sx.cmip5so.sop[k][:] 
    41   cmip5GroupsIx.add( string.split( k, '_' )[0] ) 
    42   for v in sx.cmip5so.sop[k]: 
    43     cmip5GroupsIVAR[ string.split( k, '_' )[0] ][v] = k 
    44   if sx.cmip5so.omipInsert and k in sx.cmip5so.sxp: 
    45     for v in sx.cmip5so.sxp[k]: 
     39  cmip5GroupsIVAR = collections.defaultdict( dict ) 
     40  for k in sx.cmip5so.sop.keys(): 
     41    sh1[k] = sx.cmip5so.sop[k][:] 
     42    cmip5GroupsIx.add( string.split( k, '_' )[0] ) 
     43    for v in sx.cmip5so.sop[k]: 
    4644      cmip5GroupsIVAR[ string.split( k, '_' )[0] ][v] = k 
    47 sh1.close() 
     45    if sx.cmip5so.omipInsert and k in sx.cmip5so.sxp: 
     46      for v in sx.cmip5so.sxp[k]: 
     47        cmip5GroupsIVAR[ string.split( k, '_' )[0] ][v] = k 
     48  sh1.close() 
    4849#### 'uuid', 'mip', 'label','title','ref','refNote' 
    4950####  i, "CMIP6",  key, ...., "CMIP5", '' 
     
    403404print 'INFO 001 ##################',nnf, nnm 
    404405 
     406if sx.doCmipVar: 
    405407##sh = shelve.open( 'shelve_vars' ) 
    406 sh = shelve.open( '%s/cmipVars' % odir, 'n' ) 
    407 sh['__info__'] = { 'label':'cmipVars', 'title':'CMIP variables', 'prov':'sx.eenv and sx.eeold' } 
    408 sh['__cols__'] = ['label','title','sn','units','description','procnote','procComment','prov','priority0','realm0'] 
    409  
    410 ee = {} 
    411 for k in sx.eenv.keys(): 
    412   this = nt_vrecix._make( map( lambda x: sx.eenv[k][x], vrecix_new ) ) 
    413   ##sh[k] = { 'label':this.v, 'title':this.l, 'sn':this.s, 'units':this.u, 'description':this.c, 'procnote':'', 'procComment':'','prov':'CMIP6 endorsement' } 
    414   prov = 'CMIP6 endorsement [%s]' % sx.eenv[k][1] 
    415   sh[k] = [ this.v, this.l, this.s, this.u, this.c, '', '',prov, sx.eenv[k][0], sx.eenv[k][8] ] 
    416   ee[this.u] = k 
    417   if this.u == 'atmos': 
    418      print 'ERROR: bad units',k, sx.eenv[k] 
    419 print '################################### var units #################' 
    420 print ee.keys() 
    421 print '##########################################################' 
    422  
    423 nk = 0 
    424 for k in ll_ov: 
    425   this = nt_vrecix._make( map( lambda x: sx.eeold[k][x], vrecix_old ) ) 
     408  sh = shelve.open( '%s/cmipVars' % odir, 'n' ) 
     409  sh['__info__'] = { 'label':'cmipVars', 'title':'CMIP variables', 'prov':'sx.eenv and sx.eeold' } 
     410  sh['__cols__'] = ['label','title','sn','units','description','procnote','procComment','prov','priority0','realm0'] 
     411 
     412  ee = {} 
     413  for k in sx.eenv.keys(): 
     414    this = nt_vrecix._make( map( lambda x: sx.eenv[k][x], vrecix_new ) ) 
     415    ##sh[k] = { 'label':this.v, 'title':this.l, 'sn':this.s, 'units':this.u, 'description':this.c, 'procnote':'', 'procComment':'','prov':'CMIP6 endorsement' } 
     416    prov = 'CMIP6 endorsement [%s]' % sx.eenv[k][1] 
     417    sh[k] = [ this.v, this.l, this.s, this.u, this.c, '', '',prov, sx.eenv[k][0], sx.eenv[k][8] ] 
     418    ee[this.u] = k 
     419    if this.u == 'atmos': 
     420       print 'ERROR: bad units',k, sx.eenv[k] 
     421  print '################################### var units #################' 
     422  print ee.keys() 
     423  print '##########################################################' 
     424 
     425  nk = 0 
     426  for k in ll_ov: 
     427    this = nt_vrecix._make( map( lambda x: sx.eeold[k][x], vrecix_old ) ) 
    426428  ##sh[k] = { 'label':this.v, 'title':this.l, 'sn':this.s, 'units':this.u, 'description':this.c, 'procnote':'', 'procComment':'','prov':sx.eeold[k][6]} 
    427   if this.v in sx.cmip5ByVar.keys(): 
    428     s = set() 
    429     for t in sx.cmip5ByVar[this.v]: 
    430       s.add( sx.cmip5so.so[t].a[this.v][18] ) 
    431  
    432     s = list(s) 
    433     rlm0 = string.join( s ) 
    434   elif this.v in sx.eenvo: 
    435     rlm0 = sx.eenvo[this.v][0][8] 
    436     print 'INFO.llll: using eenvo .....',this.v 
    437   else: 
    438     rlm0 = '__na__' 
     429    if this.v in sx.cmip5ByVar.keys(): 
     430      s = set() 
     431      for t in sx.cmip5ByVar[this.v]: 
     432        s.add( sx.cmip5so.so[t].a[this.v][18] ) 
     433 
     434      s = list(s) 
     435      rlm0 = string.join( s ) 
     436    elif this.v in sx.eenvo: 
     437      rlm0 = sx.eenvo[this.v][0][8] 
     438      print 'INFO.llll: using eenvo .....',this.v 
     439    else: 
     440      rlm0 = '__na__' 
    439441       
    440   sh[k] = [ this.v, this.l, this.s, this.u, this.c, '', '',sx.eeold[k][6], 101, rlm0 ] 
    441   nk += 1 
    442  
    443 print len( sx.eenv.keys() ) + len(ll_ov), len( sh.keys() ),  len( sx.eenv.keys() ) 
    444 sh.close() 
     442    sh[k] = [ this.v, this.l, this.s, this.u, this.c, '', '',sx.eeold[k][6], 101, rlm0 ] 
     443    nk += 1 
     444 
     445  print len( sx.eenv.keys() ) + len(ll_ov), len( sh.keys() ),  len( sx.eenv.keys() ) 
     446  sh.close() 
    445447   
    446448### 
     
    842844 
    843845dorest = True 
     846doexpt = False 
    844847 
    845848class psort(object): 
     
    11781181 
    11791182 
     1183if doexpt: 
     1184 
    11801185 ##wb = utils_wb.workbook( 'CMIP6DataRequest_ConsolidatedExperiments_20151028.xls' ) 
    11811186 cvdir = '/data/work/tmp/git/CMIP6_CVs' 
    11821187 efn = 'CMIP6DataRequest_ConsolidatedExperiments_20160714.xls' 
    11831188 efn = 'CMIP6DataRequest_ConsolidatedExperiments_20161111.xls' 
     1189 efn = 'CMIP6DataRequest_ConsolidatedExperiments_20170117.xls' 
    11841190 wb = utils_wb.workbook( efn ) 
    11851191 sht = wb.book.sheet_by_name( 'Experiments' ) 
Note: See TracChangeset for help on using the changeset viewer.