mbtrack2.utilities.optics module¶
Module where the class to store the optic functions is defined.
- class Optics(lattice_file: str | None = None, tracking_loc: float = 0, local_beta: ndarray[tuple[int, ...], dtype[_ScalarType_co]] | None = None, local_alpha: ndarray[tuple[int, ...], dtype[_ScalarType_co]] | None = None, local_dispersion: ndarray[tuple[int, ...], dtype[_ScalarType_co]] | None = None, **kwargs)[source]¶
Bases:
objectClass used to handle optic functions.
Parameters¶
- lattice_filestr, optional if local_beta, local_alpha and
local_dispersion are specified. AT lattice file path.
- tracking_locfloat, optional
Longitudinal position where the tracking is in the AT lattice in [m]. Only used if an AT lattice is loaded to compute the optic functions at this location. Default is 0.
- local_betaarray of shape (2,), optional if lattice_file is specified.
Beta function at the location of the tracking. Default is mean beta if lattice has been loaded.
- local_alphaarray of shape (2,), optional if lattice_file is specified.
Alpha function at the location of the tracking. Default is mean alpha if lattice has been loaded.
- local_dispersionarray of shape (4,), optional if lattice_file is
specified. Dispersion function and derivative at the location of the tracking. Default is zero if lattice has been loaded.
Attributes¶
- use_local_valuesbool
True if no lattice has been loaded.
- local_gammaarray of shape (2,)
Gamma function at the location of the tracking.
lattice : AT lattice average_beta : array of shape (2,)
H and V average beta functions.
Methods¶
- load_from_AT(lattice_file, **kwargs)
Load a lattice from accelerator toolbox (AT).
- setup_interpolation()
Setup interpolation of the optic functions.
- beta(position)
Return beta functions at specific locations given by position.
- alpha(position)
Return alpha functions at specific locations given by position.
- gamma(position)
Return gamma functions at specific locations given by position.
- dispersion(position)
Return dispersion functions at specific locations given by position.
- plot(self, var, option, n_points=1000)
Plot optical variables.
- __init__(lattice_file: str | None = None, tracking_loc: float = 0, local_beta: ndarray[tuple[int, ...], dtype[_ScalarType_co]] | None = None, local_alpha: ndarray[tuple[int, ...], dtype[_ScalarType_co]] | None = None, local_dispersion: ndarray[tuple[int, ...], dtype[_ScalarType_co]] | None = None, **kwargs)[source]¶
- load_from_AT(lattice_file: str, **kwargs)[source]¶
Load a lattice from accelerator toolbox (AT).
Parameters¶
- lattice_filestr
AT lattice file path.
- n_pointsint or float, optional
Minimum number of points to use for the optic function arrays.
- periodicityint, optional
Lattice periodicity, if not specified the AT lattice periodicity is used.
- property local_beta: ndarray[tuple[int, ...], dtype[_ScalarType_co]]¶
Return beta function at the location defined by the lattice file.
- property local_alpha: ndarray[tuple[int, ...], dtype[_ScalarType_co]]¶
Return alpha function at the location defined by the lattice file.
- property local_gamma: ndarray[tuple[int, ...], dtype[_ScalarType_co]]¶
Return beta function at the location defined by the lattice file.
- beta(position: ndarray[tuple[int, ...], dtype[_ScalarType_co]] | float) ndarray[tuple[int, ...], dtype[_ScalarType_co]][source]¶
Return beta functions at specific locations given by position. If no lattice has been loaded, local values are returned.
Parameters¶
- positionarray or float
Longitudinal position at which the beta functions are returned.
Returns¶
- betaarray
Beta functions.
- alpha(position: ndarray[tuple[int, ...], dtype[_ScalarType_co]] | float) ndarray[tuple[int, ...], dtype[_ScalarType_co]][source]¶
Return alpha functions at specific locations given by position. If no lattice has been loaded, local values are returned.
Parameters¶
- positionarray or float
Longitudinal position at which the alpha functions are returned.
Returns¶
- alphaarray
Alpha functions.
- gamma(position: ndarray[tuple[int, ...], dtype[_ScalarType_co]] | float) ndarray[tuple[int, ...], dtype[_ScalarType_co]][source]¶
Return gamma functions at specific locations given by position. If no lattice has been loaded, local values are returned.
Parameters¶
- positionarray or float
Longitudinal position at which the gamma functions are returned.
Returns¶
- gammaarray
Gamma functions.
- dispersion(position: ndarray[tuple[int, ...], dtype[_ScalarType_co]] | float) ndarray[tuple[int, ...], dtype[_ScalarType_co]][source]¶
Return dispersion functions at specific locations given by position. If no lattice has been loaded, local values are returned.
Parameters¶
- positionarray or float
Longitudinal position at which the dispersion functions are returned.
Returns¶
- dispersionarray
Dispersion functions.
- mu(position: ndarray[tuple[int, ...], dtype[_ScalarType_co]] | float) ndarray[tuple[int, ...], dtype[_ScalarType_co]][source]¶
Return phase advances at specific locations given by position. If no lattice has been loaded, None is returned.
Parameters¶
- positionarray or float
Longitudinal position at which the phase advances are returned.
Returns¶
- muarray
Phase advances.
- plot(var: str, option: str, n_points: int = 1000, ax: Axes | None = None) Axes[source]¶
Plot optical variables.
Parameters¶
- var{“beta”, “alpha”, “gamma”, “dispersion”, “mu”}
Optical variable to be plotted.
- optionstr
If var = “beta”, “alpha” and “gamma”, option = {“x”,”y”} specifying the axis of interest. If var = “dispersion”, option = {“x”,”px”,”y”,”py”} specifying the axis of interest for the dispersion function or its derivative.
- n_pointsint
Number of points on the plot. The default value is 1000.
- axAxes, optional
Axes where the plot is displayed. If None, a new figure is created.
Return¶
- axAxes
Axes with the plot on it.