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

class FieldMap(line, default_field_map_folder, cavity_settings, dat_idx=None, **kwargs)[source]

Bases: Element

A generic FIELD_MAP.

Parameters:
base_name = 'FM'
n_attributes: int | range | Collection = 10
__init__(line, default_field_map_folder, cavity_settings, dat_idx=None, **kwargs)[source]

Set most of attributes defined in TraceWin.

Parameters:
cavity_settings

Stores the settings of the cavity, such as amplitude or phase.

field: Field

Stores the field properties, such as interpolated field or frequency. This object is shared by all the caviities with the same geometry.

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

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.

Parameters:

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

Return type:

None

set_full_path(extensions)[source]

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.

Return type:

None

keep_cavity_settings(cavity_settings)[source]

Keep the cavity settings that were found.

Parameters:

cavity_settings (CavitySettings)

Return type:

None

has(key)[source]

Tell if required attribute is in this object or its cavity settings.

Parameters:

key (str) – Name of the attribute to check.

Returns:

True if the key is found in self or self.cavity_settings.

Return type:

bool

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

Get attributes from this class or its attributes.

Parameters:
  • *keys (Literal['aperture_flag', 'field_map_filename', 'field_map_folder', 'geometry'] | Literal['e_spat', 'n_cell', 'n_z', 'starting_position', 'section_idx'] | Literal['dat_idx', 'elt_idx', 'idx', 'idx_in_lattice', 'lattice', 'length_m', 'name', 'nature', 'section'] | Literal['abs_mesh', 'd_z', 'n_steps', 'rel_mesh', 's_in', 's_out', 'transf_mat_function'] | Literal['acceptance_energy', 'acceptance_phi', 'field', 'freq_cavity_mhz', 'k_e', 'omega_0_rf', 'phi_ref', 'phi_rf', 'phi_s', 'reference', 'rf_field', 'status', 'v_cav_mv'] | Literal['phi_0_abs', 'phi_0_rel', 'phi_s']) – Name of the desired attributes.

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

  • **kwargs (Any) – Other arguments passed to recursive getter.

  • none_to_nan (bool, default: False)

Return type:

Any

Returns:

Attribute(s) value(s).

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

Get attributes from this class or its attributes.

Parameters:
  • *keys (Literal['aperture_flag', 'field_map_filename', 'field_map_folder', 'geometry'] | Literal['e_spat', 'n_cell', 'n_z', 'starting_position', 'section_idx'] | Literal['dat_idx', 'elt_idx', 'idx', 'idx_in_lattice', 'lattice', 'length_m', 'name', 'nature', 'section'] | Literal['abs_mesh', 'd_z', 'n_steps', 'rel_mesh', 's_in', 's_out', 'transf_mat_function'] | Literal['acceptance_energy', 'acceptance_phi', 'field', 'freq_cavity_mhz', 'k_e', 'omega_0_rf', 'phi_ref', 'phi_rf', 'phi_s', 'reference', 'rf_field', 'status', 'v_cav_mv'] | Literal['phi_0_abs', 'phi_0_rel', 'phi_s']) – 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.

Return type:

Any

Returns:

Attribute(s) value(s).

to_line(which_phase, *args, **kwargs)[source]

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

Parameters:
  • which_phase (Literal['phi_0_abs', 'phi_0_rel', 'phi_s'] | Literal['as_in_original_dat'] | Literal['as_in_settings']) – Which phase should be put in the output DAT.

  • inplace – 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 0x75e517541dc0>
_phase_for_line(which_phase)[source]

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

Parameters:

which_phase (Literal['phi_0_abs', 'phi_0_rel', 'phi_s'] | Literal['as_in_original_dat'] | Literal['as_in_settings'])

Return type:

tuple[float, int, str]