source: ETALON/CLIO/Analysis/Data24May/Bpower.m @ 719

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