def set_simulator(self, magnet_file, energy_eV='file', timestamp=None): self.simulator = elegant_matrix.get_simulator(magnet_file) if energy_eV == 'file': try: self.energy_eV = self.simulator.get_data( 'SARBD01-MBND100:P-SET', timestamp) * 1e6 except KeyError: self.energy_eV = self.simulator.get_data( 'SARBD01-MBND100:ENERGY-OP', timestamp) * 1e6 else: self.energy_eV = energy_eV self._r12 is None self._disp is None
import datetime import elegant_matrix #data_timestamps = list(elegant_matrix.mag_data.values())[0][:,0] simulator = elegant_matrix.get_simulator( '/afs/psi.ch/intranet/SF/Beamdynamics/Philipp/data/archiver_api_data/2020-10-03.h5' ) year, month = 2020, 10 times = [ (3, 15, 0, 0), (3, 18, 0, 0), (3, 21, 0, 0), (4, 1, 0, 0), (4, 15, 0, 0), (4, 18, 0, 0), (4, 21, 0, 0), (4, 23, 0, 0), ] for day, hour, minute, second in times: date = datetime.datetime(int(year), int(month), int(day), int(hour), int(minute), int(second)) timestamp = int(date.strftime('%s')) #mat0 = elegant_matrix.get_elegant_matrix(0, timestamp, del_sim=False, print_=False) mat1, disp_dict = simulator.get_elegant_matrix(1, timestamp, del_sim=False, print_=False) dscr0 = 'SARBD01.DSCR050'
import myplotstyle as ms import data_loader import elegant_matrix import wf_model data_dir = '/storage/data_2020-02-03/' #data_dir = '/afs/psi.ch/intranet/SF/Beamdynamics/Philipp/data/data_2020-02-03/' reverse_current_profile = True linear_fit_details = True quadratic_fit_details = True archiver_dir = '/storage/Philipp_data_folder/archiver_api_data/' simulator = elegant_matrix.get_simulator(archiver_dir + '2020-02-03.json11') plt.close('all') figsize = (16, 12) ny, nx = 2, 4 subplot = ms.subplot_factory(ny, nx) xlabel = 'Offset [mm]' ylabel = 'BPM reading [mm]' xlabel2 = 's [$\mu$m]' guessed_centers = [0.46e-3, 0.69e-3] bpm_reading_0 = [0.3e-3, 0.39e-3]
calc_long_dipole=False) gaussian_wake_tt = time_gauss gaussian_wake = wf_dict['dipole']['wake_potential'] tt_dict[sig_t2] = time_gauss wake_dict[sig_t2] = gaussian_wake time_gauss = tt_dict[sig_t] gaussian_wake = wake_dict[sig_t] current_gauss0 = current_dict[sig_t] if investigate_wake: # Forward track with elegant and Gaussian beam simulator = elegant_matrix.get_simulator(magnet_file) #mat_dict, disp_dict = simulator.get_elegant_matrix(0, timestamp) sim, mat_dict, wf_dicts, disp_dict = simulator.simulate_streaker( time_gauss, current_gauss, timestamp, (gap, 10e-3), (beam_offset, 0), energy_eV, linearize_twf=False) mat_dict, _ = simulator.get_elegant_matrix(0, timestamp) r12 = mat_dict['SARBD02.DSCR050'][0, 1] single_wake2 = np.interp(time_gauss, wf_dicts[0]['t'], wf_dicts[0]['WX']) convoluted_wake2 = np.convolve(current_gauss, single_wake2)[:len(current_gauss)]
import numpy as np; np import matplotlib.pyplot as plt import myplotstyle as ms import data_loader import elegant_matrix import wf_model #data_dir = '/storage/data_2020-02-03/' data_dir = '/afs/psi.ch/intranet/SF/Beamdynamics/Philipp/data/data_2020-02-03/' reverse_current_profile = True linear_fit_details = True quadratic_fit_details = True simulator = elegant_matrix.get_simulator(file_json='/afs/psi.ch/intranet//SF/Beamdynamics/Philipp/data/archiver_api_data/2020-02-03.json11') plt.close('all') figsize = (16, 12) ny, nx = 2, 4 subplot = ms.subplot_factory(ny, nx) xlabel = 'Offset [mm]' ylabel = 'BPM reading [mm]' xlabel2 = r's [$\mu$m]' guessed_centers = [0.46e-3, 0.69e-3] bpm_reading_0 = [0.3e-3, 0.39e-3]