at.latticetools.observablelist#

ObservableList(lattice, …)

This container based on list is in charge of optics computations and provides each individual Observable with its specific data.

ObservableList provides the evaluate() method and the following properties:

Classes

ObservableList([obsiter, method, orbit, ...])

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 all list methods, like appending, insertion or concatenation with the “+” operator.

Parameters:

obsiter (Iterable[Observable]) – Iterable of Observables

Keyword Arguments:
  • orbit (Orbit) – Initial orbit. Avoids looking for the closed orbit if it is already known. Used for MatrixObservable and LocalOpticsObservable

  • twiss_in – Initial conditions for transfer line optics. See get_optics(). Used for LocalOpticsObservable

  • 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

append(obs)[source]#

Append object to the end of the list.

evaluate(ring=None, *, dp=None, dct=None, df=None, initial=False, **kwargs)[source]#

Compute all the Observable values

Parameters:
  • ring (Lattice | None) – Lattice used for evaluation

  • dp (float) – Momentum deviation. Defaults to None

  • dct (float) – Path lengthening. Defaults to None

  • df (float) – Deviation from the nominal RF frequency. Defaults to None

  • initial (bool) – If True, store the values as initial values

Keyword Arguments:
exclude(obsname, excluded)[source]#
extend(obsiter)[source]#

Extend list by appending elements from the iterable.

get_deviations(*obsnames, err=None)[source]#

Return the deviations from target values

Parameters:
  • *obsnames (str) – names of selected observables (Default all)

  • err (float | None) – Default observable value to be used when the evaluation failed. By default, an Exception is raised.

get_flat_deviations(*obsnames, err=None, order='F')[source]#

Return a 1-D array of deviations from target values

Parameters:
  • *obsnames (str) – names of selected observables (Default all)

  • err (float | None) – Default observable value to be used when the evaluation failed. By default, an Exception is raised.

  • order (str) – Ordering for reshaping. See reshape()

get_flat_shape(*obsnames)[source]#

Shape of the flattened values

Parameters:

*obsnames (str) – names of selected observables (Default all)

get_flat_values(*obsnames, err=None, order='F')[source]#

Return a 1-D array of Observable values

Parameters:
  • *obsnames (str) – names of selected observables (Default all)

  • err (float | None) – Default observable value to be used when the evaluation failed. By default, an Exception is raised.

  • order (str) – Ordering for reshaping. See reshape()

get_flat_weighted_deviations(*obsnames, err=None, order='F')[source]#

Return a 1-D array of weighted deviations from target values

Parameters:
  • *obsnames (str) – names of selected observables (Default all)

  • err (float | None) – Default observable value to be used when the evaluation failed. By default, an Exception is raised.

  • order (str) – Ordering for reshaping. See reshape()

get_flat_weighted_values(*obsnames, err=None, order='F')[source]#

Return a 1-D array of Observable weighted values

Parameters:
  • *obsnames (str) – names of selected observables (Default all)

  • err (float | None) – Default observable value to be used when the evaluation failed. By default, an Exception is raised.

  • order (str) – Ordering for reshaping. See reshape()

get_flat_weights(*obsnames, order='F')[source]#

Return a 1-D array of Observable weights

Parameters:
  • *obsnames (str) – names of selected observables (Default all)

  • order (str) – Ordering for reshaping. See reshape()

get_residuals(*obsnames, err=None)[source]#

Return the residuals of observables

Parameters:
  • *obsnames (str) – names of selected observables (Default all)

  • err (float | None) – Default observable value to be used when the evaluation failed. By default, an Exception is raised.

get_shapes(*obsnames)[source]#

Return the shapes of all values

Parameters:

*obsnames (str) – names of selected observables (Default all)

get_sum_residuals(*obsnames, err=None)[source]#

Return the sum of residual values

Parameters:
  • *obsnames (str) – names of selected observables (Default all)

  • err (float | None) – Default observable value to be used when the evaluation failed. By default, an Exception is raised.

get_values(*obsnames, err=None)[source]#

Return the values of observables

Parameters:
  • *obsnames (str) – names of selected observables (Default all)

  • err (float | None) – Default observable value to be used when the evaluation failed. By default, an Exception is raised.

get_weighted_deviations(*obsnames, err=None)[source]#

Return the weighted deviations from target values

Parameters:
  • *obsnames (str) – names of selected observables (Default all)

  • err (float | None) – Default observable value to be used when the evaluation failed. By default, an Exception is raised.

get_weighted_values(*obsnames, err=None)[source]#

Return the weighted values of observables

Parameters:
  • *obsnames (str) – names of selected observables (Default all)

  • err (float | None) – Default observable value to be used when the evaluation failed. By default, an Exception is raised.

get_weights(*obsnames)[source]#

Return the weights of observables

Parameters:

*obsnames (str) – names of selected observables (Default all)

insert(index, obs)[source]#

Insert object before index.

property deviations: list#

Deviations from target values

property flat_deviations: ndarray#

1-D array of deviations from target value

property flat_shape#

Shape of the flattened values

property flat_values: ndarray#

1-D array of Observable values

property flat_weighted_deviations: ndarray#

1-D array of weighted deviations from target values

property flat_weighted_values: ndarray#

1-D array of Observable weigthed values

property flat_weights: ndarray#

1-D array of Observable weights

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}#
property residuals: list#

Residuals of all observable

property shapes: list#

Shapes of all values

property sum_residuals: float#

Sum of all residual values

property values: list#

values of all observables

property weighted_deviations: list#

Weighted deviations from target values

property weighted_values: list#

Weighted values of all observables