1 | close all; clear all; clc |
---|
2 | load FFXBP.mat |
---|
3 | cd('./KK') |
---|
4 | |
---|
5 | for c=1:6%, 14:18 |
---|
6 | c |
---|
7 | % for c=1:20 |
---|
8 | SP=flip(Freq(3:end)); |
---|
9 | SS(c,:)=flip(FF(c,3:end))/9; |
---|
10 | % SSM(c)=max(SS); |
---|
11 | [RSP,ISP(c,:)]=SRf(SP,SS(c,:)); |
---|
12 | % |
---|
13 | |
---|
14 | % figure (1) |
---|
15 | % plot(SP,SS(c,:),'or') |
---|
16 | % hold on |
---|
17 | % plot(RSP) |
---|
18 | |
---|
19 | PhaseH=-(imag(hilbert(log(abs(RSP))))); |
---|
20 | RPH=real((ifft(RSP.*exp(1i.*(PhaseH))))); |
---|
21 | |
---|
22 | |
---|
23 | % figure(2) |
---|
24 | [mx,ps]=max(RPH) |
---|
25 | RPH= [zeros(1,80-ps), RPH(1:end-(80-ps))] |
---|
26 | % plot((1:length(RPH))*1e-9/length(RPH),RPH) |
---|
27 | |
---|
28 | Gauss=@(mu,sig,A,x)A.*exp(-(x-mu).^2/(2*sig^2)) |
---|
29 | % hold on |
---|
30 | %2.1e-12 |
---|
31 | Profile5=Gauss(ps*1e-9/length(RPH),2.1e-12,mx,(1:length(RPH))*1e-9/length(RPH)); |
---|
32 | % plot((1:length(RPH))*1e-9/length(RPH),Profile5,'r') |
---|
33 | FWHM(c)=sum(RPH>max(RPH)/2)*1e-9/length(RPH) |
---|
34 | FW01M(c)=sum(RPH>max(RPH)*0.1)*1e-9/length(RPH) |
---|
35 | FW09M(c)=sum(RPH>max(RPH)*0.9)*1e-9/length(RPH) |
---|
36 | |
---|
37 | |
---|
38 | PR(c,:)=RPH; |
---|
39 | sum(Profile5>max(Profile5)/2)*1e-9/length(Profile5) |
---|
40 | % figure(1) |
---|
41 | % plot(abs(fft(RPH)),'r') |
---|
42 | % plot(abs(fft(Profile5./sum(Profile5))),'k') |
---|
43 | |
---|
44 | end |
---|
45 | Bphase=[2.4 2.2 2.0 1.8 1.6 1.4 1.2]; |
---|
46 | |
---|
47 | % ds=1:20; |
---|
48 | figure |
---|
49 | hold on |
---|
50 | plot(Bphase(1:6),FW01M(:)*1e+12,'->k','linewidth',2) |
---|
51 | plot(Bphase(1:6),FWHM(:)*1e+12,'->b','linewidth',2) |
---|
52 | plot(Bphase(1:6),FW09M(:)*1e+12,'->r','linewidth',2) |
---|
53 | |
---|
54 | set(gca,'fontsize',16) |
---|
55 | xlabel('Buncher power, [a.u.]') |
---|
56 | ylabel('Pulsewidth, [ps]') |
---|
57 | legend('FW0.1M','FWHM','FW0.9M','Orientation','horizontal') |
---|
58 | grid on |
---|
59 | title('Pulsewidth vs. Buncher power') |
---|
60 | |
---|
61 | figure |
---|
62 | [hc hc]=contourf((1:length(RPH))*1e-9/length(RPH)*1e+12,Bphase(1:6),PR*500) |
---|
63 | colorbar |
---|
64 | set(hc,'LineStyle','none'); |
---|
65 | xlim([0 50]) |
---|
66 | set(gca,'fontsize',16) |
---|
67 | |
---|
68 | xlabel('Time, [ps]') |
---|
69 | ylabel('Buncher power, [a.u.]') |
---|
70 | title('Bunch profile') |
---|
71 | |
---|
72 | |
---|
73 | figure |
---|
74 | |
---|
75 | hold on |
---|
76 | plot(SP, SS(1,:),'ob','linewidth',2) |
---|
77 | plot(0:(length(ISP)-1), ISP(1,:),'-.b','linewidth',2) |
---|
78 | plot(SP, SS(2,:),'om','linewidth',2) |
---|
79 | plot(0:(length(ISP)-1), ISP(2,:),'-.m','linewidth',2) |
---|
80 | plot(SP, SS(3,:),'ok','linewidth',2) |
---|
81 | plot(0:(length(ISP)-1), ISP(3,:),'-.k','linewidth',2) |
---|
82 | plot(SP, SS(4,:),'og','linewidth',2) |
---|
83 | plot(0:(length(ISP)-1), ISP(4,:),'-.g','linewidth',2) |
---|
84 | plot(SP, SS(5,:),'or','linewidth',2) |
---|
85 | plot(0:(length(ISP)-1), ISP(5,:),'-.r','linewidth',2) |
---|
86 | |
---|
87 | set(gca,'fontsize',16) |
---|
88 | xlabel('Frequency, [GHz]') |
---|
89 | legend('BP=2.4','','BP=2.2','','BP=2.0','','BP=1.8','','BP=1.6','') |
---|
90 | % 2 4 6 8 10 |
---|
91 | title('Form Factor (BGS=10 mm)') |
---|
92 | ylabel('Amplitude, [a.u.]') |
---|
93 | xlim([0, 200]) |
---|
94 | grid on |
---|
95 | |
---|
96 | figure |
---|
97 | |
---|
98 | hold on |
---|
99 | plot((0:(length(RPH)-1))*1e-9/length(RPH)*1e+12, PR(1,:)*500,'-.b','linewidth',2) |
---|
100 | plot((0:(length(RPH)-1))*1e-9/length(RPH)*1e+12, PR(2,:)*500,'-.m','linewidth',2) |
---|
101 | plot((0:(length(RPH)-1))*1e-9/length(RPH)*1e+12, PR(3,:)*500,'-.k','linewidth',2) |
---|
102 | plot((0:(length(RPH)-1))*1e-9/length(RPH)*1e+12, PR(4,:)*500,'-.g','linewidth',2) |
---|
103 | plot((0:(length(RPH)-1))*1e-9/length(RPH)*1e+12, PR(5,:)*500,'-.r','linewidth',2) |
---|
104 | plot((0:(length(RPH)-1))*1e-9/length(RPH)*1e+12, PR(6,:)*500,'-.y','linewidth',2) |
---|
105 | |
---|
106 | set(gca,'fontsize',16) |
---|
107 | xlabel('Time, [ps]') |
---|
108 | legend('BP=2.4','BP=2.2','BP=2.0','BP=1.8','BP=1.6','BP=1.4') |
---|
109 | % 2 4 6 8 10 |
---|
110 | title('Reconstructed profile') |
---|
111 | ylabel('Amplitude, [a.u.]') |
---|
112 | xlim([0, 50]) |
---|
113 | grid on |
---|
114 | |
---|
115 | |
---|
116 | |
---|
117 | |
---|
118 | time =(0:(length(RPH)-1))*1e-9/length(RPH)*1e+9;%ns |
---|
119 | Profile=PR(3,:)*500; |
---|
120 | |
---|
121 | save P6BP.mat time Profile |
---|
122 | |
---|
123 | |
---|
124 | |
---|
125 | |
---|
126 | |
---|
127 | |
---|
128 | |
---|
129 | |
---|
130 | |
---|
131 | |
---|
132 | |
---|
133 | |
---|
134 | |
---|
135 | cd('..') |
---|