File tree Expand file tree Collapse file tree 2 files changed +12
-10
lines changed
Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -98,21 +98,18 @@ def correct(
9898 trims = trims_v
9999 corr_array = self ._vcorr
100100
101- corrector_was_used = {key : False for key in trims .keys ()}
102101 corrector_names = corr_array .names ()
102+ corrector_to_index = {name : idx for idx , name in enumerate (corrector_names )}
103103 data_to_send = corr_array .strengths .get ()
104- for idx , name in enumerate (corrector_names ):
105- data_to_send [idx ] += trims [name ] * gain
106- corrector_was_used [name ] = True
107-
108- # check that all corrector trims will be sent
109- for key in trims .keys ():
110- if not corrector_was_used [key ]:
104+ for name in trims .keys ():
105+ idx = corrector_to_index .get (name , None )
106+ if idx is None :
111107 raise PyAMLException (
112- f"Corrector { key } was not used in the orbit correction . "
113- "There is an inconcistency between corrector arrays and "
108+ f"Corrector { name } not found in the magnet array for orbit corr . "
109+ "Possible inconcistency between corrector arrays and "
114110 "response matrix."
115111 )
112+ data_to_send [idx ] += trims [name ] * gain
116113
117114 corr_array .strengths .set (data_to_send )
118115 return
Original file line number Diff line number Diff line change @@ -24,6 +24,11 @@ def test_tuning_orm():
2424 vcorr = element_holder .get_magnets ("VCorr" )
2525 bpms = element_holder .get_bpms ("BPM" )
2626
27+ x , y = bpms .positions .get ().T # get reference orbit
28+ reference = np .concat ((x , y ))
29+ # there should be nothing to correct, but still work
30+ element_holder .orbit .correct (reference = reference )
31+
2732 # mangle orbit
2833 hcorr .strengths .set (
2934 hcorr .strengths .get () + std_kick * np .random .normal (size = len (hcorr ))
You can’t perform that action at this time.
0 commit comments