Controller
rionid.gui.controller
display_nions(nions, yield_data, nuclei_names, simulated_data_dict, ref_ion, harmonics)
Filters the simulated data to retain only the top N ions based on yield.
This function modifies the simulated_data_dict in-place. It ensures that
the Reference Ion is always included in the list, even if its yield is low.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nions
|
int
|
The number of ions to keep. |
required |
yield_data
|
array - like
|
Array of yield values for all simulated ions. |
required |
nuclei_names
|
array - like
|
Array of ion names corresponding to the yield data. |
required |
simulated_data_dict
|
dict
|
Dictionary mapping harmonic numbers to simulation arrays. |
required |
ref_ion
|
str
|
The name of the reference ion (e.g., '72Ge+35'). |
required |
harmonics
|
list of float
|
The list of harmonics being simulated. |
required |
Source code in src/rionid/gui/controller.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
import_controller(datafile=None, filep=None, alphap=None, refion=None, harmonics=None, nions=None, amplitude=None, circumference=None, mode=None, value=None, reload_data=None, remove_baseline=False, psd_baseline_removed_l=1000000.0, peak_threshold_pct=0.05, min_distance=10, highlight_ions=None, io_params=None, sim_scalingfactor=None, matching_freq_min=None, matching_freq_max=None, correct=None)
Main orchestration function for the RionID simulation workflow.
This function acts as the bridge between the GUI/CLI inputs and the physics core.
It initializes the ImportData model, loads experimental data, performs the
physics calculations (mass-to-charge, revolution frequencies), runs the
simulation, and saves the results to disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datafile
|
str
|
Path to the experimental data file (.npz, .csv, .root, etc.). |
None
|
filep
|
str
|
Path to the particle list file (e.g., LISE++ .lpp output). |
None
|
alphap
|
float
|
Momentum compaction factor of the ring. If the value provided is > 1,
it is treated as Gamma Transition (gamma_t) and converted automatically
via |
None
|
refion
|
str
|
The reference ion string in the format 'AAEl+QQ' (e.g., '72Ge+35'). |
None
|
harmonics
|
str or list of float
|
Harmonic numbers to simulate. Can be a list or a space/comma-separated string. |
None
|
nions
|
int
|
If provided, filters the output to show only the top |
None
|
amplitude
|
int
|
Display option for spectral lines (0 for constant height, 1 for scaled). |
None
|
circumference
|
float
|
Ring circumference in meters. |
None
|
mode
|
str
|
The operation mode. Options: 'Frequency', 'Brho', 'Kinetic Energy', 'Gamma'. |
None
|
value
|
float
|
The numerical value corresponding to the selected |
None
|
reload_data
|
bool
|
If True, reloads experimental data from the raw file; otherwise loads from the cached .npz. |
None
|
remove_baseline
|
bool
|
If True, applies baseline subtraction algorithms to the experimental spectrum. |
False
|
psd_baseline_removed_l
|
float
|
The smoothness parameter (lambda) for the baseline subtraction algorithm (BrPLS). Default is 1e6. |
1000000.0
|
peak_threshold_pct
|
float
|
Relative threshold for peak detection (0.0 to 1.0). Default is 0.05 (5%). |
0.05
|
min_distance
|
float
|
Minimum distance (in data points) between detected peaks. |
10
|
highlight_ions
|
str
|
Comma-separated string of ion names to highlight in the plot (e.g., '72Ge+35, 74Se+34'). |
None
|
io_params
|
dict
|
Dictionary containing specific I/O parameters (e.g., keys for NPZ files, histogram names for ROOT files). |
None
|
sim_scalingfactor
|
float
|
Factor to scale the simulated yield/amplitude. |
None
|
matching_freq_min
|
float
|
Minimum frequency (Hz) bound for the peak matching algorithm. |
None
|
matching_freq_max
|
float
|
Maximum frequency (Hz) bound for the peak matching algorithm. |
None
|
correct
|
list of float
|
Coefficients [a0, a1, a2] for a second-order polynomial correction applied to the simulated frequencies. |
None
|
Returns:
| Type | Description |
|---|---|
ImportData
|
The populated data model object containing simulation results and experimental data. |
Exception
|
Returns the exception object if an error occurs during processing. |
Source code in src/rionid/gui/controller.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
save_simulation_results(mydata, mode, harmonics, sort_index, filename='simulation_result.out')
Saves the simulation results to a formatted text file.
Writes a table containing Ion Name, Frequency, Yield, m/q, and Mass for
every simulated ion, sorted according to sort_index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mydata
|
ImportData
|
The data object containing the calculated physics results (srrf, moq, etc.). |
required |
mode
|
str
|
The simulation mode ('Frequency', 'Brho', etc.) used to determine how absolute frequencies are calculated. |
required |
harmonics
|
list of float
|
The list of harmonics used in the simulation. |
required |
sort_index
|
array - like
|
Indices used to sort the output (typically sorted by frequency). |
required |
filename
|
str
|
The output filename. Default is 'simulation_result.out'. |
'simulation_result.out'
|
Source code in src/rionid/gui/controller.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |