def histogram_intensity(file): fills = fills_from_file(file, "OML") intensities = [] for nbr in fills: fill = Fill(nbr, fetch=False) fill.fetch() intensities.append(max(fill.intensity().y)) draw_histogram('Intensity for {}'.format(file), intensities, 1e13, "Intensity", "Count")
def comp_blm_ir3_vs_intensity(file): fills = fills_from_file(file, "OML") intensity = [] mean_loss = [] max_loss = [] discarded = 0 for nbr in fills: fill = Fill(nbr, False) fill.fetch() smin, smax = fill.OML_period() ssubset = fill.blm_ir3().y[smin:smax] maxint = max(fill.intensity().y) if maxint < 1.8e14: discarded += 1 continue mean_loss.append(np.mean(ssubset)) max_loss.append(max(ssubset)) intensity.append(maxint) fig = plt.figure() ax1 = fig.add_subplot(121) ax2 = fig.add_subplot(122, sharey=ax1) ax1.set_xlabel("Mean momentum (IR3) TCP") ax1.set_ylabel("Intensity") ax1.scatter(mean_loss, intensity, color='b', label='mean') ax1.set_xlim([0, 1.1 * max(mean_loss)]) ax1.set_ylim([1.5e14, 1.1 * max(intensity)]) ax1.legend(loc="lower right") ax2.set_xlabel("Max momentum (IR3) TCP") ax2.set_ylabel("Intensity") ax2.scatter(max_loss, intensity, color='r', label='max') ax2.set_xlim([0, 1.1 * max(max_loss)]) ax2.legend(loc="lower right") percent_used = int( round(float(len(intensity)) / (len(intensity) + discarded) * 100)) fig.suptitle( "Intensity vs OML for {} (only intenities > 1.8e14, {}% of total)\n". format(file, percent_used)) plt.show()
def histogram_intensity_lost_during_OML(fills, beam): agg_fill = aggregate_fill(beam=beam, from_cache=True) t_agg = agg_fill.blm_ir3().x[agg_fill.OML_period()] lost_agg_period = np.empty(len(fills)) lost_fill_period = np.empty(len(fills)) total_lost_during_ramp = np.empty(len(fills)) for i, nbr in enumerate(fills): fill = Fill(nbr) a_index = fill.intensity().index_for_time(t_agg) int_agg = fill.intensity().y[a_index] lost_agg_period[i] = int_agg[0] - int_agg[1] f_index = fill.intensity().index_for_time( fill.blm_ir3().x[fill.OML_period()]) int_fill = fill.intensity().y[f_index] lost_fill_period[i] = int_fill[0] - int_fill[1] total_lost_during_ramp[i] = fill.intensity().y[0] - fill.intensity( ).y[-1] fig, ax = plt.subplots() ax.hist((lost_agg_period, lost_fill_period), label=("Aggregate OML period", "Fill OML period"), edgecolor='white') # ax.hist((lost_agg_period,), label=("Aggregate OML period",) , edgecolor='white') ax.legend(loc='upper right') ax.xaxis.set_major_formatter( FuncFormatter(lambda x, pos: "{0:.2f}".format(x * 100.0))) ax.set_xlabel("Intensity lost (%)") ax.set_ylabel("# fills") plt.title( "Intensity during off-momentum loss peak at start of ramp (beam {})". format(beam)) # ax.hist(lost_fill_period, edgecolor='white') fig2, ax2 = plt.subplots() ax2.hist(total_lost_during_ramp, edgecolor='white') ax2.xaxis.set_major_formatter( FuncFormatter(lambda x, pos: "{0:.2f}".format(x * 100.0))) ax2.set_xlabel("Intensity lost (%)") ax2.set_ylabel("# fills") plt.title("Total intensity lost during whole ramp (beam {})".format(beam)) plt.show()