Ejemplo n.º 1
0
i_turn = 300

obbea = mfm.myloadmat_to_obj(tag+'_matrices.mat')

x_mat = obbea.mean_x
y_mat = obbea.mean_y
n_mat = obbea.macroparticlenumber

n_turns = x_mat.shape[0]

mask_bunch = n_mat[1, :]>0
n_bunches = np.sum(mask_bunch)
bslots = np.where(mask_bunch)[0]/N_slots_bsp

plt.close('all')
ms.mystyle_arial(fontsz=16, dist_tick_lab=5)

figrt = plt.figure(2000)
axx = plt.subplot(3,1,1)
axx.plot(x_mat[:,mask_bunch])
axy = plt.subplot(3,1,2, sharex=axx)
axy.plot(y_mat[:,mask_bunch])
axn = plt.subplot(3,1,3, sharex=axx)
axn.plot(n_mat[:,mask_bunch])

figm = plt.figure(10, figsize=(8,6*1.3))
axm1 = figm.add_subplot(3,1,1)
axm2 = figm.add_subplot(3,1,2, sharex=axm1)
axm3 = figm.add_subplot(3,1,3, sharex=axm1)

mask_bunch = n_mat[1, :]>0
Ejemplo n.º 2
0
tau_damp_y = 100.

flag_check_Qs = True
Q_s = np.nan

#ob = mfm.monitorh5_to_obj('bunch_evolution_00.h5')
ob = mfm.monitorh5list_to_obj(
        ['bunch_evolution_%02d.h5'%ii for ii in range(3)])


plt.close('all')

# Plot transverse positions
fig1 = plt.figure(1, figsize=(8,6*1.2))
fig1.set_facecolor('w')
ms.mystyle_arial(fontsz=16)

axx = fig1.add_subplot(2,1,1)
axy = fig1.add_subplot(2,1,2, sharex=axx)

axx.plot(ob.mean_x)
axy.plot(ob.mean_y)

if flag_check_damp_time:
    turn_num = np.arange(0, len(ob.mean_x), dtype=np.float)
    ix_max = np.argmax(ob.mean_x)
    iy_max = np.argmax(ob.mean_y)

    axx.plot(ob.mean_x[ix_max]*np.exp(-(turn_num-ix_max)/tau_damp_x),
            linewidth=2, color='red', linestyle='--',
            label=r'Damping time = %.0f turns'%tau_damp_x)
deltas_r = extract_sey_curves(n_rep,
                              E_impact_eV_test_r,
                              cos_theta_test,
                              charge=qe,
                              mass=me)

del_true_mat = deltas['true']
del_elast_mat = deltas['elast']
del_rediff_mat = deltas['rediff']
del_absorb_mat = deltas['absorb']

del_elast_mat_2 = deltas_e['elast']
del_rediff_mat_2 = deltas_r['rediff']

plt.close('all')
ms.mystyle_arial()

fig1 = plt.figure(1, figsize=(3 * 8, 2 * 8))
fig1.set_facecolor('w')
sp1 = fig1.add_subplot(2, 3, 1)
sp2 = fig1.add_subplot(2, 3, 2, sharex=sp1)
sp3 = fig1.add_subplot(2, 3, 3, sharex=sp1)
sp4 = fig1.add_subplot(2, 3, 4, sharex=sp1)
sp5 = fig1.add_subplot(2, 3, 5, sharex=sp1)
sp6 = fig1.add_subplot(2, 3, 6, sharex=sp1)

fig_ts = plt.figure(2, figsize=(12, 9), facecolor='white')
plt.xticks(fontsize=sz - 5)
plt.yticks(fontsize=sz - 5)
plt.subplots_adjust(bottom=.11)
sp_ts = fig_ts.add_subplot(1, 1, 1)
Ejemplo n.º 4
0
Qp_tag_vect = []
for index_tag,Qp_x in enumerate(Qp_x_vect):
    
    if Qp_x < 0:
        Qp_tag_vect.append(('minus' + '%s')%(np.abs(Qp_x)))

    else:
        Qp_tag_vect.append(Qp_x) 


folder_plot = 'footprint'
if not os.path.exists(folder_plot):
    os.makedirs(folder_plot)


ms.mystyle_arial(18)
i_fig = 0
#~ for betax, betay in zip(betax_vect, betay_vect):
    
    #~ for fraction_device_quad in fraction_device_quad_vec:

# 1. Intensity
for intensity in intensity_vect:

    # 2. Chromaticity
    for Qp_x,Qp_y,Qp_tag in zip(Qp_x_vect,Qp_y_vect,Qp_tag_vect):
             
        sim_ident = '../simulations_PyPARIS/Inj_ArcQuad_T0_x_slices_750_seg_8_MPslice_5e3_eMPs_250e3_length_7_VRF_4MV_intensity_%.1fe11ppb_Qp_xy_%s'%(intensity/1e11,Qp_tag)           
        filename_footprint = 'footprint.h5'
        print sim_ident
        
Ejemplo n.º 5
0
t_ref_str = '13-04-2015 07:00'
t_ref = time.mktime(time.strptime(t_ref_str, '%d-%m-%Y %H:%M'))	

filename='bct_overview.pkl'
with open(filename) as fid:
    beams_bct = pickle.load(fid)
	
filename='ws_overview.pkl'
with open(filename) as fid:
    ws_dict = pickle.load(fid)
	
list_SPSusers = [ 'MD3' ]

pl.close('all')
ms.mystyle_arial(fontsz=16, dist_tick_lab=10)
fig = pl.figure(figsize=(14,12))

for SPSuser in list_SPSusers:
    n_ws_meas = len(ws_dict[SPSuser]['timestamp_ws'])

    for ii in range(n_ws_meas):
        try:
            pl.clf()
            sp1 = pl.subplot2grid((3,2), (0,0), colspan=2, rowspan=1)
            for SPSuser_ in beams_bct.keys():
                pl.plot((np.array(beams_bct[SPSuser_]['timestamp_float'])-t_ref)/3600/24., np.array(beams_bct[SPSuser_]['bct_max_vect']),'.', label=SPSuser_)
        
            timestamp_bct = ws_dict[SPSuser]['timestamp_bct'][ii]
            timestamp_ws = ws_dict[SPSuser]['timestamp_ws'][ii]
            sp1.axvline(x=(timestamp_bct- t_ref)/24./3600, color = 'k', linestyle='--', linewidth = 3)
Ejemplo n.º 6
0
smooth = partial(gaussian_filter1d, sigma=2, mode='nearest')

n_turns_window = 20
n_sigmaz_sim = 10. #we are simulating 10 long sigmas
i_want_to_count_over = 4.
flag_weighted =  True


#Figure parameters
ii_fig = 0
tick_size = 20
axis_font = {'fontname':'Arial', 'size':'24'}
fig_size = (15, 5)
line_width = 3.5

ms.mystyle_arial(16)


# calculate intra-bunch modes
for fraction_device_quad in fraction_device_quad_vect:
        
        kk = np.argmin(np.abs(dic['fraction_device_quad_vect']-fraction_device_quad))
    for betax, betay in zip(betax_vect, betay_vect):
                jj = np.argmin(np.abs(dic['betax_vect']-betax)) 
        subfolder_plot = folder_plot + 'betaxy_%d_length_%.2f/'%(betax,fraction_device_quad)
        if not os.path.exists(subfolder_plot) and savefigure:
            os.makedirs(subfolder_plot)
        
        for n_slices in n_slices_vect:
                        ii = np.argmin(np.abs(dic['n_slices_vect']-n_slices)) 
            if not math.isnan(tt[ii,jj,kk]):
    print('Done extracting emission angles.')

    return cos_theta_emit, divider, flag_divide_by_zero


# Test parameters
cos_theta_test = 0.7
E_impact_eV_test = 300.
n_rep = int(5e5)
# Extraction
cos_theta_emit, divider, flag_divide_by_zero = extract_emission_angles(
    n_rep, E_impact_eV_test, cos_theta_test, charge=qe, mass=me)

plt.close('all')
ms.mystyle_arial(25)

# Plotting emission angles
plt.figure(1, facecolor='white', figsize=(12, 9))
plt.hist(np.arccos(cos_theta_emit), density=True, bins=60)
plt.xlabel(r'$\theta_{emit}$')
plt.ylabel('Normalized emission angle spectrum')
plt.title('cos_theta_imp=%.2f' % cos_theta_test)
plt.grid(alpha=.5)

plt.figure(2, facecolor='white', figsize=(12, 9))
plt.hist(cos_theta_emit, density=True, bins=60)
plt.xlabel(r'cos($\theta_{emit}$)')
plt.title('cos_theta_imp=%.2f' % cos_theta_test)
plt.ylabel('Normalized emission angle spectrum')
plt.grid(alpha=.5)
Ejemplo n.º 8
0
        sp3.set_ylabel('Charge weighted\nhorizontal centroid rms [a.u]')
        sp4.set_ylabel('Charge weighted\nvertical centroid rms [a.u]')
        sp5.set_ylabel('Normalized emittance x [um]')
        sp6.set_ylabel('Normalized emittance y [um]')
        sp7.set_ylabel('Number of macroparticles')
        sp8.set_ylabel('Bunch length (4$\sigma$) [ns]')

        #sp1.set_xlim(0, 1.0)
        for sp in [sp1, sp2, sp3, sp4, sp5, sp6, sp7, sp8]:
            sp.set_xlabel('Turns')
            sp.ticklabel_format(useOffset=False)
            sp.grid('on')
            ms.sciy()
            #~ sp.set_xlim(0, 20000)

        ms.mystyle_arial(14)
        gs1.tight_layout(fig, rect=[0.02, 0, 0.86, .95], w_pad=.2, h_pad=1.5)
        #~ title = fig.suptitle(os.getcwd().split('/')[-2])
        title = fig.suptitle(
            'ArcQuad:   Segments = %d   MPs/Slice = %d   Length: %.2f   Beta_xy: %.0f m'
            % (n_segments, macroparticles_per_slice, fraction_device_quad,
               betax))
        #~ pl.title('ArcQuad Drift    Length = %.2f'%(fraction_device_quad))
        if savefigures:
            fig.savefig(folder_plot + 'scanSlice_length%.2f_betaxy%.0f.png' %
                        (fraction_device_quad, betax),
                        dpi=300,
                        bbox_inches='tight',
                        bbox_extra_artists=[legend, title])

pl.show()
Ejemplo n.º 9
0
t_ref_str = '13-04-2015 07:00'
t_ref = time.mktime(time.strptime(t_ref_str, '%d-%m-%Y %H:%M'))	

filename = 'bct_overview.pkl'
with open(filename) as fid:
	beams_bct = pickle.load(fid)

filename='ecm_overview.pkl'
with open(filename) as fid:
	beams_ecm = pickle.load(fid)
	
# ylim_ec_max = 3.5e5
# thresh_max_good_shot = 1.1e11

pl.close('all')
ms.mystyle_arial(fontsz=13, dist_tick_lab=10)
#ms.mystyle(fontsz=13)

for ecm_id in '1a 1b 2a 2b'.split():

	fig = pl.figure()
	for SPS_user in beams_ecm[ecm_id].keys():

		N_cycles = len(np.array(beams_bct[SPS_user]['bct_1st_inj']))

      		# mask_good_shots = np.array(beams_bct[SPS_user]['bct_max_vect']) > thresh_max_good_shot

		sp1 = pl.subplot(4,1,1)
		pl.plot((array(beams_bct[SPS_user]['timestamp_float'])-t_ref)/3600./24., array(beams_bct[SPS_user]['bct_max_vect']),'.', label = SPS_user)
		ms.sciy()
		pl.grid('on')
Ejemplo n.º 10
0
flag_check_damp_time = True
tau_damp_x = 200.
tau_damp_y = 100.

flag_check_Qs = True
Q_s = 5.664e-03

ob = mfm.myloadmat_to_obj(tag+'_matrices.mat')

plt.close('all')

# Plot transverse positions
fig1 = plt.figure(1, figsize=(8,6*1.2))
fig1.set_facecolor('w')
ms.mystyle_arial(fontsz=16)

axx = fig1.add_subplot(2,1,1)
axy = fig1.add_subplot(2,1,2, sharex=axx)

axx.plot(ob.mean_x[:, i_bunch])
axy.plot(ob.mean_y[:, i_bunch])

if flag_check_damp_time:
    turn_num = np.arange(0, len(ob.mean_x[:, i_bunch]), dtype=np.float)
    axx.plot(ob.mean_x[0, i_bunch]*np.exp(-turn_num/tau_damp_x), 
            linewidth=2, color='red', linestyle='--',
            label=r'Damping time = %.0f turns'%tau_damp_x)
    axy.plot(ob.mean_y[0, i_bunch]*np.exp(-turn_num/tau_damp_y), 
            linewidth=2, color='red', linestyle='--',
            label=r'Damping time = %.0f turns'%tau_damp_y)