Utils
AT wrapper
This module contains wrappers to all the pyAT
functions, used in pySC
,
which are not member functions of used pyAT
objects.
This is due to observed side effects, such as modification of input parameters.
Tracking fuctions latice_track
, find_orbit4
, find_orbit6
index the result the same way as get_s_pos
,
i.e. 0 means entrance of the first element, len(elements) means end of the last element.
Function get_value_refpts
indexes elements as usual.
- pySC.utils.sc_tools.ords_from_regex(ring: Lattice, regex: str) ndarray [source]
Returns the indices of the elements in the ring whose names match the regex.
- Parameters:
ring (Lattice) -- The ring to search.
regex (str) -- The regular expression to match.
- Returns:
The indices of the matched elements.
- Return type:
ndarray
- pySC.utils.sc_tools.pinv(matrix: ndarray, num_removed: int = 0, alpha: float = 0, damping: float = 1, plot: bool = False) ndarray [source]
Computes the pseudo-inverse of a matrix using the Singular Value Decomposition (SVD) method.
- Parameters:
matrix (ndarray) -- The matrix to be inverted.
num_removed (int, optional) -- The number of singular values to be removed from the matrix.
alpha (float, optional) -- The regularization parameter.
damping (float, optional) -- The damping factor.
plot (bool, optional) -- If True, plots the singular values and the damping factor.
- Returns:
matrix_inv -- The pseudo-inverse of the matrix.
- Return type:
ndarray
- pySC.utils.sc_tools.randnc(cut_off: float = 2, shape: tuple = (1,)) ndarray | float64 [source]
Generates an array of random number(s) from normal distribution with a cut-off. If shape = () a single float value is returned.
- Parameters:
cut_off (float) -- The cut-off value.
shape (tuple) -- The shape of the output array.
- Returns:
out -- The output array (If shape = () a single float value)
- Return type:
Union[ndarray, float64]