sp.set_ylim(-10, None) ms.comb_legend(sp, sp2, bbox_to_anchor=(1.3, 1), fontsize=myfontsz) if args.contributions: fig = ms.figure('Heat load contributions', figs) fig.subplots_adjust(right=0.75, wspace=0.45, hspace=0.4) sp = None fill_dict.update( tm.parse_timber_file( './fill_bunchbybunch_data_csvs/bunchbybunch_data_fill_%d.csv' % filln, verbose=False)) hli_calculator = ihl.HeatLoadCalculatorImpedanceLHCArc() hlsr_calculator = srhl.HeatLoadCalculatorSynchrotronRadiationLHCArc() hl_imped_fill = fc.HeatLoad_calculated_fill(fill_dict, hli_calculator) hl_sr_fill = fc.HeatLoad_calculated_fill(fill_dict, hlsr_calculator) model_time = (hl_sr_fill.t_stamps - t_ref) / 3600 t_start_injphys = (dict_fill_bmodes[filln]['t_start_INJPHYS'] - t_ref) / 3600. def compute_offset(tt, yy): mask_offset = np.logical_and(tt < t_start_injphys, tt > t_start_injphys - 600) offset = np.mean(yy[mask_offset]) return offset
def extract_and_compute_extra_fill_data(fill_dict, t_ref, t_sample_h, thresh_bint=3e10): from LHCMeasurementTools.LHC_FBCT import FBCT from LHCMeasurementTools.LHC_BCT import BCT from LHCMeasurementTools.LHC_BQM import blength from LHCMeasurementTools.LHC_Energy import energy import HeatLoadCalculators.impedance_heatload as ihl import HeatLoadCalculators.synchrotron_radiation_heatload as srhl import HeatLoadCalculators.FillCalculator as fc fbct_bx = {} bct_bx = {} blength_bx = {} for beam_n in [1, 2]: fbct_bx[beam_n] = FBCT(fill_dict, beam=beam_n) bct_bx[beam_n] = BCT(fill_dict, beam=beam_n) blength_bx[beam_n] = blength(fill_dict, beam=beam_n) hli_calculator = ihl.HeatLoadCalculatorImpedanceLHCArc() hlsr_calculator = srhl.HeatLoadCalculatorSynchrotronRadiationLHCArc() hl_imped_fill = fc.HeatLoad_calculated_fill(fill_dict, hli_calculator, bct_dict=bct_bx, fbct_dict=fbct_bx, blength_dict=blength_bx) hl_sr_fill = fc.HeatLoad_calculated_fill(fill_dict, hlsr_calculator, bct_dict=bct_bx, fbct_dict=fbct_bx, blength_dict=blength_bx) hl_imped_sample = hl.magnet_length['AVG_ARC'][0] * np.interp( t_sample_h, (hl_imped_fill.t_stamps - t_ref) / 3600, hl_imped_fill.heat_load_calculated_total) hl_sr_sample = hl.magnet_length['AVG_ARC'][0] * np.interp( t_sample_h, (hl_imped_fill.t_stamps - t_ref) / 3600, hl_sr_fill.heat_load_calculated_total) intensity_b1 = np.interp(t_sample_h, (bct_bx[1].t_stamps - t_ref) / 3600, bct_bx[1].values) intensity_b2 = np.interp(t_sample_h, (bct_bx[2].t_stamps - t_ref) / 3600, bct_bx[2].values) bl_ave_b1 = np.interp(t_sample_h, (blength_bx[1].t_stamps - t_ref) / 3600, blength_bx[1].avblen) bl_ave_b2 = np.interp(t_sample_h, (blength_bx[2].t_stamps - t_ref) / 3600, blength_bx[2].avblen) n_bunches_b1 = np.sum(fbct_bx[1].nearest_older_sample(t_sample_h * 3600 + t_ref) > thresh_bint) n_bunches_b2 = np.sum(fbct_bx[2].nearest_older_sample(t_sample_h * 3600 + t_ref) > thresh_bint) energy_GeV = energy(fill_dict, beam=1).nearest_older_sample(t_sample_h * 3600 + t_ref) return intensity_b1, intensity_b2, bl_ave_b1, bl_ave_b2, n_bunches_b1, n_bunches_b2, energy_GeV, hl_imped_sample, hl_sr_sample