field_map module

Hold a FIELD_MAP.

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:
Return type:

None

field_map_folder

Where all the field map files are to be found.

filename

Base name of all field map files, without extension.

cavity_settings

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

property status: Literal['compensate (in progress)', 'compensate (not ok)', 'compensate (ok)', 'failed', 'nominal', 'rephased (in progress)', 'rephased (ok)']

Give the status from the CavitySettings.

property is_accelerating: bool

Tell if the cavity is working.

property is_altered: bool

Tell if cavity is altered, i.e. not in nominal settings.

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.

Return type:

bool

Returns:

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

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['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['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, round=None, **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.

  • round (int | None, default: None) – Rounding numbers in exported line.

Return type:

list[str]

Returns:

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

property _indexes_in_line: dict[str, int]

Give the position of the arguments in the FIELD_MAP command.

_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']) – Name of the phase we are trying to export.

Return type:

tuple[float, int, Literal['phi_0_abs', 'phi_0_rel', 'phi_s']]

Returns:

  • float – Phase to write in the DAT file.

  • int0 for phi_0_rel, 1 for phi_0_abs. Unused for phi_s, a SET_SYNCH_PHASE command is added by :meth:` .FieldMap.to_line`.

  • REFERENCE_PHASES_T – Actual name of the phase that is exported.

_abc_impl = <_abc._abc_data object at 0x7318faa95740>
property z_0: float

Shifting constant of the field map.

Used in superposed maps.

plot()[source]

Plot the profile of the electric field.

Return type:

None