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