simulation_output module
Define a class to store outputs from different BeamCalculator.
Todo
Do I really need the r_zz_elt key??
Todo
Do I really need z_abs? Envelope1D does not uses it while TraceWin does.
Todo
Transfer matrices are stored in TransferMatrix, but also in
BeamParameters.zdelta.
Todo
Maybe the synchronous phase model should appear somewhere in here?
- class SimulationOutput(out_folder: Path, is_multiparticle: bool, is_3d: bool, synch_trajectory: ParticleFullTrajectory, cav_params: dict[str, float | None] | None, beam_parameters: BeamParameters, element_to_index: Callable[[str | Element, str | None], int | slice] | None, set_of_cavity_settings: SetOfCavitySettings, transfer_matrix: TransferMatrix | None = None, z_abs: ndarray | None = None, in_tw_fashion: DataFrame | None = None, r_zz_elt: list[ndarray] | None = None)
Bases:
objectStore the information produced by a
BeamCalculator.Used for fitting, post-processing, plotting.
- Parameters:
out_folder (pathlib.Path) – Results folder used by the
BeamCalculatorthat created this.is_multiparticle (bool) – Tells if the simulation is a multiparticle simulation.
is_3d (bool) – Tells if the simulation is in 3D.
synch_trajectory (ParticleFullTrajectory | None) – Holds energy, phase of the synchronous particle.
cav_params (dict[str, float | None] | None) – Holds amplitude, synchronous phase, absolute phase, relative phase of cavities.
beam_parameters (BeamParameters | None) – Holds emittance, Twiss parameters, envelopes in the various phase spaces.
element_to_index (Callable[[str | Element, str | None], int | slice] | None) – Takes an
Element, its name, ‘first’ or ‘last’ as argument, and returns corresponding index. Index should be the same in all the arrays attributes of this class:z_abs,beam_parametersattributes, etc. Used to easilygetthe desired properties at the proper position.set_of_cavity_settings (SetOfCavitySettings) – The cavity parameters used for the simulation.
transfer_matrix (TransferMatrix) – Holds absolute and relative transfer matrices in all planes.
z_abs (numpy.ndarray | None, optional) – Absolute position in the linac in m. The default is None.
in_tw_fashion (pandas.DataFrame | None, optional) – A way to output the
SimulationOutputin the same way as theDatatab of TraceWin. The default is None.r_zz_elt (list[numpy.ndarray] | None, optional) – Cumulated transfer matrices in the [z-delta] plane. The default is None.
- synch_trajectory: ParticleFullTrajectory
- beam_parameters: BeamParameters
- set_of_cavity_settings: SetOfCavitySettings
- transfer_matrix: TransferMatrix | None = None
- property beam_calculator_information: Path
Use
out_pathto retrieve info onBeamCalculator.
- has(key: str) bool
Tell if the required attribute is in this class.
We also call the
InitialBeamParameters.has(), as it is designed to handle the alias (such astwiss_zdelta<=>zdelta.twiss).
- get(*keys: str, to_numpy: bool = True, to_deg: bool = False, elt: Element | str | None = None, pos: Literal['in', 'out'] | None = None, none_to_nan: bool = False, **kwargs: str | bool | 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.
to_deg (bool, optional) – To apply np.rad2deg function over every
keycontaining the string.elt (Element | str | None, optional) – If provided, return the attributes only at the considered element.
pos (Literal["in", "out"] | None, optional) – If you want the attribute at the entry, exit, or in the whole element.
none_to_nan (bool, optional) – To convert None to np.nan. The default is False.
**kwargs (str | bool | None) – Other arguments passed to recursive getter.
- Returns:
out – Attribute(s) value(s).
- Return type:
Any
- compute_complementary_data(elts: ListOfElements, ref_simulation_output: Self | None = None) None
Compute some other indirect quantities.
- Parameters:
elts (ListOfElements) – Must be a full
ListOfElements, containing all the elements of the linac.ref_simulation_output (SimulationOutput | None, optional) – For calculation of mismatch factors. The default is None, in which case the calculation is simply skipped.
- pickle(pickler: MyPickler, path: Path | str | None = None) Path
Pickle (save) the object.
This is useful for debug and temporary saves; do not use it for long time saving.
- classmethod from_pickle(pickler: MyPickler, path: Path | str) Self
Instantiate object from previously pickled file.
- __init__(out_folder: Path, is_multiparticle: bool, is_3d: bool, synch_trajectory: ParticleFullTrajectory, cav_params: dict[str, float | None] | None, beam_parameters: BeamParameters, element_to_index: Callable[[str | Element, str | None], int | slice] | None, set_of_cavity_settings: SetOfCavitySettings, transfer_matrix: TransferMatrix | None = None, z_abs: ndarray | None = None, in_tw_fashion: DataFrame | None = None, r_zz_elt: list[ndarray] | None = None) None