interface module
Define functions for TraceWin command-line interface.
- variables_to_command(warn_skipped=False, **kwargs)[source]
Generate a TraceWin command from the input dictionary.
If the
valueof thedictis None, only correspondingkeyis added (behavior forhidecommand).If
valueisnp.nan, it is ignored.Else, the pair
key-valueis added askey=valuestring.
- beam_calculator_to_command(executable, ini_path, path_cal, **kwargs)[source]
Give command calling TraceWin according to
BeamCalculatorattribs.
- list_of_elements_to_command(dat_filepath)[source]
Return a command from
ListOfElementsattributes.ParticleInitialStateandBeamParametershave their own method, they are not called from here.
- beam_parameters_to_command(eps_x, alpha_x, beta_x, eps_y, alpha_y, beta_y, eps_z, alpha_z, beta_z)[source]
Return a TraceWin command from the attributes of a
BeamParameters.
- particle_initial_state_to_command(w_kin)[source]
Return a TraceWin command from attributes of
ParticleInitialState.We could use the
zpcommand to modify the phase at the entry of the first element (when it is not the first element of the linac). We rather keep the absolute phase at the beginning of the zone to 0. and modify theDATfile insubset_of_pre_existing_list_of_elementsfunction in order to always keep the same relative phi_0.
- set_of_cavity_settings_to_command(set_of_cavity_settings, phi_bunch_first_element, idx_first_element)[source]
Return the
elecommands forSetOfCavitySettings.- Parameters:
set_of_cavity_settings (
SetOfCavitySettings) – All the new cavity settings.phi_bunch_first_element (
float) – Phase of synchronous particle at entry of first element ofListOfElementsunder study.idx_first_element (
int) – Index of first element ofListOfElementsunder study.
- Return type:
- Returns:
Full command that will alter the TraceWin exection to match the desired
set_of_cavity_settings.
- failed_cavities_to_command(cavities, idx_first_element)[source]
Return the
elecommands to desactivate some cavities.
- _cavity_settings_to_command(field_map, cavity_settings, delta_phi_bunch=0.0, delta_index=0)[source]
Convert
cavity_settingsinto TraceWin CLI arguments.- Parameters:
field_map (
FieldMap) – Cavity under study.cavity_settings (
CavitySettings) – Settings to try.delta_phi_bunch (
float, default:0.0) – Phase at entry of first element ofListOfElementsunder study.delta_index (
int, default:0) – Index of the first element ofListOfElementsunder study.
- Return type:
- Returns:
Piece of command to alter
field_mapwithcavity_settings.
- ARGS_POSITIONS = {'k_e': 6, 'phi_0': 3}
- _alter_element(index, alter_kwargs)[source]
Create the command piece to modify the element at
index.- Parameters:
index (
int) – Position of the element to modify in LightWin referential (first element has index 0).alter_kwargs (
dict[str,float|int]) – Key-pair values, where key is the LightWin name of the parameter to update, and value the new value to set. Key-pair value is skipped if value is np.nan. Key must be inARGS_POSITIONS.
- Returns:
The
ele[i][j]=valcommand altering the given element.- Return type: