48
48
49
49
The response matrix may be built by three methods:
50
50
51
- 1. :py:meth:`~ResponseMatrix.build ` computes the matrix using tracking
51
+ 1. :py:meth:`~ResponseMatrix.build_tracking ` computes the matrix using tracking
52
52
(any :py:class:`ResponseMatrix`)
53
53
2. :py:meth:`~OrbitResponseMatrix.build_analytical` analytically computes the matrix
54
54
using formulas from [1]_ (:py:class:`OrbitResponseMatrix` only)
@@ -210,12 +210,16 @@ def __init__(self):
210
210
self ._varmask = None
211
211
212
212
@abc .abstractmethod
213
- def build (self ) -> None :
213
+ def build_tracking (self ) -> None :
214
214
"""Build the response matrix."""
215
215
nobs , nvar = self ._response .shape
216
216
self ._obsmask = np .ones (nobs , dtype = bool )
217
217
self ._varmask = np .ones (nvar , dtype = bool )
218
218
219
+ def build_analytical (self ) -> None :
220
+ """Build the response matrix."""
221
+ raise NotImplementedError ("build_analytical not implemented for self.__class__.__name__" )
222
+
219
223
@property
220
224
@abc .abstractmethod
221
225
def varweights (self ): ...
@@ -255,7 +259,9 @@ def response(self):
255
259
"""Response matrix."""
256
260
resp = self ._response
257
261
if resp is None :
258
- raise AtError ("No response matrix yet: run build() or load() first" )
262
+ raise AtError (
263
+ "No response matrix yet: run build_tracking() or load() first"
264
+ )
259
265
return resp
260
266
261
267
@property
@@ -302,7 +308,7 @@ def save(self, file) -> None:
302
308
be appended to the filename if it does not already have one.
303
309
"""
304
310
if self ._response is None :
305
- raise AtError ("No response matrix: run build () first" )
311
+ raise AtError ("No response matrix: run build_tracking() or load () first" )
306
312
np .save (file , self ._response )
307
313
308
314
def load (self , file ) -> None :
@@ -417,7 +423,7 @@ def correct(
417
423
self .variables .increment (corr , ring = ring )
418
424
return sumcorr
419
425
420
- def build (
426
+ def build_tracking (
421
427
self ,
422
428
use_mp : bool = False ,
423
429
pool_size : int | None = None ,
@@ -481,14 +487,14 @@ def build(
481
487
results = _resp (ring .deepcopy (), self .observables , self .variables , ** kwargs )
482
488
483
489
self ._response = np .stack (results , axis = - 1 )
484
- super ().build ()
490
+ super ().build_tracking ()
485
491
486
492
def exclude_obs (self , obsname : str , excluded : Refpts ) -> None :
487
493
# noinspection PyUnresolvedReferences
488
494
r"""Exclude items from :py:class:`.Observable`\ s.
489
495
490
496
After excluding observation points, the matrix must be rebuilt with
491
- :py:meth:`build `.
497
+ :py:meth:`build_tracking `.
492
498
493
499
Args:
494
500
obsname: :py:class:`.Observable` name.
@@ -583,7 +589,7 @@ def steerer(ik, delta):
583
589
584
590
def set_norm ():
585
591
bpm = LocalOpticsObservable (bpmrefs , "beta" , plane = pl )
586
- sts = LocalOpticsObservable (ids , "beta" , plane = pl )
592
+ sts = LocalOpticsObservable (steerrefs , "beta" , plane = pl )
587
593
dsp = LocalOpticsObservable (bpmrefs , "dispersion" , plane = 2 * pl )
588
594
tun = GlobalOpticsObservable ("tune" , plane = pl )
589
595
obs = ObservableList ([bpm , sts , dsp , tun ])
@@ -602,6 +608,9 @@ def set_norm():
602
608
603
609
pl = plane_ (plane , "index" )
604
610
plcode = plane_ (plane , "code" )
611
+ ids = ring .get_uint32_index (steerrefs )
612
+ nbsteers = len (ids )
613
+ deltas = np .broadcast_to (steerdelta , nbsteers )
605
614
if steersum and stsumweight is None or cavrefs and cavdelta is None :
606
615
cavd , stsw = set_norm ()
607
616
@@ -625,9 +634,6 @@ def set_norm():
625
634
observables .append (sumobs )
626
635
627
636
# Variables
628
- ids = ring .get_uint32_index (steerrefs )
629
- nbsteers = len (ids )
630
- deltas = np .broadcast_to (steerdelta , nbsteers )
631
637
variables = VariableList (steerer (ik , delta ) for ik , delta in zip (ids , deltas ))
632
638
if cavrefs is not None :
633
639
active = (el .longt_motion for el in ring .select (cavrefs ))
0 commit comments