source: MML/trunk/mml/quadplotall.m @ 4

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

Initial import--MML version from SOLEIL@2013

File size: 4.4 KB
Line 
1function [Xnew, Ynew, BPMxFamily, QUADxFamily, BPMyFamily, QUADyFamily, DateMatX, DateMatY] = quadplotall(DirName, PlotFlag)
2%QUADPLOTALL - Collect the date from a quadrupole center run.
3%              When all the quadrupole center data files are stored in a directory this function
4%              will go through all the files and pull out and plot some of the important information.
5%              Note: if more than one quadrupole center file for the same quadrupole is in the directory
6%                    then only the latter file will be returned.  Use quadgetdata to get all the data.
7%
8%  [X, Y, BPMxFamily, QUADxFamily, BPMyFamily, QUADyFamily, XfileDate, YfilesDate] = quadplotall(DirName, PlotFlag)
9%
10%  INPUTS
11%  1. DirName - Directory name to look for quadrupole center files 
12%               [] to browse {Default}
13%  2. PlotFlag - 0 to just get data without plotting results, else, plot results
14
15%  OUTPUTS
16%  1. X - Horizontal output matrix (format below)
17%  2. Y - Vertical output matrix (format below)
18%
19%             1&2     3       4        5     6       7         8         9      10       11      12       13
20%  Output = [BPMDev Center CenterSTD BPMpos DCCT BPMATIndex Quadpos QuadATIndex BPMBeta BPMPhi QuadBeta QuadPhi]
21%
22%  3-6. BPMxFamily, QUADxFamily, BPMyFamily, QUADyFamily - Family name for each center measurement
23%  7-8. XfileDate, YfilesDate - Date string for the file name
24%
25%  Written by Greg Portmann
26
27
28if nargin == 0
29    DirName = '';
30end
31
32if nargin < 2
33    PlotFlag = 1;
34end
35
36
37[X, Y, BPMxFamily, QUADxFamily, BPMyFamily, QUADyFamily, DateMatX, DateMatY] = quadgetdata(DirName, PlotFlag);
38
39
40dx = family2dev('BPMx',0);
41Xnew = NaN * ones(size(dx,1),size(X,2));
42Xnew(:,1:2) = dx;
43i = findrowindex(X(:,1:2), dx);
44Xnew(i,:) = X;
45
46
47dy = family2dev('BPMy',0);
48Ynew = NaN * ones(size(dy,1),size(Y,2));
49Ynew(:,1:2) = dy;
50j = findrowindex(Y(:,1:2), dy);
51Ynew(j,:) = Y;
52
53
54% Add to quadgetdata output
55
56
57% Get the average Beta and Phi at all AT indicies
58[BetaX, BetaY] = modeltwiss('Beta'); 
59BetaX = [(BetaX(1:end-1)+BetaX(2:end))/2; BetaX(end)];
60BetaY = [(BetaY(1:end-1)+BetaY(2:end))/2; BetaY(end)];
61
62[PhiX,  PhiY]  = modeltwiss('Phase'); 
63PhiX = [(PhiX(1:end-1)+PhiX(2:end))/2; PhiX(end)];
64PhiY = [(PhiY(1:end-1)+PhiY(2:end))/2; PhiY(end)];
65
66i = findrowindex(X(:,1:2), dx);
67j = findrowindex(Y(:,1:2), dy);
68Xnew = [Xnew NaN*ones(size(Xnew,1),4)];
69Xnew(i,end-3:end) = [BetaX(Xnew(i,7)) PhiX(Xnew(i,7)) BetaX(Xnew(i,9)) PhiX(Xnew(i,9))];
70Ynew = [Ynew NaN*ones(size(Ynew,1),4)];
71Ynew(j,end-3:end) = [BetaY(Ynew(j,7)) PhiY(Ynew(j,7)) BetaY(Ynew(j,9)) PhiY(Ynew(j,9))];
72
73
74
75if PlotFlag
76    L = getfamilydata('Circumference');
77
78    XOffset = getoffset('BPMx', Xnew(:,1:2));
79    YOffset = getoffset('BPMy', Ynew(:,1:2));
80
81
82    figure;
83    subplot(2,1,1);
84    plot(Xnew(:,5), Xnew(:,3)-XOffset, '.b');
85    ylabel('Horizontal [mm]');
86    xaxis([0 L]);
87    title('New BPM Offsets Relative to the Present Offset Orbit');
88
89    subplot(2,1,2);
90    plot(Ynew(:,5), Ynew(:,3)-YOffset, '.b');
91    xlabel('BPM Position [meters]');
92    ylabel('Vertical [mm]');
93    xaxis([0 L]);
94
95
96    figure;
97    subplot(2,1,1);
98    plot(Xnew(:,5),360*(Xnew(:,11)-Xnew(:,13))/2/pi,'.r');
99    xaxis([0 L]);
100    ylabel('Horizontal [degrees]');
101    title('Phase Advance Between the BPM and Quadrupole');
102
103    subplot(2,1,2);
104    plot(Ynew(:,5),360*(Ynew(:,11)-Ynew(:,13))/2/pi,'.r');
105    xaxis([0 L]);
106    xlabel('BPM Position [meters]');
107    ylabel('Vertical [degrees]');
108
109   
110    figure;
111    subplot(2,1,1);
112    plot(Xnew(:,5),Xnew(:,10),'.b', Xnew(:,8),Xnew(:,12),'.r');
113    xaxis([0 L]);
114    ylabel('Horizontal [meters]');
115    legend('BPM', 'Quadrupole');
116    title('Beta Function at the BPM and Quadrupole');
117
118    subplot(2,1,2);
119    plot(Ynew(:,5),Ynew(:,10),'.b', Ynew(:,8),Ynew(:,12),'.r');
120    xaxis([0 L]);
121    xlabel('Position [meters]');
122    ylabel('Vertical [meters]');
123    legend('BPM', 'Quadrupole');
124
125
126    figure;
127    subplot(2,1,1);
128    plot(Xnew(:,5),Xnew(:,6),'.');
129    xaxis([0 L]);
130    xlabel('Position [meters]');
131    ylabel('DCCT [mamps]');
132    title('Beam Current During the Horizontal Measurement');
133
134    subplot(2,1,2);
135    plot(Ynew(:,5),Ynew(:,6),'.');
136    xaxis([0 L]);
137    xlabel('Position [meters]');
138    ylabel('DCCT [mamps]');
139    title('Beam Current During the Vertical Measurement');
140
141
142    % Only return the measure centers
143    i = find(~isnan(Xnew(:,3)));
144    Xnew = Xnew(i,:);
145
146    i = find(~isnan(Ynew(:,3)));
147    Ynew = Ynew(i,:);
148end
Note: See TracBrowser for help on using the repository browser.