Changeset 63 for FCC2


Ignore:
Timestamp:
02/10/13 18:52:44 (6 years ago)
Author:
mjuckes
Message:

comp_mip update for CCMI

File:
1 edited

Legend:

Unmodified
Added
Removed
  • FCC2/trunk/source/comp_mip.py

    r55 r63  
    1  
    21from fcc_utils import mipTableScan 
    32import re, os, string 
     
    54ml = ['CORDEX_3h', 'CORDEX_6h', 'CORDEX_Aday', 'CORDEX_day', 'CORDEX_grids', 'CORDEX_mon' ] 
    65ml = ['CORDEX_3h', 'CORDEX_6h', 'CORDEX_fx', 'CORDEX_day', 'CORDEX_mon', 'CORDEX_sem' ] 
     6ml = ['CCMI1_Amon_v1_complete'] 
     7newMip = 'CCMI' 
    78ml2 = ['CMIP5_3hr', 'CMIP5_6hrPlev', 'CMIP5_Amon', 'CMIP5_cfDay', 'CMIP5_cfOff', 'CMIP5_day', 'CMIP5_grids', 'CMIP5_Lmon', 'CMIP5_OImon', 'CMIP5_Oyr', 
    89       'CMIP5_6hrLev', 'CMIP5_aero', 'CMIP5_cf3hr', 'CMIP5_cfMon', 'CMIP5_cfSites', 'CMIP5_fx', 'CMIP5_LImon', 'CMIP5_Oclim', 'CMIP5_Omon']  
     
    6566      f3 = False 
    6667      f4 = False 
    67       if e1[k][1]['standard_name'] not in self.snl: 
     68      if e1[k][1]['standard_name'] in [None,'None']: 
     69        print 'ERROR[A]: standard name for %s not set' % k 
     70      elif e1[k][1]['standard_name'] not in self.snl: 
    6871        if e1[k][1]['standard_name'] not in self.snla: 
    6972          print 'ERROR[0]: standard name %s for %s [%s] not in snl or snla' % (e1[k][1]['standard_name'], k, e1[k][2] ) 
    7073        else: 
    7174          print 'WARNING: standard name %s for %s not in snl' % (e1[k][1]['standard_name'], k ) 
    72       if k not in self.ec1.keys(): 
    73         print 'ERROR[1]: variable %s [%s] not in CORDEX variable requirements list' % (k,e1[k][2]) 
    74         vrln = None 
    75       else: 
    76         vrln = self.ec1[k][1] 
    77         if e1[k][1]['long_name'] != self.ec1[k][1]: 
    78           f2 = True 
    79         if checkCellMethods:   
    80           if e1[k][1]['cell_methods'] != self.ec1[k][3]: 
    81             if not (e1[k][1]['cell_methods']=="None" and string.strip(self.ec1[k][3]) == "time:"): 
    82               f3 = True 
    83         if checkAll:   
    84           if (e1[k][1].has_key( 'positive' ) and self.ec1[k][4] == '') or ( (not e1[k][1].has_key( 'positive' )) and self.ec1[k][4] != ''): 
    85               f4 = True 
    86           elif e1[k][1].has_key( 'positive' ): 
    87             if e1[k][1]['positive'] != self.ec1[k][4]: 
    88               if not (e1[k][1]['positive']=="None" and string.strip(self.ec1[k][4]) == ""): 
     75      if self.ec1 != None: 
     76        if k not in self.ec1.keys(): 
     77          print 'ERROR[1]: variable %s [%s] not in CORDEX variable requirements list' % (k,e1[k][2]) 
     78          vrln = None 
     79        else: 
     80          vrln = self.ec1[k][1] 
     81          if e1[k][1]['long_name'] != self.ec1[k][1]: 
     82            f2 = True 
     83          if checkCellMethods:   
     84            if e1[k][1]['cell_methods'] != self.ec1[k][3]: 
     85              if not (e1[k][1]['cell_methods']=="None" and string.strip(self.ec1[k][3]) == "time:"): 
     86                f3 = True 
     87          if checkAll:   
     88            if (e1[k][1].has_key( 'positive' ) and self.ec1[k][4] == '') or ( (not e1[k][1].has_key( 'positive' )) and self.ec1[k][4] != ''): 
    8989                f4 = True 
    90           if (e1[k][1].has_key( 'modeling_realm' ) and self.ec1[k][5] == '') or ( (not e1[k][1].has_key( 'modeling_realm' )) and self.ec1[k][5] != ''): 
    91               f4 = True 
    92           elif e1[k][1].has_key( 'modeling_realm' ): 
    93             if e1[k][1]['modeling_realm'] != self.ec1[k][5]: 
    94               if not (e1[k][1]['modeling_realm']=="None" and string.strip(self.ec1[k][5]) == ""): 
     90            elif e1[k][1].has_key( 'positive' ): 
     91              if e1[k][1]['positive'] != self.ec1[k][4]: 
     92                if not (e1[k][1]['positive']=="None" and string.strip(self.ec1[k][4]) == ""): 
     93                  f4 = True 
     94            if (e1[k][1].has_key( 'modeling_realm' ) and self.ec1[k][5] == '') or ( (not e1[k][1].has_key( 'modeling_realm' )) and self.ec1[k][5] != ''): 
    9595                f4 = True 
     96            elif e1[k][1].has_key( 'modeling_realm' ): 
     97              if e1[k][1]['modeling_realm'] != self.ec1[k][5]: 
     98                if not (e1[k][1]['modeling_realm']=="None" and string.strip(self.ec1[k][5]) == ""): 
     99                  f4 = True 
    96100         
    97101      cks = ['units', 'long_name', 'standard_name'] 
     
    100104        if e1[k][1] != e2[k][1]: 
    101105          ne1 = 0 
     106          nmm = [] 
    102107          for k2 in cks: 
    103108             if e1[k][1][k2] != e2[k][1][k2]: 
    104                 ne1 += 0 
     109                ne1 += 1 
     110                nmm.append(k2) 
    105111          if ne1 > 0: 
    106                 print 'ERROR[4A]: Anomaly bewteen MIP tables: %s:: %s -- %s [%s]' % (k, str(e1[k][1]), str( e2[k][1] ), vrln ) 
     112                print 'ERROR[4A]: Anomaly bewteen MIP tables: %s:: %s ' % (k, str(nmm) ) 
    107113          else: 
    108114             if not suppress4B: 
     
    110116          e0 = 1 
    111117        else: 
    112           ## print '%s OK -- %s -- %s' % (k,str(e1[k][1]), str( e2[k][1] ) ) 
     118          ##print '%s OK -- %s -- %s' % (k,str(e1[k][1]), str( e2[k][1] ) ) 
    113119          e0 = 2 
    114120      else: 
    115         ## print '%s not in table 2' % k 
     121        ##print '%s not in table 2' % k 
    116122        e0 = 3 
    117123 
     
    119125      if self.tag != None: 
    120126         xxx += '[%s]' % self.tag 
    121       if f2 and (e0 == 2): 
    122          print 'ERROR[2]: Difference between CORDEX/CMIP5 MIP tables and VR: %s:: %s [%s] --- %s' % (k,e1[k][1]['long_name'],e1[k][2], self.ec1[k][1]) 
    123       elif f2 and (e0 == 3): 
    124          print 'ERROR[3]: Difference between CORDEX MIP tables and VR: %s:: %s [%s] --- %s' % (k,e1[k][1]['long_name'],e1[k][2], self.ec1[k][1]) 
    125       elif f2: 
    126          print 'ERROR[5]: Difference between CORDEX MIP tables and VR %s: %s --- %s' % (xxx,e1[k][1]['long_name'], self.ec1[k][1]) 
    127       if f3: 
    128          print 'ERROR[6]: Difference between CORDEX MIP tables and VR in cell_methods: %s:: %s --- %s' % (k,e1[k][1]['cell_methods'], self.ec1[k][3]) 
    129       if f4: 
    130          print 'ERROR[7]: Difference between CORDEX MIP tables and VR in positive, realm: %s:: %s,%s --- %s' % (xxx,e1[k][1].get('positive','None'),e1[k][1].get('modeling_realm','None'), self.ec1[k][4:6]) 
     127      if self.ec1 != None: 
     128        if f2 and (e0 == 2): 
     129           print 'ERROR[2]: Difference between CORDEX/CMIP5 MIP tables and VR: %s:: %s [%s] --- %s' % (k,e1[k][1]['long_name'],e1[k][2], self.ec1[k][1]) 
     130        elif f2 and (e0 == 3): 
     131           print 'ERROR[3]: Difference between CORDEX MIP tables and VR: %s:: %s [%s] --- %s' % (k,e1[k][1]['long_name'],e1[k][2], self.ec1[k][1]) 
     132        elif f2: 
     133           print 'ERROR[5]: Difference between CORDEX MIP tables and VR %s: %s --- %s' % (xxx,e1[k][1]['long_name'], self.ec1[k][1]) 
     134        if f3: 
     135           print 'ERROR[6]: Difference between CORDEX MIP tables and VR in cell_methods: %s:: %s --- %s' % (k,e1[k][1]['cell_methods'], self.ec1[k][3]) 
     136        if f4: 
     137           print 'ERROR[7]: Difference between CORDEX MIP tables and VR in positive, realm: %s:: %s,%s --- %s' % (xxx,e1[k][1].get('positive','None'),e1[k][1].get('modeling_realm','None'), self.ec1[k][4:6]) 
    131138         
    132  
    133139base='/home/users/prototype/cordex/exarch/FCC2/trunk/work/' 
    134140snl,snla = gen_sn_list( base + cfsntab ) 
    135141print 'Len snl = %s' % len(snl) 
    136  
    137142 
    138143dkrz_cordex_version = 3 
     
    195200     eeee[tab] = ee 
    196201 
    197  
    198  
     202newMipDir = '/cordex_vocabs/mip/' 
     203mpat = 'CORDEX_%s' 
     204newMipDir = '/ccmi_vocabs/mip/' 
     205mpat = 'CCMI1_%s_v1_complete' 
    199206def validate( t,cc ): 
    200207  if t == 'all': 
     
    202209    l2 = {} 
    203210    for m in ml: 
    204       l1 = ms.scan_table( open( base + '/cordex_vocabs/mip/' + m ).readlines(), None, asDict=True, appendTo=l1, lax=True, tag=m) 
     211      l1 = ms.scan_table( open( base + newMipDir + m ).readlines(), None, asDict=True, appendTo=l1, lax=True, tag=m) 
    205212    for m in ml2: 
    206213      l2 = ms.scan_table( open( base + '/cmip5_vocabs/mip/' + m ).readlines(), None, asDict=True, appendTo=l2, lax=True, tag=m) 
     
    211218      l2 = ms.scan_table( open( base + '/cmip5_vocabs/mip/' + m ).readlines(), None, asDict=True, appendTo=l2, lax=True, tag=m) 
    212219    k = { '3hr':'3h', '6hr':'6h' }.get( t,t ) 
    213     l1 = ms.scan_table( open( base + '/cordex_vocabs/mip/CORDEX_%s' % k ).readlines(), None, asDict=True) 
     220    l1 = ms.scan_table( open( base + newMipDir + mpat % k ).readlines(), None, asDict=True) 
    214221    ccm = True 
    215  
    216222  cc.comp( l1, l2, checkCellMethods=ccm, tag=t ) 
    217223 
    218 for tab in ['3hr','6hr','day','mon','sem','fx']: 
     224tlist = ['3hr','6hr','day','mon','sem','fx'] 
     225tlist = ['Amon'] 
     226for tab in tlist: 
    219227  ms = mipTableScan() 
    220228  print 'Validating table %s ' % tab 
    221   print eeee[tab].keys() 
    222   c = comp( snl,snla=snla, ec1=eeee[tab]) 
     229  if newMip == 'CCMI': 
     230    ec1 = None 
     231  else: 
     232    ec1=eeee[tab] 
     233    print eeee[tab].keys() 
     234  c = comp( snl,snla=snla, ec1=ec1) 
    223235  validate(tab,c) 
    224      
Note: See TracChangeset for help on using the changeset viewer.