1 | function [bufferX bufferZ RMSX RMSZ]=monbpmFA(record_length) |
---|
2 | |
---|
3 | %%TODO input parameter to be mapped as for monbpm (choice BPM etc ...) |
---|
4 | |
---|
5 | if record_length > 15 |
---|
6 | warning('Record length too long. Maximumvalue 15 s'); |
---|
7 | record_length = 15; |
---|
8 | end |
---|
9 | dev='ANS/DG/fofb-sniffer.2'; |
---|
10 | |
---|
11 | Nbpm=size(family2tangodev('BPMx'),1); |
---|
12 | h1=waitbar(0,'Recording on sniffer, please wait...'); |
---|
13 | tango_write_attribute2(dev,'recordLengthInSecs',record_length) |
---|
14 | pause(1) |
---|
15 | record_length=tango_read_attribute2(dev,'recordLengthInSecs'); |
---|
16 | for i=1:(record_length.value(1)+2) |
---|
17 | pause(1) |
---|
18 | waitbar(i/record_length.value(1),h1); |
---|
19 | end |
---|
20 | close(h1) |
---|
21 | |
---|
22 | h2=waitbar(0,'Reading on sniffer, please wait...'); |
---|
23 | |
---|
24 | for j=1:1:Nbpm |
---|
25 | bufferX(j,:)=double(tango_command_inout2(dev,'GetXPosData',uint16(j)))./10^3; |
---|
26 | bufferZ(j,:)=double(tango_command_inout2(dev,'GetZPosData',uint16(j)))./10^3; |
---|
27 | waitbar(j/Nbpm,h2) |
---|
28 | end |
---|
29 | RMSX=std(bufferX'); |
---|
30 | RMSZ=std(bufferZ'); |
---|
31 | close(h2) |
---|
32 | |
---|
33 | %% plot |
---|
34 | figure |
---|
35 | subplot(2,2,1) |
---|
36 | plot(bufferX(:,1:100:end)') |
---|
37 | xlabel('FA samples @ 10 kHz') |
---|
38 | ylabel('µm') |
---|
39 | title('Position X') |
---|
40 | subplot(2,2,2) |
---|
41 | plot(RMSX') |
---|
42 | xlabel('BPM number') |
---|
43 | ylabel('µm rms') |
---|
44 | title('Horizontal noise') |
---|
45 | subplot(2,2,3) |
---|
46 | plot(bufferZ(:,1:100:end)') |
---|
47 | xlabel('FA samples @ 10 kHz') |
---|
48 | ylabel('µm') |
---|
49 | title('Position Z') |
---|
50 | subplot(2,2,4) |
---|
51 | plot(RMSZ') |
---|
52 | xlabel('BPM number') |
---|
53 | ylabel('µm rms') |
---|
54 | title('Vertical noise') |
---|
55 | |
---|
56 | %% plot fit of the dispersion in the H-plane |
---|
57 | figure |
---|
58 | spos = getspos('BPMx',family2dev('BPMx')); |
---|
59 | etax = modeldisp('BPMx',family2dev('BPMx')); |
---|
60 | % y = disp*delta + y0 |
---|
61 | x = lsqr([etax ones(size(RMSX'))], RMSX'*1e-6); |
---|
62 | plot(spos, RMSX); hold on |
---|
63 | plot(spos,(etax*x(1)+x(2))*1e6,'r'); hold on |
---|
64 | legend('Data', 'fit') |
---|
65 | title(sprintf('Noise in H-plane: Delta = %.2e %% (x0 = %.2e um)', x(1)*100, x(2)*1e6)); |
---|
66 | xlabel('s-position (m)') |
---|
67 | ylabel('RMS x (um)') |
---|
68 | |
---|
69 | |
---|