source: CCCC/trunk/ceda_cc/config_c4.py @ 270

Subversion URL: http://proj.badc.rl.ac.uk/svn/exarch/CCCC/trunk/ceda_cc/config_c4.py@270
Revision 270, 24.0 KB checked in by mjuckes, 5 years ago (diff)

added resolution attribute check

Line 
1import string
2import utils_c4 as utils
3import os
4import os.path as op
5import shutil, collections
6
7NT_project = collections.namedtuple( 'project', ['id','v'] )
8NT_fnParts = collections.namedtuple( 'fnParts', ['len','fxLen','unfLen','checkTLen','ixDomain','ixFreq'] )
9
10##############################################################################
11# Configure config-file paths
12#
13# All configuration directories, e.g. cmip5_vocabs, are looked for in a single
14# parent directory.  This is the "config" directory within the package unless
15# the environment variable CC_CONFIG_DIR is set.
16
17HERE = op.dirname(__file__)
18CC_CONFIG_DEFAULT_DIR = op.join(HERE, 'config')
19CC_CONFIG_DIR = os.environ.get('CC_CONFIG_DIR', CC_CONFIG_DEFAULT_DIR)
20
21##############################################################################
22
23validCmip5Experiments = ['1pctCO2', 'abrupt4xCO2', 'amip', 'amip4K', 'amip4xCO2', 'amipFuture', 'aqua4K', 'aqua4xCO2', 'aquaControl', 'decadal1959', 'decadal1960', 'decadal1961', 'decadal1962', 'decadal1963', 'decadal1964', 'decadal1965', 'decadal1966', 'decadal1967', 'decadal1968', 'decadal1969', 'decadal1970', 'decadal1971', 'decadal1972', 'decadal1973', 'decadal1974', 'decadal1975', 'decadal1976', 'decadal1977', 'decadal1978', 'decadal1979', 'decadal1980', 'decadal1981', 'decadal1982', 'decadal1983', 'decadal1984', 'decadal1985', 'decadal1986', 'decadal1987', 'decadal1988', 'decadal1989', 'decadal1990', 'decadal1991', 'decadal1992', 'decadal1993', 'decadal1994', 'decadal1995', 'decadal1996', 'decadal1997', 'decadal1998', 'decadal1999', 'decadal2000', 'decadal2001', 'decadal2002', 'decadal2003', 'decadal2004', 'decadal2005', 'decadal2006', 'decadal2007', 'decadal2008', 'decadal2009', 'decadal2010', 'decadal2011', 'decadal2012', 'esmControl', 'esmFdbk1', 'esmFdbk2', 'esmFixClim1', 'esmFixClim2', 'esmHistorical', 'esmrcp85', 'historical', 'historicalExt', 'historicalGHG', 'historicalMisc', 'historicalNat', 'lgm', 'midHolocene', 'noVolc1960', 'noVolc1965', 'noVolc1970', 'noVolc1975', 'noVolc1980', 'noVolc1985', 'noVolc1990', 'noVolc1995', 'noVolc2000', 'noVolc2005', 'past1000', 'piControl', 'rcp26', 'rcp45', 'rcp60', 'rcp85', 'sst2020', 'sst2030', 'sst2090', 'sst2090rcp45', 'sstClim', 'sstClim4xCO2', 'sstClimAerosol', 'sstClimSulfate', 'volcIn2010']
24
25validCordexExperiment = validCmip5Experiments + ['evaluation']
26
27
28validCmip5Frequencies = ['fx','yr','monClim','mon','day','6hr','3hr','subhr']
29validCordexFrequencies = ['fx','sem','mon','day','6hr','3hr']
30validSpecsFrequencies = ['fx','mon','day','6hr']
31validCcmiFrequencies = ['fx','yr','mon','day','hr','subhr']
32validSpecsExptFamilies = map( lambda x: string.strip( x ), 
33                              open( op.join(CC_CONFIG_DIR, 'specs_vocabs/exptFamily.txt' )).readlines() )
34
35validCordexDomainsL = [ 'SAM-44', 'CAM-44', 'NAM-44', 'EUR-44', 'AFR-44', 'WAS-44', 'EAS-44', 'CAS-44', 'AUS-44', 'ANT-44', 'ARC-44', 'MED-44']
36validCordexDomainsLi = map( lambda x: x + 'i', validCordexDomainsL )
37validCordexDomainsH = ['EUR-11']
38validCordexDomains = validCordexDomainsL + validCordexDomainsLi + validCordexDomainsH
39
40plevRequired = ['clh', 'clm', 'cll', 'ua850', 'va850', 'ta850', 'hus850', 'ua500', 'va500', 'ta500', 'zg500', 'ua200', 'va200', 'ta200', 'zg200']
41plevBndsRequired = ['clh', 'clm', 'cll']
42heightRequired = ['tas','tasmax','tasmin','huss','sfcWind','sfcWindmax','wsgsmax','uas','vas']
43
44
45ii = open( op.join(CC_CONFIG_DIR, 'cordex_vocabs/GCMModelName.txt' )).readlines()
46validGcmNames = []
47for l in ii:
48  if l[0] != '#' and len( string.strip(l) ) > 0:
49    validGcmNames.append( string.split(l)[0] )
50
51ii = open( op.join(CC_CONFIG_DIR, 'cordex_vocabs/RCMModelName.txt' )).readlines()
52validRcmNames = []
53validInstNames = []
54for l in ii:
55  if l[0] != '#' and len( string.strip(l) ) > 0:
56    bits = string.split(l)
57    validRcmNames.append( bits[0] )
58    validInstNames.append( bits[1] )
59
60plevValues = {'clh':22000, 'clm':56000, 'cll':84000}
61for i in [200,500,850]:
62  for v in ['zg','ua', 'va', 'ta', 'hus']:
63    k = '%s%s' % (v,i)
64    plevValues[k] = i*100
65
66heightRequired = ['tas', 'tasmax', 'tasmin', 'huss', 'sfcWind', 'sfcWindmax', 'wsgsmax', 'uas', 'vas']
67heightValues = {}
68heightRange = {}
69for v in heightRequired:
70  if v in ['tas', 'tasmax', 'tasmin', 'huss']:
71    heightValues[v] = 2
72  else:
73    heightValues[v] = 10
74  heightRange[v] = (1.5,10.)
75
76ii = open( op.join(CC_CONFIG_DIR, 'cordex_vocabs/cordex_domains.csv' )).readlines()
77keys = ['name','tag','res','grid_np_lon','grid_np_lat','nlon','nlat','w','e','s','n']
78rotatedPoleGrids = {}
79for l in ii[2:16]:
80  bits = string.split(string.strip(l),',')
81  ee = {}
82  i = 0
83  for k in keys:
84    if k in ['nlon','nlat']:
85      ee[k] = int(bits[i])
86    elif k in ['grid_np_lon','grid_np_lat','w','e','s','n','res']:
87      if bits[i] != 'N/A':
88        ee[k] = float(bits[i])
89      else:
90        ee[k] = bits[i]
91    else:
92      ee[k] = bits[i]
93    i += 1
94    rotatedPoleGrids[bits[1]] = ee
95
96##Area,Name, deg,Nlon,Nlat,West8,East8,South8,North8,
97keys = ['name','tag','res','nlon','nlat','w','e','s','n']
98interpolatedGrids = {}
99for l in ii[18:33]:
100  bits = string.split(string.strip(l),',')
101  ee = {}
102  i = 0
103  for k in keys:
104    if k in ['nlon','nlat']:
105      ee[k] = int(bits[i])
106    elif k in ['w','e','s','n','res']:
107        ee[k] = float(bits[i])
108    else:
109      ee[k] = bits[i]
110    i += 1
111    interpolatedGrids[bits[1]] = ee
112
113class readVocab(object):
114
115  def __init__(self,dir):
116    self.dir = dir
117
118  def getSimpleList(self,file,bit=None,omt=None):
119    ii = open('%s/%s/%s' % (CC_CONFIG_DIR, self.dir,file) )
120    oo = []
121    for l in ii.readlines():
122      if l[0] != '#':
123        ll = string.strip(l)
124        if omt == 'last':
125          oo.append(string.join(string.split(ll)[:-1]))
126        elif bit == None:
127          oo.append(ll)
128        else:
129          oo.append(string.split(ll)[bit])
130    return oo
131
132validSpecsInstitutions = ['IC3', 'MPI-M', 'KNMI', 'UOXF', 'CNRM-CERFACS', 'ENEA', 'MOHC', 'SMHI', 'IPSL', 'UREAD', 'ECWMF']
133
134def getVocabs(pcfg):
135  "Returns a dictionary of vocabulary details for the project provided."
136  if pcfg.projectV.id == 'SPECS':
137               ##'experiment_id':utils.patternControl( 'experiment_id', "(?P<val>.*)[0-9]{4}", list=validSpecsExptFamilies ), \
138    vocabs = { 'variable':utils.mipVocab(pcfg), \
139               'Conventions':utils.listControl( 'Conventions', ['CF-1.6'] ), \
140               'frequency':utils.listControl( 'frequency', validSpecsFrequencies ), \
141               'experiment_id':utils.listControl( 'experiment_id', validSpecsExptFamilies ), \
142               'initialization_method':utils.patternControl( 'initialization_method', "[0-9]+" ), \
143               'physics_version':utils.patternControl( 'physics_version', "[0-9]+" ), \
144               'realization':utils.patternControl( 'realization', "[0-9]+" ), \
145               'startdate':utils.patternControl( 'startdate', "S[0-9]{8}" ), \
146               ## 'associated_experiment':utils.patternControl( 'associated_experment', "(?P<val>(N/A|(decadal|seasonal): r\*i[0-9]{1,4}p[0-9]{1,4}))" ), \
147               'project_id':utils.listControl( 'project_id', ['SPECS', 'NMME-SPECS'] ), \
148               ## 'institution':utils.listControl( 'institution', validSpecsInstitutions ), \
149               'modeling_realm':utils.listControl( 'realm', ['atmos', 'ocean', 'land', 'landIce', 'seaIce', 'aerosol', 'atmosChem', 'ocnBgchem'], split=True ), \
150             }
151  elif pcfg.projectV.id == 'CMIP5':
152               ##'experiment_id':utils.patternControl( 'experiment_id', "(?P<val>.*)[0-9]{4}", list=validSpecsExptFamilies ), \
153    lrdr = readVocab( 'cmip5_vocabs/')
154    vocabs = { 'variable':utils.mipVocab(pcfg), \
155               'Conventions':utils.listControl( 'Conventions', ['CF-1.4','CF-1.5'] ), \
156               'experiment_id':utils.listControl( 'experiment_id', lrdr.getSimpleList( 'experiments.txt' ) ), \
157               'frequency':utils.listControl( 'frequency', validCmip5Frequencies ), \
158               'initialization_method':utils.patternControl( 'initialization_method', "[0-9]+" ), \
159               'physics_version':utils.patternControl( 'physics_version', "[0-9]+" ), \
160               'realization':utils.patternControl( 'realization', "[0-9]+" ), \
161               'project_id':utils.listControl( 'project_id', ['CMIP5'] ), \
162               ## 'institution':utils.listControl( 'institution', validSpecsInstitutions ), \
163               'modeling_realm':utils.listControl( 'realm', ['atmos', 'ocean', 'land', 'landIce', 'seaIce', 'aerosol', 'atmosChem', 'ocnBgchem'], split=True ), \
164             }
165  elif pcfg.projectV.id == 'CCMI':
166   
167    lrdr = readVocab( 'ccmi_vocabs/')
168    vocabs = { 'variable':utils.mipVocab(pcfg), \
169               'frequency':utils.listControl( 'frequency', validCcmiFrequencies ), \
170               'experiment_id':utils.listControl( 'experiment_id', lrdr.getSimpleList( 'ccmi_experiments.txt', bit=-1 ) ), \
171## do not preserve or check relation between model and institution.
172               'institution':utils.listControl( 'institution', lrdr.getSimpleList( 'models_insts.txt', bit=1 ) ), \
173               'model_id':utils.listControl( 'model_id', lrdr.getSimpleList( 'models_insts.txt', bit=0 ) ), \
174               'modeling_realm':utils.listControl( 'realm', ['atmos', 'ocean', 'land', 'landIce', 'seaIce', 'aerosol', 'atmosChem', 'ocnBgchem'] ), \
175               'project_id':utils.listControl( 'project_id', ['CCMI'] ) }
176
177  elif pcfg.projectV.id == 'ESA-CCI':
178    lrdr = readVocab( 'esacci_vocabs/')
179    vocabs = { 'variable':utils.mipVocab(pcfg), \
180               'version':utils.patternControl( 'version',  '^(fv[0-9]+(\.[0-9]+){0,1})$' ), \
181               'level':utils.listControl( 'level', lrdr.getSimpleList( 'procLevel01.txt', bit=0 ) ), \
182               'platform':utils.listControl( 'platforms', lrdr.getSimpleList( 'platforms.txt', bit=0 ) ), \
183               'institution':utils.listControl( 'institution', lrdr.getSimpleList( 'institutions.txt', omt='last' ) ), \
184               'Conventions':utils.patternControl( 'Conventions', '^CF-1.[56789](,.*){0,1}$' ), \
185               'sensor':utils.listControl( 'sensors', lrdr.getSimpleList( 'sensors.txt', bit=0 ) ), \
186               'cdm_data_type':utils.listControl( 'cdm_data_type', lrdr.getSimpleList( 'threddsDataType.txt', bit=0 ) ), \
187               'time_coverage_duration':utils.patternControl( 'time_coverage_duration',  'ISO8601 duration', cls='ISO' ), \
188               'spatial_resolution':utils.patternControl( 'spatial_resolution',  '([0-9]+(.[0-9]+){0,1})(km|m).*' ), \
189               'project':utils.listControl( 'project', ['Climate Change Initiative - European Space Agency'] ), \
190               'cciProject':utils.listControl( 'project', lrdr.getSimpleList( 'cciProject.txt', bit=-1 ) ), \
191               'var':utils.listControl( 'var', lrdr.getSimpleList( 'variables.txt', bit=-1 ) ) \
192             }
193  elif pcfg.projectV.id == '__dummy':
194    vocabs = { 'variable':utils.mipVocab(pcfg,dummy=True) }
195  else:
196    vocabs = { 'variable':utils.mipVocab(pcfg), \
197           'driving_experiment_name':utils.listControl( 'driving_experiment_name', validCordexExperiment ), \
198           'project_id':utils.listControl( 'project_id', ['CORDEX'] ), \
199           'CORDEX_domain':utils.listControl( 'CORDEX_domain',  validCordexDomains ), \
200           'driving_model_id':utils.listControl( 'driving_model_id',  validGcmNames ), \
201           'driving_model_ensemble_member':utils.patternControl( 'driving_model_ensemble_member',  'r[0-9]+i[0-9]+p[0-9]+' ), \
202           'rcm_version_id':utils.patternControl( 'rcm_version_id',  '[a-zA-Z0-9-]+' ), \
203           'model_id':utils.listControl( 'model_id',  validRcmNames ), \
204           'institute_id':utils.listControl( 'institute_id',  validInstNames ), \
205           'frequency':utils.listControl( 'frequency', validCordexFrequencies ) }
206
207  return vocabs
208
209class projectConfig(object):
210
211  def __init__(self, project, version=-1):
212    knownProjects = ['CMIP5','CCMI','CORDEX','SPECS','ESA-CCI', '__dummy']
213    assert project in knownProjects, 'Project %s not in knownProjects %s' % (project, str(knownProjects))
214
215    self.project = project
216    self.fNameSep = '_'
217    self.varIndex = 0
218    self.fnvdict = None
219    self.varTables='CMIP'
220    self.checkVarType = True
221    self.projectV = NT_project(project,version)
222    self.gridSpecTol = 0.01
223## default encoding of time range in file names: YYYY[MM[DD[HH]]]-YYYY[MM[DD[HH]]]
224    self.trangeType = 'CMIP'
225    self.controlledFnParts = []
226    if project == 'CORDEX':
227      self.requiredGlobalAttributes = [ 'institute_id', 'contact', 'rcm_version_id', 'product', 'CORDEX_domain', 'creation_date', \
228             'frequency', 'model_id', 'driving_model_id', 'driving_experiment', 'driving_model_ensemble_member', 'experiment_id']
229      self.controlledGlobalAttributes = ['frequency', 'driving_experiment_name', 'project_id', 'CORDEX_domain', 'driving_model_id', 'model_id', 'institute_id','driving_model_ensemble_member','rcm_version_id']
230      self.globalAttributesInFn = [None,'CORDEX_domain','driving_model_id','experiment_id','driving_model_ensemble_member','model_id','rcm_version_id']
231      self.requiredVarAttributes = ['long_name', 'standard_name', 'units']
232      self.drsMappings = {'variable':'@var','institute':'institute_id', 'product':'product', 'experiment':'experiment_id', \
233                        'ensemble':'driving_model_ensemble_member', 'model':'model_id', 'driving_model':'driving_model_id', \
234                        'frequency':'frequency', \
235                        'project':'project_id', 'domain':'CORDEX_domain', 'model_version':'rcm_version_id' }
236
237    elif project == 'SPECS':
238      lrdr = readVocab( 'specs_vocabs/')
239      self.requiredGlobalAttributes = lrdr.getSimpleList( 'globalAts.txt' )
240      self.exptFamilies = lrdr.getSimpleList( 'exptFamily.txt', bit=0 )
241      self.controlledGlobalAttributes = [ 'project_id','experiment_id', 'frequency','Conventions','modeling_realm', \
242                       'initialization_method','physics_version','realization']
243      self.globalAttributesInFn = [None,'@mip_id','model_id','experiment_id','startdate','@ensemble']
244#sic_Oimon_EC-Earth2_seaIceBestInit_S19910501_r1i1p1_199501-199502.nc
245## mip_id derived from global attribute Table_id (CMOR convention); ensemble derived from rip attributes.
246      self.requiredVarAttributes = ['long_name', 'standard_name', 'units']
247      self.drsMappings = {'variable':'@var', 'institute':'institute_id', 'product':'product', 'experiment':'experiment_id', \
248                        'ensemble':'@ensemble', 'model':'model_id', 'realm':'modeling_realm', \
249                        'frequency':'frequency', 'start_date':'@forecast_reference_time', \
250                        'table':'@mip_id',
251                        'project':'project_id'}
252
253    elif project == 'CMIP5':
254      lrdr = readVocab( 'cmip5_vocabs/')
255      self.requiredGlobalAttributes = [ 'contact', 'product', 'creation_date', 'tracking_id', \
256              'experiment_id']
257      ##self.requiredGlobalAttributes = lrdr.getSimpleList( 'globalAts.txt' )
258      self.controlledGlobalAttributes = [ 'project_id','experiment_id', 'frequency','Conventions','modeling_realm', \
259                       'initialization_method','physics_version','realization']
260      self.globalAttributesInFn = [None,'@mip_id','model_id','experiment_id','@ensemble']
261#sic_Oimon_EC-Earth2_seaIceBestInit_S19910501_series1_r1i1p1_199501-199502.nc
262## mip_id derived from global attribute Table_id (CMOR convention); experiment family derived from experiment_id, ensemble derived from rip attributes.
263      self.requiredVarAttributes = ['long_name', 'standard_name', 'units']
264## key: DRS element name, value: global attribute name or tag for mapping from file information ("@....").
265      self.drsMappings = {'variable':'@var', 'institute':'institute_id', 'product':'product', 'experiment':'experiment_id', \
266                        'ensemble':'@ensemble', 'model':'model_id', 'realm':'modeling_realm', \
267                        'frequency':'frequency',  'table':'@mip_id',
268                        'project':'project_id'}
269
270    elif project == 'CCMI':
271      lrdr = readVocab( 'ccmi_vocabs/')
272      self.requiredGlobalAttributes = [ 'creation_date', 'tracking_id', 'forcing', 'model_id', 'parent_experiment_id', 'parent_experiment_rip', 'branch_time', 'contact', 'institute_id' ]
273      self.requiredGlobalAttributes = lrdr.getSimpleList( 'globalAts.txt', bit=0 )
274      self.controlledGlobalAttributes = [ 'experiment_id', 'project', 'frequency' ]
275      self.globalAttributesInFn = [None,'@mip_id','model_id','experiment_id','@ensemble']
276      self.requiredVarAttributes = ['long_name', 'standard_name', 'units']
277      self.drsMappings = {'variable':'@var', 'institute':'institute_id', 'product':'product', 'experiment':'experiment_id', \
278                        'ensemble':'@ensemble', 'model':'model_id', 'realm':'modeling_realm', \
279                        'frequency':'frequency',  'table':'@mip_id',
280                        'project':'project_id'}
281
282    elif project == 'ESA-CCI':
283      lrdr = readVocab( 'esacci_vocabs/')
284      self.varTables='FLAT'
285      self.fNameSep = '-'
286      self.checkVarType = False
287      self.requiredGlobalAttributes = lrdr.getSimpleList( 'requiredGlobalAts.txt', bit=0 )
288      self.controlledGlobalAttributes = ['platform','sensor','project','Conventions','institution','cdm_data_type','time_coverage_duration','spatial_resolution' ]
289      self.controlledFnParts = ['level','cciProject','var','version']
290      self.requiredVarAttributes = ['long_name', 'standard_name', 'units']
291      self.drsMappings = {'variable':'@var','platform':'platform','sensor':'sensor','level':'@level'}
292      self.globalAttributesInFn = [None,]
293    elif project == '__dummy':
294      self.requiredGlobalAttributes = map( lambda x: 'ga%s' % x, range(10) )
295      self.controlledGlobalAttributes = [ ]
296      self.globalAttributesInFn = [None,'ga2', 'ga3', 'ga4' ]
297      self.requiredVarAttributes = ['long_name', 'standard_name', 'units']
298      self.drsMappings = {'variable':'@var'}
299
300####### used in checkStandardDims
301
302    self.plevRequired = plevRequired
303    self.plevValues = plevValues
304    self.heightRequired = heightRequired
305    self.heightValues = heightValues
306    self.heightRange = heightRange
307
308####### used in checkGrids
309    self.rotatedPoleGrids = rotatedPoleGrids
310    self.interpolatedGrids = interpolatedGrids
311    self.doCheckGrids = self.projectV.id in ['CORDEX',]
312
313####### used in checkFileName (freqIndex also used in checkByVar)
314
315    if self.projectV.id == 'CORDEX':
316      self.fnParts = NT_fnParts( len=[8,9], fxLen=[8,],  unfLen=[9,], checkTLen=True, ixDomain=1, ixFreq=7 )
317    ##  self.fnPartsOkLen = [5,6]
318      ##self.fnPartsOkFixedLen = [5,]
319      ##self.fnPartsOkUnfixedLen = [6,]
320      ##self.checkTrangeLen = True
321      ##self.domainIndex = 1
322      ##self.freqIndex = 7
323    elif self.projectV.id == 'CMIP5':
324      self.fnParts = NT_fnParts( len=[5,6], fxLen=[5,],  unfLen=[6,], checkTLen=False, ixDomain=None, ixFreq=None )
325      ##self.fnPartsOkLen = [5,6]
326      ##self.fnPartsOkFixedLen = [5,]
327      ##self.fnPartsOkUnfixedLen = [6,]
328      ##self.checkTrangeLen = False
329      ##self.domainIndex = None
330      ##self.freqIndex = None
331    elif self.projectV.id == 'SPECS':
332      self.fnParts = NT_fnParts( len=[6,7], fxLen=[6,],  unfLen=[7,], checkTLen=False, ixDomain=None, ixFreq=1 )
333      ##self.fnPartsOkLen = [6,7]
334      ##self.fnPartsOkFixedLen = [6,]
335      ##self.fnPartsOkUnfixedLen = [7,]
336      ##self.checkTrangeLen = False
337      ##self.domainIndex = None
338      ##self.freqIndex = 1
339    elif self.projectV.id == 'CCMI':
340      self.fnParts = NT_fnParts( len=[5,6], fxLen=[5,],  unfLen=[6,], checkTLen=False, ixDomain=None, ixFreq=None )
341      ##self.fnPartsOkLen = [5,6]
342      ##self.fnPartsOkFixedLen = [5,]
343      ##self.fnPartsOkUnfixedLen = [6,]
344      ##self.checkTrangeLen = False
345      ##self.domainIndex = None
346      ##self.freqIndex = None
347    elif self.projectV.id == 'ESA-CCI':
348      self.fnParts = NT_fnParts( len=[7,8,9], fxLen=[0,],  unfLen=[7,8,9,], checkTLen=False, ixDomain=None, ixFreq=1 )
349      self.trangeType = 'ESA-CCI'
350    elif self.projectV.id == '__dummy':
351      self.fnParts = NT_fnParts( len=[4,5], fxLen=[4,],  unfLen=[5,], checkTLen=False, ixDomain=None, ixFreq=1 )
352
353    self.fnPartsOkLen = self.fnParts.len
354    self.fnPartsOkFixedLen = self.fnParts.fxLen
355    self.fnPartsOkUnfixedLen = self.fnParts.unfLen
356    self.checkTrangeLen = self.fnParts.checkTLen
357    self.domainIndex = self.fnParts.ixDomain
358    self.freqIndex = self.fnParts.ixFreq
359
360
361    self.defaults = { 'variableDataType':'float' }
362######## used in mipVocabs
363    if self.projectV.id == 'CORDEX':
364       self.mipVocabDir = op.join(CC_CONFIG_DIR, 'cordex_vocabs/mip/')
365       self.mipVocabTl = ['fx','sem','mon','day','6h','3h']
366       self.mipVocabVgmap = {'6h':'6hr','3h':'3hr'}
367       self.mipVocabFnpat = 'CORDEX_%s'
368    elif self.projectV.id == 'CMIP5':
369       self.mipVocabDir = op.join(CC_CONFIG_DIR, 'cmip5_vocabs/mip/')
370       self.mipVocabTl = ['fx','Oyr','Oclim','Omon','Amon','Lmon','LImon','OImon','cfMon','aero','cfDay','day','cfOff','cfSites','6hrLev','6hrPlev','3hr','cf3hr']
371       self.mipVocabVgmap = {}
372       self.mipVocabFnpat = 'CMIP5_%s'
373       self.defaults['variableDataType'] = None 
374    elif self.projectV.id == 'SPECS':
375       self.mipVocabDir = op.join(CC_CONFIG_DIR, 'specs_vocabs/mip/')
376       self.mipVocabTl = ['fx','Omon','Amon','Lmon','OImon','day','6hr']
377       self.mipVocabVgmap = {}
378       self.mipVocabFnpat = 'SPECS_%s'
379    elif self.projectV.id == 'CCMI':
380       self.mipVocabDir = op.join(CC_CONFIG_DIR, 'ccmi_vocabs/mip/')
381       self.mipVocabTl = ['fixed','annual','monthly','daily','hourly']
382       self.mipVocabVgmap = {'fixed':'fx','annual':'yr','monthly':'mon','daily':'day','hourly':'hr'}
383       self.mipVocabFnpat = 'CCMI1_%s'
384    elif self.projectV.id == 'ESA-CCI':
385       self.mipVocabDir = op.join(CC_CONFIG_DIR, 'esacci_vocabs/')
386       self.mipVocabTl = []
387       self.mipVocabVgmap = 'ESACCI'
388       self.mipVocabFnpat = 'variableInFile.txt'
389    else:
390       self.mipVocabDir = None
391       self.mipVocabTl = ['day', 't2']
392       self.mipVocabVgmap = {}
393       self.mipVocabFnpat = None
394    self.mipVocabPars = [self.mipVocabDir, self.mipVocabTl, self.mipVocabVgmap, self.mipVocabFnpat]
395
396######## used in checkByVar
397    if self.project == 'CORDEX':
398      self.groupIndex = 7
399    elif self.project in ['CMIP5','CCMI','SPECS','__dummy']:
400      self.groupIndex = 1
401    elif self.project in ['ESA-CCI']:
402      self.fnvdict = { 'SSTskin':{'v':'sea_surface_temperature', 'sn':'sea_surface_skin_temperature'} }
403      self.fnoptions = {'groupIndex':[3,1], 'trangeIndex':[0,-2] }
404      self.fnoptions['inFn'] = [[None,'*activity','*level','*project','*var','*product','*additional','*gdsv','*version'],
405                                ['*activity','*project','*level','*var','*additional',None,'*version']]
406      self.fnoptions['varIndex'] = [4,3]
407##Indicative Date>[<Indicative Time>]-ESACCI-<Processing Level>_<CCI Project>-<Data Type>-<Product String>[- <Additional Segregator>][-v<GDS version>]-fv<File version>.nc
408##ESACCI-<CCI Project>-<Processing Level>-<Data Type>-<Product String>[-<Additional Segregator>]-<IndicativeDate>[<Indicative Time>]-fv<File version>.nc
409
410    self.trangeIndex = -1
411
412    self.vocabs = getVocabs(self)
413    test = False
414    if test:
415      for k in self.vocabs['variable'].varcons.keys():
416        for k2 in self.vocabs['variable'].varcons[k].keys():
417          if "height2m" in self.vocabs['variable'].varcons[k][k2].get( '_dimension',[]):
418            print 'config_c4: %s , %s: %s' % (k,k2,str(self.vocabs['variable'].varcons[k][k2]['_dimension'] ) )
419
420    ##assert self.project != 'CCMI', 'Not completely set up for CCMI yet'
421
422  def setEsaCciFNType(self,id):
423      self.groupIndex =  self.fnoptions['groupIndex'][id]
424      self.trangeIndex = self.fnoptions['trangeIndex'][id]
425      self.globalAttributesInFn = self.fnoptions['inFn'][id]
426      self.varIndex = self.fnoptions['varIndex'][id]
427
428
429def copy_config(dest_dir):
430   """
431   Copy the current default configuration directory into a separate directory.
432
433   The directory <ceda_cc-package-dir>/config is copied to `dest_dir`.
434   This is useful when ceda-cc is installed as a Python package and the user may
435   not know where the config directory is stored.
436
437   :param dest_dir: should be a path to a directory which does not yet exist. 
438       The configuration directory will be copied to this path.
439
440   """
441   shutil.copytree(CC_CONFIG_DEFAULT_DIR, dest_dir)
Note: See TracBrowser for help on using the repository browser.