Changeset 151


Ignore:
Timestamp:
24/04/14 17:06:59 (6 years ago)
Author:
astephen
Message:

Updates to run smoothly on CMIP5: taking type from mip tables; cleaned up error messages

Location:
CCCC/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • CCCC/trunk/README.txt

    r148 r151  
    77Required arguments: 
    88 
    9 python c4.py -p <project> -D <directory>  ## check all files in directory tree, for project in SPECS, CORDEX, CCMI. 
     9python c4.py -p <project> -D <directory>  ## check all files in directory tree, for project in SPECS, CORDEX, CCMI, CMIP5. 
    1010python c4.py -p <project> -d <directory>  ## check all files in directory 
    1111python c4.py -p <project> -f <file>       ## check a single file. 
  • CCCC/trunk/config_c4.py

    r150 r151  
    288288 
    289289 
     290    self.defaults = { 'variableDataType':'float' } 
    290291######## used in mipVocabs 
    291292    if self.project == 'CORDEX': 
     
    296297    elif self.project == 'CMIP5': 
    297298       self.mipVocabDir = 'cmip5_vocabs/mip/' 
    298        self.mipVocabTl = ['fx','Oyr','Oclim','Omon','Amon','Lmon','OImon','cfMon','aero','cfDay','day','cfOff','cfSites','6hrLev','6hrPlev','3hr','cf3hr'] 
     299       self.mipVocabTl = ['fx','Oyr','Oclim','Omon','Amon','Lmon','LImon','OImon','cfMon','aero','cfDay','day','cfOff','cfSites','6hrLev','6hrPlev','3hr','cf3hr'] 
    299300       self.mipVocabVgmap = {} 
    300301       self.mipVocabFnpat = 'CMIP5_%s' 
     302       self.defaults['variableDataType'] = None  
    301303    elif self.project == 'SPECS': 
    302304       self.mipVocabDir = 'specs_vocabs/mip/' 
  • CCCC/trunk/summary.py

    r150 r151  
    22import string, sys, glob 
    33 
    4 idir = sys.argv[1] 
     4args = sys.argv[1:-1] 
     5idir = sys.argv[-1] 
     6ndisp = 2 
     7while len(args) > 0: 
     8  x = args.pop(0) 
     9  if x == '-n': 
     10    ndisp = int( args.pop(0) ) 
    511 
    612fl = glob.glob( '%s/*__qclog_*.txt' % idir ) 
     
    3844keys = ee.keys() 
    3945keys.sort() 
     46def cmin(x,y): 
     47  if x < 0: 
     48    return y 
     49  else: 
     50    return min(x,y) 
     51 
    4052for k in keys: 
    4153  ks = ee[k][1].keys() 
    4254  if len(ks) == 1: 
    4355    print k,ee[k][0],ks[0] 
    44     for i in range(min(2,ee[k][0])): 
     56    for i in range(cmin(ndisp,ee[k][0])): 
    4557      print '               ',ee[k][1][ks[0]][1][i] 
    4658  else: 
     
    4961    for k2 in ks: 
    5062      print '  --- ',k2,ee[k][1][k2][0] 
    51       for i in range(min(2,ee[k][1][k2][0])): 
     63      for i in range(cmin(ndisp,ee[k][1][k2][0])): 
    5264        print '               ',ee[k][1][k2][1][i] 
    5365 
  • CCCC/trunk/utils_c4.py

    r147 r151  
    11 
    22import string, re, os, sys, traceback 
     3 
     4def strmm3( mm ): 
     5  return string.join( map( lambda x: '%s="%s" [correct: "%s"]' % x, mm ), '; ' ) 
    36 
    47from fcc_utils import mipTableScan 
     
    236239    self.test( len(bits) in self.pcfg.fnPartsOkLen, 'File name not parsed in %s elements [%s]' % (str(self.pcfg.fnPartsOkLen),str(bits)), abort=True ) 
    237240 
     241    if self.pcfg.groupIndex != None: 
     242      self.group = self.fnParts[self.pcfg.groupIndex] 
     243    else: 
     244      self.group = None 
     245 
    238246    if self.pcfg.freqIndex != None: 
    239247      self.freq = self.fnParts[self.pcfg.freqIndex] 
     248    elif self.group == 'fx': 
     249      self.freq = 'fx' 
    240250    else: 
    241251      self.freq = None 
    242  
    243     if self.pcfg.groupIndex != None: 
    244       self.group = self.fnParts[self.pcfg.groupIndex] 
    245     else: 
    246       self.group = None 
    247252 
    248253    ##if self.cls == 'CORDEX': 
     
    356361    self.checkId = '003' 
    357362 
    358     self.test( varAts[varName]['_type'] == "float32", 'Variable [%s] not of type float' % varName ) 
     363    mipType = vocabs['variable'].getAttr( varName, varGroup, 'type' ) 
     364    thisType = {'real':'float32', 'integer':'int32' }.get( mipType, mipType ) 
     365    self.test( mipType == None or varAts[varName]['_type'] == thisType, 'Variable [%s/%s] not of type %s [%s]' % (varName,varGroup,thisType,varAts[varName]['_type']) ) 
    359366 
    360367    self.checkId = '004' 
     
    382389      tval = ( varAts[varName].get( 'missing_value', None ) != None ) and varAts[varName].has_key( '_FillValue' ) 
    383390      ok &= self.test( tval, 'missing_value and _FillValue must both be present if one is [%s]' % varName ) 
    384       if varAts[varName].has_key( 'missing_value' ): 
    385          msg = 'Variable [%s] has incorrect missing_value attribute' % varName 
    386          ok &= self.test( varAts[varName]['missing_value'] == self.missingValue, msg, part=True ) 
    387       if varAts[varName].has_key( '_FillValue' ): 
    388          msg = 'Variable [%s] has incorrect _FillValue attribute' % varName 
    389          ok &= self.test( varAts[varName]['_FillValue'] == self.missingValue, msg, part=True ) 
     391      if mipType == 'real': 
     392        if varAts[varName].has_key( 'missing_value' ): 
     393           msg = 'Variable [%s] has incorrect missing_value attribute' % varName 
     394           ok &= self.test( varAts[varName]['missing_value'] == self.missingValue, msg, part=True ) 
     395        if varAts[varName].has_key( '_FillValue' ): 
     396           msg = 'Variable [%s] has incorrect _FillValue attribute' % varName 
     397           ok &= self.test( varAts[varName]['_FillValue'] == self.missingValue, msg, part=True ) 
    390398 
    391399    mm = [] 
     
    420428          if string.find( targ, val): 
    421429             mm.append( (k,targ,val) ) 
    422       elif targ != val: 
     430      elif targ != 'Attribute not present' and targ != val: 
    423431        mm.append( (k,targ,val) ) 
    424432 
    425     ok &= self.test( len(mm)  == 0, 'Variable [%s] has incorrect attributes: %s' % (varName, str(mm)), part=True ) 
     433    ok &= self.test( len(mm)  == 0, 'Variable [%s] has incorrect attributes: %s' % (varName, strmm3(mm)), part=True ) 
    426434    if len( mm  ) != 0: 
    427435      if self.parent.amapListDraft == None: 
     
    764772        ee = ms.scan_table(ll,None,asDict=True) 
    765773        for v in ee.keys(): 
    766           eeee = {} 
     774## set global default: type float 
     775          eeee = { 'type':pcfg.defaults.get( 'variableDataType', 'float' ) } 
    767776          ar = [] 
    768777          ac = [] 
     
    790799          eeee['cell_methods'] = 'time: point' 
    791800          eeee['units'] = ee['units'] 
     801          eeee['type'] = 'float' 
    792802          ar = [] 
    793803          ac = [] 
Note: See TracChangeset for help on using the changeset viewer.