1 | function plotlattice(varargin) |
---|
2 | %PLOTLATTICE - Plot the lattice |
---|
3 | % plotlattice(FamilyName, FileName) |
---|
4 | % plotlattice(FamilyName, FileName) |
---|
5 | % |
---|
6 | % KEY WORDS |
---|
7 | % 1. 'Golden' - Golden lattice {Default} |
---|
8 | % 2. 'Injection' - Injection lattice |
---|
9 | % 3. 'Present' - Present lattice |
---|
10 | |
---|
11 | |
---|
12 | % 3. 'Position' - X-axis is the position along the ring {Default} |
---|
13 | % 4. 'Phase' - X-axis is the phase along the ring |
---|
14 | |
---|
15 | |
---|
16 | XAxisFlag = 'Position'; |
---|
17 | XLabel = 'Position [meters]'; |
---|
18 | |
---|
19 | FamilyName = ''; |
---|
20 | FileName = ''; |
---|
21 | ConfigSetpoint = []; |
---|
22 | |
---|
23 | % Input parsing |
---|
24 | for i = length(varargin):-1:1 |
---|
25 | if isstruct(varargin{i}) |
---|
26 | % Ignor structures |
---|
27 | elseif iscell(varargin{i}) |
---|
28 | % Ignor cells |
---|
29 | elseif strcmpi(varargin{i},'struct') |
---|
30 | % Just remove |
---|
31 | varargin(i) = []; |
---|
32 | elseif strcmpi(varargin{i},'numeric') |
---|
33 | % Just remove |
---|
34 | varargin(i) = []; |
---|
35 | elseif strcmpi(varargin{i},'Position') |
---|
36 | XAxisFlag = 'Position'; |
---|
37 | varargin(i) = []; |
---|
38 | elseif strcmpi(varargin{i},'Phase') |
---|
39 | XAxisFlag = 'Phase'; |
---|
40 | varargin(i) = []; |
---|
41 | elseif strcmpi(varargin{i},'Golden') || strcmpi(varargin{i},'Production') |
---|
42 | FileName = 'Production'; |
---|
43 | varargin(i) = []; |
---|
44 | elseif strcmpi(varargin{i},'Present') |
---|
45 | FileName = 'Present'; |
---|
46 | varargin(i) = []; |
---|
47 | elseif strcmpi(varargin{i},'Injection') || strcmpi(varargin{i},'Inj') |
---|
48 | FileName = 'Injection'; |
---|
49 | varargin(i) = []; |
---|
50 | elseif strcmpi(varargin{i},'Offset') |
---|
51 | % Just remove |
---|
52 | varargin(i) = []; |
---|
53 | end |
---|
54 | end |
---|
55 | |
---|
56 | if length(varargin) >= 1 |
---|
57 | if iscell(varargin{1}) |
---|
58 | FamilyName = varargin{1}; |
---|
59 | varargin(1) = []; |
---|
60 | elseif size(varargin{1},1) > 1 && ischar(varargin{1}) |
---|
61 | FamilyName = varargin{1}; |
---|
62 | varargin(1) = []; |
---|
63 | elseif isfamily(varargin{1}) |
---|
64 | FamilyName = varargin{1}; |
---|
65 | varargin(1) = []; |
---|
66 | elseif isstruct(varargin{1}) |
---|
67 | ConfigSetpoint = varargin{1}; |
---|
68 | varargin(1) = []; |
---|
69 | elseif ischar(varargin{1}) |
---|
70 | FileName = varargin{1}; |
---|
71 | varargin(1) = []; |
---|
72 | end |
---|
73 | end |
---|
74 | if length(varargin) >= 1 |
---|
75 | if iscell(varargin{1}) |
---|
76 | FamilyName = varargin{1}; |
---|
77 | varargin(1) = []; |
---|
78 | elseif size(varargin{1},1) > 1 && ischar(varargin{1}) |
---|
79 | FamilyName = varargin{1}; |
---|
80 | varargin(1) = []; |
---|
81 | elseif isfamily(varargin{1}) |
---|
82 | FamilyName = varargin{1}; |
---|
83 | varargin(1) = []; |
---|
84 | elseif isstruct(varargin{1}) |
---|
85 | ConfigSetpoint = varargin{1}; |
---|
86 | varargin(1) = []; |
---|
87 | elseif ischar(varargin{1}) |
---|
88 | FileName = varargin{1}; |
---|
89 | varargin(1) = []; |
---|
90 | end |
---|
91 | end |
---|
92 | |
---|
93 | if isempty(ConfigSetpoint) |
---|
94 | try |
---|
95 | if isempty(FileName) |
---|
96 | % Default file |
---|
97 | %FileName = getfamilydata('Default', 'CNFArchiveFile'); |
---|
98 | DirectoryName = getfamilydata('Directory', 'ConfigData'); |
---|
99 | [FileName, DirectoryName] = uigetfile('*.mat', 'Select a configuration file to load', DirectoryName); |
---|
100 | if FileName == 0 |
---|
101 | return |
---|
102 | end |
---|
103 | load([DirectoryName FileName]); |
---|
104 | FileName = [DirectoryName FileName]; |
---|
105 | AskStartQuestion = 0; |
---|
106 | elseif strcmpi(FileName, 'Production') |
---|
107 | % Get the production file name (full path) |
---|
108 | % AD.OpsData.LatticeFile could have the full path else default to AD.Directory.OpsData |
---|
109 | FileName = getfamilydata('OpsData','LatticeFile'); |
---|
110 | [DirectoryName, FileName, Ext, VerNumber] = fileparts(FileName); |
---|
111 | if isempty(DirectoryName) |
---|
112 | DirectoryName = getfamilydata('Directory', 'OpsData'); |
---|
113 | end |
---|
114 | FileName = fullfile(DirectoryName,[FileName, '.mat']); |
---|
115 | load(FileName); |
---|
116 | elseif strcmpi(FileName, 'Injection') |
---|
117 | % Get the injection file name (full path) |
---|
118 | % AD.OpsData.InjectionFile could have the full path else default to AD.Directory.OpsData |
---|
119 | FileName = getfamilydata('OpsData','InjectionFile'); |
---|
120 | [DirectoryName, FileName, Ext, VerNumber] = fileparts(FileName); |
---|
121 | if isempty(DirectoryName) |
---|
122 | DirectoryName = getfamilydata('Directory', 'OpsData'); |
---|
123 | end |
---|
124 | FileName = fullfile(DirectoryName,[FileName, '.mat']); |
---|
125 | load(FileName); |
---|
126 | elseif strcmpi(FileName, 'Present') |
---|
127 | [ConfigSetpoint, ConfigMonitor, FileName] = getmachineconfig; |
---|
128 | else |
---|
129 | % Input file name |
---|
130 | load(FileName); |
---|
131 | end |
---|
132 | catch |
---|
133 | fprintf('%s\n', lasterr) |
---|
134 | return |
---|
135 | end |
---|
136 | end |
---|
137 | |
---|
138 | |
---|
139 | L = getfamilydata('Circumference'); |
---|
140 | |
---|
141 | clf reset |
---|
142 | if ~isempty(FamilyName) |
---|
143 | FamilyName = [FamilyName,'.Setpoint']; |
---|
144 | plot(getspos(ConfigSetpoint.(FamilyName)), ConfigSetpoint.(FamilyName).Data, '.-'); |
---|
145 | xlabel(XLabel); |
---|
146 | ylabel(sprintf('%s [%s]',ConfigSetpoint.(FamilyName).FamilyName, ConfigSetpoint.(FamilyName).UnitsString)); |
---|
147 | |
---|
148 | else |
---|
149 | % Plot a bunch of typical families |
---|
150 | subplot(2,2,1); |
---|
151 | plot(getspos(ConfigSetpoint.HCM.Setpoint), ConfigSetpoint.HCM.Setpoint.Data, '.-'); |
---|
152 | %xlabel(XLabel); |
---|
153 | ylabel(sprintf('%s [%s]',ConfigSetpoint.HCM.Setpoint.FamilyName, ConfigSetpoint.HCM.Setpoint.UnitsString)); |
---|
154 | |
---|
155 | subplot(2,2,3); |
---|
156 | plot(getspos(ConfigSetpoint.VCM.Setpoint), ConfigSetpoint.VCM.Setpoint.Data, '.-'); |
---|
157 | xlabel(XLabel); |
---|
158 | ylabel(sprintf('%s [%s]',ConfigSetpoint.VCM.Setpoint.FamilyName, ConfigSetpoint.VCM.Setpoint.UnitsString)); |
---|
159 | |
---|
160 | subplot(2,2,2); |
---|
161 | plot(getspos(ConfigSetpoint.QF.Setpoint), ConfigSetpoint.QF.Setpoint.Data, '.-'); |
---|
162 | %xlabel(XLabel); |
---|
163 | ylabel(sprintf('%s [%s]',ConfigSetpoint.QF.Setpoint.FamilyName, ConfigSetpoint.QF.Setpoint.UnitsString)); |
---|
164 | |
---|
165 | subplot(2,2,4); |
---|
166 | plot(getspos(ConfigSetpoint.QD.Setpoint), ConfigSetpoint.QD.Setpoint.Data, '.-'); |
---|
167 | xlabel(XLabel); |
---|
168 | ylabel(sprintf('%s [%s]',ConfigSetpoint.QD.Setpoint.FamilyName, ConfigSetpoint.QD.Setpoint.UnitsString)); |
---|
169 | end |
---|
170 | xaxiss([0 L]); |
---|
171 | |
---|
172 | |
---|
173 | addlabel(1, 0, ['Lattice saved on ', datestr(ConfigSetpoint.VCM.Setpoint.TimeStamp,0)]); |
---|
174 | |
---|
175 | %addlabel(0, 0, sprintf(sprintf('RMS: Horizontal %6.3f %s Vertical %6.3f %s', std(x.Data), x.UnitsString, std(y.Data), y.UnitsString))); |
---|