@@ -48,65 +48,92 @@ def main():
4848 minim_files = [sys .argv [x ] + '.dat' for x in range (1 , len (sys .argv ))]
4949
5050 # Check if all the files exist
51+ plot_frequencies = None
52+ plot_minim = None
5153 for f , m in zip (freqs_files , minim_files ):
52- assert os .path .exists (f ), 'Error, file {} not found.' .format (f )
53- assert os .path .exists (m ), 'Error, file {} not found.' .format (m )
54-
55- print ("Reading the input..." )
56-
57- # Load all the data
58- freqs_data = np .concatenate ([np .loadtxt (f ) for f in freqs_files ])
59- minim_data = np .concatenate ([np .loadtxt (f ) for f in minim_files ])
60-
61- print ("Plotting..." )
62-
63- # Insert the x axis in the plotting data
64- xsteps = np .arange (minim_data .shape [0 ])
65- new_data = np .zeros (( len (xsteps ), 8 ), dtype = np .double )
66- new_data [:,0 ] = xsteps
67- new_data [:, 1 :] = minim_data
68- minim_data = new_data
54+ if os .path .exists (f ):
55+ if plot_frequencies is None :
56+ plot_frequencies = True
57+ if not plot_frequencies :
58+ raise IOError ("Error, file {} found, but not others .freqs" .format (f ))
59+ else :
60+ if plot_frequencies :
61+ raise IOError ("Error, file {} not found." .format (f ))
62+ plot_frequencies = False
63+
64+
65+ if os .path .exists (m ):
66+ if plot_minim is None :
67+ plot_minim = True
68+ if not plot_minim :
69+ raise IOError ("Error, file {} found, but not others .freqs" .format (m ))
70+ else :
71+ if plot_minim :
72+ raise IOError ("Error, file {} not found." .format (m ))
73+ plot_minim = False
74+
75+ if not plot_frequencies and not plot_minim :
76+ print ("Nothing to plot, check if the .dat and .freqs files exist." )
77+ exit ()
78+
79+ if plot_minim :
80+ print ("Preparing the minimization data..." )
81+ minim_data = np .concatenate ([np .loadtxt (f ) for f in minim_files ])
82+
83+ # Insert the x axis in the plotting data
84+ xsteps = np .arange (minim_data .shape [0 ])
85+ new_data = np .zeros (( len (xsteps ), 8 ), dtype = np .double )
86+ new_data [:,0 ] = xsteps
87+ new_data [:, 1 :] = minim_data
88+ minim_data = new_data
89+
90+ fig_data , axarr = plt .subplots (nrows = 2 , ncols = 2 , sharex = True , dpi = DPI )
91+
92+ # Plot the data
93+ axarr [0 ,0 ].fill_between (minim_data [:,0 ], minim_data [:,1 ] - minim_data [:, 2 ]* .5 ,
94+ minim_data [:, 1 ] + minim_data [:, 2 ] * .5 , color = "aquamarine" )
95+ axarr [0 ,0 ].plot (minim_data [:,0 ], minim_data [:,1 ], color = "k" )
96+ axarr [0 ,0 ].set_ylabel ("Free energy / unit cell [meV]" , fontsize = LBL_FS )
97+
98+
99+ axarr [0 ,1 ].fill_between (minim_data [:,0 ], minim_data [:,3 ] - minim_data [:, 4 ]* .5 ,
100+ minim_data [:, 3 ] + minim_data [:, 4 ] * .5 , color = "aquamarine" )
101+ axarr [0 ,1 ].plot (minim_data [:,0 ], minim_data [:,3 ], color = "k" )
102+ axarr [0 ,1 ].set_ylabel ("FC gradient" , fontsize = LBL_FS )
103+
104+ axarr [1 ,1 ].fill_between (minim_data [:,0 ], minim_data [:,5 ] - minim_data [:, 6 ]* .5 ,
105+ minim_data [:, 5 ] + minim_data [:, 6 ] * .5 , color = "aquamarine" )
106+ axarr [1 ,1 ].plot (minim_data [:,0 ], minim_data [:,5 ], color = "k" )
107+ axarr [1 ,1 ].set_ylabel ("Structure gradient" , fontsize = LBL_FS )
108+ axarr [1 ,1 ].set_xlabel ("Good minimization steps" , fontsize = LBL_FS )
109+
110+
111+ axarr [1 ,0 ].plot (minim_data [:,0 ], minim_data [:,7 ], color = "k" )
112+ axarr [1 ,0 ].set_ylabel ("Effective sample size" , fontsize = LBL_FS )
113+ axarr [1 ,0 ].set_xlabel ("Good minimization steps" , fontsize = LBL_FS )
114+ fig_data .tight_layout ()
69115
70- fig_data , axarr = plt .subplots (nrows = 2 , ncols = 2 , sharex = True , dpi = DPI )
71-
72- # Plot the data
73- axarr [0 ,0 ].fill_between (minim_data [:,0 ], minim_data [:,1 ] - minim_data [:, 2 ]* .5 ,
74- minim_data [:, 1 ] + minim_data [:, 2 ] * .5 , color = "aquamarine" )
75- axarr [0 ,0 ].plot (minim_data [:,0 ], minim_data [:,1 ], color = "k" )
76- axarr [0 ,0 ].set_ylabel ("Free energy / unit cell [meV]" , fontsize = LBL_FS )
77-
78116
79- axarr [0 ,1 ].fill_between (minim_data [:,0 ], minim_data [:,3 ] - minim_data [:, 4 ]* .5 ,
80- minim_data [:, 3 ] + minim_data [:, 4 ] * .5 , color = "aquamarine" )
81- axarr [0 ,1 ].plot (minim_data [:,0 ], minim_data [:,3 ], color = "k" )
82- axarr [0 ,1 ].set_ylabel ("FC gradient" , fontsize = LBL_FS )
83117
84- axarr [1 ,1 ].fill_between (minim_data [:,0 ], minim_data [:,5 ] - minim_data [:, 6 ]* .5 ,
85- minim_data [:, 5 ] + minim_data [:, 6 ] * .5 , color = "aquamarine" )
86- axarr [1 ,1 ].plot (minim_data [:,0 ], minim_data [:,5 ], color = "k" )
87- axarr [1 ,1 ].set_ylabel ("Structure gradient" , fontsize = LBL_FS )
88- axarr [1 ,1 ].set_xlabel ("Good minimization steps" , fontsize = LBL_FS )
89118
119+ if plot_frequencies :
120+ print ("Plotting the frequencies" )
90121
91- axarr [1 ,0 ].plot (minim_data [:,0 ], minim_data [:,7 ], color = "k" )
92- axarr [1 ,0 ].set_ylabel ("Effective sample size" , fontsize = LBL_FS )
93- axarr [1 ,0 ].set_xlabel ("Good minimization steps" , fontsize = LBL_FS )
94- fig_data .tight_layout ()
95-
96-
97- # Now plot the frequencies
98- fig_freqs = plt .figure (dpi = DPI )
99- ax = plt .gca ()
122+ # Load all the data
123+ freqs_data = np .concatenate ([np .loadtxt (f ) for f in freqs_files ])
124+ # Now plot the frequencies
125+ fig_freqs = plt .figure (dpi = DPI )
126+ ax = plt .gca ()
100127
101- N_points , Nw = np .shape (freqs_data )
128+ N_points , Nw = np .shape (freqs_data )
102129
103- for i in range (Nw ):
104- ax .plot (freqs_data [:, i ] * CC .Units .RY_TO_CM )
130+ for i in range (Nw ):
131+ ax .plot (freqs_data [:, i ] * CC .Units .RY_TO_CM )
105132
106- ax .set_xlabel ("Good minimization steps" , fontsize = LBL_FS )
107- ax .set_ylabel ("Frequency [cm-1]" , fontsize = LBL_FS )
108- ax .set_title ("Frequcency evolution" , fontsize = TITLE_FS )
109- fig_freqs .tight_layout ()
133+ ax .set_xlabel ("Good minimization steps" , fontsize = LBL_FS )
134+ ax .set_ylabel ("Frequency [cm-1]" , fontsize = LBL_FS )
135+ ax .set_title ("Frequcency evolution" , fontsize = TITLE_FS )
136+ fig_freqs .tight_layout ()
110137
111138 plt .show ()
112139
0 commit comments