source: MML/trunk/machine/SOLEIL/StorageRing/diagnostics/get_LT.m @ 4

Last change on this file since 4 was 4, checked in by zhangj, 10 years ago

Initial import--MML version from SOLEIL@2013

File size: 4.7 KB
Line 
1function [previous_LT_Lib,LT_lib_mean,LT_lib_by_quarter,N_lib_valid,N_lib_valid_first_sort,N_lib_valid_second_sort,LT_DCCT,index_seuil_1,index_seuil_2,Time_history,DCCT_history]=...
2            get_LT(bpm_group,BPM_index,N_samples,previous_LT_Lib,LT_lib_mean,LT_lib_by_quarter,N_lib_valid,...
3            N_lib_valid_first_sort,N_lib_valid_second_sort,LT_DCCT,seuil_1,seuil_2,NLib2valid,Time_history,DCCT_history)
4
5historic_size=size(LT_lib_mean,2);
6N_BPM=tango_group_size(bpm_group);
7
8tic
9h=now;
10fprintf('*********  %s ***********\n',datestr(h))
11attr_list={'current','lifeTime'};
12result_DCCT=tango_read_attributes2('ANS/DG/DCCT-CTRL',attr_list);
13
14[LT_lib,is_valid,valid_samples]=duree_vie(bpm_group,N_samples);
15valid_Nb=size(find(is_valid),2);
16fprintf('%d Libera have long enough buffer, averaged size is %1.0f\n',valid_Nb,mean(valid_samples))
17N_lib_valid=circshift(N_lib_valid',-1)';
18N_lib_valid(historic_size)=valid_Nb;
19
20
21%first sort
22for j=1:N_BPM
23    if is_valid(j)
24        LT_Lib_valid(j)=LT_lib(j);
25    else
26        LT_Lib_valid(j)=previous_LT_Lib(j);
27        %LT_Lib_valid(j)=0;
28    end
29end
30previous_LT_Lib=LT_Lib_valid;
31ma1=mean(LT_Lib_valid);
32seuil_1_high=(1+seuil_1)*ma1;
33seuil_1_low=(1-seuil_1)*ma1;
34fover=find(LT_Lib_valid>seuil_1_high);
35funder=find(LT_Lib_valid<seuil_1_low);   
36f=[fover,funder];fs=sort(f);   
37for j=1:length(fs)
38    rido=fs(j);
39    LT_Lib_valid(rido-j+1)=[];
40end;
41fprintf('%d Libera remaining after first sort\n',size(LT_Lib_valid,2))
42N_lib_valid_first_sort=circshift(N_lib_valid_first_sort',-1)';   
43N_lib_valid_first_sort(historic_size)=size(LT_Lib_valid,2);
44
45%second sort
46ma2=mean(LT_Lib_valid);
47seuil_2_high=(1+seuil_2)*ma2;
48seuil_2_low=(1-seuil_2)*ma2;
49fover=find(LT_Lib_valid>seuil_2_high);
50funder=find(LT_Lib_valid<seuil_2_low);
51f=[fover,funder];fs=sort(f);
52for j=1:length(fs)
53    rido=fs(j);
54    LT_Lib_valid(rido-j+1)=[];
55end;
56fprintf('%d Libera remaining after second sort\n',size(LT_Lib_valid,2))
57fprintf('LT with Libera= %d \n',mean(LT_Lib_valid))
58N_lib_valid_second_sort=circshift(N_lib_valid_second_sort',-1)';   
59N_lib_valid_second_sort(historic_size)=size(LT_Lib_valid,2);
60LT_lib_mean=circshift(LT_lib_mean',-1)';
61for i=1:4
62    LT_lib_by_quarter(i,:)=circshift(LT_lib_by_quarter(i,:)',-1)';
63end
64
65if size(LT_Lib_valid,2)<NLib2valid
66    LT_lib_mean(historic_size)=LT_lib_mean(historic_size-1);
67    LT_lib_by_quarter(:,historic_size)=LT_lib_by_quarter(:,historic_size-1);
68else
69    LT_lib_mean(historic_size)=mean(LT_Lib_valid);
70    quarter_size=floor(N_lib_valid_second_sort(historic_size)/4);
71    for i=1:4
72    LT_lib_by_quarter(i,historic_size)=mean(LT_Lib_valid(quarter_size*(i-1)+1:quarter_size*(i)));
73    end
74end
75
76LT_DCCT=circshift(LT_DCCT',-1)';
77LT_DCCT(historic_size)=result_DCCT(2).value;
78
79DCCT_history=circshift(DCCT_history',-1)';
80DCCT_history(historic_size)=result_DCCT(1).value;
81
82Time_history=circshift(Time_history',-1)';
83Time_history(historic_size)=h;
84
85
86index_over=find(previous_LT_Lib>seuil_2_high);
87index_under=find(previous_LT_Lib<seuil_2_low);
88index_seuil_2=[index_over index_under];
89index_over=find(previous_LT_Lib>seuil_1_high);
90index_under=find(previous_LT_Lib<seuil_1_low);
91index_seuil_1=[index_over index_under];
92
93
94
95%figure(2)
96
97% subplot(3,1,1)
98% plot(LT_lib,'bo','LineWidth',2)
99% xlabel('BPM Number')
100% ylabel('Hours')
101% title('Last LT measurment for each Libera')
102% hold on
103% ma1(1:N_BPM)=ma1;
104% plot(BPM_index,ma1,'r')
105% index_over=find(LT_lib>seuil_2_high);
106% index_under=find(LT_lib<seuil_2_low);
107% index_seuil2=[index_over index_under];
108% plot(index_seuil2,LT_lib(index_seuil2),'gx','LineWidth',3,'MarkerSize',20)
109% ma2(1:N_BPM)=ma2;
110% plot(BPM_index,ma2,'g')
111% index_over=find(LT_lib>seuil_1_high);
112% index_under=find(LT_lib<seuil_1_low);
113% index_seuil_1=[index_over index_under];
114% plot(index_seuil_1,LT_lib(index_seuil_1),'rx','LineWidth',3,'MarkerSize',20)
115% plot(BPM_index,LT_lib_mean(historic_size),'b');
116% hold off
117% [Y,I]=sort(LT_lib(index_seuil_1));
118% for k=1:1:size(index_seuil_1,2)   
119%     %fprintf('%s: %3.1f hours\n',dev_list{index(I(k))},Y(k));
120% end
121% subplot(3,1,2)
122% plot(N_lib_valid,'b')
123% hold on
124% plot(N_lib_valid_first_sort,'r')
125% plot(N_lib_valid_second_sort,'g')
126% hold off
127% legend('valid buffer length','first sort','second sort')
128% title('History of valid Libera measurments number')
129% subplot(3,1,3)
130% plot(LT_lib_mean)
131% hold on
132% % plot(LT_Lib_by_quarter(:,1),'c--')
133% % plot(LT_Lib_by_quarter(:,2),'m--')
134% % plot(LT_Lib_by_quarter(:,3),'y--')
135% % plot(LT_Lib_by_quarter(:,4),'k--')
136%
137% % plot(LT_DCCT_instant,'r')
138% plot(LT_DCCT,'c')
139% hold off
140% grid on
141% %legend('Libera all','Libera quart 1','Libera quart 2','Libera quart 3','Libera quart 4','DCCT')
142% legend('Libera all','DCCT')
143% ylabel('Hours')
144% title('Lifetime History')
145% t=toc;
146% fprintf('processing time = %2.1f s\n',t)
147
148
Note: See TracBrowser for help on using the repository browser.