Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MatlabOperation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
49
Issues
49
List
Boards
Labels
Service Desk
Milestones
Jira
Jira
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
BeamDynamics
MatlabOperation
Commits
27849c0f
Commit
27849c0f
authored
Mar 11, 2019
by
Thomas Perron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
just trying to do a litle tiny step
parent
063a578d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
145 additions
and
33 deletions
+145
-33
+ebs/get_steerresp.m
+ebs/get_steerresp.m
+2
-0
fun_tom/search_obs.m
fun_tom/search_obs.m
+143
-33
No files found.
+ebs/get_steerresp.m
View file @
27849c0f
...
...
@@ -16,7 +16,9 @@ if nargin<2, decodef=@ebs.steerindex; end
% [s1,s2,strs]=celldeal(strsplit(inpt,'\t','CollapseDelimiters',false));
% [sname,salgo,~]=celldeal(strsplit(s2,',','CollapseDelimiters',false));
[
s1
,
s2
,
strs
]
=
celldeal
(
regexp
(
inpt
,
'\t'
,
'split'
));
[
sname
,
salgo
,
~
]
=
celldeal
(
regexp
(
s2
,
','
,
'split'
));
gradient
=
str2double
(
s1
);
idx
=
decodef
(
sname
);
%resp=1.0E-3*str2double(strs'); % convert mm to m
...
...
fun_tom/search_obs.m
View file @
27849c0f
...
...
@@ -5,56 +5,165 @@ classdef search_obs
properties
CUR
BLM
ORBITH
ORBITV
LT
RING
ATSTRUCT
MODEL
HRESP
VRESP
HSTRENGTH
VSTRENGTH
INITSTRENGTH
s_ok
HSTNAME
VSTNAME
end
methods
function
obj
=
search_obs
(
machine
)
function
obj
=
search_obs
()
%UNTITLED Construct an instance of this class
% Detailed explanation goes here
% f=pwd;
%cd /machfs/perron/matlab/programs;
%addpathtom;
%cd(f);
if
strcmp
(
machine
,
'ebs'
)
res
=
(
'ebs selected'
);
curdir
=
pwd
;
cd
/
machfs
/
perron
/
matlab
/
programs
;
addpathtom
;
cd
(
curdir
);
obj
.
CUR
=
tango
.
Attribute
(
'sr/d-ct/1/current'
);
%obj.BUMPH=tango.Device('sr/beam-bump/all-h');
%obj.BUMPV=tango.Device('sr/beam-bump/all-v');
obj
.
BLM
=
tango
.
Device
(
'srdiag/beam-position/all'
);
obj
.
ORBITH
=
tango
.
Attribute
(
'srdiag/beam-position/all/SA_HPositions'
);
obj
.
ORBITV
=
tango
.
Attribute
(
'srdiag/beam-position/all/SA_VPositions'
);
obj
.
LT
=
tango
.
Attribute
(
'srdiag/beam-position/all/SA_HPositions_Peak'
);
obj
.
RING
=
'ebs'
;
obj
.
ATSTRUCT
=
ebs
.
model
;
dirname
=
uigetdir
(
'/operation/appdata/ebs/optics/settings'
,
'optic to be loaded'
);
obj
.
MODEL
=
ebs
.
model
(
dirname
);
obj
.
MODEL
.
directory
=
dirname
;
obj
.
HRESP
=
load
(
fullfile
(
dirname
,
'h_resp.csv'
));
obj
.
VRESP
=
load
(
fullfile
(
dirname
,
'v_resp.csv'
));
end
obj
.
s_ok
=
true
(
288
,
1
);
if
size
(
obj
.
HRESP
,
1
)
>
288
st
=
readtable
(
fullfile
(
dirname
,
'h_steerers.csv'
));
isdq
=
strfind
(
table2array
(
st
(:,
1
)),
'dq'
);
for
i
=
1
:
numel
(
isdq
);
obj
.
s_ok
(
i
)
=
isempty
(
isdq
{
i
});
end
end
in
=
obj
.
s_ok
;
obj
.
HRESP
=
obj
.
HRESP
(:,
in
);
obj
.
HSTRENGTH
=
tango
.
Attribute
(
'srmag/hst/all/Strengths'
);
obj
.
VSTRENGTH
=
tango
.
Attribute
(
'srmag/vst/all/Strengths'
);
obj
.
INITSTRENGTH
.
h
=
obj
.
HSTRENGTH
.
set
;
obj
.
INITSTRENGTH
.
v
=
obj
.
VSTRENGTH
.
set
;
obj
.
HSTNAME
=
tango
.
Attribute
(
'srmag/hst/all/CorrectorNames'
);
obj
.
VSTNAME
=
tango
.
Attribute
(
'srmag/vst/all/CorrectorNames'
);
end
function
reset_steer
(
obj
)
% resets steerers to the value they had when creating the instance
% of the object.
obj
.
HSTRENGTH
.
set
=
obj
.
INITSTRENGTH
.
h
;
obj
.
VSTRENGTH
.
set
=
obj
.
INITSTRENGTH
.
v
;
end
function
[
bumpini
,
bump_name
]
=
mkbump
(
obj
,
bump_name
,
bump_amplitude
)
%sets the bumps defined by BUMP_NAME (eg c02-h09) with the
function
[
or_fit
,
err_exec
]
=
mkbump
(
obj
,
bump_name
,
amplitude
,
numvect
)
%Makes a closed bump, using 30 correctors, on bpm corresponding to BUMP_NAME (formated like:'c02-h09') with the
%amplitude given by BUMP_AMPLITUDE (m)
%NUMVECT eigenvectors used to compute the bump, should be lower than 30. (default 10)
%
%outputs:
%OR_FIT: fited orbit as from matrix response
%ERR_EXEC, steerer strength increment in radiants used to perform the bump.
if
nargin
<
4
%input variable checks
numvect
=
10
end
if
numvect
>
28
fprintf
(
'error: numvect should be lower than29\n'
);
return
end
% loads response matrix, corrector indices and strengths depending on the needed plane.
if
strfind
(
bump_name
,
'h'
)
resp
=
obj
.
HRESP
;
icors
=
obj
.
MODEL
.
get
(
0
,
'steerh'
);
st_strength
=
obj
.
HSTRENGTH
;
stname
=
obj
.
HSTNAME
;
else
resp
=
obj
.
VRESP
;
icors
=
obj
.
MODEL
.
get
(
0
,
'steerv'
);
st_strength
=
obj
.
VSTRENGTH
;
stname
=
obj
.
VSTNAME
;
end
amp
=
bump_amplitude
;
%converts bump name to BPM name
bump_name
=
bump_name
([
1
2
3
4
6
7
]);
bump
=
tango
.
Attribute
([
'sr/beam-bump/'
bump_name
'/Amplitude'
]);
if
abs
(
amp
)
>
20E-4
res
=
(
'error bump amplitude too large'
);
% finds in the lattice structure lists of bpm and corrector
%to be considered for the given bump.
ibpms
=
obj
.
MODEL
.
get
(
0
,
'BPM'
);
ibpm
=
findcells
(
obj
.
MODEL
.
ring
,
'Device'
,[
'srdiag/beam-position/'
bump_name
]);
numbpm
=
find
(
ibpm
<=
ibpms
,
1
)
numcor
=
find
(
ibpm
<
icors
,
1
);
% if numcor>numel(icors); numcor=1; end
numcor
=
[
numcor
-
20
:
numcor
+
20
];
orb
=
zeros
(
numel
(
ibpms
),
1
);
orb
(
numbpm
)
=
amplitude
;
bpmok
=
true
(
1
,
320
);
bpmok
([
numbpm
-
3
numbpm
-
2
numbpm
-
1
numbpm
+
3
numbpm
+
2
numbpm
+
1
])
=
false
;
orb
(
~
bpmok
)
=
nan
;
numcor
=
mod
(
numcor
-
1
,
288
)
+
1
;
bpmok
=
mod
(
bpmok
-
1
,
320
)
+
1
;
%calculates the steerer strengths to be applied
[
or_fit
,
err_exec
]
=
calc_correction
(
numvect
,
resp
(:,
numcor
),
orb
,
0
);
% checks if the steerer strength is resonable and if yes aplies it.
stit
=
zeros
(
288
,
1
);
stit
(
numcor
)
=
err_exec
;
if
numel
(
st_strength
.
set
)
==
288
stfin
=
st_strength
.
set
+
stit
'
;
else
size
(
st_strength
.
set
(
obj
.
s_ok
))
stfin
(
obj
.
s_ok
)
=
stit
'+
st_strength
.
set
(
obj
.
s_ok
);
stfin
(
~
obj
.
s_ok
)
=
st_strength
.
set
(
~
obj
.
s_ok
);
end
else
bump
.
set
=
amp
;
end
end
if
sum
(
stfin
>
4.42E-4
)
>
0
%fprintf('too strong steerers');
steernok
=
find
(
stfin
>
4.42E-4
);
for
i
=
1
:
numel
(
steernok
)
error
=
[
'Strength send to corrector '
stname
.
read
{
steernok
(
i
)}
' out of range ('
num2str
(
1000
*
stfin
(
steernok
(
i
)))
'mrad)'
]
end
else
st_strength
.
set
=
stfin
;
end
end
function
plot_or_cells
(
obj
,
cini
,
cend
,
plane
)
...
...
@@ -62,7 +171,7 @@ classdef search_obs
%and CEND. PLANE=1 refers to horizontal, PLANE=2 refers to
%vertical.
mach
=
obj
.
ATSTRUCT
.
ring
;
mach
=
obj
.
MODEL
.
ring
;
mark
=
[
findcells
(
mach
,
'FamName'
,
'ID\w*'
)
sort
([
findcells
(
mach
,
'FamName'
,
'SDH\w*'
)
findcells
(
mach
,
'FamName'
,
'SDL\w*'
)])]
if
numel
(
mark
)
==
64
...
...
@@ -76,7 +185,7 @@ classdef search_obs
end
mach
=
circshift
(
mach
,
-
mark
(
mod
(
cini
-
4
,
32
)
+
1
));
orb
=
circshift
(
reshape
(
orb
,[],
32
)
',-mod(cini-
2
,32)+1)'
;
orb
=
circshift
(
reshape
(
orb
,[],
32
)
',-mod(cini-
3
,32)+1)'
;
orb
=
orb
(:,[
1
:
mod
(
cend
-
cini
,
32
)]);
orb
=
orb
(:);
...
...
@@ -95,7 +204,7 @@ classdef search_obs
atbaseplot
(
cells
);
whos
if
(
numel
(
orb
)
==
numel
(
bpm
))
spos
=
findspos
(
cells
,
bpm
);
hold
on
...
...
@@ -115,7 +224,7 @@ classdef search_obs
%and CEND. PLANE=1 refers to horizontal, PLANE=2 refers to
%vertical.
mach
=
obj
.
ATSTRUCT
.
ring
;
mach
=
obj
.
MODEL
.
ring
;
mark
=
[
findcells
(
mach
,
'FamName'
,
'ID\w*'
)
sort
([
findcells
(
mach
,
'FamName'
,
'SDH\w*'
)
findcells
(
mach
,
'FamName'
,
'SDL\w*'
)])];
if
numel
(
mark
)
==
64
...
...
@@ -150,11 +259,11 @@ classdef search_obs
cells
=
mach
(
1
:
mark_shift
(
mod
(
cend
-
cini
,
32
)));
iblm
=
sort
([
findcells
(
cells
,
'FamName'
,
'ID\w*'
)
findcells
(
cells
,
'FamName'
,
'QF7'
)
findcells
(
cells
,
'FamName'
,
'B1H'
)
findcells
(
cells
,
'FamName'
,
'DL\w*A\w*_2'
)
findcells
(
cells
,
'FamName'
,
'DL\w*E\w*_2'
)
...
findcells
(
cells
,
'FamName'
,
'JL\w*_2'
)
findcells
(
cells
,
'FamName'
,
'DL\w*D\w*_2'
)]);
figure
(
1
);
clf
(
1
);
figure
(
2
);
clf
(
2
);
atbaseplot
(
cells
);
whos
if
(
numel
(
blm
)
==
numel
(
iblm
))
spos
=
findspos
(
cells
,
iblm
);
hold
on
...
...
@@ -167,8 +276,9 @@ classdef search_obs
else
error
=
'blm vector length different from bmls numbers'
end
end
function
res
=
obs_search
(
obj
,
cell
,
plane
,
amplitude
)
end
function
res
=
obs_search
(
obj
,
cell
,
plane
,
amplitude
)
for
i
=
1
:
9
if
numel
(
num2str
(
cell
))
==
1
;
cell_str
=
[
num2str
(
0
)
num2str
(
cell
)];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment