Пример #1
0
def load_multibunch_beam(dirname, reset_i_turns=True):
    import PyPARIS.myfilemanager as mfm
    import PyPARIS.communication_helpers as ch

    print(('Loading the beam from %s' % dirname))

    bzero = ch.buffer_2_beam(
        mfm.dict_of_arrays_and_scalar_from_h5(dirname +
                                              '/bunch0.h5')['bunchbuffer'])
    N_bunches_tot_beam = bzero.slice_info['N_bunches_tot_beam']
    list_bunches = [bzero]
    for ibun in range(1, N_bunches_tot_beam):
        list_bunches.append(
            ch.buffer_2_beam(
                mfm.dict_of_arrays_and_scalar_from_h5(dirname + '/bunch%d.h5' %
                                                      ibun)['bunchbuffer']))

    list_bunches = list_bunches[::-1]  # We want the last bunch to be in pos 0
    if reset_i_turns:
        for bb in list_bunches:
            bb.slice_info['i_turn'] = 0

    return list_bunches
Пример #2
0
	def buffer_to_piece(self, buf):
		piece = ch.buffer_2_beam(buf)
		return piece
Пример #3
0


# re-split buffer
list_buffers_rec = ch.split_float_buffers(big_buffer)

# Plot including sub-slicing
fig1 = plt.figure(1, figsize=(8, 6*1.3))
fig1.set_facecolor('w')
sp1 = plt.subplot(3,1,1)
sp2 = plt.subplot(3,1,2, sharex=sp1)
sp3 = plt.subplot(3,1,3, sharex=sp1)


for ibuf, buf in enumerate(list_buffers_rec):
        ss = ch.buffer_2_beam(buf)
        #sp1.axvline(x=ss.slice_info['z_bin_center'], color='k', alpha=0.3, linestyle='--')
        sp1.axvspan(xmin=ss.slice_info['z_bin_left'], xmax=ss.slice_info['z_bin_right'],
            color={0:'green', 1:'orange'}[ibuf%2], alpha = 0.3)
        sp2.stem([ss.slice_info['z_bin_center']], [ss.slice_info['interact_with_EC']])
        sp3.stem([ss.slice_info['z_bin_center']], [ss.slice_info['i_slice']])
sp1.plot(thin_slice_set.z_centers, thin_slice_set.lambda_z(smoothen=False),'-', linewidth=2, color='k')

# check bunch merge
list_bunches_rec = []
for ibun, lbun in enumerate(list_bunch_buffers):
    list_sl = list(map(ch.buffer_2_beam, lbun))
    list_bunches_rec.append(st.merge_slices_into_bunch(list_sl))
    
fig2 = plt.figure(2, figsize=(8, 6*1.3))
fig2.set_facecolor('w')
Пример #4
0
 def buffer_to_piece(self, buf):
     piece = ch.buffer_2_beam(buf)
     return piece