source: MML/trunk/applications/orbit/lib/sortbpms.m

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

Initial import--MML version from SOLEIL@2013

File size: 3.4 KB
Line 
1function varargout=SortBPMss(varargin)
2% SortBPMss compares vectors for:
3%(1) available electronically (BPM.status)
4%(2) available in reference orbit (BPM.iref)
5%(3) available in response matrix (RSP.ib)
6%*** BPM.avail requires reference, response matrix, status
7
8BPM=varargin{1};
9RSP=varargin{2};
10
11% [C,IA,IB] = INTERSECT(A,B) returns index vectors IA and IB
12% such that C = A(IA) and C = B(IB)
13% [C,I] = SETDIFF(...) returns an index vector I such that C = A(I)
14
15for ip=1:2
16% compare status with reference orbit
17[BPM(ip).avail,IA,IB]=intersect(BPM(ip).iref,BPM(ip).status);     %BPM.iref and BPM.status are compressed
18[C,IA]=setdiff(BPM(ip).iref,BPM(ip).iref(IA));                    %check for rejected reference BPMs
19if ~isempty(IA)
20    %disp('SortBPMs Warning 1A: BPMs in reference orbit do not have valid status');
21    for ii=IA
22        %disp(BPM(ip).name(ii,:));
23    end
24end
25% [C,IB]=setdiff(BPM(ip).status,BPM(ip).status(IB));              %check for rejected status BPMs
26% if ~isempty(IB)
27%     disp('SortBPMs Warning 1B: BPMs with valid status not in reference orbit');
28%     for ii=IB
29%         disp(BPM(ip).name(ii,:));
30%     end
31% end
32
33% compare result with response matrix
34[BPM(ip).avail,IA,IB]=intersect(BPM(ip).avail,RSP(ip).ib);     %BPM.avail and RSP.ib are compressed
35[C,IA]=setdiff(BPM(ip).avail,BPM(ip).avail(IA));                  %check for rejected available BPMs
36if ~isempty(IA)
37    %disp('SortBPMs Warning 2A: BPMs with valid status and in reference orbit not in response matrix');
38    for ii=IA
39        %disp(BPM(ip).name(ii,:));
40    end
41end
42% [C,IB]=setdiff(RSP(ip).ib,RSP(ip).ib(IB));                      %check for rejected response matrix BPMs
43% if ~isempty(IB)
44%     disp('SortBPMs Warning 2B: BPMs in response matrix do not have valid status or not in reference orbit');
45%     for ii=IB
46%         disp(BPM(ip).name(ii,:));
47%     end
48% end
49
50% compare result with fit selection
51[BPM(ip).ifit,IA,IB]=intersect(BPM(ip).avail,BPM(ip).ifit);     %BPM.avail and BPM.ifit are compressed
52[C,IA]=setdiff(BPM(ip).avail,BPM(ip).avail(IA));                %check for rejected available BPMs
53% if ~isempty(IA)
54%     disp('SortBPMs Warning 3A: BPMs with valid status, in reference orbit, and in response matrix not in fit');
55%     for ii=IA
56%         disp(BPM(ip).name(ii,:));
57%     end
58% end
59%%%[C,IB]=setdiff(BPM(ip).ifit,BPM(ip).ifit(IB));                   %check for rejected fit BPMs
60if ~isempty(IB)
61    %disp('SortBPMs Warning 3B: BPMs in fit not do not have valid status, in reference orbit, or not in response matrix');
62    for ii=IB
63        %%%disp(BPM(ip).name(ii,:));
64    end
65end
66
67
68
69
70end  %end of plane loop
71
72% for ip=1:2
73% [navail,BPM(ip).avail]=intland(BPM(ip).status,BPM(ip).iref);  % compare status matrix with reference orbit
74% [navail,BPM(ip).avail]=intland(BPM(ip).avail,RSP(ip).ib);     % compare with response matrix
75% [nfit,BPM(ip).ifit]   =intland(BPM(ip).avail,BPM(ip).ifit);   % compare with fit selection
76% end
77
78varargout{1}=BPM;
79
80
81function t=testsort
82
83
84family='BPMx';
85[index,AO]=isfamily(family);
86name=family2common(AO);   
87status=[1 2 3 4 5]';
88avail =[1 2 3 4 5]';
89ifit  =[1 2 3 4 5]';
90iref  =[1 2 3 4 5]';
91irsp  =[1 2 3 4 5]';
92
93t.name=name;
94t.status=status;
95t.avail=avail;
96t.ifit=ifit;
97t.iref=iref;
98
99BPM(1)=t;
100BPM(2)=t;
101
102RSP(1).ib=irsp;
103RSP(2).ib=irsp;
104RSP(2).ic=irsp;
105RSP(2).ic=irsp;
106
107BPM=SortBPMs(BPM,RSP);
108
109t=BPM(1);
110disp('status')
111t.status
112disp('avail')
113t.avail
114disp('ifit')
115t.ifit
116disp('iref')
117t.iref
118disp('irsp')
119RSP(1).ib
120
Note: See TracBrowser for help on using the repository browser.