Changeset 1363 in lmdz_wrf
- Timestamp:
- Dec 4, 2016, 1:07:13 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/model_graphics.py
r1345 r1363 1142 1142 wrongstats.append(CFvarn + '_' + opers) 1143 1143 break 1144 1145 elif op[0:11] == 'dimvarvalue': 1146 # Slicing along the index at the nearest given value of a dimension-variable 1147 dimvarn = op.split('~')[1] 1148 dimvalue = op.split('~')[2] 1149 vals = dimvarn + ',' + dimvalue + ',' + dimvalue + ',0' 1150 if dofile: 1151 try: 1152 with gen.Capturing() as output: 1153 ncvar.DataSetSection_multivars(vals,prevfile,CFvarnp) 1154 except: 1155 print errmsg 1156 print 'DataSetSection_multivars('+vals+',', prevfile, ',' + \ 1157 CFvarnp + ')' 1158 for s1out in output: print s1out 1159 quit(-1) 1160 1161 if db: 1162 for s1out in output: print s1out 1163 1164 sout = sub.call('mv DataSetSection_multivars.nc '+fileon, shell=True) 1165 1166 # Keeping the operations 1167 pyins=pyH + "/nc_var.py -o DataSetSection_multivars -S '" + vals + \ 1168 "' -f " + prevfile + " -v " + CFvarnp 1169 otrackf.write("\n") 1170 otrackf.write("# " + CFvarnp + " " + Fopers + "\n") 1171 otrackf.write(pyins + "\n") 1172 1173 # removing the given variable-dimension 1174 varnCFs.remove(dimvarn) 1175 1144 1176 elif op == 'direct': 1145 1177 # no statistics … … 2334 2366 return 2335 2367 2368 def opexplained(Opn,Exp): 2369 """ Function to provide the final explanation for the title in the graph. Some operations have 2370 values separated by `~' which need to be processed 2371 Opn= full operation string 2372 Exp= explanation from dictionary 2373 >>> opexplained('dimvarvalue~pres~85000','@') 2374 pres@85000 2375 >>> opexplained('xmean','xmean') 2376 xmean 2377 """ 2378 fname = 'opexplained' 2379 2380 if Opn.find('~') == -1: 2381 explanation = Exp 2382 else: 2383 Opnv = Opn.split('~') 2384 if Opnv[0] == 'dimvarvalue': 2385 explanation = Opnv[1] + Exp + Opnv[2] 2386 else: 2387 print errormsg 2388 print ' ' + fname + ": unknow '~' separated operation '" + Opnv[0] + \ 2389 "' !!" 2390 quit(-1) 2391 return explanation 2392 2336 2393 def optitle(op,opexp): 2337 2394 """ Function to creat the operation section in the title of a figure ('!' for spaces) … … 2340 2397 >>> optitle('pinterp+xmean+tmean',{'pinterp':'pinterp', 'xmean':'xmean', 'tmean':'tmean'}) 2341 2398 $_{[pinterp\!xmean\!tmean]}$ 2399 >>> optitle('pinterp+dimvarvalue~pres~85000+tmean',{'dimvarvalue':'@', 'pinterp':'pinterp', 'xmean':'xmean', 'tmean':'tmean'}) 2400 $_{[pinterp\!pres@85000\!tmean]}$ 2342 2401 """ 2343 2402 fname = 'optitle' … … 2345 2404 opvals = op.split('+') 2346 2405 for op1 in opvals: 2347 if not opexp.has_key(op1): 2406 op1n = op1.split('~')[0] 2407 if not opexp.has_key(op1n): 2348 2408 print errmsg 2349 print ' ' +fname+": no explanation for operation '"+op1+"' !!"2409 print ' ' + fname + ": no explanation for operation '" + op1n + "' !!" 2350 2410 print ' provided:', opexp.keys() 2351 2411 quit(-1) 2352 if op1 == opvals[0]: 2353 titop = '$_{[' + opexp[op1].replace(' ','!') 2412 # Final explanation 2413 op1en = opexplained(op1,opexp[op1n]).replace(' ','!') 2414 2415 if op1n == opvals[0].split('~')[0]: 2416 titop = '$_{[' + op1en 2354 2417 if len(opvals) == 1: titop = titop + ']}$' 2355 elif op1 == opvals[len(opvals)-1]:2356 titop = titop + '\!' + op exp[op1].replace(' ','!')+ ']}$'2418 elif op1n == opvals[len(opvals)-1].split('~')[0]: 2419 titop = titop + '\!' + op1en + ']}$' 2357 2420 else: 2358 titop = titop + '\!' + op exp[op1].replace(' ','!')2421 titop = titop + '\!' + op1en 2359 2422 2360 2423 return titop … … 2373 2436 >>> create_figure_title('WRF','current',['ua|pinterp+xmean+tmean', 'va|pinterp+xmean+last'], expops) 2374 2437 WRF!current!ua$_{[pinterp\!xmean\!tmean]}$!&!va$_{[pinterp\!xmean\!last]}$ 2438 >>> create_figure_title('WRF','current',['uas|dimvarvalue~lon~23.23', 'vas|dimvarvalue~lon~23.23'], expops) 2439 WRF!current!uas!&!vas$_{[lon@23.23]}$ 2440 >>> create_figure_title('WRF','current',['hus|pinterp+tmean+dimvarvalue~pres~85000.', 'ta|pinterp+tmean+dimvarvalue~pres~85000.'], expops) 2441 WRF!current!hus!&!ta$_{[pinterp\!tmean\!pres@85000.]}$ 2375 2442 """ 2376 2443 fname = 'create_figure_title' … … 2435 2502 titfig = titfig + ',!' + vnop 2436 2503 2437 return titfig 2504 return titfig.replace('!!','!') 2505 #expops = {'dimvarvalue':'@', 'last':'last', 'pinterp':'pinterp', 'xmean':'xmean', 'tmean':'tmean'} 2438 2506 2439 2507 def draw_plots(config, plots, mod, exp, odir, allvarcomp, figscr, debug): … … 2619 2687 # End of variable-operation 2620 2688 figname = figname + '.' + kindfigure 2689 2690 # Removig double '..' (from `dimvarvalue') 2691 figname = figname.replace('..', '.') 2621 2692 2622 2693 # Title of figure … … 2978 3049 acc: temporal accumulated values 2979 3050 diff: differences between models 3051 dimvarvalue~[dimvarn]~[value]: Slicing along the index at the nearest given value of a dimension-variable 2980 3052 direct: no statistics 2981 3053 last: last temporal value … … 3066 3138 wrongstats.append(varn + '_' + opers) 3067 3139 break 3140 3141 elif op[0:11] == 'dimvarvalue': 3142 # Slicing along the index at the nearest given value of a dimension-variable 3143 dimvarn = op.split('~')[1] 3144 dimvalue = op.split('~')[2] 3145 vals = dimvarn + ',' + dimvalue + ',' + dimvalue + ',0' 3146 if dofile: 3147 try: 3148 with gen.Capturing() as output: 3149 ncvar.DataSetSection_multivars(vals,prevfile,CFvarnp) 3150 except: 3151 print errmsg 3152 print 'DataSetSection_multivars('+vals+',', prevfile, ',' + \ 3153 CFvarnp + ')' 3154 for s1out in output: print s1out 3155 quit(-1) 3156 3157 if db: 3158 for s1out in output: print s1out 3159 3160 sout = sub.call('mv DataSetSection_multivars.nc '+fileon, shell=True) 3161 3162 # Keeping the operations 3163 pyins=pyH + "/nc_var.py -o DataSetSection_multivars -S '" + vals + \ 3164 "' -f " + prevfile + " -v " + CFvarnp 3165 otrackf.write("\n") 3166 otrackf.write("# " + CFvarnp + " " + Fopers + "\n") 3167 otrackf.write(pyins + "\n") 3168 3169 # removing the given variable-dimension 3170 varnCFs.remove(dimvarn) 3171 3068 3172 elif op == 'direct': 3069 3173 # no statistics … … 4692 4796 # op and var differences 4693 4797 diffvarcompf = owdir + '/' + difffiles[0] 4694 print 'Lluis HERE !2!1!: diffvarcompf:', diffvarcompf4695 4798 if not os.path.isfile(diffvarcompf): 4696 4799 alldiffop, alldiffvar,Nopdiffs,Nvardiffs=diffvarop_listconstruct(cnf,\
Note: See TracChangeset
for help on using the changeset viewer.