Ignore:
Timestamp:
18/12/15 13:50:34 (5 years ago)
Author:
mjuckes
Message:

update on structures etc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CMIP6dreqbuild/trunk/src/workbook/importWbMods.py

    r526 r530  
    2020 
    2121class 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 ) 
    2729 
    2830    self.d1 = {} 
     
    3032    s1 = wb.book.sheet_by_name(u'var') 
    3133    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 
    3844     
    3945class loadFixes(object): 
     
    7985    for i in range(s1.nrows): 
    8086      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) 
    8492   
    85 fx = loadFixes() 
    86 vars = loadVars() 
    87 ls = loadSpatial() 
    88 cm = loadCmorDims() 
    89 mmsi = loadMipMaps( 'SIMIP' ) 
     93class 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' ) 
Note: See TracChangeset for help on using the changeset viewer.