1 | function rsp=response2rsp(datastruct,rsp,plane) |
---|
2 | %load middlelayer response matrix data format into orbit program response structure |
---|
3 | %rsp=orbit program response structure |
---|
4 | %datastruct=middlelayer response matrix data format |
---|
5 | |
---|
6 | temp=datastruct; |
---|
7 | if iscell(temp) |
---|
8 | temp=temp{1} |
---|
9 | end |
---|
10 | |
---|
11 | BPMFamily={'BPMx', 'BPMy'}; |
---|
12 | CORFamily={'HCM' , 'VCM' }; |
---|
13 | |
---|
14 | if ~exist('plane','var') %check if variable |
---|
15 | for ip=1:2 |
---|
16 | nbpm=length(getfamilydata(BPMFamily{ip},'Status')); |
---|
17 | ncor=length(getfamilydata(CORFamily{ip},'Status')); |
---|
18 | rsp(ip).ib=dev2elem(BPMFamily{ip}, temp(ip,ip).Monitor.DeviceList); %BPM index list |
---|
19 | rsp(ip).ic=dev2elem(CORFamily{ip}, temp(ip,ip).Actuator.DeviceList); %corrector index list |
---|
20 | rsp(ip).c=zeros(nbpm,ncor); |
---|
21 | rsp(ip).c(rsp(ip).ib,rsp(ip).ic)=temp(ip,ip).Data; %response matrix INCLUDING NaN ENTRIES |
---|
22 | rsp(ip).cur=temp(ip,ip).ActuatorDelta; %corrector currents |
---|
23 | nbl=length(getfamilydata('BLOpen','ElementList')); %number of beamlines |
---|
24 | rsp(ip).ibl=zeros(1,nbl); %photon bpms |
---|
25 | rsp(ip).cp=zeros(nbl,length(rsp(ip).ic)); %response matrix to pbpms |
---|
26 | rsp(ip).respstruct=temp(ip,ip); |
---|
27 | end |
---|
28 | else |
---|
29 | ip=plane; |
---|
30 | nbpm=length(getfamilydata(BPMFamily{ip},'Status')); |
---|
31 | ncor=length(getfamilydata(CORFamily{ip},'Status')); |
---|
32 | rsp.ib=dev2elem(BPMFamily{ip},temp.Monitor.DeviceList); %BPM index list |
---|
33 | rsp.ic=dev2elem(CORFamily{ip},temp.Actuator.DeviceList); %corrector index list |
---|
34 | rsp.c=zeros(nbpm,ncor); |
---|
35 | rsp.c(rsp.ib,rsp.ic)=temp.Data; %response matrix INCLUDING NaN ENTRIES |
---|
36 | rsp.cur=temp.ActuatorDelta; %corrector currents |
---|
37 | nbl=length(getfamilydata('BLOpen','ElementList')); %number of beamlines |
---|
38 | rsp.ibl=zeros(1,nbl); %photon bpms |
---|
39 | rsp.cp=zeros(nbl,length(rsp.ic)); %response matrix to pbpms |
---|
40 | rsp.respstruct=temp; |
---|
41 | end |
---|
42 | |
---|