MakePlotDump.py
Go to the documentation of this file.
1 import sys,shutil,os,glob
2 import Optimizations
3 
4 ##### PARSE INPUT ARGUMENT #####
5 
6 if not len(sys.argv) > 1:
7  print "Please specify an optimization name"
8  sys.exit()
9 
10 optname = sys.argv[1]
11 
12 optimization = Optimizations.Optimization(optname)
13 
14 temp_dir = optname+"_temp"
15 
16 if os.path.exists(temp_dir):
17  shutil.rmtree(temp_dir)
18 
19 os.makedirs(temp_dir)
20 
21 tarfile = temp_dir+".tar.gz"
22 if os.path.exists(tarfile):
23  os.remove(tarfile)
24 
25 
26 os.makedirs(temp_dir+"/fitness_vs_configuration/")
27 os.makedirs(temp_dir+"/fitness_vs_configuration/eps")
28 os.makedirs(temp_dir+"/fitness_vs_configuration/png")
29 
30 fitness_types = ["Standard","fhcnumu","fhcnumubar","fhcnuenuebar","rhcnumu","rhcnumubar","rhcnuenuebar","ih","nh","mh"]
31 for type in fitness_types:
32  subdir = temp_dir+"/fitness_vs_configuration/"
33  file_prefix = optname+"_"+type+"_fitness_vs_configuration"
34  shutil.copyfile("plots/"+file_prefix+".eps",subdir+"/eps/"+file_prefix+".eps")
35  shutil.copyfile("plots/"+file_prefix+".png",subdir+"/png/"+file_prefix+".png")
36 
37 os.makedirs(temp_dir+"/best_fluxes/")
38 os.makedirs(temp_dir+"/best_fluxes/eps")
39 os.makedirs(temp_dir+"/best_fluxes/png")
40 versions = ["numu_fhc","numubar_fhc","nue_fhc","nuebar_fhc","numu_rhc","numubar_rhc","nue_rhc","nuebar_rhc"]
41 for version in versions:
42  subdir = temp_dir+"/best_fluxes/"
43  file_prefix = optname+"_"+version+"_best_fluxes"
44  shutil.copyfile("plots/"+file_prefix+".eps",subdir+"/eps/"+file_prefix+".eps")
45  shutil.copyfile("plots/"+file_prefix+".png",subdir+"/png/"+file_prefix+".png")
46 
47 os.makedirs(temp_dir+"/fitness_vs_parameter/")
48 os.makedirs(temp_dir+"/fitness_vs_parameter/eps")
49 os.makedirs(temp_dir+"/fitness_vs_parameter/png")
50 params = optimization.parameter_names
51 for param in params:
52  for fitness_type in fitness_types:
53  subdir = temp_dir+"/fitness_vs_parameter/"
54  file_prefix = optname+"_"+fitness_type+"_fitness_vs_"+param
55  shutil.copyfile("plots/"+file_prefix+".eps",subdir+"/eps/"+file_prefix+".eps")
56  shutil.copyfile("plots/"+file_prefix+".png",subdir+"/png/"+file_prefix+".png")
57 
58 os.makedirs(temp_dir+"/parameter_vs_configuration/")
59 os.makedirs(temp_dir+"/parameter_vs_configuration/eps")
60 os.makedirs(temp_dir+"/parameter_vs_configuration/png")
61 params = optimization.parameter_names
62 for param in params:
63  for fitness_type in fitness_types:
64  subdir = temp_dir+"/parameter_vs_configuration/"
65  file_prefix = optname+"_"+param+"_vs_configuration"
66  shutil.copyfile("plots/"+file_prefix+".eps",subdir+"/eps/"+file_prefix+".eps")
67  shutil.copyfile("plots/"+file_prefix+".png",subdir+"/png/"+file_prefix+".png")
68 
69 os.makedirs(temp_dir+"/parameter_vs_parameter/")
70 os.makedirs(temp_dir+"/parameter_vs_parameter/eps")
71 os.makedirs(temp_dir+"/parameter_vs_parameter/png")
72 params = optimization.parameter_names
73 for param1 in params:
74  for param2 in params:
75  subdir = temp_dir+"/parameter_vs_parameter/"
76  file_prefix = optname+"_"+param1+"_vs_"+param2
77  if(os.path.exists("plots/"+file_prefix+".eps")):
78  shutil.copyfile("plots/"+file_prefix+".eps",subdir+"/eps/"+file_prefix+".eps")
79  shutil.copyfile("plots/"+file_prefix+".png",subdir+"/png/"+file_prefix+".png")
80 
81 os.makedirs(temp_dir+"/visualizations/")
82 os.makedirs(temp_dir+"/visualizations/eps")
83 os.makedirs(temp_dir+"/visualizations/png")
84 params = optimization.parameter_names
85 
86 subdir = temp_dir+"/visualizations/"
87 file_prefix = optname
88 eps_to_copy = glob.glob("vis_plots/*"+file_prefix+"*.eps")
89 png_to_copy = glob.glob("vis_plots/*"+file_prefix+"*.png")
90 print eps_to_copy
91 for eps_file in eps_to_copy:
92  shutil.copyfile(eps_file,subdir+"/eps/"+os.path.basename(eps_file))
93 
94 for png_file in png_to_copy:
95  shutil.copyfile(png_file,subdir+"/png/"+os.path.basename(png_file))
96 
97 os.makedirs(temp_dir+"/scans/")
98 os.makedirs(temp_dir+"/scans/eps")
99 os.makedirs(temp_dir+"/scans/png")
100 params = optimization.parameter_names
101 
102 subdir = temp_dir+"/scans/"
103 file_prefix = optname
104 eps_to_copy = glob.glob("scan_plots/*"+file_prefix+"*.eps")
105 png_to_copy = glob.glob("scan_plots/*"+file_prefix+"*.png")
106 print eps_to_copy
107 for eps_file in eps_to_copy:
108  shutil.copyfile(eps_file,subdir+"/eps/"+os.path.basename(eps_file))
109 
110 for png_file in png_to_copy:
111  shutil.copyfile(png_file,subdir+"/png/"+os.path.basename(png_file))
112 
113 os.system("tar cvzf " + tarfile+ " " + temp_dir)
114 
if(!yymsg) yymsg