- Timestamp:
- Nov 14, 2016, 10:01:57 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/model_graphics.py
r1325 r1327 2714 2714 diffvar = gen.get_specdictionary_HMT(config, H='DIFFVAR_') 2715 2715 2716 print ' ' + fname + '; Lluis HERE !!!' 2717 2716 2718 if debug: 2717 2719 if diffop is not None: … … 4644 4646 # op and var differences 4645 4647 diffvarcompf = owdir + '/' + difffiles[0] 4648 print 'Lluis HERE !2!1!: diffvarcompf:', diffvarcompf 4646 4649 if not os.path.isfile(diffvarcompf): 4647 4650 alldiffop, alldiffvar,Nopdiffs,Nvardiffs=diffvarop_listconstruct(cnf,\ … … 4650 4653 if dbg: 4651 4654 print warnmsg 4652 print ' ' + main + ": getting 'op' and 'var' differences to " +\4655 print ' ' + main + ": getting 'op' and 'var' differences to " + \ 4653 4656 "compute already from file !!" 4654 4657 alldiffop, Nopdiffops = read_diff_file(diffvarcompf) 4655 4658 alldiffvar, Nopdiffvars = read_diff_file(owdir+'/'+difffiles[1]) 4656 4657 # End of avoiding to repeat all the experiment search 4658 4659 print " For experiments '"+exp2+"'-'"+exp1+"' is required to compute:", \ 4660 Nvar, "differences" 4661 4662 if dbg: 4663 print 'Differences to compute _______' 4664 gen.printing_dictionary(alldiffop) 4665 gen.printing_dictionary(alldiffvar) 4666 4667 # Computing differences 4668 ## 4669 print " Computing operation differences ..." 4670 compute_op_diffs(cnf, alldiffop, owdir, diffscratch, dbg) 4671 print " Computing variable differences ..." 4672 compute_var_diffs(cnf, alldiffvar, owdir, diffscratch, dbg) 4673 4674 # Plotting operation differences 4675 ## 4676 print " " + main + ": Plotting operation differences' figures ..." 4677 dirfigf = owdir + '/diffopplotsdraw.inf' 4678 if figscratch: 4679 sout = sub.call('rm ' + dirfigf + ' >& /dev/null', shell=True) 4680 4681 objf = open(owdir+'/all_diffopfigures.inf','w') 4682 objf.write("## Drawing of all operation difference figures \n") 4683 objf.close() 4684 4685 if adddifffigures: 4659 print 'Nopdiffops:', Nopdiffops,'Nopdiffvars:', Nopdiffvars 4660 4661 # End of avoiding to repeat all the experiment search 4662 print " For experiments '"+exp2+"'-'"+exp1+"' is required to " + \ 4663 "compute:", Nvar, "differences" 4664 4686 4665 if dbg: 4687 print ' ' + main + ": adding differences' figures removing file '" +\ 4688 dirfigf + "' ..." 4689 4690 sout = sub.call('rm ' + dirfigf + ' >& /dev/null', shell=True) 4691 4692 if not os.path.isfile(dirfigf): 4693 listplots, Nplt = plots_listconstruct(cnf, 'PLOTDIFFOP', dirfigf, owdir, \ 4694 dbg) 4695 else: 4666 print 'Differences to compute _______' 4667 gen.printing_dictionary(alldiffop) 4668 gen.printing_dictionary(alldiffvar) 4669 4670 # Computing differences 4671 ## 4672 print " Computing operation differences ..." 4673 compute_op_diffs(cnf, alldiffop, owdir, diffscratch, dbg) 4674 print " Computing variable differences ..." 4675 compute_var_diffs(cnf, alldiffvar, owdir, diffscratch, dbg) 4676 4677 # Plotting operation differences 4678 ## 4679 print " " + main + ": Plotting operation differences' figures ..." 4680 dirfigf = owdir + '/diffopplotsdraw.inf' 4681 if figscratch: 4682 sout = sub.call('rm ' + dirfigf + ' >& /dev/null', shell=True) 4683 4684 objf = open(owdir+'/all_diffopfigures.inf','w') 4685 objf.write("## Drawing of all operation difference figures \n") 4686 objf.close() 4687 4688 if adddifffigures: 4689 if dbg: 4690 print ' ' + main + ": adding differences' figures removing " + \ 4691 "file '" + dirfigf + "' ..." 4692 4693 sout = sub.call('rm ' + dirfigf + ' >& /dev/null', shell=True) 4694 4695 if not os.path.isfile(dirfigf): 4696 listplots, Nplt = plots_listconstruct(cnf, 'PLOTDIFFOP', dirfigf, \ 4697 owdir, dbg) 4698 else: 4699 if dbg: 4700 print warnmsg 4701 print ' ' + main + ": getting plots to draw already from file !!" 4702 listplots, Nplt = read_plot_file(dirfigf) 4703 4704 # End of avoiding to repeat all the plots search 4705 4706 print " For experiment 'operation' differences '" + Sexps + "' is " + \ 4707 "required to plot:" , Nplt, "plots" 4708 4696 4709 if dbg: 4697 print warnmsg 4698 print ' ' + main + ": getting plots to draw already from file !!" 4699 listplots, Nplt = read_plot_file(dirfigf) 4700 4701 # End of avoiding to repeat all the plots search 4702 4703 print " For experiment 'operation' differences '" + Sexps + "' is " + \ 4704 "required to plot:" , Nplt, "plots" 4705 4706 if dbg: 4707 print ' Plots to draw _______' 4708 gen.printing_dictionary(listplots) 4709 4710 draw_diff_plots(cnf, listplots, owdir, alldiffop, 'diffop', figdiffscratch, \ 4711 dbg) 4712 4713 # Plotting variable differences 4714 ## 4715 print " " + main + ": Plotting variable differences' figures ..." 4716 dirfigf = owdir + '/diffvarplotsdraw.inf' 4717 if figscratch: 4718 sout = sub.call('rm ' + dirfigf + ' >& /dev/null', shell=True) 4719 4720 objf = open(owdir+'/all_diffvarfigures.inf','w') 4721 objf.write("## Drawing of all variables difference figures \n") 4722 objf.close() 4723 4724 if adddifffigures: 4710 print ' Plots to draw _______' 4711 gen.printing_dictionary(listplots) 4712 4713 draw_diff_plots(cnf, listplots, owdir, alldiffop, 'diffop', \ 4714 figdiffscratch, dbg) 4715 4716 # Plotting variable differences 4717 ## 4718 print " " + main + ": Plotting variable differences' figures ..." 4719 dirfigf = owdir + '/diffvarplotsdraw.inf' 4720 if figscratch: 4721 sout = sub.call('rm ' + dirfigf + ' >& /dev/null', shell=True) 4722 4723 objf = open(owdir+'/all_diffvarfigures.inf','w') 4724 objf.write("## Drawing of all variables difference figures \n") 4725 objf.close() 4726 4727 if adddifffigures: 4728 if dbg: 4729 print ' '+main+": adding differences' figures removing file '" +\ 4730 dirfigf + "' ..." 4731 sout = sub.call('rm ' + dirfigf + ' >& /dev/null', shell=True) 4732 4733 if not os.path.isfile(dirfigf): 4734 listplots, Nplt = plots_listconstruct(cnf, 'PLOTDIFFVAR', dirfigf, \ 4735 owdir, dbg) 4736 else: 4737 if dbg: 4738 print warnmsg 4739 print ' ' + main + ": getting plots to draw already from file !!" 4740 listplots, Nplt = read_plot_file(dirfigf) 4741 4742 # End of avoiding to repeat all the plots search 4743 4744 print " For experiment 'variables' differences '" + Sexps + "' is " + \ 4745 "required to plot:" , Nplt, "plots" 4746 4725 4747 if dbg: 4726 print ' ' + main + ": adding differences' figures removing file '" +\ 4727 dirfigf + "' ..." 4728 sout = sub.call('rm ' + dirfigf + ' >& /dev/null', shell=True) 4729 4730 if not os.path.isfile(dirfigf): 4731 listplots, Nplt = plots_listconstruct(cnf, 'PLOTDIFFVAR', dirfigf, owdir,\ 4732 dbg) 4733 else: 4734 if dbg: 4735 print warnmsg 4736 print ' ' + main + ": getting plots to draw already from file !!" 4737 listplots, Nplt = read_plot_file(dirfigf) 4738 4739 # End of avoiding to repeat all the plots search 4740 4741 print " For experiment 'variables' differences '" + Sexps + "' is " + \ 4742 "required to plot:" , Nplt, "plots" 4743 4744 if dbg: 4745 print ' Plots to draw _______' 4746 gen.printing_dictionary(listplots) 4747 4748 draw_diff_plots(cnf, listplots, owdir, alldiffvar, 'diffvar', figdiffscratch,\ 4749 dbg) 4748 print ' Plots to draw _______' 4749 gen.printing_dictionary(listplots) 4750 4751 draw_diff_plots(cnf, listplots, owdir, alldiffvar, 'diffvar', \ 4752 figdiffscratch, dbg) 4750 4753 4751 4754 # end of mods loop … … 5134 5137 5135 5138 Nmods = len(mods) 5139 lmodexps = [] 5140 ldiffmodexps = [] 5136 5141 # Figures from mod/exp pairs 5137 5142 for mod in mods: … … 5139 5144 for exp in exps: 5140 5145 print ' direct plots:', mod, exp 5146 lmodexps.append(mod+'/'+exp) 5141 5147 owdirme = owdir + '/' + mod + '/' + exp 5142 5148 otexf.write('% ' + mod + ' ' + exp + '\n') … … 5166 5172 except: 5167 5173 print errmsg 5168 print 'gen.latex_fig_array(' +modexpimg+', '+otexf+', '+ \5174 print 'gen.latex_fig_array(',modexpimg,', '+otexf+', '+ \ 5169 5175 'gen.latex_text(' + caption + '), ' + flab + \ 5170 5176 ", refsize=0.5, dist='sqr', dorest='center')" … … 5182 5188 owdirme = owdir + '/' + mod + '/' + Sexps 5183 5189 print ' diffs:', mod + '/' + Sexps + ' ...' 5190 ldiffmodexps.append(mod + '/' + Sexps) 5184 5191 for diffn in ['op', 'var']: 5185 5192 fileplotinf = owdirme + '/diff' + diffn + 'plotsdraw.inf' … … 5213 5220 except: 5214 5221 print errmsg 5215 print 'gen.latex_fig_array(' +modexpimg+', '+ \5222 print 'gen.latex_fig_array(',modexpimg,', '+ \ 5216 5223 otexf+', gen.latex_text(' + caption + '), ' + \ 5217 5224 flab + ", refsize=0.5, dist='sqr', " + \ … … 5238 5245 Sexps = exp2 + '-' + exp1 5239 5246 print ' ' + Smods + ' ' + Sexps + ' ...' 5247 ldiffmodexps.append(Smods + '/' + Sexps) 5240 5248 owdirme = owdir + '/' + Smods + '/' + Sexps 5241 5249 for diffn in ['op', 'var']: … … 5271 5279 except: 5272 5280 print errmsg 5273 print 'gen.latex_fig_array(' +modexpimg+\5281 print 'gen.latex_fig_array(',modexpimg, \ 5274 5282 ', '+otexf+', gen.latex_text(' + \ 5275 5283 caption + '), '+flab+ ", refsize=0.5,"+\ … … 5309 5317 except: 5310 5318 print errmsg 5311 print 'gen.latex_fig_array(' +modexpimg+', '+otexf+ \5319 print 'gen.latex_fig_array(',modexpimg,', '+otexf+ \ 5312 5320 ', gen.latex_text(' + caption + '), ' +flab+ ", refsize=0.5," +\ 5313 5321 " dist='sqr', dorest='center')" … … 5316 5324 5317 5325 otexf.write('%\\clearpage\n') 5326 # 5327 # Grouping by type of figure 5328 # 5329 Nmods = len(mods) 5330 # Figures from mod/exp pairs 5331 owsearch = owdir + '/' + mods[0] + '/' + modexps[mods[0]][0] 5332 print " Looking in '" + owsearch + "' for figures by kind and variable..." 5333 otexf.write('% figures by kind and variable from:' + owsearch + '\n') 5334 modexpimg = gen.files_folder_HMT(owsearch, tail=cnf['kindfig']) 5335 # dictionary with kind of plots 5336 dplots = {} 5337 # list with kind of plots 5338 lplots = [] 5339 # dictionary with variable-statistics of each kind of plot 5340 dvarstats = {} 5341 # list with variables of each kind of plot 5342 lvars = [] 5343 for plot in modexpimg: 5344 plotk = plot.split('_')[0] 5345 varn = plot.split('_')[1] 5346 statn = plot.split('_')[3].split('.')[0] 5347 if not gen.searchInlist(lplots,plotk): 5348 lplots.append(plotk) 5349 if not dplots.has_key(plotk+'_'+varn): 5350 if not gen.searchInlist(lvars,varn): lvars.append(varn) 5351 dplots[plotk+'_'+varn] = [statn] 5352 else: 5353 vals = dplots[plotk+'_'+varn] 5354 dplots[plotk+'_'+varn] = vals + [statn] 5355 else: 5356 if not dplots.has_key(plotk+'_'+varn): 5357 if not gen.searchInlist(lvars,varn): lvars.append(varn) 5358 dplots[plotk+'_'+varn] = [statn] 5359 else: 5360 vals = dplots[plotk+'_'+varn] 5361 dplots[plotk+'_'+varn] = vals + [statn] 5362 5363 # Figures found 5364 print ' direct figures to group:', modexpimg 5365 print ' plots:', lplots 5366 print ' variables:', lvars 5367 5368 for var in lvars: 5369 otexf.write('% ' + var + '\n') 5370 otexf.write('\\modexp{' + gen.latex_text(var) + '}\n') 5371 for plot in lplots: 5372 if dplots.has_key(plot+'_'+varn): 5373 for stn in dplots[plot+'_'+varn]: 5374 plotvarfigs = [] 5375 caption = varn + ' ' + plot + ' ' + stn + ' ' 5376 flab = 'fig:' + varn + '_' + plot + '_' + stn + '_allmodexp' 5377 for me in lmodexps: 5378 modexpn = expGC[me].label 5379 modn = me.split('/')[0] 5380 imgns = gen.files_folder_HMT(owdir+'/'+me, head=plot+'_'+varn, \ 5381 middle=stn, tail=cnf['kindfig']) 5382 caption = caption + ', ' + modexpn 5383 imgn = owdir+'/'+me+'/'+imgns[0] 5384 if os.path.isfile(imgn): 5385 plotvarfigs.append(imgn) 5386 if dbg: 5387 print ' Grouping figures:', plotvarfigs 5388 try: 5389 with gen.Capturing() as output: 5390 gen.latex_fig_array(plotvarfigs, otexf, \ 5391 gen.latex_text(caption), flab, refsize=0.5, dist='sqr', \ 5392 dorest='center') 5393 except: 5394 print errmsg 5395 print 'gen.latex_fig_array(',plotvarfigs,', '+otexf+', '+ \ 5396 'gen.latex_text(' + caption + '), ' + flab + \ 5397 ", refsize=0.5, dist='sqr', dorest='center')" 5398 for s1out in output: print s1out 5399 quit(-1) 5400 5401 Nmods = len(mods) 5402 # Figures from mod/exp differences 5403 owsearch = owdir + '/' + ldiffmodexps[0] 5404 print " Looking in '" + owsearch + "' for difference figures by kind and variable..." 5405 otexf.write('% difference figures by kind and variable from:' + owsearch + '\n') 5406 modexpimg = gen.files_folder_HMT(owsearch, tail=cnf['kindfig']) 5407 # dictionary with kind of plots 5408 dplots = {} 5409 # list with kind of plots 5410 lplots = [] 5411 # dictionary with variable-statistics of each kind of plot 5412 dvarstats = {} 5413 # list with variables of each kind of plot 5414 lvars = [] 5415 for plot in modexpimg: 5416 plotk = plot.split('_')[0] 5417 varn = plot.split('_')[1] 5418 statn = plot.split('_')[5].split('.')[0] 5419 if not gen.searchInlist(lplots,plotk): 5420 lplots.append(plotk) 5421 if not dplots.has_key(plotk+'_'+varn): 5422 if not gen.searchInlist(lvars,varn): lvars.append(varn) 5423 dplots[plotk+'_'+varn] = [statn] 5424 else: 5425 vals = dplots[plotk+'_'+varn] 5426 dplots[plotk+'_'+varn] = vals + [statn] 5427 else: 5428 if not dplots.has_key(plotk+'_'+varn): 5429 if not gen.searchInlist(lvars,varn): lvars.append(varn) 5430 dplots[plotk+'_'+varn] = [statn] 5431 else: 5432 vals = dplots[plotk+'_'+varn] 5433 dplots[plotk+'_'+varn] = vals + [statn] 5434 5435 # Figures found 5436 print ' difference figures to group:', modexpimg 5437 print ' plots:', lplots 5438 print ' variables:', lvars 5439 5440 for var in lvars: 5441 otexf.write('% ' + var + '\n') 5442 otexf.write('\\modexp{diff ' + gen.latex_text(var) + '}\n') 5443 for plot in lplots: 5444 if dplots.has_key(plot+'_'+varn): 5445 for stn in dplots[plot+'_'+varn]: 5446 plotvarfigs = [] 5447 caption = varn + ' ' + plot + ' ' + stn + ' ' 5448 flab = 'fig:' + varn + '_' + plot + '_' + stn + '_alldiffmodexp' 5449 for me in ldiffmodexps: 5450 mods = me.split('/')[0] 5451 exps = me.split('/')[1] 5452 if exps.find('-') != -1: 5453 expn1 = exps.split('-')[0] 5454 expn2 = exps.split('-')[1] 5455 else: 5456 expn1 = exps 5457 expn2 = exps 5458 5459 if mods.find('-') != -1: 5460 modn1 = mods.split('-')[0] 5461 modn2 = mods.split('-')[1] 5462 else: 5463 modn1 = mods 5464 modn2 = mods 5465 modexpn1 = expGC[modn1 + '/' + expn1].label 5466 modexpn2 = expGC[modn2 + '/' + expn2].label 5467 modexpn = modexpn1 + '-' + modexpn2 5468 5469 modn = me.split('/')[0] 5470 imgns = gen.files_folder_HMT(owdir+'/'+me, head=plot+'_'+varn, \ 5471 middle=stn, tail=cnf['kindfig']) 5472 caption = caption + ', ' + modexpn 5473 imgn = owdir+'/'+me+'/'+imgns[0] 5474 if os.path.isfile(imgn): 5475 plotvarfigs.append(imgn) 5476 if dbg: 5477 print ' Grouping figures:', plotvarfigs 5478 try: 5479 with gen.Capturing() as output: 5480 gen.latex_fig_array(plotvarfigs, otexf, \ 5481 gen.latex_text(caption), flab, refsize=0.5, dist='sqr', \ 5482 dorest='center') 5483 except: 5484 print errmsg 5485 print 'gen.latex_fig_array(',plotvarfigs,', '+otexf+', '+ \ 5486 'gen.latex_text(' + caption + '), ' + flab + \ 5487 ", refsize=0.5, dist='sqr', dorest='center')" 5488 for s1out in output: print s1out 5489 quit(-1) 5318 5490 5319 5491 otexf.write('\\end{document}\n')
Note: See TracChangeset
for help on using the changeset viewer.