hyloa.data.processing module

Code that contains some standard operations to do on the data.

hyloa.data.processing.apply_column_inversion(file_index, selected_columns, dataframes, logger, plot_instance)[source]

Inverts the sign of selected columns in the given DataFrame.

Parameters:
  • file_index (int) – Index of the selected DataFrame.

  • selected_columns (dict) – dict of selected colums for inversion

  • dataframes (list) – list of loaded files, each file is a pandas dataframe

  • logger (instance of logging.getLogger) – logger of the app

  • plot_instance (QWidget) – Widget from which this dialog is called (usually the plot panel).

hyloa.data.processing.apply_loop_closure(ell_up, ell_dw, i_up=None, i_dw=None)[source]

Apply a linear drift correction to close an hysteresis loop.

The function corrects the mismatch between the two branches of a loop (ell_up and ell_dw) by applying a symmetric, point-wise correction.

Two modes are available:

1) Local correction (pivot-based)

If i_up and i_dw are provided, a local linear correction is applied.

  • The correction is anchored to a pivot index (i_up), which defines where the two branches are forced to match.

  • The magnitude of the correction is determined by the difference between the two branches at the selected indices:

  • A linear correction profile is applied from one end of the loop (slope) to the pivot:

    • zero correction at the slope

    • maximum correction (±0.5 * delta) at the pivot

  • The sign of the correction is determined by the relative position of the two branches (i.e. which one is higher in value), ensuring a physically consistent closure:

    • the upper branch is shifted downward

    • the lower branch is shifted upward

NOTE: The pivot index is taken from i_up. The index i_dw is used only to evaluate the mismatch (delta), not to define the correction shape.

2) Global correction

If no indices are provided, a global linear correction is applied.

  • The function compares the mismatch at the beginning and at the end of the loop.

  • The dominant mismatch is selected (either start or end).

  • A linear correction is applied across the entire loop, gradually reducing the mismatch:

    • maximum correction at the dominant end

    • zero correction at the opposite end

  • The correction is applied symmetrically to the two branches.

param ell_up:

Values of the increasing (upper) branch.

type ell_up:

numpy.ndarray

param ell_dw:

Values of the decreasing (lower) branch.

type ell_dw:

numpy.ndarray

param i_up:

Pivot index on the increasing branch used to anchor the local correction.

type i_up:

int, optional

param i_dw:

Index on the decreasing branch used only to evaluate the mismatch at the pivot location.

type i_dw:

int, optional

returns:
  • ell_up_corr (numpy.ndarray) – Corrected increasing branch.

  • ell_dw_corr (numpy.ndarray) – Corrected decreasing branch.

hyloa.data.processing.apply_norm(plot_instance, app_instance, file_index, selected_cols)[source]

Cycle normalization function. For each cycle the procedure implemented is the following:

  1. Compute the initial and final average values of the first and last 5 points of each branch.

  2. Reconcile the average values to correct any inconsistencies in direction. If both branches grow or decrease in a coherent way, the averages of the same branch are averaged. Otherwise, the “cross-branch” average is averaged.

  3. Compute the shift and the amplitude of the cycle.

  4. Normalize the branches so that the cycle is centered and with unit amplitude.

Parameters:
  • plot_instance (instance of the plot class) – Instance of the plot class

  • app_instance (MainApp) – Main application instance containing the session data.

  • file_index (list) – list of indices of the selected DataFrames.

  • selected_cols (list) – List of columns to normalize (should be pairs).

hyloa.data.processing.close_loop_dialog(plot_instance, app_instance)[source]

Qt window to select file and columns for loop closure.

Parameters:
  • plot_instance (QWidget) – Widget from which this dialog is called (usually the plot panel).

  • app_instance (MainApp) – Main application instance with session state.

hyloa.data.processing.inv_single_column_dialog(parent_widget, app_instance)[source]

Creates the window to select the file and columns to reverse.

Parameters:
  • plot_instance (QWidget) – Widget from which this dialog is called (usually the plot panel).

  • app_instance (MainApp) – Main application instance with session state.

hyloa.data.processing.norm_dialog(plot_instance, app_instance)[source]

Qt window to select file and columns for normalization.

Parameters:
  • plot_instance (QWidget) – Widget that called this dialog (usually the plot panel).

  • app_instance (MainApp) – Main application instance containing the session.