示例#1
0
        def gaussian_baf(sig_t):
            sig_t = np.round(sig_t / prec) * prec
            if sig_t in sig_t_list:
                return
            assert 1e-15 < sig_t < 1e-12

            bp_gauss = iap.get_gaussian_profile(sig_t, float(tt_halfrange),
                                                int(self.len_screen),
                                                float(charge),
                                                float(self.energy_eV))

            if self_consistent:
                bp_back0 = self.track_backward2(meas_screen, bp_gauss, gaps,
                                                beam_offsets, n_streaker)
            else:
                bp_back0 = bp_gauss

            baf = self.back_and_forward(meas_screen, bp_back0, gaps,
                                        beam_offsets, n_streaker)
            screen = copy.deepcopy(baf['screen'])
            diff = screen.compare(meas_screen)
            bp_out = baf['beam_profile']

            index = bisect.bisect(sig_t_list, sig_t)
            sig_t_list.insert(index, sig_t)
            opt_func_values.insert(index, (float(sig_t), diff))
            opt_func_screens.insert(index, screen)
            opt_func_profiles.insert(index, bp_out)
            opt_func_sigmas.insert(index, sig_t)
            opt_func_screens_no_smoothen.insert(index,
                                                baf['screen_no_smoothen'])
            gauss_profiles.insert(index, bp_gauss)
            gauss_wakes.insert(index, baf['wake_dict'])
示例#2
0
 def set_bs_at_streaker(self):
     test_profile = iap.get_gaussian_profile(40e-15, 200e-15,
                                             self.len_screen, 200e-12,
                                             self.energy_eV)
     forward_dict = self.matrix_forward(test_profile, [10e-3, 10e-3],
                                        [0, 0])
     self.bs_at_streaker = forward_dict['bs_at_streaker']
示例#3
0
    def fit_emittance(self, target_beamsize, assumed_screen_res, tt_halfrange):
        if target_beamsize <= assumed_screen_res:
            raise ValueError(
                'Target beamsize must be larger assumed screen resolution')

        bp_test = iap.get_gaussian_profile(40e-15, tt_halfrange,
                                           self.len_screen, 200e-12,
                                           self.energy_eV)
        screen_sim = self.matrix_forward(bp_test, [10e-3, 10e-3],
                                         [0, 0])['screen_no_smoothen']

        target_beamsize2 = np.sqrt(target_beamsize**2 - assumed_screen_res**2)
        sim_beamsize = screen_sim.gaussfit.sigma
        emittance = self.n_emittances[0]
        emittance_fit = emittance * (target_beamsize2 / sim_beamsize)**2
        return emittance_fit
median_screen.cutoff2(3e-2)
median_screen.crop()
median_screen.reshape(len_profile)

tracker = tracking.Tracker(magnet_file=magnet_file, timestamp=timestamp, n_particles=n_particles, n_emittances=n_emittances, screen_bins=screen_bins, screen_cutoff=screen_cutoff, smoothen=smoothen, profile_cutoff=profile_cutoff, len_screen=len_profile, bp_smoothen=bp_smoothen, quad_wake=False)

energy_eV = tracker.energy_eV
blmeas = data_dir+'113876237_bunch_length_meas.h5'

profile_meas = iap.profile_from_blmeas(blmeas, 200e-15, charge, energy_eV)
profile_meas.cutoff(5e-2)
profile_meas.reshape(len_profile)
profile_meas.crop()
tt_range = (profile_meas.time.max() - profile_meas.time.min())

profile_gauss = iap.get_gaussian_profile(38e-15, tt_range, len_profile, charge, energy_eV)



bp_back = tracker.track_backward2(median_screen, profile_gauss, gaps, beam_offsets, 1)

bp_back2 = tracker.track_backward2(median_screen, bp_back, gaps, beam_offsets, 1)

#bp_back3 = tracker.track_backward2(median_screen, bp_back2, gaps, beam_offsets, 1)

#bp_back4 = tracker.track_backward2(median_screen, bp_back3, gaps, beam_offsets, 1)

median_screen.plot_standard(sp_screen, label='Measured', color='black')
def get_color(label):
    if 'measured' in label:
        return 'black'
示例#5
0
    if fit_emittance and main_label != 'Short':

        timestamp0 = misc.get_timestamp(os.path.basename(p_dict['filename0']))
        tracker0 = tracking.Tracker(magnet_file,
                                    timestamp0,
                                    struct_lengths,
                                    n_particles,
                                    n_emittances,
                                    screen_bins,
                                    screen_cutoff,
                                    smoothen,
                                    profile_cutoff,
                                    len_profile,
                                    quad_wake=quad_wake)

        bp_test = iap.get_gaussian_profile(40e-15, tt_halfrange, len_profile,
                                           charge, tracker0.energy_eV)
        screen_sim = tracker0.matrix_forward(bp_test, [10e-3, 10e-3],
                                             [0, 0])['screen']
        all_emittances = []
        all_beamsizes = []
        for proj in projx0:
            screen_meas = get_screen_from_proj(proj, x_axis0, invert_x0)
            all_beamsizes.append(screen_meas.gaussfit.sigma)
            emittance_fit = misc.fit_nat_beamsize(screen_meas,
                                                  screen_sim,
                                                  n_emittances[0],
                                                  smoothen,
                                                  print_=False)
            #print(screen_meas.gaussfit.sigma)
            all_emittances.append(emittance_fit)
示例#6
0
gaps = [10e-3, 10e-3]

beam_profile = iap.profile_from_blmeas(blmeas_file, tt_halfrange, charge,
                                       tracker.energy_eV, True, 1)
beam_profile.reshape(tracker.len_screen)
beam_profile.cutoff2(tracker_kwargs['profile_cutoff'])
beam_profile.crop()
beam_profile.reshape(tracker.len_screen)

gauss_sigma = beam_profile.rms()

gauss_profile = iap.get_gaussian_profile(
    gauss_sigma,
    tt_halfrange,
    tracker_kwargs['len_screen'],
    charge,
    tracker.energy_eV,
    cutoff=tracker_kwargs['profile_cutoff'])

ms.figure('Forward propagated jaw distance scaling', figsize=(26, 13))
subplot = ms.subplot_factory(2, 3)
sp_ctr = 1
sp_profile = subplot(sp_ctr,
                     xlabel='t (fs)',
                     ylabel='I (kA)',
                     title='Current profile')
sp_ctr += 1
sp_centroids = subplot(sp_ctr,
                       xlabel='d ($\mu$m)',
                       ylabel='$\Delta$x (mm)',