-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathSCgetDispersion.m
103 lines (84 loc) · 2.32 KB
/
SCgetDispersion.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
function eta = SCgetDispersion(SC,RFstep,varargin)
% SCgetDispersion
% ===============
%
% NAME
% ----
% SCgetDispersion - Measure dispersion by changing the rf frequency of the cavities
%
% SYNOPSIS
% --------
% `eta = SCgetDispersion(SC, RFstep)`
%
%
% DESCRIPTION
% -----------
% Calculates reference BPM reading, then changes the rf frequency and gets a
% second BPM reading in order to calculate the dispersion.
%
% INPUTS
% ------
% `SC`::
% SC base structure
% `RFstep`::
% Change of RF frequency in Hz
%
% OPTIONS
% -------
% The following options can be given as name/value-pairs:
%
% `'BPMords'` (`SC.ORD.BPM`)::
% List of BPM ordinates at which the dispersion should be returned
% `'CAVords'` (`SC.ORD.CAV`)::
% List of cavity ordinates with which the dispersion should be measured
% `'nSteps'` (2)::
% Number of RF steps (1st RF step is considered the reference). If more than 2 steps are
% specified, the measurement is bi-directional
%
% RETURN VALUE
% ------------
% `eta`::
% Dispersion [m/Hz]
%
% EXAMPLES
% --------
% Calculate the dispersion with a 1 kHz rf frequency change.
% -------------------------------
% eta = SCgetDispersion(SC,1E3);
% -------------------------------
%
% SEE ALSO
% --------
% *SCsetCavs2SetPoints*
warning('TODO: needs to be updated!')
% Parse optional arguments
p = inputParser;
addOptional(p,'BPMords',SC.ORD.BPM);
addOptional(p,'CAVords',SC.ORD.Cavity);
addOptional(p,'nSteps',2);
parse(p,varargin{:});
par = p.Results;
% Define RF steps
for nCav=1:length(par.CAVords)
RFsteps(nCav,:) = SC.RING{par.CAVords(nCav)}.FrequencySetPoint + linspace(-RFstep,RFstep,par.nSteps);
end
% Get reference BPM reading
Bref = reshape(SCgetBPMreading(SC,'BPMords',par.BPMords)',[],1);
if par.nSteps==2
% Change RF frequency
SC = SCsetCavs2SetPoints(SC,par.CAVords,'Frequency',RFstep,'add');
% Calculate second BPM reading
B = reshape(SCgetBPMreading(SC,'BPMords',par.BPMords)',[],1);
% Calculate dispersion
eta = (B-Bref)/RFstep;
else
% Loop over frequency setpoints
for nStep=1:par.nSteps
% Change RF frequency
SC = SCsetCavs2SetPoints(SC,par.CAVords,'Frequency',RFsteps(:,nStep),'abs');
% Calculate BPM reading differences
dB(nStep,:) = reshape(SCgetBPMreading(SC,'BPMords',par.BPMords)',[],1) - Bref;
end
% Linear regression
eta = linspace(-RFstep,RFstep,par.nSteps)'\dB;
end