-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_analysis_cycle.py
1540 lines (1404 loc) · 69.9 KB
/
data_analysis_cycle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import points_analysis_2D as pa
import numpy as np
import matplotlib.pyplot as plt
import os
import proceed_file as pf
def save_exp_20230113_6(i, stable=True):
R"""
import data_analysis_cycle as dac
dac.save_exp_20230113_6()
"""
import pandas as pd
import particle_tracking as pt
spe = pt.save_points_from_exp()
path_to_folder = '/home/remote/xiaotian_file/data/20230113'
video_name = 'DefaultVideo_6'
spe.set_worksapce(path_to_folder, video_name)
tsf_filename = 'trap_honeycomb_part.txt'
# image size
pixel_size = np.array([1008, 1014])
pixel_to_um = 3.0/32.0
um_size = pixel_size*pixel_to_um
# trap location
# adjust coordinations to match particle and traps
# standard_tune, precise_tune
center = np.array([48, 48])+[10, 10]
trap_locate = np.array([38.53, -40.92])+np.array([13, -11])
xy_adjust = center+trap_locate
pos, trap_filename = spe.get_trap_positions(tsf_filename, xy_adjust, 1, 90)
directory = spe.path_to_results+'/'
dataname = video_name
if stable:
txyz = np.load(directory+'txyz_stable.npy')
xyi = txyz[i]
else:
txyz = pd.read_csv(directory+'txyz.csv')
frame_num = txyz['frame'].values.max()+1
if i < 0:
i = frame_num+i
txyz_ith = txyz[txyz['frame'] == i]
xyi = txyz_ith[['x', 'y', 'z']].values
xyi = xyi*pixel_to_um
a_frame = pa.static_points_analysis_2d(xyi)
data_name = dataname
prefix = directory
trap_filename = trap_filename
bond_cut_off = 8
trap_lcr = 0.8
str_index = data_name
png_filename1 = prefix + 'bond_hist_index'+str_index+'_'+str(int(i))+'.png'
png_filename2 = prefix + 'bond_plot_1st_minima_index'+str_index+'_'+str(int(i))+'.png'
a_frame.get_first_minima_bond_length_distribution(
lattice_constant=1, hist_cutoff=bond_cut_off, png_filename=png_filename1) # ,png_filename=png_filename1
a_frame.draw_bonds_conditional_bond_oop(
check=[0.4, a_frame.bond_first_minima_left],
png_filename=png_filename2, x_unit='(um)', LinearCompressionRatio=trap_lcr,
trap_filename=trap_filename, axis_limit=um_size)
# dpa = pa.dynamic_points_analysis_2d(txyz,'exp')
# dpa.plot_bond_neighbor_change_oop(data_name=dataname,prefix=directory,final_cut=True,#init_cut=True,#final_cut=True,
# trap_filename=trap_filename,bond_cut_off=10,
# trap_lcr=0.8)
def save_exp_20230113_8(i, stable=True):
R"""
import data_analysis_cycle as dac
dac.save_exp_20230113_6()
"""
import pandas as pd
import particle_tracking as pt
spe = pt.save_points_from_exp()
path_to_folder = '/home/remote/xiaotian_file/data/20230113'
video_name = 'DefaultVideo_8'
spe.set_worksapce(path_to_folder, video_name)
tsf_filename = 'trap_kagome_part.txt'
# image size
pixel_size = np.array([1024, 1024])
pixel_to_um = 3.0/32.0
um_size = pixel_size*pixel_to_um
# trap location
# adjust coordinations to match particle and traps
# standard_tune, precise_tune
center = np.array([48, 48])+[10, 10]
trap_locate = np.array([30.55, -38.26])+np.array([0.5, -9])
xy_adjust = center+trap_locate
pos, trap_filename = spe.get_trap_positions(tsf_filename, xy_adjust, 1, 90)
directory = spe.path_to_results+'/'
dataname = video_name
if stable:
txyz = np.load(directory+'txyz_stable.npy')
xyi = txyz[i]
else:
txyz = pd.read_csv(directory+'txyz.csv')
frame_num = txyz['frame'].values.max()+1
if i < 0:
i = frame_num+i
txyz_ith = txyz[txyz['frame'] == i]
xyi = txyz_ith[['x', 'y', 'z']].values
xyi = xyi*pixel_to_um
a_frame = pa.static_points_analysis_2d(xyi)
data_name = dataname
prefix = directory
trap_filename = trap_filename
bond_cut_off = 8
trap_lcr = 0.88+0.012
str_index = data_name
png_filename1 = prefix + 'bond_hist_index'+str_index+'_'+str(int(i))+'.png'
png_filename2 = prefix + 'bond_plot_1st_minima_index'+str_index+'_'+str(int(i))+'.png'
a_frame.get_first_minima_bond_length_distribution(
lattice_constant=1, hist_cutoff=bond_cut_off, png_filename=png_filename1) # ,png_filename=png_filename1
a_frame.draw_bonds_conditional_bond_oop(
check=[0.4, a_frame.bond_first_minima_left],
png_filename=png_filename2, x_unit='(um)', LinearCompressionRatio=trap_lcr,
trap_filename=trap_filename, axis_limit=um_size)
def get_KBT_pressure(file_log):
data = np.genfromtxt(fname=file_log, skip_header=True)
average_KBT = np.average(data[300:-1, 2])
average_pressure = np.average(data[300:-1, 3])
# check temperature
return average_KBT, average_pressure
def rearrange_data():
R"""
Purpose:
merge multiple txt file [index psi_k_global psi_k_rate] into one,
and at last get
[1 2 3 4 5 ]
[index k linear_compression_ratio psi_k_global psi_k_rate]
"""
lcr_list = np.linspace(0.77, 0.88, 12)
# control pointers, not data.
# linear_compression_ratio2=0.80
fn1 = '/home/tplab/Downloads/91-102'
# fn2='/home/tplab/Downloads/103-132'
# fn3='/home/tplab/Downloads/133-192'
data1 = readdata(fn1)
# data2=readdata(fn2)
# data3=readdata(fn3)
sp1 = np.shape(data1)
# sp2=np.shape(data2)
# sp3=np.shape(data3)
data_ex = np.zeros((sp1[0], sp1[1]+2)) # +sp2[0]+sp3[0]
data_ex[0:sp1[0], 0] = data1[:, 0]
data_ex[0:sp1[0], 1] = 800
data_ex[0:sp1[0], 2] = lcr_list
data_ex[0:sp1[0], 3:5] = data1[:, 1:3]
print(data_ex)
# save_filename=fn1+'kl'
save_filename = '/home/tplab/Downloads/91-102kl'
np.savetxt(save_filename, data_ex)
'''
#merge two 5-column list
fn1='/home/tplab/Downloads/103-132kl'
fn2='/home/tplab/Downloads/133-192kl'
data1=readdata(fn1)
data2=readdata(fn2)
sp1=np.shape(data1)
sp2=np.shape(data2)
data_ex=np.zeros((sp1[0]+sp2[0],sp1[1]))
data_ex[0:sp1[0]]=data1[:]
data_ex[sp1[0]:(sp1[0]+sp2[0])]=data2[:]
'''
'''
#merge two 3-column list
data_ex[0:30,1]=k_list
data_ex[30:60,1]=k_list
data_ex[0:30,2]=linear_compression_ratio1
data_ex[30:60,2]=linear_compression_ratio2
'''
'''
#add kl for 3-column list, generate 5-column list
lcr_list=np.linspace(0.77,0.88,12)
fn1='/home/tplab/Downloads/91-102'
data1=readdata(fn1)
sp1=np.shape(data1)
data_ex=np.zeros((sp1[0],sp1[1]+2))
data_ex[0:sp1[0],0]=data1[:,0]
data_ex[0:sp1[0],1]=800
data_ex[0:sp1[0],2]=lcr_list
data_ex[0:sp1[0],3:5]=data1[:,1:3]
'''
def readdata(fn):
data = np.loadtxt(fn)
return data
def plotHarmonicKAndPsi():
data = readdata("/home/tplab/Downloads/193-205kl")
data_psi3 = data[:, [1, 3]]
data_psi6 = data[:, [1, 4]]
plt.figure()
p3 = plt.scatter(data_psi3[:, 0], data_psi3[:, 1], c='r')
p6 = plt.scatter(data_psi6[:, 0], data_psi6[:, 1], c='b')
plt.legend(handles=[p3, p6], labels=['Psi3', 'Psi6'], loc='best')
plt.xlabel('Harmonic_K')
plt.ylabel('Psi_3 & Psi6')
plt.show()
def phase_diagram(select=True):
if select:
tt = 'Psi_3_ratio' # tt='Psi_3_ratio'
prefix = '/home/tplab/Downloads/'
name = '103-192kl'
filename = prefix+name
data = readdata(filename)
k_unit = 0.5*data[:, 1]*np.multiply(1, 1)
k_unit = k_unit.astype(int)
plt.figure()
plt.scatter(data[:, 2]*100, k_unit, c=data[:, 4])
plt.title(tt+'(>0.9)(E_yukawa=233,substrate=400)')
plt.colorbar()
plt.xlabel('linear_compression_ratio/%')
plt.ylabel('depth of trap/kT')
png_filename = filename+tt
plt.savefig(png_filename)
plt.show()
else:
tt = 'Psi_3' # tt='Psi_3_ratio'
prefix = '/home/tplab/Downloads/'
name = '103-192kl'
filename = prefix+name
data = readdata(filename)
k_unit = 0.5*data[:, 1]*np.multiply(1, 1)
k_unit = k_unit.astype(int)
plt.figure()
plt.scatter(data[:, 2]*100, k_unit, c=data[:, 3])
plt.title(tt+'(E_yukawa=233,substrate=400)')
plt.colorbar()
plt.xlabel('linear_compression_ratio/%')
plt.ylabel('depth of trap/kT')
png_filename = filename+tt
plt.savefig(png_filename)
plt.show()
def phase_diagram_line(select=True):
prefix = '/home/tplab/Downloads/'
name = '91-102kl'
filename = prefix+name
data = readdata(filename)
# k_unit=0.5*data[:,1]*np.multiply(1,1)
# k_unit=k_unit.astype(int)
if select:
tt = 'Psi_3_ratio' # tt='Psi_3_ratio'
plt.figure()
plt.plot(data[:, 2]*100, data[:, 4])
plt.title(tt+'(>0.9)(E_yukawa=233,)')
plt.xlabel('linear_compression_ratio/%')
plt.ylabel(tt)
png_filename = filename+tt
plt.savefig(png_filename)
plt.show()
else:
tt = 'Psi_3' # tt='Psi_3_ratio'
plt.figure()
plt.plot(data[:, 2]*100, data[:, 3])
plt.title(tt+'(E_yukawa=233)')
plt.xlabel('linear_compression_ratio/%')
plt.ylabel(tt)
png_filename = filename+tt
plt.savefig(png_filename)
plt.show()
def save_from_gsd(
simu_index=None, seed=None, frame_cut=0, trajectory=False, save_result_txt=False,
displacement_field=False, final_cut=False, psik=False, psik_plot=None, neighbor_cloud=False,
coordination_number=False, lattice_constant=3, p_cairo=False, bond_plot=False,
bond_plot_gr=False, show_traps=False, trap_filename=None, trap_lcr=None, list_traps=None,
gr=False, sk=False, log_sk=False, msd=False, single_particle=False, account='tplab'):
R"""
Introduction:
Read a gsd file and save a series of analyzed results as follow.
trajectory:
displacement_field:
psik: global psi_k vs time.
neighbor_cloud:
coordination_number:
coordination_number3_plot:
final_cut: true to proceed the last frame only.
Format:
[Psi_3_global,Psi_6_global]
example:
import data_analysis_cycle as da
i=3003
while i<3062:
da.save_from_gsd(simu_index=i,seed=9,
bond_plot =True,
show_traps=True,
trap_filename="/home/tplab/hoomd-examples_0/testkagome_part3-11-6",
trap_lcr=0.86)
i=i+1
example2:
i=1233
while i<1243:
da.save_from_gsd(simu_index=i,final_cut=True,
bond_plot =True,
gr=True,
sk=True)#,seed=9
i+=1
example3:
import data_analysis_cycle as da
da.save_from_gsd(simu_index=4728,seed=9,
coordination_number=True,
bond_plot=True,
show_traps=True,
trap_filename='/home/tplab/hoomd-examples_0/testkagome3-11-6',
trap_lcr=0.853,
account='remote',)
"""
import freud
# prefix = "/home/remote/xiaotian_file/link_to_HDD/hoomd-examples_0/"
prefix = "/home/tplab/hoomd-examples_0/record/"
log_prefix = prefix
# prefix='/home/'+account+'/Downloads/'#'/home/tplab/Downloads/'
# log_prefix='/home/'+account+'/hoomd-examples_0/'#'/home/tplab/hoomd-examples_0/'
# /home/remote/xiaotian_file/link_to_HDD/hoomd-examples_0/testhoneycomb3-8-12-part1
# load time steps
if seed is None:
str_index = str(int(simu_index))
gsd_data = pf.proceed_gsd_file(simu_index=simu_index)
else:
str_index = str(int(simu_index))+'_'+str(seed)
file_gsd = log_prefix+'trajectory_auto'+str_index+'.gsd' # +'_'+str(seed)
gsd_data = pf.proceed_gsd_file(filename_gsd_seed=file_gsd, account=account)
"""file_log=log_prefix+'log-output_auto'+str_index+'.log'#+'_'+str(seed)
log_data = np.genfromtxt(fname=file_log, skip_header=True)
time_steps = log_data[:,0]"""
time_steps = 0 # just in case
# print(gsd_data.num_of_frames)
# gsd_data.trajectory.
if msd:
# print('this function msd is fault!')
# pass
# load particle trajectory [N_frames,N_particles,system_dimension]
"""
iframes = 0
nframes=gsd_data.num_of_frames
Np_edge_cut=np.shape(gsd_data.edge_cut_positions_list)
pos_list = np.zeros([nframes,Np_edge_cut[1],3])#gsd_data.trajectory[0].particles.N,
while iframes < nframes:
af = gsd_data.trajectory.read_frame(iframes)
pos_list[iframes] = af.particles.position[gsd_data.edge_cut_positions_list]
iframes = iframes + 1
#select particles never walking across boundaries.
cut = pa.select_particle_in_box(pos_list)
particles_reasonable=cut.compute()
msds = freud.msd.MSD(af.configuration.box)#the class is fault,,'direct'
msds.compute(positions=pos_list[:,particles_reasonable,:])#,images=pos_list
#print(msds.msd)#print(msds.particle_msd)
"""
iframes = 0
nframes = gsd_data.num_of_frames
af = gsd_data.trajectory.read_frame(iframes)
pos_list = np.zeros([nframes, af.particles.N, 3]) # gsd_data.trajectory[0].particles.N,
while iframes < nframes:
af = gsd_data.trajectory.read_frame(iframes)
pos_list[iframes] = af.particles.position
iframes = iframes + 1
msds = freud.msd.MSD(af.configuration.box) # the class is fault,,'direct'
msds.compute(positions=pos_list) # ,images=pos_list
# print(msds.msd)#print(msds.particle_msd)
# Plot the MSD
plt.figure()
plt.plot(msds.msd)
plt.title("Mean Squared Displacement")
plt.xlabel("$t$")
plt.ylabel("MSD$(t)$")
png_filename = prefix + 'msd_'+'index'+str_index+'.png'
plt.savefig(png_filename) # png_filename
plt.close()
if single_particle:
plt.figure()
lenth = np.shape(msds.particle_msd[0, :])
for i in range(lenth[0]):
# ,msds.particle_msd[:,1],msds.particle_msd[:,2])
plt.semilogy(msds.particle_msd[10:-20, i], base=10)
plt.title("Mean Squared Displacement")
plt.xlabel("$t$")
plt.ylabel("MSD$(t)$")
# plt.set_yscale("log",base=2)
png_filename = prefix + 'msd_'+'index'+str_index+'_single.png'
print(png_filename)
plt.savefig(png_filename) # png_filename
plt.close()
if trajectory:
gsd_data.plot_trajectory()
for i in range(gsd_data.num_of_frames):
if i < 0:
pass
else:
if final_cut:
i = gsd_data.num_of_frames-1 # i=9#!!! 23
list_points = np.logical_not(list_traps)
# gsd_data.read_a_frame(i),hide_figure=False
a_frame = pa.static_points_analysis_2d(
points=gsd_data.trajectory[i].particles.position[list_points, 0:2])
if save_result_txt:
result_filename = prefix+'index'+str_index
points = snap.particles.position[:] # temp
np.savetxt(result_filename, points) # temp
if displacement_field:
png_filename1 = prefix + 'Displacement_Field_xy_' + \
'index'+str_index+'_'+str(int(i))+'.png'
gsd_data.get_displacement_field_xy(i, plot=True, png_filename=png_filename1)
png_filename2 = prefix + 'Displacement_Field_hist_log_' + \
'index'+str_index+'_'+str(int(i))+'.png'
gsd_data.get_displacement_field_distribution(
i, log_mode=True, png_filename=png_filename2)
png_filename3 = prefix + 'Displacement_Field_hist_' + \
'index'+str_index+'_'+str(int(i))+'.png'
gsd_data.get_displacement_field_distribution(i, png_filename=png_filename3)
if psik:
if not "record_psik" in locals(): # check if the variable exists
# load Psi_k s
record_psik = np.zeros((gsd_data.num_of_frames, 3)) # [time_steps,psi3,psi6]
record_psik[:, 0] = time_steps # [0:25]*20
a_frame.get_bond_orientational_order(k_set=3)
record_psik[i, 1] = a_frame.Psi_k_global_cut_edge
a_frame.get_bond_orientational_order(k_set=6)
record_psik[i, 2] = a_frame.Psi_k_global_cut_edge
if not psik_plot is None:
png_filename_psik = prefix + 'bond_orientational_order_'+str(
int(psik_plot))+'_'+'index'+str_index+'_'+str(int(i))+'.png'
a_frame.get_bond_orientational_order(
k_set=psik_plot, plot=True, png_filename=png_filename_psik)
if neighbor_cloud:
folder_name = prefix+"record_"+str_index # +"/"
# check if the folder exists
isExists = os.path.exists(folder_name)
if isExists:
pass
else:
os.makedirs(folder_name)
png_filename = folder_name+"/"+'neighbor_cloud_1st_minima_index' + \
str_index+'_'+str(int(i))+'.png'
# a_frame.get_neighbor_cloud(png_filename=png_filename)
a_frame.get_neighbor_cloud_method_1st_minima_bond(png_filename=png_filename)
if coordination_number:
R"""
CN0 % should be 0 for all the particles must be linked by bond.
CN1 % is likely to be edge?
CN2 % in body(edge-cutted) shows the mechanical unstability
CN3 % shows the proportion of honeycomb.
CN4 % shows the proportion of kagome.
CN6 % shows the proportion of hexagonal.
CN5/7 % shows the proportion of disclination.
record_cn: Nframes of [time_step, CN0, CN1,..., CN12]
"""
# print('index '+str(i))
# print(snap.particles.position[137])
a_frame.get_coordination_number_conditional(
lattice_constant=lattice_constant) # cut edge to remove CN012
ccn = a_frame.count_coordination_ratio # [time_steps,psi3,psi6]
ccn = np.transpose(ccn)
if not "record_cn" in locals(): # check if the variable exists
# load CN_k s
record_cn = np.zeros((gsd_data.num_of_frames, np.shape(ccn)[1]+1))
# time_steps##gsd frame is different from log frame for period set 100 vs 2e3
record_cn[:, 0] = range(10)
# print(np.shape(ccn)[1])
record_cn[i, 1:np.shape(ccn)[1]+1] = ccn # [0:np.shape(ccn)[1]-1]
if bond_plot:
if final_cut:
# bond_plot+trap_plot
png_filename1 = 'bond_hist_index'+str_index+'_'+str(int(i))+'.png' # prefix +
# prefix +
png_filename2 = 'bond_plot_1st_minima_index'+str_index+'_'+str(int(i))+'.png'
else:
folder_name = prefix+"record_"+str_index # +"/"
# check if the folder exists
isExists = os.path.exists(folder_name)
if isExists:
pass
else:
os.makedirs(folder_name)
# bond_plot+trap_plot
png_filename1 = folder_name+"/" + 'bond_hist_index' + \
str_index+'_'+str(int(i))+'.png'
png_filename2 = folder_name+"/" + 'bond_plot_1st_minima_index' + \
str_index+'_'+str(int(i))+'.png'
# a_frame is static_points_analysis_2d
# a_frame.get_first_minima_bond_length_distribution(lattice_constant=3)#,png_filename=png_filename1
spa = a_frame
pa.bond_plot_module()
a_frame.get_first_minima_bond_length_distribution()
# a_frame.get_first_minima_ridge_length_distribution()
bpm = pa.bond_plot_module()
bpm.restrict_axis_property_relative(spa.points, '($\sigma$)')
# list_bond_index = bpm.get_bonds_with_conditional_ridge_length(spa.voronoi.ridge_length,spa.voronoi.ridge_points,spa.ridge_first_minima_left)
list_bond_index = bpm.get_bonds_with_conditional_bond_length(
spa.bond_length, [0.9, spa.bond_first_minima_left])
# color_name: https://www.cssportal.com/html-colors/x11-colors.php
bond_color = 'k' # 'gold'#'mediumseagreen'#'tan'#'bisque'#'gold'#'darkorange'
bpm.plot_points_with_given_bonds(
spa.points, list_bond_index, 50, bond_color, bond_color, bond_width=1) # 200
bpm.plot_traps(LinearCompressionRatio=1.0, trap_filename=trap_filename,
mode='map', trap_color='r', trap_size=10) # array
semibox = gsd_data.trajectory[0].configuration.box[0:2]/2
bpm.restrict_axis_limitation([-semibox[0], semibox[0]], [-semibox[1], semibox[1]])
save_filename = png_filename2
bpm.save_figure(png_filename=save_filename)
"""
a_frame.draw_bonds_conditional_bond_oop(check=[0.4, a_frame.bond_first_minima_left], png_filename=png_filename2,
LinearCompressionRatio=trap_lcr,trap_filename=trap_filename,
x_unit='($\sigma$)',axis_limit=[10,10])#show_traps=show_traps,
"""
if bond_plot_gr:
if final_cut:
# bond_plot+trap_plot
png_filename1 = prefix + 'bond_gr_index'+str_index+'_'+str(int(i))+'.png'
png_filename2 = prefix + 'bond_plot_gr_1st_minima_index' + \
str_index+'_'+str(int(i))+'.png'
else:
folder_name = prefix+"record_"+str_index # +"/"
# check if the folder exists
isExists = os.path.exists(folder_name)
if isExists:
pass
else:
os.makedirs(folder_name)
# bond_plot+trap_plot
# png_filename1 = folder_name+"/" +'bond_hist_index'+str_index+'_'+str(int(i))+'.png'
png_filename2 = folder_name+"/" + 'bond_plot_1st_minima_index' + \
str_index+'_'+str(int(i))+'.png'
rdf = freud.density.RDF(bins=150, r_max=15.0, r_min=1.0)
rdf.compute(system=snap)
a_frame.draw_radial_distribution_function_and_first_minima(
rdf, lattice_constant=3, png_filename=png_filename1)
a_frame.draw_bonds_conditional_bond(
check=[0.4, a_frame.bond_first_minima_left],
png_filename=png_filename2, show_traps=show_traps,
LinearCompressionRatio=trap_lcr, trap_filename=trap_filename)
"""
rdf = freud.density.RDF(bins=150, r_max=15.0)#
rdf.compute(system=snap)
#print(rdf.bin_centers) print(rdf.bin_counts)
rdf.plot()
fig_type = 'gr'
data_filename=prefix+fig_type+'_index'+str_index+'_'+str(int(i))+'.png'
plt.savefig(data_filename)
plt.close()
"""
"""
#checked right
import gsd.hoomd
import freud
traj = gsd.hoomd.open('/home/tplab/hoomd-examples_0/trajectory_auto5208_9.gsd')
rdf = freud.density.RDF(bins=50,r_max=10)
rdf.compute(system=traj[-1])
r =rdf.bin_centers
y = rdf.rdf
import matplotlib.pyplot as plt
fig,ax = plt.subplots()
rdf.plot(ax=ax)
plt.savefig('/home/tplab/Downloads/gr.png')
"""
if sk:
sk = freud.diffraction.DiffractionPattern()
snap = gsd_data.trajectory.read_frame(i)
sk.compute(system=snap)
if log_sk:
fig_type = 'log_sk'
data_filename = prefix+fig_type+'_index'+str_index+'_'+str(int(i))+'.png'
ax = sk.plot(vmin=0.01, vmax=1)
else:
fig_type = 'sk'
data_filename = prefix+fig_type+'_index'+str_index+'_'+str(int(i))+'.png'
fig, ax = plt.subplots()
im = ax.pcolormesh(sk.k_values, sk.k_values,
sk.diffraction, cmap='afmhot') # im =
# ax.colorbar().remove()
fig.colorbar(im)
ax.axis('equal')
"""
#method1
ax = sk.plot()
ax.pcolormesh(sk.k_values,sk.k_values,sk.diffraction,cmap='afmhot')
#method2
fig,ax = plt.subplots()
#print(sk.k_values)
X, Y = np.meshgrid(sk.k_values, sk.k_values)
im = ax.pcolormesh(X,Y,sk.diffraction,cmap='summer')#'afmhot' im =
#https://matplotlib.org/stable/tutorials/colors/colormaps.html
# ?highlight=afmhot
#ax.colorbar().remove()
fig.colorbar(im)
ax.axis('equal')
"""
plt.savefig(data_filename)
plt.close()
# ax.pcolormesh(X, Y, Z,cmap="plasma",)
"""
maybe that the loglog map is not suitable for my sk.
linear colorbar is the right choice
"""
if final_cut:
break
if psik:
plt.figure()
plt.plot(record_psik[:, 0], record_psik[:, 1], label='Psi_3') # psi3
plt.plot(record_psik[:, 0], record_psik[:, 2], label='Psi_6') # psi6
plt.legend()
plt.title('Psi_3 VS Psi_6 '+'index:'+str_index)
plt.xlabel('time(steps)')
plt.ylabel('Psi_k(1)')
# plt.show()
png_filename = prefix + 'T_VS_Psi_k_'+'index'+str_index+'.png'
plt.savefig(png_filename)
plt.close()
if p_cairo:
if not "record_pcairo" in locals(): # check if the variable exists
# record_pcairo: Nframes of [time_step, cn3, cn4, pcairo]
record_pcairo = np.array(record_cn[:, :4])
record_pcairo[:, 1] = record_cn[:, 4]
record_pcairo[:, 2] = record_cn[:, 5]
record_pcairo[:, 3] = 0
for i in range(gsd_data.num_of_frames):
record_pcairo[i, 3] = a_frame.get_cairo_order_parameter(
record_cn[i, 4], record_cn[i, 5]) # ccn[3],ccn[4])
fig, ax = plt.subplots()
if frame_cut == 0:
ax.plot(record_cn[:, 0], record_cn[:, 4], label='CN_3')
ax.plot(record_cn[:, 0], record_cn[:, 5], label='CN_4')
ax.plot(record_cn[:, 0], record_cn[:, 7], label='CN_6')
ax.plot(record_cn[:, 0], record_pcairo[:, 3], label='Pcairo')
png_filename = prefix + 'T_VS_Pcairo'+'index'+str_index+'egcut'+'.png'
plt.legend()
plt.title('CN_k '+'index:'+str_index)
plt.xlabel('time(steps)')
plt.ylabel('Order Parameter(1)')
# plt.show()
plt.savefig(png_filename)
record_filename = prefix + 'T_VS_Pcairo_cut'+'index'+str_index+'.txt'
np.savetxt(record_filename, record_cn) # np.savetxt(record_filename,record_cn)
plt.close()
scp = pa.show_cairo_order_parameter()
fig, ax = scp.plot_diagram()
# fig,ax = plt.subplots()
if frame_cut == 0:
ax.plot(record_cn[:, 4], record_cn[:, 5], 'r',)
# ax.plot(record_cn[:,0],record_pcairo[:,3],label='Pcairo')
png_filename = prefix + 'trajectory_Pcairo'+'index'+str_index+'egcut'+'.png'
plt.savefig(png_filename)
plt.close()
if False: # coordination_number:
# txt_filename = prefix +'T_VS_CN_k_tcut'+'index'+str_index+'egcut'+'.txt'
# np.savetxt(txt_filename,record_cn)
plt.figure()
if frame_cut == 0: # frame_cut is set to abstract a part of the process to watch in detail
# plt.plot(record_cn[:,0],record_cn[:,1],label='CN_0')
# plt.plot(record_cn[:,0],record_cn[:,2],label='CN_1')
# plt.plot(record_cn[:,0],record_cn[:,3],label='CN_2')
plt.plot(record_cn[:, 0], record_cn[:, 4], label='CN_3')
plt.plot(record_cn[:, 0], record_cn[:, 5], label='CN_4')
plt.plot(record_cn[:, 0], record_cn[:, 6], label='CN_5')
plt.plot(record_cn[:, 0], record_cn[:, 7], label='CN_6')
plt.plot(record_cn[:, 0], record_cn[:, 8], label='CN_7')
# plt.plot(record_cn[:,0],record_cn[:,9],label='CN_8')
# plt.plot(record_cn[:,0],record_cn[:,-1],label='CN_9')
png_filename = prefix + 'T_VS_CN_k'+'index'+str_index+'egcut'+'.png'
else:
# plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,1],label='CN_0')
# plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,2],label='CN_1')
# plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,3],label='CN_2')
plt.plot(record_cn[0:frame_cut, 0], record_cn[0:frame_cut, 4], label='CN_3')
plt.plot(record_cn[0:frame_cut, 0], record_cn[0:frame_cut, 5], label='CN_4')
plt.plot(record_cn[0:frame_cut, 0], record_cn[0:frame_cut, 6], label='CN_5')
plt.plot(record_cn[0:frame_cut, 0], record_cn[0:frame_cut, 7], label='CN_6')
plt.plot(record_cn[0:frame_cut, 0], record_cn[0:frame_cut, 8], label='CN_7')
# plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,9],label='CN_8')
# plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,-1],label='CN_9')
png_filename = prefix + 'T_VS_CN_k_tcut'+'index'+str_index+'egcut'+'.png'
plt.legend()
plt.title('CN_k '+'index:'+str_index)
plt.xlabel('time(steps)')
plt.ylabel('CN_k(1)')
# plt.show()
plt.savefig(png_filename)
record_filename = prefix + 'T_VS_CN_k_cut'+'index'+str_index+'.txt'
np.save(record_filename, record_cn) # np.savetxt(record_filename,record_cn)
plt.close()
def save_from_gsd_to_cn3(simu_index=None, seed=None, frame_cut=0,
final_cut=False,
coordination_number=False, lattice_constant=3,
account='tplab',
prefix=None):
R"""
Introduction:
Read a gsd file and save a series of analyzed results as follow.
coordination_number:
Format:
[Psi_3_global,Psi_6_global]
example:
"""
# prefix='/home/remote/xiaotian_file/link_to_HDD/hoomd-examples_0/'#'/home/'+account+'/Downloads/cn3-t/'#'/home/tplab/Downloads/'
# '/home/'+account+'/hoomd-examples_0/'#'/home/tplab/hoomd-examples_0/'
log_prefix = '/home/remote/xiaotian_file/link_to_HDD/hoomd-examples_1/'
# /home/remote/xiaotian_file/link_to_HDD/hoomd-examples_0/
# load time steps
if seed is None:
str_index = str(int(simu_index))
gsd_data = pf.proceed_gsd_file(simu_index=simu_index)
else:
str_index = str(int(simu_index))+'_'+str(seed)
file_gsd = log_prefix+'trajectory_auto'+str_index+'.gsd' # +'_'+str(seed)
gsd_data = pf.proceed_gsd_file(filename_gsd_seed=file_gsd, account=account)
# file_log=log_prefix+'log-output_auto'+str_index+'.log'#+'_'+str(seed)
# log_data = np.genfromtxt(fname=file_log, skip_header=True)
time_steps = range(2001) # log_data[:,0]
for i in range(gsd_data.num_of_frames):
if final_cut:
i = gsd_data.num_of_frames-1 # i=9#!!! 23
a_frame = pa.static_points_analysis_2d(points=gsd_data.read_a_frame(i)) # hide_figure=False
if coordination_number:
R"""
CN0 % should be 0 for all the particles must be linked by bond.
CN1 % is likely to be edge?
CN2 % in body(edge-cutted) shows the mechanical unstability
CN3 % shows the proportion of honeycomb.
CN4 % shows the proportion of kagome.
CN6 % shows the proportion of hexagonal.
CN5/7 % shows the proportion of disclination.
"""
# print('index '+str(i))
# print(snap.particles.position[137])
a_frame.get_coordination_number_conditional(
lattice_constant=lattice_constant) # cut edge to remove CN012
ccn = a_frame.count_coordination_ratio # [time_steps,psi3,psi6]
ccn = np.transpose(ccn)
if not "record_cn" in locals(): # check if the variable exists
# load CN_k s
# hoomd_v43 remove the 1st init_frame, so the record_cn should be added 1
record_cn = np.zeros((gsd_data.num_of_frames+1, np.shape(ccn)[1]+1))
# range(10)##gsd frame is different from log frame for period set 100 vs 2e3
record_cn[:, 0] = time_steps
record_cn[:, 0] *= 1e3
record_cn[0, 6] = 1.0
# print(np.shape(ccn)[1])
# hoomd_v43 remove the 1st init_frame, so the record_cn should be added 1
record_cn[i+1, 1:np.shape(ccn)[1]+1] = ccn # [0:np.shape(ccn)[1]-1]
if coordination_number: # False:#
# txt_filename = prefix +'T_VS_CN_k_tcut'+'index'+str_index+'egcut'+'.txt'
# np.savetxt(txt_filename,record_cn)
plt.figure()
if frame_cut == 0: # frame_cut is set to abstract a part of the process to watch in detail
# plt.plot(record_cn[:,0],record_cn[:,1],label='CN_0')
# plt.plot(record_cn[:,0],record_cn[:,2],label='CN_1')
# plt.plot(record_cn[:,0],record_cn[:,3],label='CN_2')
plt.plot(record_cn[:, 0], record_cn[:, 4], label='CN_3')
plt.plot(record_cn[:, 0], record_cn[:, 5], label='CN_4')
plt.plot(record_cn[:, 0], record_cn[:, 6], label='CN_5')
plt.plot(record_cn[:, 0], record_cn[:, 7], label='CN_6')
plt.plot(record_cn[:, 0], record_cn[:, 8], label='CN_7')
# plt.plot(record_cn[:,0],record_cn[:,9],label='CN_8')
# plt.plot(record_cn[:,0],record_cn[:,-1],label='CN_9')
png_filename = prefix + 'T_VS_CN_k'+'index'+str_index+'egcut'+'.png'
else:
# plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,1],label='CN_0')
# plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,2],label='CN_1')
# plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,3],label='CN_2')
plt.plot(record_cn[0:frame_cut, 0], record_cn[0:frame_cut, 4], label='CN_3')
plt.plot(record_cn[0:frame_cut, 0], record_cn[0:frame_cut, 5], label='CN_4')
plt.plot(record_cn[0:frame_cut, 0], record_cn[0:frame_cut, 6], label='CN_5')
plt.plot(record_cn[0:frame_cut, 0], record_cn[0:frame_cut, 7], label='CN_6')
plt.plot(record_cn[0:frame_cut, 0], record_cn[0:frame_cut, 8], label='CN_7')
# plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,9],label='CN_8')
# plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,-1],label='CN_9')
png_filename = prefix + 'T_VS_CN_k_tcut'+'index'+str_index+'egcut'+'.png'
plt.legend()
plt.title('CN_k '+'index:'+str_index)
plt.xlabel('time(steps)')
plt.ylabel('CN_k(1)')
# plt.show()
plt.savefig(png_filename)
record_filename = prefix + 'T_VS_CN_k_cut'+'index'+str_index+'.txt'
np.save(record_filename, record_cn) # np.savetxt(record_filename,record_cn)
plt.close()
if final_cut:
break
"""
#plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,1],label='CN_0')
#plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,2],label='CN_1')
#plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,3],label='CN_2')
plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,4],label='CN_3')
plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,5],label='CN_4')
plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,6],label='CN_5')
plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,7],label='CN_6')
plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,8],label='CN_7')
#plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,9],label='CN_8')
#plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,-1],label='CN_9')
png_filename = prefix +'T_VS_CN_k_tcut'+'index'+str_index+'egcut'+'.png'
plt.legend()
plt.title('CN_k '+'index:'+str_index)
plt.xlabel('time(steps)')
plt.ylabel('CN_k(1)')
#plt.show()
plt.savefig(png_filename)
plt.close()
"""
record_filename = prefix + 'T_VS_CN_k_cut'+'index'+str_index+'.npy'
np.save(record_filename, record_cn) # np.savetxt(record_filename,record_cn)
return record_filename
def save_from_txyz_to_cn3(simu_index=None, seed=None, frame_cut=0,
final_cut=False,
coordination_number=False, lattice_constant=3,
txyz=None,
prefix=None):
R"""
Introduction:
Read a gsd file and save a series of analyzed results as follow.
coordination_number:
Format:
[Psi_3_global,Psi_6_global]
example:
"""
if seed is None:
str_index = str(int(simu_index))
else:
str_index = str(int(simu_index))+'_'+str(seed)
Nframes, Nparticles, Ndimensions = np.shape(txyz)
for i in range(np.shape(txyz)[0]):
if final_cut:
i = Nframes-1
a_frame = pa.static_points_analysis_2d(
points=txyz[i],
dis_edge_cut=lattice_constant) # hide_figure=False
if coordination_number:
R"""
CN0 % should be 0 for all the particles must be linked by bond.
CN1 % is likely to be edge?
CN2 % in body(edge-cutted) shows the mechanical unstability
CN3 % shows the proportion of honeycomb.
CN4 % shows the proportion of kagome.
CN6 % shows the proportion of hexagonal.
CN5/7 % shows the proportion of disclination.
"""
a_frame.get_coordination_number_conditional(
lattice_constant=lattice_constant) # cut edge to remove CN012
ccn = a_frame.count_coordination_ratio # [time_steps,psi3,psi6]
ccn = np.transpose(ccn)
if not "record_cn" in locals(): # check if the variable exists
# load CN_k s
# hoomd_v43 remove the 1st init_frame, so the record_cn should be added 1
record_cn = np.zeros((Nframes+1, np.shape(ccn)[1]+1))
# range(10)##gsd frame is different from log frame for period set 100 vs 2e3
record_cn[:, 0] = range(Nframes+1)
record_cn[:, 0] *= 1e3
record_cn[0, 6] = 1.0
# print(np.shape(ccn)[1])
# hoomd_v43 remove the 1st init_frame, so the record_cn should be added 1
record_cn[i+1, 1:np.shape(ccn)[1]+1] = ccn # [0:np.shape(ccn)[1]-1]
if final_cut:
break
if coordination_number: # False:#
# txt_filename = prefix +'T_VS_CN_k_tcut'+'index'+str_index+'egcut'+'.txt'
# np.savetxt(txt_filename,record_cn)
plt.figure()
if frame_cut == 0: # frame_cut is set to abstract a part of the process to watch in detail
# plt.plot(record_cn[:,0],record_cn[:,1],label='CN_0')
# plt.plot(record_cn[:,0],record_cn[:,2],label='CN_1')
# plt.plot(record_cn[:,0],record_cn[:,3],label='CN_2')
plt.plot(record_cn[:, 0], record_cn[:, 4], label='CN_3')
plt.plot(record_cn[:, 0], record_cn[:, 5], label='CN_4')
plt.plot(record_cn[:, 0], record_cn[:, 6], label='CN_5')
plt.plot(record_cn[:, 0], record_cn[:, 7], label='CN_6')
plt.plot(record_cn[:, 0], record_cn[:, 8], label='CN_7')
# plt.plot(record_cn[:,0],record_cn[:,9],label='CN_8')
# plt.plot(record_cn[:,0],record_cn[:,-1],label='CN_9')
png_filename = prefix + 'T_VS_CN_k'+'index'+str_index+'egcut'+'.png'
else:
# plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,1],label='CN_0')
# plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,2],label='CN_1')
# plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,3],label='CN_2')
plt.plot(record_cn[0:frame_cut, 0], record_cn[0:frame_cut, 4], label='CN_3')
plt.plot(record_cn[0:frame_cut, 0], record_cn[0:frame_cut, 5], label='CN_4')
plt.plot(record_cn[0:frame_cut, 0], record_cn[0:frame_cut, 6], label='CN_5')
plt.plot(record_cn[0:frame_cut, 0], record_cn[0:frame_cut, 7], label='CN_6')
plt.plot(record_cn[0:frame_cut, 0], record_cn[0:frame_cut, 8], label='CN_7')
# plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,9],label='CN_8')
# plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,-1],label='CN_9')
png_filename = prefix + 'T_VS_CN_k_tcut'+'index'+str_index+'egcut'+'.png'
plt.legend()
plt.title('CN_k '+'index:'+str_index)
plt.xlabel('time(steps)')
plt.ylabel('CN_k(1)')
# plt.show()
plt.savefig(png_filename)
record_filename = prefix + 'T_VS_CN_k_cut'+'index'+str_index+'.txt'
np.save(record_filename, record_cn) # np.savetxt(record_filename,record_cn)
plt.close()
record_filename = prefix + 'T_VS_CN_k_cut'+'index'+str_index+'.npy'
np.save(record_filename, record_cn) # np.savetxt(record_filename,record_cn)
return record_filename
def save_t_cnk_png(record_cn, prefix, str_index, frame_cut=0):
plt.figure()
if frame_cut == 0: # frame_cut is set to abstract a part of the process to watch in detail
# plt.plot(record_cn[:,0],record_cn[:,1],label='CN_0')
# plt.plot(record_cn[:,0],record_cn[:,2],label='CN_1')
# plt.plot(record_cn[:,0],record_cn[:,3],label='CN_2')
plt.plot(record_cn[:, 0], record_cn[:, 4], label='CN_3')
plt.plot(record_cn[:, 0], record_cn[:, 5], label='CN_4')
plt.plot(record_cn[:, 0], record_cn[:, 6], label='CN_5')
plt.plot(record_cn[:, 0], record_cn[:, 7], label='CN_6')
plt.plot(record_cn[:, 0], record_cn[:, 8], label='CN_7')
# plt.plot(record_cn[:,0],record_cn[:,9],label='CN_8')
# plt.plot(record_cn[:,0],record_cn[:,-1],label='CN_9')
png_filename = prefix + 'T_VS_CN_k'+'index'+str_index+'egcut'+'.png'
else:
# plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,1],label='CN_0')
# plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,2],label='CN_1')
# plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,3],label='CN_2')
plt.plot(record_cn[0:frame_cut, 0], record_cn[0:frame_cut, 4], label='CN_3')
plt.plot(record_cn[0:frame_cut, 0], record_cn[0:frame_cut, 5], label='CN_4')
plt.plot(record_cn[0:frame_cut, 0], record_cn[0:frame_cut, 6], label='CN_5')
plt.plot(record_cn[0:frame_cut, 0], record_cn[0:frame_cut, 7], label='CN_6')
plt.plot(record_cn[0:frame_cut, 0], record_cn[0:frame_cut, 8], label='CN_7')
# plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,9],label='CN_8')
# plt.plot(record_cn[0:frame_cut,0],record_cn[0:frame_cut,-1],label='CN_9')
png_filename = prefix + 'T_VS_CN_k_tcut'+'index'+str_index+'egcut'+'.png'
plt.legend()
plt.title('CN_k '+'index:'+str_index)