GUIs
These GUIs are part of the API package
in order to bring some functionality to the user
when working on the command line.
Here,
we solely use matloplib
and Qt frontends.
This is not the description of the main GUI,
which can be found in Graphical User Interface.
Mass Calibration GUIs
Define the mass calibration by clicking on a plot.
CreateMassCalibration
- class rimseval.guis.mcal.CreateMassCalibration(crd: CRDFileProcessor, logy=True, mcal: array = None, theme=None)
QMainWindow to create a mass calibration.
- append_to_mcal(tof: float, mass: float) None
Append a given value to the mass calibration.
- Parameters:
tof – Time of flight.
mass – Mass.
- apply()
Apply the mass calibration and return it.
- check_mcal_length()
Check length of mcal to set button statuses, start guessing.
- guess_mass(tof: float) str
Guess the mass depending on what is currently set.
If not drawn from iniabu, I assume the user wants even masses!
- Parameters:
tof – Time of Flight (us)
- Returns:
Guessed mass.
- query_mass(tof: float) float | None
Query mass from user.
Query a mass from the user using a QInputDialog.
- Parameters:
tof – Time of flight of the clicked area.
- Returns:
Mass of the peak as given by user.
- right_click_event(xpos: float, *args, **kwargs) None
Act on an emitted right click event.
- secondary_axis(params: List = None, visible: bool = False) None
Toggle secondary axis.
- Parameters:
params – Parameters for the transfer functions t0 and const. Only required when visible=True.
visible – Turn it on? If so, params are required.
- signal_calibration_applied
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- undo_last_mcal()
Undo the last mass calibration by popping the last entry of list.
create_mass_cal_app()
- rimseval.guis.mcal.create_mass_cal_app(crd: CRDFileProcessor, logy: bool = True, theme=None) None
Create a PyQt5 app for the mass cal window.
- Parameters:
crd – CRD file to calibrate for.
logy – Should the y axis be logarithmic? Defaults to True.
theme – Theme of GUI, requires
pyqtdarktheme
to be installed
find_closest_iso()
- rimseval.guis.mcal.find_closest_iso(mass: float, key: List = None) Tuple[str, float]
Find closest iniabu isotope to given mass and return its name.
If a key is given, will only consider that element, otherwise all.
- Parameters:
mass – Mass of the isotope to look for.
key – An element or isotope key that is valid for iniabu.
- Returns:
Closest isotpoe, name and mass as tuple.
Integrals & Background
Classes to define integrals and backgrounds. These are both very similar in nature, therefore, one superclass is created and individual routines subclass this one further.
DefineAnyTemplate
- class rimseval.guis.integrals.DefineAnyTemplate(crd: CRDFileProcessor, logy=True, theme: str = None)
Template to define integrals and backgrounds.
- apply()
Apply the mass calibration and return it.
- button_pressed(name: str)
Define action for left click of a peak button.
- Parameters:
name – Name of the peak.
- check_peak_overlapping(peak_pos: array) List | None
Check if a given peak position overlaps with any other peaks.
- Parameters:
peak_pos – Position of peak, 2 entry array with from, to.
- Returns:
List of all peak names that it overlaps or
None
.
- clear_layout(layout) None
Clear a given layout of all widgets, etc.
- create_buttons()
Create the buttons in the right menubar.
- mouse_right_press(xpos: float) None
Act on right mouse button pressed.
- Parameters:
xpos – Position on x axis.
- mouse_right_released(xpos: float) None
Right mouse button was released.
- Parameters:
xpos – Position on x axis.
- peaks_changed()
Go through the list of peaks, make buttons and shade areas.
- shade_peaks()
Shade the peaks with given integrals.
- sort_integrals()
Sort the names and integrals using routine from processor_utilities.
- user_input(peak_pos: array, name: str = '') None
Query user for position.
- Parameters:
peak_pos – Sorted array, left and right position of peak.
name – Name to preset the line-edit with.
DefineBackgrounds
- class rimseval.guis.integrals.DefineBackgrounds(crd: CRDFileProcessor, logy=True, theme: str = None)
QMainWindow to define backgrounds.
- apply()
Apply the mass calibration and return it.
- button_pressed(name: str)
Delete a peak from consideration names and values list.
- Parameters:
name – Name of the peak.
- peaks_changed()
Go through the list of peaks, make buttons and shade areas.
- shade_backgrounds()
Go through background list and shade them.
Note
Canvas is not cleared prior to this!
- signal_backgrounds_defined
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- user_input(bg_pos: array, name: str = '') None
Query user for position of background.
- Parameters:
bg_pos – Sorted array, left and right position of background.
name – Name of the peak, for reloading the UI.
DefineIntegrals
- class rimseval.guis.integrals.DefineIntegrals(crd: CRDFileProcessor, logy=True, theme: str = None)
QMainWindow to define integrals.
- apply()
Apply the mass calibration and return it.
- button_pressed(name: str)
Delete a peak from consideration names and values list.
- Parameters:
name – Name of the peak.
- peaks_changed()
Go through the list of peaks, make buttons and shade areas.
- signal_integrals_defined
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- user_input(peak_pos: array, name: str = '') None
Query user for position.
- Parameters:
peak_pos – Sorted array, left and right position of peak.
name – Name to pre-populate line-edit with.
define_backgrounds_app()
- rimseval.guis.integrals.define_backgrounds_app(crd: CRDFileProcessor, logy: bool = True) None
Create a PyQt5 app for defining backgruonds.
- Parameters:
crd – CRD file to calibrate for.
logy – Should the y axis be logarithmic? Defaults to True.
define_integrals_app()
- rimseval.guis.integrals.define_integrals_app(crd: CRDFileProcessor, logy: bool = True) None
Create a PyQt5 app for defining integrals.
- Parameters:
crd – CRD file to calibrate for.
logy – Should the y axis be logarithmic? Defaults to True.
tableau_color()
- rimseval.guis.integrals.tableau_color(it: int = 0) str
Return nth color from matplotlib TABLEAU_COLORS.
If out of range, start at beginning.
- Parameters:
it – Which tableau color to get.
- Returns:
Matplotlib color string.
Matplotlib Canvas Classes
These classes create spectra plotters and handling
for theses specific tasks.
Uses the matplotlib Qt5Agg
backend.
PlotSpectrum
Plots the spectrum and serves it as a matplotlib figure. It adds toolbar and canvas (see below) plus makes two layouts available, a bottom layout and a right layout. This allows the addition to QWidgets into this layouts later on.
The plot widget adds one button in the bottom layout to toggle logarithmic axes for the vertical / signal axis.
- class rimseval.guis.mpl_canvas.PlotSpectrum(crd: CRDFileProcessor, logy: bool = True, theme: str = None)
QMainWindow to plot a ToF or mass spectrum.
- logy_toggle()
Toggle logy.
- plot_ms()
Plot mass spectrum.
- plot_tof()
Plot ToF spectrum.
MplCanvasRightClick
Handle right-click on matplotlib
canvas.
Releases to signals: one on right mouse button press
and one on right mouse button release.
These signals send the x and y position where
the mouse event took place.
- class rimseval.guis.mpl_canvas.MplCanvasRightClick(figure: Figure)
MPL Canvas reimplementation to catch right click.
On right click, emits the coordinates of the position in axes coordinates as a signal of two floats (x_position, y_position).
- emit_mouse_position(event, case)
Emit a signal on a right mouse click event.
Here, bring up a box to ask for the mass, then send it, along with the time the mass is at, to the parent class receiver.
- Parameters:
event – PyQt event.
case – Which case are we handling? Currently implemented are “pressed”, “released”.
- mouse_right_press_position
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- mouse_right_release_position
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
Plots
These routines allow for specialty plots, i.e., to plot figures that are enot regularly used or needed during data evaluation but can give useful further information on the instrument, etc.
dt_ions()
Create a PyQt app and run it.
- rimseval.guis.plots.dt_ions(crd: CRDFileProcessor, logy: bool = False, theme: str = None, max_ns: float = None) None
Plot ToF difference between ions for shots with 2+ ions.
- Parameters:
crd – CRD file to process.
logy – Plot with logarithmic y axis? Defaults to
True
theme – Theme to plot in, defaults to
None
.max_ns – Maximum time to plot in ns. If None, plots all.
integrals_packages()
Create a PyQt app and run it.
- rimseval.guis.plots.integrals_packages(crd: CRDFileProcessor, logy: bool = False, theme: str = None) None
Plot all the integrals versus package number for data split into packages.
- Parameters:
crd – CRD file to process.
logy – Plot with logarithmic y axis? Defaults to
True
theme – Theme to plot in, defaults to
None
.
nof_ions_per_shot()
Create a PyQt app and run it.
- rimseval.guis.plots.nof_ions_per_shot(crd: CRDFileProcessor, logy: bool = False, theme: str = None) None
Plot a histogram of the number of shots in a given crd file.
The histogram is compared with the theoretical curve based on poisson statistics.
- Parameters:
crd – CRD file to process.
logy – Plot with logarithmic y axis? Defaults to
True
theme – Theme to plot in, defaults to
None
.
PlotFigure
Class to plot a figure.
DtIons
Matplotlib PyQt figure to plot histogram for arrival time differences between ions.
- class rimseval.guis.plots.DtIons(crd: CRDFileProcessor, logy: bool = False, theme: str = None, max_ns: float = None)
Plot time differences between ions.
- calc_and_draw() None
Calculate the required data and draw it.
IntegralsPerPackage
Matplotlib PyQt figure to integrals per package.
- class rimseval.guis.plots.IntegralsPerPackage(crd: CRDFileProcessor, logy: bool = False, theme: str = None)
Plot integrals of all packages versus package number.
- calc_and_draw() None
Create the plot for all the defined integrals.
IonsPerShot
Matplotlib PyQt figure to plot histogram of ions per shot.
- class rimseval.guis.plots.IonsPerShot(crd: CRDFileProcessor, logy: bool = False, theme: str = None)
Plot histogram for number of ions per shot.
- calc_and_draw() None
Calculate the histogram and plot it.