Changeset 68


Ignore:
Timestamp:
15/10/13 13:32:52 (7 years ago)
Author:
mjuckes
Message:

fixed bug in exception handling in checkStandardDims

Location:
CCCC/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • CCCC/trunk/README.txt

    r67 r68  
    2525  -- "Rec.txt" -- single record for each file, as above 
    2626 
    27 VOCABULARIES 
    28 ------------ 
    2927 
    3028Vocabulary lists GCMModelName.txt and RCMModelName.txt are held on the DMI CORDEX site: 
     
    3331  http://cordex.dmi.dk/joomla/images/CORDEX/RCMModelName.txt 
    3432 
    35  
    36  
    37  
     33Exceptions 
     34---------- 
     35The exception handling is designed to ensure that problems analysing one file do not prevent testing of other files. 
     36Traceback information is written to log file. 
  • CCCC/trunk/c4.py

    r60 r68  
    281281        rec.addErr( f, 'ERRORS FOUND AND CHECKS ABORTED' ) 
    282282    except: 
    283       c4i.logger.info( 'Exception caught' ) 
     283      c4i.logger.error("Exception has occured" ,exc_info=1) 
    284284      rec.addErr( f, 'ERROR: Exception' ) 
    285       raise 
    286285 
    287286  cc.info.log = c4i.logger 
  • CCCC/trunk/utils_c4.py

    r66 r68  
    9595    self.controlledGlobalAttributes = ['frequency', 'driving_experiment_name', 'project_id', 'CORDEX_domain', 'driving_model_id', 'model_id', 'institute_id','driving_model_ensemble_member','rcm_version_id'] 
    9696    self.globalAttributesInFn = [None,'CORDEX_domain','driving_model_id','experiment_id','driving_model_ensemble_member','model_id','rcm_version_id'] 
    97     self.requiredVarAttributes = ['long_name', 'standard_name', 'units'] 
     97    self.requiredVarAttributes = ['long_name', 'standard_name', 'units', 'missing_value', '_FillValue'] 
    9898    self.checks = () 
    9999    self.drsMappings = {'variable':'@var','institute':'institute_id', 'product':'product', 'experiment':'experiment_id', \ 
     
    303303    self.checkId = '005' 
    304304    ok = True 
    305     if varAts[varName].has_key('missing_value'): 
    306       msg = 'Variable [%s] has incorrect missing_value attribute' % varName 
    307       ok &= self.test( varAts[varName]['missing_value'] == self.missingValue, msg, part=True ) 
    308     if varAts[varName].has_key('_FillValue'): 
    309       msg = 'Variable [%s] has incorrect _FillValue attribute' % varName 
    310       ok &= self.test( varAts[varName]['_FillValue'] == self.missingValue, msg, part=True ) 
     305    msg = 'Variable [%s] has incorrect missing_value attribute' % varName 
     306    ok &= self.test( varAts[varName]['missing_value'] == self.missingValue, msg, part=True ) 
     307    msg = 'Variable [%s] has incorrect _FillValue attribute' % varName 
     308    ok &= self.test( varAts[varName]['_FillValue'] == self.missingValue, msg, part=True ) 
    311309    mm = [] 
    312310     
     
    352350    self.checkId = 'unset' 
    353351    self.step = 'Initialised' 
     352    self.checks = (self.do_check,) 
    354353 
    355354  def check(self,varName,varGroup, da, va, isInsta): 
     355    self.errorCount = 0 
     356    assert type(varName) in [type('x'),type(u'x')], '1st argument to "check" method of checkGrids shound be a string variable name (not %s)' % type(varName) 
     357    self.var = varName 
     358    self.varGroup = varGroup 
     359    self.da = da 
     360    self.va = va 
     361    self.isInsta = isInsta 
     362    self.runChecks() 
     363 
     364  def do_check(self): 
     365    varName = self.var 
     366    varGroup = self.varGroup 
     367    da = self.da 
     368    va = self.va 
     369    isInsta = self.isInsta 
     370 
    356371    self.errorCount = 0 
    357372    self.completed = False 
     
    548563class mipVocab: 
    549564 
    550   def __init__(self,project='CORDEX'): 
    551      assert project in ['CORDEX','SPECS'],'Project %s not recognised' % project 
    552      if project == 'CORDEX': 
    553        dir = 'cordex_vocabs/mip/' 
    554        tl = ['fx','sem','mon','day','6h','3h'] 
    555        vgmap = {'6h':'6hr','3h':'3hr'} 
    556        fnpat = 'CORDEX_%s' 
     565  def __init__(self): 
    557566     ms = mipTableScan() 
     567     dir = '/home/martin/2013/mipML/FCC2/trunk/work/cordex_vocabs/mip/' 
    558568     self.varInfo = {} 
    559569     self.varcons = {} 
    560      for f in tl: 
    561         vg = vgmap.get( f, f ) 
     570     for f in ['fx','sem','mon','day','6h','3h']: 
     571        vg = f 
     572        if f in ['6h','3h']: 
     573          vg += 'r' 
    562574        self.varcons[vg] = {} 
    563         fn = fnpat % f 
     575        fn = 'CORDEX_%s' % f 
    564576        ll = open( '%s%s' % (dir,fn) ).readlines() 
    565577        ee = ms.scan_table(ll,None,asDict=True) 
Note: See TracChangeset for help on using the changeset viewer.