Ignore:
Timestamp:
20/12/16 22:52:47 (3 years ago)
Author:
mjuckes
Message:

draft code to edit tables

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CMIP6dreqbuild/trunk/src/framework/audit.py

    r903 r909  
    2222class checkUnits(object): 
    2323 
    24   def __init__(self, cc): 
     24  def __init__(self, cc, extra=None): 
    2525    assert python2, 'The checkUnits module requires cf, which is not available in python 3' 
    2626    import cf 
     27    if extra != None: 
     28      for k in sorted( extra.keys() ): 
     29        try: 
     30          a = cf.units.Units( k ) 
     31        except: 
     32          log.warn( 'WARN.001.0004: bad units %s (%s)' % (k,str(extra[k])) ) 
     33 
    2734    for k in sorted( cc.keys() ): 
    2835      try: 
     
    131138    cc = collections.defaultdict( list ) 
    132139    ss = collections.defaultdict( c1 ) 
     140    ssx = collections.defaultdict( set ) 
    133141    umap = { 'Wm-2':'W m-2', 'string':''} 
    134142    for i in self.dq.coll['var'].items: 
     
    138146        u = umap.get( isn.units, isn.units ) 
    139147        ss[u].a[i.units].append( i.label ) 
     148      else: 
     149        ssx[i.units].add( i.label ) 
    140150 
    141151    ii = [k for k in cc if len(cc[k]) > 1] 
     
    156166      log.warn( 'Skipping the units check .. not available in python3' ) 
    157167    else: 
    158       checkUnits( ss ) 
     168      checkUnits( ss, extra=ssx ) 
    159169    
    160170  def audit_str(self): 
Note: See TracChangeset for help on using the changeset viewer.