field_map module

Hold a FIELD_MAP.

Todo

Handle the different kind of field_maps…

Todo

Completely handle the SET_SYNCH_PHASE command

Todo

Hande phi_s fitting with TraceWin.

Note

When subclassing field_maps, do not forget to update the transfer matrix selector in: - Envelope3D - ElementEnvelope3DParameters - SetOfCavitySettings - the run_with_this methods

IMPLEMENTED_STATUS = (   'nominal',     'rephased (in progress)',     'rephased (ok)',     'failed',     'compensate (in progress)',     'compensate (ok)',     'compensate (not ok)')
class FieldMap(line: DatLine, default_field_map_folder: Path, cavity_settings: CavitySettings, dat_idx: int | None = None, **kwargs)

Bases: Element

A generic FIELD_MAP.

base_name = 'FM'
n_attributes: int | range | Collection = 10
__init__(line: DatLine, default_field_map_folder: Path, cavity_settings: CavitySettings, dat_idx: int | None = None, **kwargs) None

Set most of attributes defined in TraceWin.

property status: str

Give the status from the CavitySettings.

property is_accelerating: bool

Tell if the cavity is working.

property can_be_retuned: bool

Tell if we can modify the element’s tuning.

update_status(new_status: str) None

Change the status of the cavity.

We use ElementBeamCalculatorParameters.re_set_for_broken_cavity() method. If k_e, phi_s, v_cav_mv are altered, this is performed in CavitySettings.status() setter.

set_full_path(extensions: dict[str, list[str]]) None

Set absolute paths with extensions of electromagnetic files.

Parameters:

extensions (dict[str, list[str]]) – Keys are nature of the field, values are a list of extensions corresponding to it without a period.

keep_cavity_settings(cavity_settings: CavitySettings) None

Keep the cavity settings that were found.

get(*keys: str, to_numpy: bool = True, none_to_nan: bool = False, **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

to_line(which_phase: Literal['phi_0_abs', 'phi_0_rel', 'phi_s', 'as_in_settings', 'as_in_original_dat'] = 'phi_0_rel', *args, **kwargs) list[str]

Convert the object back into a line in the .dat file.

Parameters:
  • which_phase (Literal["phi_0_abs", "phi_0_rel", "phi_s", ) – “as_in_settings”, “as_in_original_dat”] Which phase should be put in the output .dat.

  • inplace (bool, optional) – To modify the Element inplace. The default is False, in which case, we return a modified copy.

Returns:

The line in the .dat, with updated amplitude and phase from current object.

Return type:

list[str]

property _indexes_in_line: dict[str, int]

Give the position of the arguments in the FIELD_MAP command.

_abc_impl = <_abc._abc_data object at 0x7f36f97bd400>
_phase_for_line(which_phase: Literal['phi_0_abs', 'phi_0_rel', 'phi_s', 'as_in_settings', 'as_in_original_dat']) tuple[float, int, str]

Give the phase to put in .dat line, with abs phase flag.