at.latticetools.observablelist#
ObservableList
(lattice, …)This container based on
list
is in charge of optics computations and provides each individualObservable
with its specific data.
ObservableList
provides the evaluate()
method and the following properties:
weights
Classes
|
Handles a list of Observables to be evaluated together |
- class ObservableList(obsiter=(), *, method=<function linopt6>, orbit=None, twiss_in=None, r_in=None, **kwargs)[source]#
Bases:
list
Handles a list of Observables to be evaluated together
ObservableList
supports alllist
methods, like appending, insertion or concatenation with the “+” operator.- Parameters:
obsiter (Iterable[Observable]) – Iterable of
Observable
s- Keyword Arguments:
orbit (Orbit) – Initial orbit. Avoids looking for the closed orbit if it is already known. Used for
MatrixObservable
andLocalOpticsObservable
twiss_in – Initial conditions for transfer line optics. See
get_optics()
. Used forLocalOpticsObservable
method (Callable) – Method for linear optics. Used for
LocalOpticsObservable
. Default:linopt6
r_in (Orbit) – Initial trajectory, used for
TrajectoryObservable
, Default: zeros(6)
Example
>>> obslist = ObservableList()
Create an empty Observable list
>>> obslist.append(OrbitObservable(at.Monitor, plane='x')) >>> obslist.append(GlobalOpticsObservable('tune')) >>> obslist.append(EmittanceObservable('emittances', plane='h'))
Add observables for horizontal closed orbit at Monitor locations, tunes and horizontal emittance
>>> obslist.evaluate(ring, initial=True)
Compute the values and mark them as the initial value
>>> obslist.values [array([-3.02189464e-09, 4.50695130e-07, 4.08205818e-07, 2.37899969e-08, -1.31783561e-08, 2.47230794e-08, 2.95310770e-08, -4.05598110e-07, -4.47398092e-07, 2.24850671e-09]), array([3.81563019e-01, 8.54376397e-01, 1.09060730e-04]), 1.320391045951568e-10]
>>> obslist.get_flat_values('tune', 'emittances[h]') array([3.815630e-01, 8.543764e-01, 1.090607e-04, 1.320391e-10])
Get a flattened array of tunes and horizontal emittance
- evaluate(ring=None, *, dp=None, dct=None, df=None, initial=False, **kwargs)[source]#
Compute all the
Observable
values- Parameters:
- Keyword Arguments:
orbit (Orbit) – Initial orbit. Avoids looking for the closed orbit if it is already known. Used for
MatrixObservable
andLocalOpticsObservable
twiss_in – Initial conditions for transfer line optics. See
get_optics()
. Used forLocalOpticsObservable
method (Callable) – Method for linear optics. Used for
LocalOpticsObservable
. Default:linopt6
r_in (Orbit) – Initial trajectory, used for
TrajectoryObservable
, Default: zeros(6)
- get_flat_deviations(*obsnames, err=None, order='F')[source]#
Return a 1-D array of deviations from target values
- get_flat_shape(*obsnames)[source]#
Shape of the flattened values
- Parameters:
*obsnames (str) – names of selected observables (Default all)
- get_flat_weighted_deviations(*obsnames, err=None, order='F')[source]#
Return a 1-D array of weighted deviations from target values
- get_flat_weighted_values(*obsnames, err=None, order='F')[source]#
Return a 1-D array of Observable weighted values
- get_shapes(*obsnames)[source]#
Return the shapes of all values
- Parameters:
*obsnames (str) – names of selected observables (Default all)
- get_weighted_deviations(*obsnames, err=None)[source]#
Return the weighted deviations from target values
- get_weights(*obsnames)[source]#
Return the weights of observables
- Parameters:
*obsnames (str) – names of selected observables (Default all)
- property flat_shape#
Shape of the flattened values
- needs_optics = {Need.GLOBALOPTICS, Need.LOCALOPTICS}#
- needs_orbit = {Need.EMITTANCE, Need.GLOBALOPTICS, Need.LOCALOPTICS, Need.MATRIX, Need.ORBIT}#
- needs_ring = {Need.EMITTANCE, Need.GEOMETRY, Need.GLOBALOPTICS, Need.LOCALOPTICS, Need.MATRIX, Need.ORBIT, Need.RING, Need.TRAJECTORY}#