Changeset 48 for FCC2


Ignore:
Timestamp:
16/07/13 16:35:53 (6 years ago)
Author:
mjuckes
Message:

correcting time constraints for partial time segments

Location:
FCC2/trunk
Files:
1 added
3 edited

Legend:

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

    r47 r48  
    11import string, os, re, stat 
    22 
     3ncdumpCmd = 'ncdump' 
    34ncdumpCmd = '/usr/local/5/bin/ncdump' 
    4 ncdumpCmd = 'ncdump' 
    55## 
    66 
     
    88class mipTableScan: 
    99 
    10   def __init__(self, vats = ['standard_name','long_name','units'] ): 
     10  def __init__(self, vats = ['standard_name','long_name','units','cell_methods'] ): 
    1111    self.vats = vats 
    1212    self.re_cmor_mip2 = re.compile( 'dimensions:(?P<dims>.*?):::' ) 
     
    1515      self.re_vats[v] = re.compile( '%s:(?P<dims>.*?):::' % v ) 
    1616## 
    17   def scan_table(self,ll,log): 
     17  def scan_table(self,ll,log,asDict=False,appendTo=None,lax=False,tag=None): 
    1818  
    1919    lll = map( string.strip, ll ) 
     
    4343        ds = mm 
    4444        raise 'Mistake?? in scan_table %s' % str(mm) 
    45       ee.append( (var,ds,aa) ) 
    46     return tuple( ee ) 
     45      ee.append( (var,ds,aa,tag) ) 
     46    if not asDict: 
     47      return tuple( ee ) 
     48    else: 
     49      ff = {} 
     50      for l in ee: 
     51        ff[l[0]] = ( l[1], l[2], l[3] ) 
     52      if appendTo != None: 
     53        for k in ff.keys(): 
     54          if appendTo.has_key(k): 
     55            if lax and  ff[k][1]['standard_name'] != appendTo[k][1]['standard_name']: 
     56              print 'ERROR[X1]: Inconsistent entry definitions %s:: %s [%s] --- %s [%s]' % (k,ff[k][1],ff[k][2], appendTo[k][1], appendTo[k][2]) 
     57            if not lax: 
     58              assert ff[k][1] == appendTo[k][1], 'Inconsistent entry definitions %s:: %s [%s] --- %s [%s]' % (k,ff[k][1],ff[k][2], appendTo[k][1], appendTo[k][2]) 
     59          else: 
     60            appendTo[k] = ff[k] 
     61        return appendTo 
     62      else: 
     63        return ff 
    4764## 
    4865## this class carries a logging method, and is used to carry information about datasets being parsed. 
     
    248265                        ##print '_arg_%s' % key , locals()['_arg_%s' % key ] 
    249266                      res = eval( tt1 ) 
    250                       ##print res,tt1 
     267                      print '#####', res,tt1 
    251268                      if res: 
    252269                        match = True 
     
    10381055#### Mip table variable attribute check 
    10391056 
     1057class Constraint__VarDimsCordexHardWired: 
     1058  def __init__(self, attribVocabs,  kpat, keys, logger=None): 
     1059     self.code = 'CQC.102.002.010' 
     1060     self.name = 'VarAtts' 
     1061     self.tables = {} 
     1062     self.keys = keys 
     1063     self.kpat = kpat 
     1064     self.logger = logger 
     1065     self.plev_vars = ['clh','clm','cll','ua850','va850'] 
     1066 
    10401067class Constraint__VarAtts: 
    10411068 
     
    10721099  def __check( self, mip, var, fns ): 
    10731100     ms = '' 
     1101     self.log( 'i', 'CHECKING %s' % var ) 
    10741102     nf = 0 
    10751103     if not self.tables[mip].has_key(var): 
     
    10781106       return ('FAIL', self.msg) 
    10791107     assert fns.has_key( 'v_%s' % var ), 'Internal error: attempt to check variable %s which is not in fns' % var 
     1108     mip_dims, mip_ats = self.tables[mip][var] 
     1109     var_dims = fns['v_%s' % var ][0] 
    10801110     for k in self.keys: 
    1081         if self.tables[mip][var][1][k] != fns['v_%s' % var ][1][k]: 
    1082            self.log( 'w', 'Variable attribute mismatch: %s -- %s' % (self.tables[mip][var][1][k], str(fns['v_%s' % var ]) ) ) 
     1111        if mip_ats[k] != fns['v_%s' % var ][1][k]: 
     1112           self.log( 'w', 'Variable attribute mismatch: %s -- %s' % (mip_ats[k], str(fns['v_%s' % var ]) ) ) 
    10831113           nf += 1 
    10841114           ms += '%s; ' % k 
    10851115        else: 
    10861116           self.log( 'i', 'Attribute OK: %s' % (self.tables[mip][var][1][k]) ) 
     1117 
     1118     # unclear how to proceed here -- want to check, e.g., time dimension.  -- possibly easiest to have a CORDEX_SPECIAL flag for some ad hoc code.. 
     1119     # ideally get axis information from "axis_entry" in mip tables -- need to improve the scanner for this. 
     1120     ##print 'DIMS:  %s -- %s -- %s' % (var, str(mip_dims), str(var_dims)) 
    10871121     if nf > 0: 
    10881122       if nf == 1: 
  • FCC2/trunk/source/run_fcc.py

    r46 r48  
    7575 
    7676        baseDir = thisDir 
    77         scriptVersion = 0.7 
     77        scriptVersion = 0.8 
    7878        scriptName = 'run_fcc' 
    7979 
  • FCC2/trunk/work/cordex_vocabs/cordex_time_constraints.txt

    r41 r48  
    1 mon: {$e==$d+1}'(?P<d>[0-9]{3})101-(?P<e>[0-9]{3})012' '(?P<startyear>[0-9]{4})[0-9]{2}-(?P<e>[0-9]{3}0)12' '%(startyear)s[0-9]{2}-(?P<e>[0-9]{3}0)12' '(?P<d>[0-9]{3})101-%(endyear)s[0-9]{2}' 
    2 sem: '(?P<d>[0-9]{3})012-(?P<e>[0-9]{3})011' '%(startyear)s(12|03|06|09)-(?P<e>[0-9]{3}0)11'  '(?P<d>[0-9]{3})012-(?P<e>%(endyear)s)(11|02|05|08)' 
    3 day: {$e==$d+1}'(?P<d>[0-9]{3})60101-(?P<e>[0-9]{3})012%(enddec)s' {$e==$d}'(?P<d>[0-9]{3})10101-(?P<e>[0-9]{3})512%(enddec)s' {$e<=$startyear+4}'(?P<startyear>[0-9]{4})(?P<d1>[0-9]{4})-(?P<e>[0-9]{3}(0|5))12%(enddec)s' {$d1<=$s+4}'(?P<s>%(startyear)s)(?P<d1>[0-9]{4})-(?P<e>[0-9]{3}(0|5))12%(enddec)s'  {$e==$d+1}'(?P<d>[0-9]{3})(1|6)0101-(?P<e>%(endyear)s)(?P<d1>[0-9]{4})' 
    4 3hr,6hr: '(?P<d>[0-9]{4})0101(?P<h1>[0-9]{2})-(?P<e>[0-9]{4})12%(enddec)s(?P<h2>[0-9]{2})' '%(startyear)s(?P<h1>[0-9]{6})-%(startyear)s12%(enddec)s(?P<h2>[0-9]{2})' '%(endyear)s0101(?P<h1>[0-9]{2})-%(endyear)s(?P<h2>[0-9]{6})' 
     1mon: {$e==$d+1}'(?P<d>[0-9]{3})101-(?P<e>[0-9]{3})012' '(?P<startyear>[0-9]{4})[0-9]{2}-(?P<e>[0-9]{3}0)12' '(?P<d>[0-9]{3})101-?P<endyear>[0-9]{4}[0-9]{2}' 
     2sem: '(?P<d>[0-9]{3})012-(?P<e>[0-9]{3})011' '(?P<startyear>[0-9]{4})(12|03|06|09)-(?P<e>[0-9]{3}0)11'  '(?P<d>[0-9]{3})012-(?P<endyear>[0-9]{4})(11|02|05|08)' 
     3day: {$e==$d+1}'(?P<d>[0-9]{3})60101-(?P<e>[0-9]{3})012%(enddec)s' {$e==$d}'(?P<d>[0-9]{3})10101-(?P<e>[0-9]{3})512%(enddec)s' {$e<=$startyear+4}'(?P<startyear>[0-9]{4})(?P<d1>[0-9]{4})-(?P<e>[0-9]{3}(0|5))12%(enddec)s' {$d1<=$startyear+4}'(?P<startyear>[0-9]{4})(?P<d1>[0-9]{4})-(?P<e>[0-9]{3}(0|5))12%(enddec)s'  {$endyear<=$d+5}'(?P<d>[0-9]{3}(1|6))0101-(?P<endyear>[0-9]{4})(?P<d1>[0-9]{4})' 
     43hr,6hr: '(?P<d>[0-9]{4})0101(?P<h1>[0-9]{2})-(?P<e>[0-9]{4})12%(enddec)s(?P<h2>[0-9]{2})' {$s=$startyear}'(?P<startyear>[0-9]{4})(?P<h1>[0-9]{6})-(?P<s>[0-9]{4})12%(enddec)s(?P<h2>[0-9]{2})' {$e==$endyear}'(?P<endyear>[0-9]{4})0101(?P<h1>[0-9]{2})-(?P<e>[0-9]{4})(?P<h2>[0-9]{6})' 
Note: See TracChangeset for help on using the changeset viewer.