element module

Define base Element, declined in Drift, FieldMap, etc.

Todo

clean the patch for the ‘name’. my has and get methods do not work with @property

class Element(line: DatLine, dat_idx: int | None = None, idx_in_lattice: int = -1, lattice: int = -1, section: int = -1, **kwargs)

Bases: Instruction

Generic element.

Parameters:
  • base_name (str, optional) – Short name for the element according to TraceWin. Should be overriden. The default is "ELT".

  • increment_elt_idx (bool, optional) – If the element should be considered when counting the elements. If False, elt_idx will keep its default value of -1. The default is True. As for now, there is no element with this attribute set to False.

  • increment_lattice_idx (bool, optional) – If the element should be considered when determining the lattice. Should be True for physical elements, such as DRIFT, and False for other elements such as DIAGNOSTIC. The default is True.

base_name = 'ELT'
increment_elt_idx = True
increment_lattice_idx = True
is_implemented: bool = True
__init__(line: DatLine, dat_idx: int | None = None, idx_in_lattice: int = -1, lattice: int = -1, section: int = -1, **kwargs) None

Init parameters common to all elements.

Parameters:
  • line (list[str]) – A line of the .dat file. If the element was given a name, it must not appear in line but rather in name. First element of the list must be in implemented_elements.

  • dat_idx (int) – Position in the .dat file.

  • name (str | None, optional) – Non-default name of the element, as given in the .dat file. The default is None, in which case an automatic name will be given later.

has(key: str) bool

Tell if the required attribute is in this class.

get(*keys: str, to_numpy: bool = True, **kwargs: bool | str | None) Any

Shorthand to get attributes from this class or its attributes.

Parameters:
  • *keys (str) – Name of the desired attributes.

  • to_numpy (bool, optional) – If you want the list output to be converted to a np.ndarray. The default is True.

  • **kwargs (bool | str | None) – Other arguments passed to recursive getter.

Returns:

out – Attribute(s) value(s).

Return type:

Any

keep_rf_field(*args, **kwargs) None

Save data calculated by BeamCalculator.run_with_this().

Deprecated since version 0.6.16: Prefer keep_cavity_settings()

keep_cavity_settings(cavity_settings: CavitySettings) None

Save data calculated by BeamCalculator.run_with_this().

property is_accelerating: bool

Say if this element is accelerating or not.

Will return False by default.

property can_be_retuned: bool

Tell if we can modify the element’s tuning.

Will return False by default.

update_status(new_status: str) None

Change the status of the element. To override.

_abc_impl = <_abc._abc_data object at 0x7f3702f82ec0>