hyloa.data.anisotropy module
- hyloa.data.anisotropy.compute_Hk(file_combo, x_up_combo, y_up_combo, x_down_combo, y_down_combo, hk_thr_edit, plot_state, logger, window, output_box)[source]
Compute the anisotropy field Hk.
This function estimates the anisotropy field using the cubic spline representations of the up and down branches previously computed. The method is based on the relative difference between the two branches: regions where the difference falls below a given threshold are used to identify the negative and positive anisotropy fields.
The final anisotropy field is computed as the mean value between the negative and positive branches, with an associated uncertainty.
- Parameters:
file_combo (QComboBox) – Combo box used to select the source data file.
x_up_combo (QComboBox) – Combo box selecting the X column for the up branch.
y_up_combo (QComboBox) – Combo box selecting the Y column for the up branch.
x_down_combo (QComboBox) – Combo box selecting the X column for the down branch.
y_down_combo (QComboBox) – Combo box selecting the Y column for the down branch.
hk_thr_edit (QComboBox or QLineEdit) – Widget containing the threshold value used to select the region where the relative difference between up and down branches is below the chosen limit.
plot_state (dict) – Dictionary storing the current plot state.
logger (logging.Logger) – Logger instance used to record the computation results.
window (QWidget) – Parent widget used to display error message boxes.
output_box (QTextEdit) – Text box where the computed anisotropy field and related information are displayed.
Notes
This function requires that the cubic splines for both branches have already been computed. If the spline data are not available, the computation will fail.
- hyloa.data.anisotropy.compute_b_spline(file_combo, x_up_combo, y_up_combo, x_down_combo, y_down_combo, data_sel, smooth_up_edit, smooth_dw_edit, plot_state, logger, window, draw_plot)[source]
Compute cubic B-spline interpolations for the corrected hysteresis loop branches.
This function applies a cubic B-spline interpolation separately to the corrected up and down branches of a hysteresis loop. The spline is computed using the corrected data stored in plot_state and is intended as a smooth representation of the loop after tilt/drift correction.
The spline can only be computed after the correction step has been performed, since it operates on the corrected arrays (x_up_corr, y_up_corr, x_dw_corr, y_dw_corr). The resulting splines are stored in plot_state and immediately visualized via the provided plotting callback.
For numerical stability and consistency with SciPy requirements, the data are internally sorted to ensure a strictly monotonic x-axis. Duplicate x values are explicitly checked and rejected, as they would invalidate the spline computation.
- Parameters:
file_combo (QComboBox) – Combo box used to select the source data file (used for logging purposes).
x_up_combo (QComboBox) – Combo boxes selecting the x and y columns corresponding to the up branch.
y_up_combo (QComboBox) – Combo boxes selecting the x and y columns corresponding to the up branch.
x_down_combo (QComboBox) – Combo boxes selecting the x and y columns corresponding to the down branch.
y_down_combo (QComboBox) – Combo boxes selecting the x and y columns corresponding to the down branch.
data_sel (QComboBox) – Combo box to select data type (corrected or original).
smooth_up_edit (QLineEdit) – Input field specifying the smoothing parameter s for the up branch spline. Must be a non-negative float.
smooth_dw_edit (QLineEdit) – Input field specifying the smoothing parameter s for the down branch spline. Must be a non-negative float.
plot_state (dict) – Dictionary storing the current plotting state.
logger (logging.Logger) – Logger instance used to record spline computation details.
window (QWidget) – Parent widget used to display error message boxes.
draw_plot (callable) – Callback function responsible for redrawing the plot after the spline computation.
Notes
The spline is computed using scipy.interpolate.splrep and evaluated on a dense, uniformly spaced grid spanning the corrected x-range.
The spline represents the full corrected curve.
- hyloa.data.anisotropy.symmetrize(file_combo, x_up_combo, y_up_combo, x_down_combo, y_down_combo, data_sel, logger, plot_state, draw_plot, window)[source]
Symmetrize a hysteresis loop using spline-interpolated up and down branches.
This function performs a symmetrization of the hysteresis loop starting from the cubic spline representations of the corrected up and down branches. The symmetrized loop is constructed by averaging the field values and antisymmetrizing the magnetization, enforcing physical symmetry conditions.
A linear spline is built from the averaged data and evaluated on the original corrected field arrays. A small random noise, estimated from the data, is added to mimic experimental uncertainty.
Optionally, the symmetrized data can be saved into a user-selected destination data file.
- Parameters:
file_combo (QComboBox) – Combo box used to select the source data file.
x_up_combo (QComboBox) – Combo box selecting the X column for the up branch.
y_up_combo (QComboBox) – Combo box selecting the Y column for the up branch.
x_down_combo (QComboBox) – Combo box selecting the X column for the down branch.
y_down_combo (QComboBox) – Combo box selecting the Y column for the down branch.
data_sel (QComboBox) – Combo box to select data type (corrected or original).
x_up_dest (QComboBox) – Combo box selecting the destination X column for the symmetrized up branch.
y_up_dest (QComboBox) – Combo box selecting the destination Y column for the symmetrized up branch.
x_dw_dest (QComboBox) – Combo box selecting the destination X column for the symmetrized down branch.
y_dw_dest (QComboBox) – Combo box selecting the destination Y column for the symmetrized 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.
window (QWidget) – Parent widget used to display error message boxes.
Notes
This function requires that both the drift correction and spline interpolation steps have already been completed.