at.load.utils
Conversion utilities for creating pyat elements.
Functions
Classes
-
element_from_dict(elem_dict, index=None, check=True, quiet=False)[source]
Builds an Element from a dictionary of attributes.
- Parameters:
elem_dict (dict) – Dictionary of element attributes
index (int | None) – Element index
check (bool) – Check the compatibility of class and PassMethod
quiet (bool) – Suppress the warning for non-standard classes
- Returns:
elem (Element) – new Element
-
find_class(elem_dict, quiet=False, index=None)[source]
Deduce the class of an element from its attributes.
find_class looks first at the “Class” field, if existing. It then tries to deduce
the class from “FamName”, from “PassMethod”, and finally form the element contents.
- Parameters:
elem_dict (dict) – The dictionary of keyword arguments passed to the
Element constructor.
quiet (bool) – Suppress the warning for non-standard classes
index (int | None) – Element index in the lattice
- Returns:
element_class – The guessed Class name
-
keep_attributes(ring)[source]
Remove Lattice attributes which must not be saved on file.
-
keep_elements(ring)[source]
Remove the ‘RingParam’ Marker.
-
protect(string, fence=('"', '"'), *, placeholder='placeholder')[source]
-
restore(replmatch, *parts)[source]
-
split_ignoring_parentheses(string, delimiter=',', fence=('\\(', '\\)'), maxsplit=-1)[source]
Split a string while keeping protected expressions intact.
Example: “l=0,hom(4,0.0,0)” -> [“l=0”, “hom(4,0.0,0)”]