Skip to content

Commit

Permalink
Current status
Browse files Browse the repository at this point in the history
  • Loading branch information
lmether committed Dec 11, 2019
1 parent 54de385 commit ccec211
Show file tree
Hide file tree
Showing 10 changed files with 692 additions and 162 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.pyc
*.mp4
*.png
*.h5
*.mat
*~
85 changes: 72 additions & 13 deletions 000_make_matrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,71 @@

import PyPARIS.myfilemanager as mfm

sim_folder = '../PyECLOUD_coupled_bunch_example'
tag = 'noecloud'
n_rings = 3
sim_folder = '../HL-LHC_coupled_bunch_450GeV_1.1e11_144b'
tag = 'HL_1.1e11_144b'
n_rings = 100
n_parts = 2

sim_folder = '../HL-LHC_coupled_bunch_450GeV_1.1e11_144b_damper'
tag = 'HL_1.1e11_144b_fb'
n_rings = 100
n_parts = 1

sim_folder = '../HL-LHC_coupled_bunch_450GeV_2.3e11_144b'
tag = 'HL_2.3e11_144b'
n_rings = 100
n_parts = 2

sim_folder = '../HL-LHC_coupled_bunch_450GeV_2.3e11_144b_damper'
tag = 'HL_2.3e11_144b_fb'
n_rings = 100
n_parts = 6

sim_folder = '../HL-LHC_coupled_bunch_450GeV_2.3e11_144b_damper_100turns'
tag = 'HL_2.3e11_144b_fb_100t'
n_rings = 100
n_parts = 6

sim_folder = '../HL-LHC_coupled_bunch_450GeV_2.3e11_144b_Qp15'
tag = 'HL_2.3e11_144b_Qp15'
n_rings = 100
n_parts = 2 #2nd part not finished

sim_folder = '../HL-LHC_coupled_bunch_450GeV_2.3e11_144b_Qp15_damper'
tag = 'HL_2.3e11_144b_Qp15_fb'
n_rings = 100
n_parts = 2 #?

sim_folder = '../HL-LHC_coupled_bunch_450GeV_2.3e11_144b_Qp0_Koct-4.5'
tag = 'HL_2.3e11_144b_Koct-4.5'
n_rings = 100
n_parts = 3 #2nd part not finished

sim_folder = '../HL-LHC_coupled_bunch_450GeV_2.3e11_144b_Qp0_Oct-4.5_damper'
tag = 'HL_2.3e11_144b_Koct-4.5_fb'
n_rings = 100
n_parts = 3 #?

sim_folder = '../HL-LHC_coupled_bunch_450GeV_2.3e11_144b_Qp15_Oct-4.5'
tag = 'HL_2.3e11_144b_Qp15_Koct-4.5'
n_rings = 100
n_parts = 3 #2nd part not finished

sim_folder = '../HL-LHC_coupled_bunch_450GeV_2.3e11_144b_Qp15_Oct-4.5_damper'
tag = 'HL_2.3e11_144b_Qp15_Koct-4.5_fb'
n_rings = 100
n_parts = 3 #?

# sim_folder = '../HL-LHC_coupled_bunch_450GeV_2.3e11_144b_sey1.5'
# tag = 'HL_2.3e11_144b_sey1.5'
# n_rings = 100
# n_parts = 2

# sim_folder = '../HL-LHC_coupled_bunch_450GeV_2.3e11_144b_sey1.5_both_planes'
# tag = 'HL_2.3e11_144b_sey1.5_xy'
# n_rings = 100
# n_parts = 2

to_be_saved = [
'epsn_x',
'epsn_y',
Expand All @@ -25,14 +85,14 @@


def make_part_matrices(list_files, to_be_saved):

dict_data = mfm.monitorh5list_to_dict(list_files, permissive=True)

print 'Data loaded!'

n_turns = int(np.max(dict_data['i_turn']))+1
n_bunches = int(np.max(dict_data['i_bunch']))+1

list_bunches = []
for i_bunch_obs in range(n_bunches):
print('Bunch %d/%d'%(i_bunch_obs, n_bunches))
Expand All @@ -43,16 +103,16 @@ def make_part_matrices(list_files, to_be_saved):
if dict_data['macroparticlenumber'][ii] > 0:
for kk in dict_data.keys():
dict_bunch[kk][i_turn] = dict_data[kk][ii]

list_bunches.append(dict_bunch)


dict_matrices = {kk: np.zeros((n_turns, n_bunches)) for kk in to_be_saved}

for i_bunch_obs in range(n_bunches):
n_turns_this = len(list_bunches[i_bunch_obs]['epsn_x'])
mask_notnan = ~np.isnan(list_bunches[i_bunch_obs]['macroparticlenumber'])

for kk in to_be_saved:
dict_matrices[kk][:n_turns_this, i_bunch_obs][mask_notnan] =\
list_bunches[i_bunch_obs][kk][mask_notnan]
Expand All @@ -71,4 +131,3 @@ def make_part_matrices(list_files, to_be_saved):

import scipy.io as sio
sio.savemat(tag+'_matrices.mat', dict_matrices, oned_as='row')

77 changes: 70 additions & 7 deletions 000s_make_slice_matrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,73 @@

import PyPARIS.myfilemanager as mfm

sim_folder = '../HL-LHC_coupled_bunch_450GeV_2.3e11_144b_sim_class'
tag = 'simclass_test'
n_rings = 10
n_parts = 6
sim_folder = '../HL-LHC_coupled_bunch_450GeV_1.1e11_144b'
tag = 'HL_1.1e11_144b'
n_rings = 100
n_parts = 2

sim_folder = '../HL-LHC_coupled_bunch_450GeV_2.3e11_144b'
tag = 'HL_2.3e11_144b'
n_rings = 100
n_parts = 2

sim_folder = '../HL-LHC_coupled_bunch_450GeV_2.3e11_144b_Qp15'
tag = 'HL_2.3e11_144b_Qp15'
n_rings = 100
n_parts = 2 #2nd part not finished

sim_folder = '../HL-LHC_coupled_bunch_450GeV_2.3e11_144b_Qp0_Koct-4.5'
tag = 'HL_2.3e11_144b_Koct-4.5'
n_rings = 100
n_parts = 3 #2nd part not finished

sim_folder = '../HL-LHC_coupled_bunch_450GeV_2.3e11_144b_Qp15_Oct-4.5'
tag = 'HL_2.3e11_144b_Qp15_Koct-4.5'
n_rings = 100
n_parts = 3 #2nd part not finished

sim_folder = '../HL-LHC_coupled_bunch_450GeV_2.3e11_144b_sey1.5'
tag = 'HL_2.3e11_144b_sey1.5'
n_rings = 100
n_parts = 2

sim_folder = '../HL-LHC_coupled_bunch_450GeV_2.3e11_144b_sey1.5_both_planes'
tag = 'HL_2.3e11_144b_sey1.5_xy'
n_rings = 100
n_parts = 2

sim_folder = '../HL-LHC_coupled_bunch_450GeV_1.1e11_144b_damper'
tag = 'HL_1.1e11_144b_fb'
n_rings = 100
n_parts = 1

sim_folder = '../HL-LHC_coupled_bunch_450GeV_2.3e11_144b_damper'
tag = 'HL_2.3e11_144b_fb'
n_rings = 100
# n_parts = 6
n_parts = 4 ### Too much data for saving all 6 parts to file ###

sim_folder = '../HL-LHC_coupled_bunch_450GeV_2.3e11_144b_damper_100turns'
tag = 'HL_2.3e11_144b_fb_100t'
n_rings = 100
# n_parts = 6
n_parts = 4 ### Too much data for saving all 6 parts to file ###

sim_folder = '../HL-LHC_coupled_bunch_450GeV_2.3e11_144b_Qp15_damper'
tag = 'HL_2.3e11_144b_Qp15_fb'
n_rings = 100
n_parts = 2 #?

sim_folder = '../HL-LHC_coupled_bunch_450GeV_2.3e11_144b_Qp0_Koct-4.5_damper'
tag = 'HL_2.3e11_144b_Koct-4.5_fb'
n_rings = 100
n_parts = 3 #?

# sim_folder = '../HL-LHC_coupled_bunch_450GeV_2.3e11_144b_Qp15_Koct-4.5_damper'
# tag = 'HL_2.3e11_144b_Qp15_Koct-4.5_fb'
# n_rings = 100
# n_parts = 3 #?


to_be_saved = [
'n_macroparticles_per_slice',
Expand Down Expand Up @@ -42,7 +105,7 @@ def make_part_matrices(list_files, to_be_saved):
dict_matrices = {kk: np.zeros((n_slices, n_turns, n_bunches)) for kk in to_be_saved}

for i_bunch_obs in range(n_bunches):
n_turns_this = len(list_bunches[i_bunch_obs]['mean_x'])
n_turns_this = len(list_bunches[i_bunch_obs]['mean_x'][0,:])
mask_notnan = ~np.isnan(list_bunches[i_bunch_obs]['n_macroparticles_per_slice'])

for kk in to_be_saved:
Expand All @@ -63,7 +126,7 @@ def make_part_matrices(list_files, to_be_saved):
[dd[kk] for dd in list_dicts], axis=1)

import scipy.io as sio
sio.savemat(tag+'_slice_matrices.mat', dict_matrices, oned_as='row')
mfm.dict_to_h5(dict_matrices, tag+'_slice_matrices.h5', compression='gzip')
# sio.savemat(tag+'_slice_matrices.mat', dict_matrices, oned_as='row')
mfm.dict_to_h5(dict_matrices, tag+'_matrices_slices.h5', compression='gzip')


47 changes: 41 additions & 6 deletions 001_plot_from_matrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,31 @@

import myfilemanager as mfm

tag = 'noecloud'
# tag = 'HL_1.1e11_144b'
# tag = 'HL_1.1e11_144b_fb'

# tag = 'HL_2.3e11_144b'
# tag = 'HL_2.3e11_144b_fb'
# tag = 'HL_2.3e11_144b_fb_100t'

# tag = 'HL_2.3e11_144b_Qp15'
# tag = 'HL_2.3e11_144b_Qp15_fb'

tag = 'HL_2.3e11_144b_Koct-4.5'
tag = 'HL_2.3e11_144b_Koct-4.5_fb'

tag = 'HL_2.3e11_144b_Qp15_Koct-4.5'
tag = 'HL_2.3e11_144b_Qp15_Koct-4.5_fb'

# tag = 'HL_2.3e11_144b_sey1.5'
# tag = 'HL_2.3e11_144b_sey1.5_xy'

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

x_mat = ob.mean_x
y_mat = ob.mean_y
ex_mat = ob.epsn_x
ey_mat = ob.epsn_y
n_mat = ob.macroparticlenumber

n_turns = x_mat.shape[0]
Expand All @@ -18,16 +37,32 @@

plt.close('all')

fig1 = plt.figure(1)
axx = plt.subplot(3,1,1)
fig1 = plt.figure(1, figsize=(8*1.5, 6*1.3))
axx = plt.subplot(3,2,1)
axx.plot(x_mat[:,mask_bunch])
axy = plt.subplot(3,1,2, sharex=axx)
axy = plt.subplot(3,2,3, sharex=axx)
axy.plot(y_mat[:,mask_bunch])
axn = plt.subplot(3,1,3, sharex=axx)
axn = plt.subplot(3,2,5, sharex=axx)
axn.plot(n_mat[:,mask_bunch])

mask_e = np.logical_and(ex_mat[:,mask_bunch] > 0, ey_mat[:,mask_bunch] > 0)

axex = plt.subplot(3,2,2)
axex.plot(ex_mat[:,mask_bunch])
# axex.ticklabel_format(axis='y', style='sci', scilimits=(0,0))
axey = plt.subplot(3,2,4, sharex=axx)
axey.plot(ey_mat[:,mask_bunch])
# axey.ticklabel_format(axis='y', style='sci', scilimits=(0,0))
axen = plt.subplot(3,2,6, sharex=axx)
axen.plot(n_mat[:,mask_bunch])

for ax in [axex, axey]:
ax.ticklabel_format(axis='y', style='sci', scilimits=(0,0))
ax.set_ylim(bottom=2.4e-6)
plt.savefig('Overview_%s.png'%(tag), dpi=200)


i_turn = 3
i_turn = 800

figm = plt.figure(10, figsize=(8,6*1.3))
axm1 = figm.add_subplot(3,1,1)
Expand Down
Loading

0 comments on commit ccec211

Please sign in to comment.