Application Programming Interface
It includes the function signatures and classes of the various modules.
Hyspecppt
Contains the entry point for the application
-
hyspecppt.Hyspecppt()[source]
Start Class
Hppt
It contains the majority of the software’s functionality organized in a Model-View-Presenter architectural pattern.
Tenchnically hppt is included as a widget in the base layout of the MainWindow.
Model
-
class hyspecppt.hppt.hppt_model.HyspecPPTModel[source]
Main model
-
calculate_graph_data() → dict[str, array][source]
Returns a dictionary of arrays [Q_low, Q_hi, E, Q2d, E2d, data of plot_types]
Args:
-
check_plot_update(deltaE) → bool[source]
Returns bool to indicate whether the Emin is different and indicate replotting
- Args:
deltaE: new DeltaE value
-
get_ang_Q_beam() → float[source]
Returns the angle between Q and the beam
-
get_crosshair_data() → dict[str, float][source]
Return experiment type
Args:
-
get_experiment_data() → dict[str, float][source]
Return experiment data: Ei,S2, alpha_p and plot_type in a dictionary format
Args:
-
get_single_crystal_data() → dict[str, float][source]
Return experiment type
Args:
-
set_crosshair_data(current_experiment_type: str, DeltaE: float = None, modQ: float = None) → None[source]
Return experiment type
- Args:
current_experiment_type: mode
DeltaE: crosshair DeltaE
modQ: crosshair modQ
-
set_experiment_data(Ei: float, S2: float, alpha_p: float, plot_type: str) → None[source]
Set experiment data
- Args:
Ei: incident energy Ei
S2: Detector angle S2
alpha_p: polarization angle
plot_type: plot function
-
set_single_crystal_data(params: dict[str, float]) → None[source]
Return experiment type
- Args:
params: dictionary of single crystal parameters
-
class hyspecppt.hppt.hppt_model.CrosshairParameters[source]
Model for the crosshair parameters
-
get_crosshair() → dict[str, float][source]
Return the crosshair
Args:
-
get_experiment_type() → str[source]
Return experiment type
Args:
-
set_crosshair(current_experiment_type: str, DeltaE: float = None, modQ: float = None) → None[source]
Store crosshair parameters including in SC mode
- Args:
current_experiment_type: selected experiment type
DeltaE: deltae value
modQ: modq value
-
class hyspecppt.hppt.hppt_model.SingleCrystalParameters[source]
Model for single crystal calculations
-
calculate_modQ() → float[source]
Returns |Q| from lattice parameters and h, k, l
Args:
-
get_parameters() → dict[str, float][source]
Returns all the parameters as a dictionary
Args:
-
set_parameters(params: dict[str, float]) → None[source]
Store single crystal parameters
- Args:
- params: dict - contains the following keys:
a, b, c, alpha, beta, gamma, h, k, l
Presenter
Presenter for the Main tab
-
class hyspecppt.hppt.hppt_presenter.HyspecPPTPresenter(view: any, model: any)[source]
Main presenter
-
handle_QZ_angle()[source]
Compute QZ_angle
-
handle_field_values_update(field_values)[source]
Save the values in the model
-
handle_switch_to_powder()[source]
Switch to Powder mode
-
handle_switch_to_sc()[source]
Switch to Single Crystal mode
-
property model
Return the model for this presenter
-
property view
Return the view for this presenter
View
-
class hyspecppt.hppt.hppt_view.HyspecPPTView(parent: QObject | None = None)[source]
Main widget
-
connect_fields_update(callback)[source]
Callback for the fields update - set by the presenter
-
connect_powder_mode_switch(callback)[source]
Callback function setup for the switching to Powder mode from the radio button
- function defined and set by the presenter
-
connect_sc_mode_switch(callback)[source]
Callback function setup for the switching to Single Crystal mode from the radio button
- function defined and set by the presenter
-
field_visibility_in_Powder() → None[source]
Set visibility for Powder mode
-
field_visibility_in_SC() → None[source]
Set visibility for Single Crystal mode
-
switch_to_powder() → None[source]
Switch to Powder mode
-
switch_to_sc() → None[source]
Switch to Single Crystal mode
-
values_update(values)[source]
Fields update
-
class hyspecppt.hppt.hppt_view.ExperimentWidget(parent: QObject | None = None)[source]
Widget for setting experiment parameters
-
initializeCombo(options: list[str]) → None[source]
Initialize the plot types in the combo box
- Args:
- options (list): list of strings describing what the user can show
in the plot
-
set_values(values: dict[str, float | str]) → None[source]
Sets widget display based on the values dictionary
- Args:
values (dict): a dictionary that contains
Ei, S2, alpha_p, plot_types values
-
validate_all_inputs() → None[source]
If all inputs are valid emit a valid_signal
-
validate_inputs(*_, **__) → None[source]
Check validity of the fields and set the stylesheet
-
class hyspecppt.hppt.hppt_view.SelectorWidget(parent: QObject | None = None)[source]
Widget that selects Powder/Single Crystal mode
-
get_selected_mode_label() → str[source]
Return the label of the selected mode
Args:
-
sc_toggle() → None[source]
Update fields based on selected mode
Args:
-
selector_init(selected_label: str)[source]
Initialize the default selected mode
- Args:
selected_label: it contains either sc_label or powder_label
based on the selected label the mode is set during initialization
-
class hyspecppt.hppt.hppt_view.CrosshairWidget(parent: QObject | None = None)[source]
Widget to enter/display crosshair parameters
-
set_QZ_values(angle: float) → None[source]
Displays the angle between momentum transfer and beam direction
- Args:
angle (float): the angle between momentum transfer and beam direction
-
set_Qmod_enabled(state: bool) → None[source]
Enable/disable the modQ line edit
- Args:
state (bool): enable editing modQ (True) or disable it(False)
-
set_values(values: dict[str, float]) → None[source]
Sets widget display based on the values dictionary
- Args:
values (dict): a dictionary that contains
deltaE and mod_Q values
-
validate_all_inputs()[source]
If all inputs are valid emit a valid_signal
-
validate_inputs(*_, **__) → None[source]
Check validity of the fields and set the stylesheet
-
validation_status_all_inputs() → bool[source]
Return validation status of all inpus, if all are valid returns True, else False
-
class hyspecppt.hppt.hppt_view.SingleCrystalWidget(parent: QObject | None = None)[source]
Widget for inputting single crystal parameters
-
set_values(values: dict[str, float]) → None[source]
Sets widget display based on the values dictionary
- Args:
values (dict): a dictionary that contains
a, b, c, alpha, beta, gamma lattice parameters
and h, k, l reciprocal lattice coordinates
-
validate_angles() → None[source]
Check validity of the angles and set the stylesheet
-
validate_inputs(*_, **__) → None[source]
Check validity of the fields and set the stylesheet
-
class hyspecppt.hppt.hppt_view.PlotWidget(parent: QObject | None = None)[source]
Widget that displays the plot
-
set_axes_meta_and_draw_plot()[source]
Set labels, color and draw static canvas
Args:
-
update_crosshair(eline: float, qline: float) → None[source]
Update the plot with crosshair lines
- Args:
eline (float): x
qline (float): y
-
update_plot(q_min: list[float], q_max: list[float], energy_transfer: list[float], q2d: list[list[float]], e2d: list[list[float]], scharpf_angle: list[list[float]], plot_label: str)[source]
Update the colormesh, colorbar and redraw the crosshair
- Args:
q_min: list of float numbers,
q_max: list of float numbers,
energy_transfer: list of float numbers,
q2d: list of lists of float numbers,
e2d: list of lists of float numbers,
scharpf_angle: list of lists of float numbers,
plot_label: used for colormap label,
-
update_plot_crosshair(crosshair_data: dict) → None[source]
Update the plot with valid crosshair_data
- Args:
crosshair_data: dictionary with: eline (float) x, qline (float) y
View Field Validators
-
class hyspecppt.hppt.hppt_view_validators.AbsValidator(parent: QObject, bottom: float, top: float, decimals: int = -1)[source]
Absolute value validator
-
validate(inp: str, pos: int) → tuple[State, str, int][source]
Override for validate method
- Args:
inp (str): the input string
pos (int): cursor position
-
class hyspecppt.hppt.hppt_view_validators.AngleValidator(parent: QObject, alpha: QObject, beta: QObject, gamma: QObject, individual: QValidator)[source]
Angle validator
-
validate(input_text: str, pos: int) → tuple[State, str, int][source]
Override for validate method
- Args:
input_text (str): the input string
pos (int): cursor position
Help
The help functionality, includes a button that directs the user to the documentation.
The help button is added in the MainWindow.
single help module
-
hyspecppt.help.help_model.help_function(context)[source]
Open a browser with the appropriate help page
Configuration
The configuration functionality includes settings that are retrieved though a configuration template.
The mechanism is created in a way to be updated automatically, when a new setting is added,
while allowing the users to update the default ones in their environment.
Module to load the the settings from SHOME/.packagename/configuration.ini file
Will fall back to a default
-
class hyspecppt.configuration.Configuration[source]
Load and validate Configuration Data
-
is_valid()[source]
Returns the configuration state
-
validate()[source]
Validates that the fields exist at the config_file_path and writes any missing fields/data
using the template configuration file: configuration_template.ini as a guide
-
hyspecppt.configuration.get_data(section, name=None)[source]
Retrieves the configuration data for a variable with name