1 | clear all; close all; clc; |
---|
2 | date=20170524; |
---|
3 | load data2405.mat ; |
---|
4 | cut=(key_value(:,8)>1e+3)&(abs(data(:,11,2))<100)&(abs(data(:,12,2))<50); |
---|
5 | |
---|
6 | position=key_value(:,4)*7.94e-6; |
---|
7 | hour=rem(key_value(:,6),date); |
---|
8 | diap(1,:)=(hour>143200)&(hour<144000); |
---|
9 | diap(2,:)=(hour>144000)&(hour<145000); |
---|
10 | diap(3,:)=(hour>145000)&(hour<145600); |
---|
11 | diap(4,:)=(hour>145600)&(hour<150300); |
---|
12 | diap(5,:)=(hour>150300)&(hour<151000); |
---|
13 | diap(6,:)=(hour>151000)&(hour<151700); |
---|
14 | diap(7,:)=(hour>151700)&(hour<152400); |
---|
15 | |
---|
16 | |
---|
17 | fromd=-14; |
---|
18 | bkgsh=1; |
---|
19 | for detector=1:11 |
---|
20 | for dd=1:7 |
---|
21 | cut2=cut&diap(dd,:)'; |
---|
22 | x=position(cut2)-48.58-3.46; |
---|
23 | tmpE=key_value(cut2,8); |
---|
24 | Es(dd)=mean(tmpE(abs(tmpE-mean(tmpE))<std(tmpE))); |
---|
25 | Ess(dd)=std(tmpE(abs(tmpE-mean(tmpE))<std(tmpE))); |
---|
26 | |
---|
27 | y=data(cut2,detector,2)./Es(dd); |
---|
28 | |
---|
29 | fb(dd,detector) = polyfit(x(x<(fromd+bkgsh)),y(x<(fromd+bkgsh)),0); |
---|
30 | |
---|
31 | %[fs, gofs] = fit(x(x>fromd),y(x>fromd),'exp1'); |
---|
32 | [fs, gofs] = fit(x((x>fromd)&y>fb(dd,detector)),y((x>fromd)&y>fb(dd,detector)),'exp1','Lower',[0 0.015]); |
---|
33 | chi(dd,detector) = gofs.adjrsquare; |
---|
34 | lamb(dd,detector)=fs.b; |
---|
35 | amp(dd,detector)=fs.a; |
---|
36 | % figure |
---|
37 | % plot(fs,x,y) |
---|
38 | tmp1=confint(fs); |
---|
39 | tmp2=(tmp1(1:2:3)-tmp1(2:2:4))/4; |
---|
40 | Ierrp(dd,detector,:)=tmp2(:); |
---|
41 | |
---|
42 | tmp1=confint(fs); |
---|
43 | tmp2=(tmp1(1:2:3)-tmp1(2:2:4))/4; |
---|
44 | Ierrp(dd,detector,:)=tmp2(:); |
---|
45 | |
---|
46 | |
---|
47 | end |
---|
48 | end |
---|
49 | |
---|
50 | Bphase=[2.4 2.2 2.0 1.8 1.6 1.4 1.2]; |
---|
51 | dd=3; |
---|
52 | cut2=cut&diap(dd,:)'; |
---|
53 | x=position(cut2)-48.58-3.46; |
---|
54 | xfits=fromd:1:(-7); |
---|
55 | xfitb=(-22):1:fromd; |
---|
56 | |
---|
57 | figure |
---|
58 | hold on |
---|
59 | detector=7; |
---|
60 | y=data(cut2,detector,2)./mean(key_value(cut2,8))*1e+3; |
---|
61 | semilogy(x,y,'^r','linewidth',2) |
---|
62 | semilogy(xfits,amp(dd,detector)*exp(xfits*lamb(dd,detector))*1e+3,'r','linewidth',2) |
---|
63 | semilogy(xfitb,repmat(fb(dd,detector),size(xfitb))*1e+3,'Color',[0.8 0.8 0.8],'linewidth',2) |
---|
64 | set(gca, 'YScale', 'log') |
---|
65 | detector=5; |
---|
66 | y=data(cut2,detector,2)./mean(key_value(cut2,8))*1e+3; |
---|
67 | semilogy(x,y,'>k','linewidth',2) |
---|
68 | semilogy(xfits,amp(dd,detector)*exp(xfits*lamb(dd,detector))*1e+3,'k','linewidth',2) |
---|
69 | semilogy(xfitb,repmat(fb(dd,detector),size(xfitb))*1e+3,'Color',[0.8 0.8 0.8],'linewidth',2) |
---|
70 | |
---|
71 | detector=9; |
---|
72 | y=data(cut2,detector,2)./mean(key_value(cut2,8))*1e+3; |
---|
73 | semilogy(x,y,'<b','linewidth',2) |
---|
74 | semilogy(xfits,amp(dd,detector)*exp(xfits*lamb(dd,detector))*1e+3,'b','linewidth',2) |
---|
75 | semilogy(xfitb,repmat(fb(dd,detector),size(xfitb))*1e+3,'Color',[0.8 0.8 0.8],'linewidth',2) |
---|
76 | |
---|
77 | set(gca,'fontsize',16) |
---|
78 | legend('76^o','Signal','Bkgnd','90^o','Signal','Bkgnd', '104^o','Signal','Bkgnd') |
---|
79 | xlabel('Position, [mm]') |
---|
80 | ylabel('Amplitude, [a.u.]') |
---|
81 | grid on |
---|
82 | title('Buncher power = 2 [a.u.]') |
---|
83 | xlim([-22 0]) |
---|
84 | % ylim([6 21]) |
---|
85 | |
---|
86 | |
---|
87 | |
---|
88 | figure |
---|
89 | errorbar(Bphase,Es/1000,Ess/1000,'-*r','linewidth',2) |
---|
90 | set(gca,'fontsize',16) |
---|
91 | xlabel('Buncher power, [a.u.]') |
---|
92 | ylabel('Electron intensity, [a.u.]') |
---|
93 | grid on |
---|
94 | |
---|
95 | |
---|
96 | |
---|
97 | |
---|
98 | figure |
---|
99 | chi(chi<0)=0; |
---|
100 | [hc hc]=contourf(Bphase(:), 48:7:118, chi',40) |
---|
101 | set(hc,'LineStyle','none'); |
---|
102 | colorbar |
---|
103 | set(gca,'fontsize',16) |
---|
104 | ylabel('Angle, [deg.]') |
---|
105 | xlabel('Buncher power, [a.u.]') |
---|
106 | title('R^2') |
---|
107 | |
---|
108 | figure |
---|
109 | [hc hc]=contourf(Bphase(:), 48:7:118, 2./lamb',40) |
---|
110 | set(hc,'LineStyle','none'); |
---|
111 | colorbar |
---|
112 | set(gca,'fontsize',16) |
---|
113 | ylabel('Angle, [deg.]') |
---|
114 | xlabel('Buncher power, [a.u.]') |
---|
115 | title('Evanescent wavelength, [mm]') |
---|
116 | |
---|
117 | %3d diap is bad |
---|
118 | |
---|
119 | figure |
---|
120 | hold on |
---|
121 | errorbar(Bphase',2./lamb(:,4),2./lamb(:,4).^2.*Ierrp(:,4,2),'-.^b','linewidth',2) |
---|
122 | errorbar(Bphase',2./lamb(:,7),2./lamb(:,7).^2.*Ierrp(:,7,2),'-.*r','linewidth',2) |
---|
123 | errorbar(Bphase',2./lamb(:,10),2./lamb(:,10).^2.*Ierrp(:,10,2),'-.ok','linewidth',2) |
---|
124 | set(gca, 'YScale', 'log') |
---|
125 | set(gca,'fontsize',16) |
---|
126 | xlabel('Buncher power, [a.u.]') |
---|
127 | ylabel('Evanescent wavelength, [mm]') |
---|
128 | grid on |
---|
129 | gam=((38:1:44)+0.2)/0.511+1; |
---|
130 | bet=sqrt(1-1./gam.^2); |
---|
131 | phi=2/180*pi; |
---|
132 | plot(Bphase',6*(1./bet-cos((69)/180*pi)).*bet.*gam/(2*pi)./(sqrt(1+(bet.*gam*sin((69)/180*pi)*sin(phi)).^2)),'-b','linewidth',2) |
---|
133 | plot(Bphase',6*(1./bet-cos((90)/180*pi)).*bet.*gam/(2*pi)./(sqrt(1+(bet.*gam*sin((90)/180*pi)*sin(phi)).^2)),'-r','linewidth',2) |
---|
134 | plot(Bphase',6*(1./bet-cos((111)/180*pi)).*bet.*gam/(2*pi)./(sqrt(1+(bet.*gam*sin((111)/180*pi)*sin(phi)).^2)),'-k','linewidth',2) |
---|
135 | legend('D. 69^o','D. 90^o', 'D. 111^o','C. 69^o','C. 90^o', 'C. 111^o') |
---|
136 | |
---|
137 | figure |
---|
138 | hold on |
---|
139 | plot(Bphase',amp(:,4),'-^b','linewidth',2) |
---|
140 | plot(Bphase',amp(:,7),'-*r','linewidth',2) |
---|
141 | plot(Bphase',amp(:,10),'-ok','linewidth',2) |
---|
142 | |
---|
143 | set(gca,'fontsize',16) |
---|
144 | legend('69^o','90^o', '111^o') |
---|
145 | xlabel('Buncher power, [a.u.]') |
---|
146 | ylabel('Amplitude, [a.u.]') |
---|
147 | grid on |
---|
148 | |
---|
149 | |
---|
150 | |
---|
151 | figure |
---|
152 | [hc hc]=contourf(Bphase(:), 48:7:118, fb',40) |
---|
153 | set(hc,'LineStyle','none'); |
---|
154 | colorbar |
---|
155 | set(gca,'fontsize',16) |
---|
156 | ylabel('Angle, [deg.]') |
---|
157 | xlabel('Buncher power, [a.u.]') |
---|
158 | title('Background, [a.u.]') |
---|
159 | % (hf,'-depsc','file.eps') |
---|
160 | |
---|
161 | figure |
---|
162 | [hc hc]=contourf(Bphase(:), 48:7:118, amp',40) |
---|
163 | set(hc,'LineStyle','none'); |
---|
164 | colorbar |
---|
165 | set(gca,'fontsize',16) |
---|
166 | ylabel('Angle, [deg.]') |
---|
167 | xlabel('Buncher power, [a.u.]') |
---|
168 | title('Amplitude, [a.u.]') |
---|
169 | % (hf,'-depsc','file.eps') |
---|
170 | |
---|
171 | |
---|
172 | |
---|
173 | |
---|
174 | figure |
---|
175 | hold on |
---|
176 | |
---|
177 | |
---|
178 | gam=44.2/0.511+1; |
---|
179 | bet=sqrt(1-1/gam^2); |
---|
180 | phi=2/180*pi; |
---|
181 | plot(48:7:118,6*(1/bet-cos((48:7:118)/180*pi))*bet*gam/(2*pi)./(sqrt(1+(bet*gam*sin((48:7:118)/180*pi)*sin(phi)).^2)),'m','linewidth',2) |
---|
182 | phi=1/180*pi; |
---|
183 | plot(48:7:118,6*(1/bet-cos((48:7:118)/180*pi))*bet*gam/(2*pi)./(sqrt(1+(bet*gam*sin((48:7:118)/180*pi)*sin(phi)).^2)),'g','linewidth',2) |
---|
184 | phi=0/180*pi; |
---|
185 | plot(48:7:118,6*(1/bet-cos((48:7:118)/180*pi))*bet*gam/(2*pi)./(sqrt(1+(bet*gam*sin((48:7:118)/180*pi)*sin(phi)).^2)),'b','linewidth',2) |
---|
186 | |
---|
187 | W=1./(Ierrp(:,:,2)).^2; |
---|
188 | chilevel=0; |
---|
189 | for c=1:11 |
---|
190 | LL(c)=sum(lamb((chi(:,c)>chilevel),c).*W((chi(:,c)>chilevel),c))/sum(W((chi(:,c)>chilevel),c)); |
---|
191 | LE(c)=sqrt(1/sum(W((chi(:,c)>chilevel),c))); |
---|
192 | end |
---|
193 | errorbar(48:7:118,2*(LL.^-1),2./(LL.^2).*LE,'-..k','linewidth',2) |
---|
194 | |
---|
195 | grid on |
---|
196 | set(gca,'fontsize',16) |
---|
197 | xlabel('Angle, [deg.]') |
---|
198 | ylabel('Evanescent wavelength, [mm]') |
---|
199 | legend('\phi=2^o','\phi=1^o','\phi=0^o','data','Location','northwest') |
---|
200 | separation=-10; |
---|
201 | |
---|
202 | figure |
---|
203 | hold on |
---|
204 | |
---|
205 | bp=1; |
---|
206 | Spectrum=amp(bp,:).*exp(lamb(bp,:)*separation); |
---|
207 | errorbar(48:7:118,Spectrum,Spectrum.*sqrt((Ierrp(bp,:,1)./amp(bp,:)).^2+(separation*Ierrp(bp,:,2)).^2),'k','linewidth',2) |
---|
208 | bp=3; |
---|
209 | Spectrum=amp(bp,:).*exp(lamb(bp,:)*separation); |
---|
210 | errorbar(48:7:118,Spectrum,Spectrum.*sqrt((Ierrp(bp,:,1)./amp(bp,:)).^2+(separation*Ierrp(bp,:,2)).^2),'r','linewidth',2) |
---|
211 | bp=5; |
---|
212 | Spectrum=amp(bp,:).*exp(lamb(bp,:)*separation); |
---|
213 | errorbar(48:7:118,Spectrum,Spectrum.*sqrt((Ierrp(bp,:,1)./amp(bp,:)).^2+(separation*Ierrp(bp,:,2)).^2),'b','linewidth',2) |
---|
214 | |
---|
215 | % bp=7; |
---|
216 | % Spectrum=amp(bp,:).*exp(lamb(bp,:)*separation); |
---|
217 | % errorbar(48:7:118,Spectrum,Spectrum.*sqrt((Ierrp(bp,:,1)./amp(bp,:)).^2+(separation*Ierrp(bp,:,2)).^2),'g','linewidth',2) |
---|
218 | % |
---|
219 | set(gca,'fontsize',16) |
---|
220 | legend('BP=2.4','BP=2.0','BP=1.6') |
---|
221 | xlabel('Angle, [deg.]') |
---|
222 | ylabel('Amplitude, [a.u.]') |
---|
223 | title('Spectrum') |
---|
224 | grid on |
---|
225 | ylim([0 0.02]) |
---|