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, dat_idx=None, idx_in_lattice=-1, lattice=-1, section=-1, **kwargs)[source]

Bases: Instruction

Generic element.

Parameters:
  • base_name – Short name for the element according to TraceWin. Should be overriden.

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

  • increment_lattice_idx – 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.

  • line (DatLine)

  • dat_idx (int | None, default: None)

  • idx_in_lattice (int, default: -1)

  • lattice (int, default: -1)

  • section (int, default: -1)

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

Init parameters common to all elements.

Parameters:
  • line (DatLine) – 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 | None, default: None) – Position in the DAT file.

  • name – 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.

  • idx_in_lattice (int, default: -1)

  • lattice (int, default: -1)

  • section (int, default: -1)

has(key)[source]

Tell if the required attribute is in this class.

Parameters:

key (str)

Return type:

bool

get(*keys, to_numpy=True, **kwargs)[source]

Shorthand to get attributes from this class or its attributes.

Parameters:
  • *keys (Literal['dat_idx', 'elt_idx', 'idx', 'idx_in_lattice', 'lattice', 'length_m', 'nature', 'section'] | Literal['abs_mesh', 'd_z', 'n_steps', 'rel_mesh', 's_in', 's_out', 'transf_mat_function']) – Name of the desired attributes.

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

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

Returns:

out – Attribute(s) value(s).

Return type:

Any

keep_rf_field(*args, **kwargs)[source]

Save data calculated by BeamCalculator.run_with_this(). :rtype: None

Deprecated since version 0.6.16: Prefer keep_cavity_settings()

keep_cavity_settings(cavity_settings)[source]

Save data calculated by BeamCalculator.run_with_this().

Parameters:

cavity_settings (CavitySettings)

Return type:

None

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)[source]

Change the status of the element. To override.

Parameters:

new_status (Literal['compensate (in progress)', 'compensate (not ok)', 'compensate (ok)', 'failed', 'nominal', 'rephased (in progress)', 'rephased (ok)'])

Return type:

None

_abc_impl = <_abc._abc_data object at 0x73dcb1fa8080>