Changeset 252 for CCCC


Ignore:
Timestamp:
04/11/14 08:57:00 (6 years ago)
Author:
mjuckes
Message:

Transparent change to start introduction of vocab versioning

Location:
CCCC/trunk/ceda_cc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • CCCC/trunk/ceda_cc/c4.py

    r243 r252  
    177177      self.completed = False 
    178178      return 
    179     if not self.info.pcfg.project[:2] == '__': 
     179    if not self.info.pcfg.projectV.id[:2] == '__': 
    180180      if not os.path.isfile( fpath ): 
    181181        print 'File %s not found [2]' % fpath 
     
    220220    self.completed = True 
    221221    self.drs = self.cga.getDrs() 
    222     self.drs['project'] = self.info.pcfg.project 
     222    self.drs['project'] = self.info.pcfg.projectV.id 
    223223    self.errorCount = self.cfn.errorCount + self.cga.errorCount + self.cgd.errorCount + self.cgg.errorCount 
    224224 
     
    474474       raise baseException( 'Cannot proceed with non-dummy [%s] project without a netcdf API' % (c4i.project) ) 
    475475    pcfg = config.projectConfig( c4i.project ) 
     476    assert pcfg.projectV.v == -1, 'Cannot handle anything other than latest version at present' 
    476477    ncReader = fileMetadata(dummy=isDummy, attributeMappingsLog=c4i.attributeMappingsLog,forceLib=c4i.forceNetcdfLib) 
    477478    self.cc = checker(pcfg, c4i.project, ncReader,abortMessageCount=abortMessageCount) 
  • CCCC/trunk/ceda_cc/config_c4.py

    r251 r252  
    33import os 
    44import os.path as op 
    5 import shutil 
     5import shutil, collections 
     6 
     7NT_project = collections.namedtuple( 'project', ['id','v'] ) 
     8NT_fnParts = collections.namedtuple( 'fnParts', ['len','fxLen','unfLen','checkTLen','ixDomain','ixFreq'] ) 
    69 
    710############################################################################## 
     
    129132def getVocabs(pcfg): 
    130133  "Returns a dictionary of vocabulary details for the project provided." 
    131   if pcfg.project == 'SPECS': 
     134  if pcfg.projectV.id == 'SPECS': 
    132135               ##'experiment_id':utils.patternControl( 'experiment_id', "(?P<val>.*)[0-9]{4}", list=validSpecsExptFamilies ), \ 
    133136    vocabs = { 'variable':utils.mipVocab(pcfg), \ 
     
    144147               'modeling_realm':utils.listControl( 'realm', ['atmos', 'ocean', 'land', 'landIce', 'seaIce', 'aerosol', 'atmosChem', 'ocnBgchem'], split=True ), \ 
    145148             } 
    146   elif pcfg.project == 'CMIP5': 
     149  elif pcfg.projectV.id == 'CMIP5': 
    147150               ##'experiment_id':utils.patternControl( 'experiment_id', "(?P<val>.*)[0-9]{4}", list=validSpecsExptFamilies ), \ 
    148151    lrdr = readVocab( 'cmip5_vocabs/') 
     
    158161               'modeling_realm':utils.listControl( 'realm', ['atmos', 'ocean', 'land', 'landIce', 'seaIce', 'aerosol', 'atmosChem', 'ocnBgchem'], split=True ), \ 
    159162             } 
    160   elif pcfg.project == 'CCMI': 
     163  elif pcfg.projectV.id == 'CCMI': 
    161164     
    162165    lrdr = readVocab( 'ccmi_vocabs/') 
     
    170173               'project_id':utils.listControl( 'project_id', ['CCMI'] ) } 
    171174 
    172   elif pcfg.project == '__dummy': 
     175  elif pcfg.projectV.id == '__dummy': 
    173176    vocabs = { 'variable':utils.mipVocab(pcfg,dummy=True) } 
    174177  else: 
     
    188191class projectConfig(object): 
    189192 
    190   def __init__(self, project): 
     193  def __init__(self, project, version=-1): 
    191194    knownProjects = ['CMIP5','CCMI','CORDEX','SPECS','__dummy'] 
    192195    assert project in knownProjects, 'Project %s not in knownProjects %s' % (project, str(knownProjects)) 
    193196 
    194197    self.project = project 
     198    self.projectV = NT_project(project,version) 
    195199    self.gridSpecTol = 0.01 
    196200    if project == 'CORDEX': 
     
    268272    self.rotatedPoleGrids = rotatedPoleGrids 
    269273    self.interpolatedGrids = interpolatedGrids 
    270     self.doCheckGrids = self.project in ['CORDEX',] 
     274    self.doCheckGrids = self.projectV.id in ['CORDEX',] 
    271275 
    272276####### used in checkFileName (freqIndex also used in checkByVar) 
    273277 
    274     if self.project == 'CORDEX': 
     278    if self.projectV.id == 'CORDEX': 
     279      self.fnParts = NT_fnParts( len=[8,9], fxLen=[8,],  unfLen=[9,], checkTLen=True, ixDomain=1, ixFreq=7 ) 
    275280      self.fnPartsOkLen = [8,9] 
    276281      self.fnPartsOkFixedLen = [8,] 
     
    279284      self.domainIndex = 1 
    280285      self.freqIndex = 7 
    281     elif self.project == 'CMIP5': 
     286    elif self.projectV.id == 'CMIP5': 
    282287## cRoot_Lmon_CESM1-WACCM_rcp85_r3i1p1_200601-205512.nc 
    283288      self.fnPartsOkLen = [5,6] 
     
    287292      self.domainIndex = None 
    288293      self.freqIndex = None 
    289     elif self.project == 'SPECS': 
     294    elif self.projectV.id == 'SPECS': 
    290295      self.fnPartsOkLen = [6,7] 
    291296      self.fnPartsOkFixedLen = [6,] 
     
    294299      self.domainIndex = None 
    295300      self.freqIndex = 1 
    296     elif self.project == 'CCMI': 
     301    elif self.projectV.id == 'CCMI': 
    297302      self.fnPartsOkLen = [5,6] 
    298303      self.fnPartsOkFixedLen = [5,] 
     
    301306      self.domainIndex = None 
    302307      self.freqIndex = None 
    303     elif self.project == '__dummy': 
     308    elif self.projectV.id == '__dummy': 
    304309      self.fnPartsOkLen = [4,5] 
    305310      self.fnPartsOkFixedLen = [4,] 
     
    312317    self.defaults = { 'variableDataType':'float' } 
    313318######## used in mipVocabs 
    314     if self.project == 'CORDEX': 
     319    if self.projectV.id == 'CORDEX': 
    315320       self.mipVocabDir = op.join(CC_CONFIG_DIR, 'cordex_vocabs/mip/') 
    316321       self.mipVocabTl = ['fx','sem','mon','day','6h','3h'] 
    317322       self.mipVocabVgmap = {'6h':'6hr','3h':'3hr'} 
    318323       self.mipVocabFnpat = 'CORDEX_%s' 
    319     elif self.project == 'CMIP5': 
     324    elif self.projectV.id == 'CMIP5': 
    320325       self.mipVocabDir = op.join(CC_CONFIG_DIR, 'cmip5_vocabs/mip/') 
    321326       self.mipVocabTl = ['fx','Oyr','Oclim','Omon','Amon','Lmon','LImon','OImon','cfMon','aero','cfDay','day','cfOff','cfSites','6hrLev','6hrPlev','3hr','cf3hr'] 
     
    323328       self.mipVocabFnpat = 'CMIP5_%s' 
    324329       self.defaults['variableDataType'] = None  
    325     elif self.project == 'SPECS': 
     330    elif self.projectV.id == 'SPECS': 
    326331       self.mipVocabDir = op.join(CC_CONFIG_DIR, 'specs_vocabs/mip/') 
    327332       self.mipVocabTl = ['fx','Omon','Amon','Lmon','OImon','day','6hr'] 
    328333       self.mipVocabVgmap = {} 
    329334       self.mipVocabFnpat = 'SPECS_%s' 
    330     elif self.project == 'CCMI': 
     335    elif self.projectV.id == 'CCMI': 
    331336       self.mipVocabDir = op.join(CC_CONFIG_DIR, 'ccmi_vocabs/mip/') 
    332337       self.mipVocabTl = ['fixed','annual','monthly','daily','hourly'] 
  • CCCC/trunk/ceda_cc/utils_c4.py

    r221 r252  
    358358    m = [] 
    359359    reqAts = self.requiredVarAttributes[:] 
    360     if varGroup != 'fx' and self.pcfg.project in ['CORDEX']: 
     360    if varGroup != 'fx' and self.pcfg.projectV.id in ['CORDEX']: 
    361361      reqAts.append( 'cell_methods' ) 
    362362    for k in reqAts + vocabs['variable'].lists(varName, 'addRequiredAttributes'): 
     
    752752 
    753753  def __init__(self,pcfg,dummy=False): 
    754      project = pcfg.project 
     754     project = pcfg.projectV.id 
    755755     if dummy: 
    756756       self.pcfg = pcfg 
Note: See TracChangeset for help on using the changeset viewer.