@@ -671,8 +671,8 @@ def fit_and_plot_transverse_profiles(self,
671671 Nb [0 , i ] = tbt_dict ['Nb' ][0 ] # initial
672672
673673 # Plot simulated particle profile
674- fig , ax = plt .subplots (1 , 1 , figsize = (8 , 6 ), constrained_layout = True )
675- fig2 , ax2 = plt .subplots (1 , 1 , figsize = (8 , 6 ), constrained_layout = True )
674+ fig , ax = plt .subplots (1 , 1 , figsize = (6 , 4.5 ), constrained_layout = True )
675+ fig2 , ax2 = plt .subplots (1 , 1 , figsize = (6 , 4.5 ), constrained_layout = True )
676676
677677 # Plot measured profiles if desired
678678 if load_measured_profiles :
@@ -685,7 +685,7 @@ def fit_and_plot_transverse_profiles(self,
685685 # Convert to m, normalize height
686686 x_pos *= 1e-3
687687 x_measured_bin_heights_sorted = np .array (sorted (x_prof_avg , reverse = True ))
688- x_measured_height_max_avg = np .mean (x_measured_bin_heights_sorted [:5 ]) # take average of top 3 values
688+ x_measured_height_max_avg = np .mean (x_measured_bin_heights_sorted [:3 ]) # take average of top 3 values
689689 x_prof_avg_norm = x_prof_avg / x_measured_height_max_avg
690690
691691 # Fit Gaussian, center the profile and re-adjust heights
@@ -705,7 +705,7 @@ def fit_and_plot_transverse_profiles(self,
705705 # Convert to m, normalize height
706706 y_pos *= 1e-3
707707 y_measured_bin_heights_sorted = np .array (sorted (y_prof_avg , reverse = True ))
708- y_measured_height_max_avg = np .mean (y_measured_bin_heights_sorted [:5 ]) # take average of top 3 values
708+ y_measured_height_max_avg = np .mean (y_measured_bin_heights_sorted [:3 ]) # take average of top 3 values
709709 y_prof_avg_norm = y_prof_avg / y_measured_height_max_avg
710710 # Fit Gaussian, center the profile and re-adjust heights
711711 popt_Y_meas , _ = fits .fit_Gaussian (y_pos , y_prof_avg_norm , p0 = (1.0 , 0.0 , 0.02 ))
@@ -717,7 +717,7 @@ def fit_and_plot_transverse_profiles(self,
717717
718718 # Select index to plot, e.g last set of 100 turns
719719 index_to_plot = [0 , - 1 ] #[-1] #
720- plot_str = ['Simulated first 100 turns' , 'Simulated last 100 turns' ] #['Simulated, last 100 turns']
720+ plot_str = ['Simulated first 100 turns' , 'Simulated, \n last 100 turns' ] #['Simulated, last 100 turns']
721721 colors = ['blue' , 'orange' ]
722722
723723 for j , ind in enumerate (index_to_plot ):
@@ -734,7 +734,7 @@ def fit_and_plot_transverse_profiles(self,
734734 ax .set_xlabel ('x [m]' )
735735 ax .set_ylabel ('Normalized counts' )
736736 ax .set_ylim (0 , 1.1 )
737- ax .text (0.02 , 0.05 , '{} = {:.2f}' .format (label_for_x_axis , scan_array_for_x_axis [i ]), transform = ax .transAxes , fontsize = 10 .8 )
737+ ax .text (0.02 , 0.05 , '{} = {:.2f}' .format (label_for_x_axis , scan_array_for_x_axis [i ]), transform = ax .transAxes , fontsize = 11 .8 )
738738
739739 # Plot profile of particles
740740 for j , ind in enumerate (index_to_plot ):
@@ -752,7 +752,7 @@ def fit_and_plot_transverse_profiles(self,
752752 ax2 .set_ylabel ('Normalized counts' )
753753 ax2 .set_xlabel ('y [m]' )
754754 ax2 .set_ylim (0 , 1.1 )
755- ax2 .text (0.02 , 0.05 , '{} = {:.2f}' .format (label_for_x_axis , scan_array_for_x_axis [i ]), transform = ax2 .transAxes , fontsize = 10 .8 )
755+ ax2 .text (0.02 , 0.05 , '{} = {:.2f}' .format (label_for_x_axis , scan_array_for_x_axis [i ]), transform = ax2 .transAxes , fontsize = 11 .8 )
756756
757757 # Fit Gaussian for the emittance
758758 popt_X , pcov_X = fits .fit_Gaussian (X_pos_data , X_profile_data , p0 = (1.0 , 0.0 , 0.02 ))
@@ -823,8 +823,8 @@ def fit_and_plot_transverse_profiles(self,
823823 print ('exn = {:.3e}, eyn = {:.3e}' .format (exn [1 , i ], eyn [1 , i ]))
824824 print ('Transmission = {:3f}\n ' .format (transmission [i ]))
825825
826- ax .legend (loc = 'upper left' , fontsize = 11 .5 )
827- ax2 .legend (loc = 'upper left' , fontsize = 11 .5 )
826+ ax .legend (loc = 'upper left' , fontsize = 10 .5 )
827+ ax2 .legend (loc = 'upper left' , fontsize = 10 .5 )
828828 fig .savefig ('output_transverse/X_profiles/{}_SPS_X_Beam_Profile_WS.png' .format (output_folder ), dpi = 250 )
829829 fig2 .savefig ('output_transverse/Y_profiles/{}_SPS_Y_Beam_Profile_WS.png' .format (output_folder ), dpi = 250 )
830830 plt .close ()
0 commit comments