sp_profile = subplot(sp_ctr, title='Resolution', xlabel='t (fs)', ylabel='I (kA)') sp_ctr += 1 sp_res = sp_profile.twinx() sp_res.set_ylabel('R (fs)') blmeas_profile.plot_standard(sp_profile, color='black') tracker.n_particles = int(200e3) res_dicts = [] for quad_wake, label in [(False, 'Dipole %i nm' % (n_emittance * 1e9)), (True, 'Quadrupole')]: tracker.quad_wake = quad_wake res_dict = iap.calc_resolution(blmeas_profile, gap, beam_offset, struct_length, tracker, 1) res = res_dict['resolution'] res_t = res_dict['time'] sp_res.plot(res_t * 1e15, res * 1e15, label=label) res_dicts.append(res_dict) #sp_image = subplot(sp_ctr, title='Raw image', xlabel='x (mm)', ylabel='y (mm)', grid=False) #sp_ctr += 1 #image.plot_img_and_proj(sp_image) gfX = gaussfit.GaussFit(x_axis_calib, screen_calib_raw_image.sum(axis=0)) beamsize = gfX.sigma #sp_screen_calib = subplot(sp_ctr, title='Screen calibration', xlabel='x (mm)', ylabel='y (mm)', grid=False) #sp_ctr += 1
distances = sc.gap0 / 2. - np.abs(beam_offsets) sort = np.argsort(distances) tracker.quad_wake = True tracker.n_particles = int(200e3) n_res = 3 for n_meta, (meta_data, ls) in enumerate([(meta_data_weak, None), (meta_data_strong, '--')]): tracker.set_simulator(meta_data) for distance in [250e-6, 300e-6, 350e-6]: beam_offset = sc.gap0 / 2. - distance res_dict = iap.calc_resolution(blmeas_profile, sc.gap0, beam_offset, 1., tracker, n_streaker, bins=(75, 50)) tt = res_dict['time'] res = res_dict['resolution'] sp_res.plot(tt * 1e15, res * 1e15, label='Setting %i %i $\mu$m' % (n_meta, round(distance * 1e6)), ls=ls) tracker.quad_wake = False sp_res.set_ylim(0, 10) sp_res.legend(title='Distance to jaw')
plot_handles = streaker_calibration.gauss_recon_figure(figsize=(9, 6)) sc.plot_reconstruction(blmeas_profile=blmeas_profile, plot_handles=plot_handles) ms.figure('Resolution') subplot = ms.subplot_factory(2, 2, grid=False) sp_ctr = 1 sp_res = subplot(sp_ctr, title='Resolution', xlabel='t (fs)', ylabel='R (fs)') sp_current = sp_res.twinx() blmeas_profile.plot_standard(sp_current, color='black') tracker.n_emittances = [300e-9, 300e-9] tracker.n_particles = int(200e3) #blmeas_profile.reshape(int(10e3)) for offset0, beam_offset in zip(sc.offsets, beam_offset_arr): if offset0 <= 0: continue t_axis, resolution = iap.calc_resolution(blmeas_profile, gap, beam_offset, 1, tracker, 1) _label = '%.2f mm' % (beam_offset * 1e3) sp_res.plot(t_axis * 1e15, resolution * 1e15, label=_label) sp_res.set_ylim(0, 20) sp_res.legend() ms.show()
mask_positive = offsets > 0 mask_negative = offsets < 0 for mask, label in [(mask_positive, 'Pos'), (mask_negative, 'Neg')]: if np.any(mask): offsets_os = offsets[mask] cent_os = centroid_mean[mask] cent_err_os = centroid_std[mask] xx_plot = gap_fit / 2. - np.abs(offsets_os - 370e-6) yy_plot = np.abs(cent_os - screen_x0) ls = '--' if label == 'Pos' else None sp_one_sided.errorbar(xx_plot * 1e3, yy_plot * 1e3, yerr=cent_err_os * 1e3, label='%i %s %i' % (ctr, label, streaker_offset * 1e6), ls=ls) tracker.quad_wake = True blmeas_profile = calib_dict['blmeas_profile'] tt, res = iap.calc_resolution(blmeas_profile, gap_fit, offsets[0], 1, tracker, 1) sp_res.plot(tt * 1e15, res * 1e15) sp_res.set_ylim(0, 20) sp_center.legend() sp_one_sided.legend() plt.show()