hyloa.data.correction module
Code with basic routines to correct some loop distortions
- hyloa.data.correction.apply_shift(data_sel, field_shift_pc_edit, plot_state, window, fit_data, args=(), logger=None)[source]
Function add a field shift after the corrections
- Parameters:
field_shift_pc_edit (QLineEdit) – Value for field shifting
plot_state (dict) – Dictionary storing the current plotting state.
window (QWidget) – Parent widget used to display error message boxes.
fit_data (callable) – Function for fitting data
args (tuple) – Argumets to pass to fit_data
logger (logging.Logger) – Logger instance used to record spline computation details.
- hyloa.data.correction.change_ps(plot_state, window, draw_plot, mode='cp')[source]
Function to change the plot status deleting the corrected or the original data
- Parameters:
plot_state (dict) – Dictionary storing the current plotting state.
window (QWidget) – Parent widget used to display error message boxes.
draw_plot (callable) – Callback function responsible for redrawing the plot.
mode (string, optional, dafult "cp") – if mode=”cp” all correction will be remove from the plot if mode=”od” the original data will be removed from the plot if mode=”spl” the splines will be removed from the plot if mode=”sym” the symmetrized data will be removed from the plot
- hyloa.data.correction.fit_data(file_combo, x_up_combo, y_up_combo, x_down_combo, y_down_combo, data_sel, x_start_up_edit, x_end_up_edit, x_start_dw_edit, x_end_dw_edit, params_edit, function_edit, logger, plot_state, draw_plot, output_box, window, option='hc')[source]
- Parameters:
file_combo (QComboBox) – Combo box to select source data file.
x_up_combo (QComboBox) – Combo box to select X column for Up branch.
y_up_combo (QComboBox) – Combo box to select Y column for Up branch.
x_down_combo (QComboBox) – Combo box to select X column for Down branch.
y_down_combo (QComboBox) – Combo box to select Y column for Down branch.
data_sel (QComboBox) – Combo box to select data type (corrected or original).
x_start_up_edit (QLineEdit) – Line edit for Up branch coercive fit start limit.
x_end_up_edit (QLineEdit) – Line edit for Up branch coercive fit end limit.
x_start_dw_edit (QLineEdit) – Line edit for Down branch coercive fit start limit.
x_end_dw_edit (QLineEdit) – Line edit for Down branch coercive fit end limit.
params_edit (QLineEdit) – Line edit for coercive fit parameter names.
function_edit (QLineEdit) – Line edit for coercive fit function.
logger (logging.Logger) – Logger instance used to record spline computation details.
plot_state (dict) – Dictionary storing the current plotting state.
draw_plot (callable) – Callback function responsible for redrawing the plot.
output_box (QTextEdit) – Text edit for displaying output results.
window (QWidget) – Parent widget used to display error message boxes.
option (str) – Option to specify the type of fit (e.g., “hc” for coercivity, “rm” for remanence).
- hyloa.data.correction.flip(plot_state, window, draw_plot)[source]
Function to flip a brach to ensure simmetricity of the loop.
- Parameters:
plot_state (dict) – dictionary of the plotted data
window (QWidget) – The main window widget.
draw_plot (callable) – Function to update the preview
- hyloa.data.correction.flip_data(file_combo, x_up_combo, y_up_combo, x_down_combo, y_down_combo, data_sel, double_branch, plot_state, window, logger, draw_plot)[source]
Function to duplicate a branch by flipping it to recontruct a simmetric loop.
- Parameters:
file_combo (QComboBox) – Combo box to select source data file.
x_up_combo (QComboBox) – Combo box to select X column for Up branch.
y_up_combo (QComboBox) – Combo box to select Y column for Up branch.
x_down_combo (QComboBox) – Combo box to select X column for Down branch.
y_down_combo (QComboBox) – Combo box to select Y column for Down branch.
data_sel (QComboBox) – Combo box to select data type (corrected or original).
double_branch (QComboBox) – Combo box to select a branch duplication.
plot_state (dict) – Dictionary storing the current plotting state.
window (QWidget) – Parent widget used to display error message boxes.
logger (logging.Logger) – Logger instance used to record spline computation details.
draw_plot (callable) – Callback function responsible for redrawing the plot.
- hyloa.data.correction.perform_correction(file_combo, x_up_combo, y_up_combo, x_down_combo, y_down_combo, field_shift_edit, field_scale_edit, x_start_n_edit, x_end_n_edit, x_start_p_edit, x_end_p_edit, tail_params_edit, tail_function_edit, smooth_up_edit, smooth_dw_edit, dataframes, logger, plot_state, draw_plot, window)[source]
Perform the loop correction using the parameters from the UI. The correction involves fitting the saturation parts (tails) of the hystersis loop to remove drifts. Using the computed error the code also provides an estimation of smoothing parameters for Bspline fitting.
- Parameters:
file_combo (QComboBox) – Combo box to select source data file.
x_up_combo (QComboBox) – Combo box to select X column for Up branch.
y_up_combo (QComboBox) – Combo box to select Y column for Up branch.
x_down_combo (QComboBox) – Combo box to select X column for Down branch.
y_down_combo (QComboBox) – Combo box to select Y column for Down branch.
field_shift_edit (QLineEdit) – Line edit for field shift value.
field_scale_edit (QLineEdit) – Line edit for field scale value.
x_start_n_edit (QLineEdit) – Line edit for negative tail start limit.
x_end_n_edit (QLineEdit) – Line edit for negative tail end limit.
x_start_p_edit (QLineEdit) – Line edit for positive tail start limit.
x_end_p_edit (QLineEdit) – Line edit for positive tail end limit.
tail_params_edit (QLineEdit) – Line edit for tail fit parameter names.
tail_function_edit (QLineEdit) – Line edit for tail fit function.
dataframes (list of pd.DataFrame) – List of dataframes containing loaded data.
smooth_up_edit (QLineEdit) – Line edit for smoothing parameter for spline for up branch
smooth_dw_edit (QlineEdit) – Line edit for smoothing parameter for spline for down branch
logger (logging.Logger) – Logger instance used to record spline computation details.
plot_state (dict) – Dictionary storing the current plotting state.
draw_plot (callable) – Callback function responsible for redrawing the plot.
output_box (QTextEdit) – Text edit for displaying output results.
window (QWidget) – Parent widget used to display error message boxes.
- hyloa.data.correction.save_corrected_data(dataframes, save_file_combo, x_up_dest, y_up_dest, x_dw_dest, y_dw_dest, save_quad_checkbox, plot_state, logger, window)[source]
Function to save the corrected data in the selected file and columns.
- Parameters:
dataframes (list of pd.DataFrame) – List of dataframes containing loaded data.
save_file_combo (QComboBox) – Combo box to select destination data file. The first item should be “No save”, followed by the loaded files.
x_up_dest (str) – Column name for the destination x-values of the upper branch.
y_up_dest (str) – Column name for the destination y-values of the upper branch.
x_dw_dest (str) – Column name for the destination x-values of the lower branch.
y_dw_dest (str) – Column name for the destination y-values of the lower branch.
save_quad_checkbox (QCheckBox) – Checkbox to indicate whether to save quadratic data.
plot_state (dict) – Dictionary storing the current plotting state.
logger (logging.Logger) – Logger instance for recording events and errors.
window (QWidget) – Parent widget used to display error message boxes.