HDF5_BLS_analyse.Analyse_backend
- class HDF5_BLS_analyse.Analyse_backend(y: ndarray, x: ndarray = None)[source]
Bases:
objectThis class is the base class for all the analyse classes. It provides a common interface for all the classes. Its purpose is to provide the basic silent functions to open, create and save algorithms, and to store the different steps of the analysis and their effects on the data. The philosophy of this class is to rely on 4 attributes that will be changed by the different functions of the class: - x: the x-axis of the data - y: the y-axis of the data - points: a list of remarkable points in the data where each point is a 2-list of the form [position, type] - windows: a list of windows in the data where each window is a 2-list of the form [start, end] And to store the different steps of the analysis and their effects on the data: - _algorithm: a dictionary that stores the name of the algorithm, its version, the author, and a description - _history: a list that stores the evolution of the 4 main attributes of the class with the steps of the analysis. The data is defined by 2 1-D arrays: x and y. Additionally, remarkable points and windows are stored in the points and windows attributes. Algorithm steps are stored in 2 attributes: _algorithm and _history. The _algorithm attribute is a dictionary that stores the name of the algorithm, its version, the author, and a description. The _history attribute is a list that stores the steps of the analysis and their effects on the data. The _execute attribute is a boolean that indicates whether the analysis should be executed or not. It is set to True by default. The _auto_run attribute is a boolean that indicates whether the analysis should be executed automatically or not. It is set to False by default. As a general rule, we encourage developers not to modify any of the underscore-prefixed attributes. These attributes are meant to be used internally by the mother class to run, save, and load the analysis and its history. All the functions of the class are functions with a zero-argument call signature that returns None. This means that the parameters of the methods of the children class need to be kew-word arguments, and that if no value for these arguments are given, the default value of the arguments leads the function to do nothing. This specificality ensures the modulability of the class.
- Parameters:
x (np.ndarray) – The x-axis of the data.
y (np.ndarray) – The y-axis of the data.
points (list of 2-list) – A list of remarkable points in the data where each point is a 2-list of the form [position, type].
windows (list of 2-list) – A list of windows in the data where each window is a 2-list of the form [start, end].
_algorithm (dict) – The algorithm used to analyse the data.
_history (list) – The history of the analysis.
- __init__(y: ndarray, x: ndarray = None)[source]
Initializes the class with the most basic attributes: the ordinates and abscissa of the data.
- Parameters:
y (array) – The array of ordinates of the data
x (array, optional) – The array of abscissa of the data. If None, the abscissa is just the index of the points in ordinates.
Methods
__init__(y[, x])Initializes the class with the most basic attributes: the ordinates and abscissa of the data.
set_x_y(x, y)Sets the x and y values of the data
silent_create_algorithm([algorithm_name, ...])Creates a new JSON algorithm with the given name, version, author and description.
silent_move_step(step, new_step)Moves a step from one position to another in the _algorithm attribute.
silent_open_algorithm([filepath, algorithm_str])Opens an existing JSON algorithm and stores it in the _algorithm attribute.
silent_remove_step([step])Removes the step from the _history attribute of the class.
silent_run_algorithm([step])Runs the algorithm stored in the _algorithm attribute of the class up to the given step (included).
silent_save_algorithm([filepath, ...])Saves the algorithm to a JSON file with or without the parameters used.
- set_x_y(x, y)[source]
Sets the x and y values of the data
- Parameters:
x (array-like) – The x values of the data
y (array-like) – The y values of the data
- silent_create_algorithm(algorithm_name: str = 'Unnamed Algorithm', version: str = '0.1', author: str = 'Unknown', description: str = '')[source]
Creates a new JSON algorithm with the given name, version, author and description. This algorithm is stored in the _algorithm attribute. This function also creates an empty history. for the software.
- Parameters:
algorithm_name (str, optional) – The name of the algorithm, by default “Unnamed Algorithm”
version (str, optional) – The version of the algorithm, by default “0.1”
author (str, optional) – The author of the algorithm, by default “Unknown”
description (str, optional) – The description of the algorithm, by default “”
- silent_move_step(step: int, new_step: int)[source]
Moves a step from one position to another in the _algorithm attribute. Deletes the elements of the _history attribute that are after the moved step (included)
- Parameters:
step (int) – The position of the function to move in the _algorithm attribute.
new_step (int) – The new position to move the function to.
- silent_open_algorithm(filepath: str = None, algorithm_str: str = '')[source]
Opens an existing JSON algorithm and stores it in the _algorithm attribute. This function also creates an empty history.
- Parameters:
filepath (str, optional) – The filepath to the JSON algorithm, by default None
- silent_remove_step(step: int = None)[source]
Removes the step from the _history attribute of the class. If no step is given, removes the last step.
- Parameters:
step (int, optional) – The number of the function up to which the algorithm has to be run. Default is None, means that the last step is removed.
- silent_run_algorithm(step: int = None)[source]
Runs the algorithm stored in the _algorithm attribute of the class up to the given step (included). If no step is given, the algorithm is run up to the last step.
- Parameters:
step (int, optional) – The number of the function up to which the algorithm has to be run (included), by default None means that all the steps of the algorithm are run.
- silent_save_algorithm(filepath: str = 'algorithm.json', save_parameters: bool = False)[source]
Saves the algorithm to a JSON file with or without the parameters used. If the parameters are not saved, their value is set to a default value proper to their type.
- Parameters:
filepath (str, optional) – The filepath to save the algorithm to. Default is “algorithm.json”.
save_parameters (bool, optional) – Whether to save the parameters of the functions. Default is False.