Changeset 874
 Timestamp:
 23/11/16 12:18:27 (2 years ago)
 Location:
 cp4cdstmp
 Files:

 1 added
 1 edited
Legend:
 Unmodified
 Added
 Removed

cp4cdstmp/simChk1.py
r870 r874 8 8 vars1 = [('Amon','tas'),('Amon','tasmin'),('Amon','tasmax'),('Amon','uas'),('Amon','vas'),('Amon','hurs'),('Amon','pr'),('Amon','ps')] 9 9 vars1 = [('Amon','tas'),('Amon','tasmin'),('Amon','tasmax'),('Amon','uas'),('Amon','vas'),('Amon','pr'),('Amon','ps')] 10 spth = {'Amon':'mon/atmos/Amon/'}11 10 11 spth = {'Amon':'mon/atmos/Amon/', 'day':'day/atmos/day/', 12 'Lmon':'mon/land/Lmon/', 13 'Omon':'mon/ocean/Omon/', 14 'OImon':'mon/seaIce/OImon/', 15 'LImon':'mon/landIce/LImon/' } 16 17 mset1 = { 'info':'Selected by simChk1, based on availabiity of 7 vars in 3 experiments', 18 'models':[('MRI', 'MRICGCM3'), ('MOHC', 'HadGEM2ES'), ('MIROC', 'MIROCESM'), ('CNRMCERFACS', 'CNRMCM5'), ('NOAAGFDL', 'GFDLESM2G'), ('IPSL', 'IPSLCM5BLR'), ('CMCC', 'CMCCCM'), ('NASAGISS', 'GISSE2RCC'), ('MIROC', 'MIROC5'), ('NASAGISS', 'GISSE2H'), ('MPIM', 'MPIESMLR'), ('NASAGISS', 'GISSE2R'), ('NOAAGFDL', 'GFDLESM2M'), ('MOHC', 'HadGEM2CC'), ('IPSL', 'IPSLCM5ALR'), ('CSIROBOM', 'ACCESS10'), ('MPIM', 'MPIESMMR'), ('IPSL', 'IPSLCM5AMR'), ('MIROC', 'MIROC4h'), ('CMCC', 'CMCCCMS'), ('NCC', 'NorESM1M'), ('BCC', 'bcccsm11m'), ('NOAAGFDL', 'GFDLCM3'), ('CSIROBOM', 'ACCESS13'), ('NASAGISS', 'GISSE2HCC'), ('BNU', 'BNUESM'), ('BCC', 'bcccsm11'), ('MIROC', 'MIROCESMCHEM'), ('INM', 'inmcm4')] 19 } 20 21 class vtab(object): 22 def __init__(self,vars1,fn='CP4CDS_Projectionsdataoverview.csv'): 23 assert os.path.isfile(fn), '%s not found' % fn 24 self.vars1 = vars1 25 self.vars2 = [] 26 ii = open( fn, 'r' ) 27 for l in ii.readlines(): 28 if len(l) > 1 and l[0] != '#': 29 var, tab = l.split( '\t' )[:2] 30 assert tab in spth, 'Unrecignised table %s' % tab 31 if (tab,var) not in self.vars1: 32 self.vars2.append( (tab,var) ) 12 33 13 34 class models(object): 14 def __init__(self, base ):35 def __init__(self, base, vars,force=False,mlist=None): 15 36 assert os.path.isdir( base ), '%s not found' % base 37 self.vars = vars 38 self.force=force 39 self.mlist=mlist 40 16 41 l10 = glob.glob( '%s/*' % base ) 17 42 l1 = [i for i in l10 if os.path.isdir( i ) ] … … 20 45 self.im = [] 21 46 22 for i in sorted( l1 ): 23 self.addModels( i ) 47 if mlist == None: 48 for i in sorted( l1 ): 49 self.addModels( i ) 50 else: 51 self.im = mlist 24 52 25 53 si = set() … … 41 69 42 70 def filterModels(self,expts): 43 pths = set( [spth[t[0]] for t in vars1] )71 pths = set( [spth[t[0]] for t in self.vars] ) 44 72 n0 = len(self.im) 45 73 n1 = n2 = n3 = n4 = 0 … … 65 93 oo = open( 'fileList.txt', 'w' ) 66 94 for e,i,m,rip in self.files: 67 if (i,m) in sok :95 if (i,m) in sok or self.force: 68 96 for f in self.files[ (e,i,m,rip) ]: 69 97 oo.write( f + '\n' ) … … 87 115 efl = [] 88 116 missing = set() 89 for t,v in vars1:117 for t,v in self.vars: 90 118 p = spth[t] 91 119 if os.path.isdir( '%s%s/%s/%s/%s/%s/latest/%s' % (base,inst,model,expt,p,e,v) ): … … 95 123 else: 96 124 missing.add( (t,v) ) 97 if len(missing) == 0 :125 if len(missing) == 0 or (self.force and len(efl) > 0): 98 126 eok.add(e) 99 127 self.files[ (expt,inst,model,e) ] = efl … … 103 131 return len(eok) 104 132 105 106 m = models(base) 133 mode = 2 134 if mode == 1: 135 m = models(base,vars1) 136 else: 137 vv = vtab( vars1 ) 138 m = models(base,vv.vars2,force=True, mlist=mset1['models']) 107 139 108 140
Note: See TracChangeset
for help on using the changeset viewer.