data_getter module
Define the function to extract the data to plot.
Todo
Fix the TransferMatrix plot with TraceWin solver.
- class _SimData(x, y, kw)[source]
Bases:
objectBundle of parallel x/y/kwargs lists for one accelerator’s simulations.
- Parameters:
- all_accelerators_data(x_axis, y_axis, *accelerators, error_presets, error_reference, to_deg=True, only_solver_id=None, **get_kwargs)[source]
Get x_data, y_data, kwargs from all Accelerators (<=> for 1 subplot).
- Parameters:
x_axis (
Literal['z_abs','elt_idx']) – Data to use as x-axis.y_axis (
Literal['acceptance_energy','acceptance_phi','beam_parameters','element_to_index','elt_idx','mismatch_factor_zdelta','phi_s','set_of_cavity_settings','synch_trajectory','v_cav_mv','z_abs'] |Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta'] |Literal['beta','gamma','phi_abs','synchronous','w_kin','z_in'] |Literal['e_mev','e_rest_mev','f_bunch_mhz','i_milli_a','q_adim','sigma','inv_e_rest_mev','gamma_init','omega_0_bunch','lambda_bunch','q_over_m','m_over_q'] |Literal['cumulated','individual','n_points','r_xx','r_yy','r_zdelta','r_zz','r_zdelta_11','r_zdelta_12','r_zdelta_21','r_zdelta_22'] |Literal['eps_t','eps_x','eps_y','mismatch_factor_t','mismatch_factor_x','mismatch_factor_y'] |Literal['eps_phiw99','eps_x99','eps_y99','pow_lost']) – Data to use as y-axis.*accelerators (
Accelerator) – Object holding theSimulationOutputto plot.error_presets (
dict[str,dict[str,str|float]]) – Dictionary passed to_error_calculation_function().error_reference (
Literal['ref accelerator (1st solv w/ 1st solv, 2nd w/ 2nd)','ref accelerator (1st solver)','ref accelerator (2nd solver)']) – Reference in errors calculations.to_deg (
bool, default:True) – Ify_axisdata with"phi"in their name should be converted to degrees.only_solver_id (
Collection[str] |str|None, default:None) – If set, we plot only data obtained with this solver(s). Must beBeamCalculator.id(or, equivalently, a key(s) inAccelerator.simulation_outputs). Typical values:"0_Envelope1D"or"1_TraceWin".
- Return type:
tuple[list[ndarray[tuple[Any,...],dtype[double]]],list[ndarray[tuple[Any,...],dtype[double]]],list[dict[str,Any]]]- Returns:
list[NDArray[np.float64]] –
(n,)list of x-arrays to plot.list[NDArray[np.float64]] –
(n,)list of y-arrays to plot.list[dict] –
(n,)list of plotkwargs.
- _single_accelerator_all_simulations_data(x_axis, y_axis, accelerator, only_solver_id=None, **get_kwargs)[source]
Get x_data, y_data, kwargs from all SimulationOutputs of Accelerator.
- Parameters:
x_axis (
Literal['z_abs','elt_idx'])y_axis (
Literal['acceptance_energy','acceptance_phi','beam_parameters','element_to_index','elt_idx','mismatch_factor_zdelta','phi_s','set_of_cavity_settings','synch_trajectory','v_cav_mv','z_abs'] |Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta'] |Literal['beta','gamma','phi_abs','synchronous','w_kin','z_in'] |Literal['e_mev','e_rest_mev','f_bunch_mhz','i_milli_a','q_adim','sigma','inv_e_rest_mev','gamma_init','omega_0_bunch','lambda_bunch','q_over_m','m_over_q'] |Literal['cumulated','individual','n_points','r_xx','r_yy','r_zdelta','r_zz','r_zdelta_11','r_zdelta_12','r_zdelta_21','r_zdelta_22'] |Literal['eps_t','eps_x','eps_y','mismatch_factor_t','mismatch_factor_x','mismatch_factor_y'] |Literal['eps_phiw99','eps_x99','eps_y99','pow_lost'])accelerator (
Accelerator)only_solver_id (
Collection[str] |None, default:None)
- Return type:
- _single_simulation_all_data(x_axis, y_axis, simulation_output, label, **get_kwargs)[source]
Get x data, y data, kwargs from a SimulationOutput.
- Parameters:
x_axis (
Literal['z_abs','elt_idx'])y_axis (
Literal['acceptance_energy','acceptance_phi','beam_parameters','element_to_index','elt_idx','mismatch_factor_zdelta','phi_s','set_of_cavity_settings','synch_trajectory','v_cav_mv','z_abs'] |Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta'] |Literal['beta','gamma','phi_abs','synchronous','w_kin','z_in'] |Literal['e_mev','e_rest_mev','f_bunch_mhz','i_milli_a','q_adim','sigma','inv_e_rest_mev','gamma_init','omega_0_bunch','lambda_bunch','q_over_m','m_over_q'] |Literal['cumulated','individual','n_points','r_xx','r_yy','r_zdelta','r_zz','r_zdelta_11','r_zdelta_12','r_zdelta_21','r_zdelta_22'] |Literal['eps_t','eps_x','eps_y','mismatch_factor_t','mismatch_factor_x','mismatch_factor_y'] |Literal['eps_phiw99','eps_x99','eps_y99','pow_lost'])simulation_output (
SimulationOutput)label (
str)
- Return type:
tuple[ndarray[tuple[Any,...],dtype[double]],ndarray[tuple[Any,...],dtype[double]],dict[str,Any]]
- _single_simulation_data(axis, simulation_output, to_deg=True, to_numpy=True, none_to_nan=True, warn_structure_dependent=False, **get_kwargs)[source]
Get single data array from single SimulationOutput.
- Parameters:
axis (
Literal['acceptance_energy','acceptance_phi','beam_parameters','element_to_index','elt_idx','mismatch_factor_zdelta','phi_s','set_of_cavity_settings','synch_trajectory','v_cav_mv','z_abs'] |Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta'] |Literal['beta','gamma','phi_abs','synchronous','w_kin','z_in'] |Literal['e_mev','e_rest_mev','f_bunch_mhz','i_milli_a','q_adim','sigma','inv_e_rest_mev','gamma_init','omega_0_bunch','lambda_bunch','q_over_m','m_over_q'] |Literal['cumulated','individual','n_points','r_xx','r_yy','r_zdelta','r_zz','r_zdelta_11','r_zdelta_12','r_zdelta_21','r_zdelta_22'] |Literal['eps_t','eps_x','eps_y','mismatch_factor_t','mismatch_factor_x','mismatch_factor_y'] |Literal['eps_phiw99','eps_x99','eps_y99','pow_lost'])simulation_output (
SimulationOutput)to_deg (
bool, default:True)
- Return type:
- _error_calculation_function(y_axis, error_presets)[source]
Set the function called to compute error.
- _compute_error(ref, fix, fun_error, error_reference)[source]
Compute error between one reference and one fix accelerator.
- Parameters:
ref (
_SimData) – Data from the reference accelerator (one entry per solver).fix (
_SimData) – Data from a single fix accelerator (one entry per solver).fun_error (
Callable[[ndarray[tuple[Any,...],dtype[double]],ndarray[tuple[Any,...],dtype[double]]],ndarray[tuple[Any,...],dtype[double]]]) – Function(y_ref, y_fix) -> error.error_reference (
Literal['ref accelerator (1st solv w/ 1st solv, 2nd w/ 2nd)','ref accelerator (1st solver)','ref accelerator (2nd solver)']) – Which reference solver(s) to pair with fix solvers.
- Return type:
- Returns:
Error data, one entry per (ref, fix) solver pair.