Iguape package

Subpackages

Submodules

Iguape.Monitor module

This is Monitor Class. It was built to track and read a given Folder for new XRD Data. It’s dependent on the iguape_fileslist.txt text file. It was built to work only for Paineira XRD Data, but it can easily be adjusted for other situations.

class Iguape.Monitor.FolderMonitor(folder_path, fit_interval=None)[source]

Bases: QThread

The Folder Monitor operates by tracking new or exiting data in a specified folder.

This class inherits the QThread class from PyQt. By reading the ‘iguape_filelist.txt’ file, it can track new or existing data files in the specified folder.

Later, it reads the data and stores it in a pandas DataFrame. If a fitting interval is specified, it fits the data to a desired model and stores the fitting parameters in another DataFrame.

Parameters

folder_path (str): Path to the data folder. fit_interval (list): 2theta interval selected to perform the peak fit.

__init__(folder_path, fit_interval=None)[source]

The constructor for the FolderMonitor class. It defines all the flags necessary for the class to work, like the folder path, the fit interval, the fit model and the DataFrames.

Parameters:
  • (str) (folder_path)

  • (list (fit_interval)

  • optional) (2theta interval selected to perform. Default is None)

new_data_signal

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

run()[source]

The run method is the main method of the FolderMonitor class. It reads the ‘iguape_filelist.txt’ file tracking all the XRD data in the folder. Then it reads the data and stores it as DataFrames. I also performs the peak fit, if a fit interval is specified.

set_distance(distance)[source]

Method for defining the minimum distance between the two peak centers. Only used when the model is Split PseduoVoigt.

Parameters:

(float) (distance)

set_fit_interval(interval)[source]

Method for defining the fit interval.

Parameters:

(list) (interval)

set_fit_model(model)[source]

Method for defining the fit model.

Parameters:

(str) (model)

set_height(height)[source]

Method for defining the minimum height of the two peaks. Only used when the model is Split PseduoVoigt.

Parameters:

(float) (height)

Iguape.Monitor.counter()[source]

Counter function. It counts the number of XRD data and returns its index.

Returns:

int

Return type:

Index of the XRD data.

Iguape.Monitor.data_read(path)[source]

Data reading function.

It reads the data from a given path and returns the 2theta and Intensity arrays, Temperature and Kelvin Signal tag.

Parameters:

(str) (path)

Returns:

  • x (np.array) (2theta array.)

  • y (np.array) (Intensity array.)

  • temp (float) (Temperature.)

  • kelvin_signal (bool) (Kelvin Signal tag.)

Iguape.Monitor.peak_fit(theta, intensity, interval, bkg='Linear')[source]

Peak fitting function for the PseudoVoigt model. Given a set of 2theta and Intensity arrays, it fits the data to the PseudoVoigt model and 2theta interval selected. It returns the fitting parameters.

Parameters:
  • (np.array) (intensity)

  • (np.array)

  • (list) (interval)

  • (str (bkg)

  • optional) (Background model. Default is 'Linear'.)

Returns:

  • dois_theta_0 (float) (Peak center.)

  • fwhm (float) (Full Width at Half Maximum.)

  • area (float) (Area under the peak.)

  • r_squared (float) (R-squared value of the fit.)

  • out (lmfit.ModelResult) (ModelResult. Inherited from the lmfit package.)

  • comps (dict) (Fitting components such as the backgroud and model function. Inherited from the lmfit package.)

  • theta_fit (np.array) (2theta array for the fitting interval.)

Iguape.Monitor.peak_fit_split_gaussian(theta, intensity, interval, bkg='Linear', height=1000000000.0, distance=35)[source]

Peak fitting function for the Split PseudoVoigt model. Given a set of 2theta and Intensity arrays, it fits the data to the Split PseudoVoigt model and 2theta interval selected. It returns the fitting parameters.

Parameters:
  • (np.array) (intensity)

  • (np.array)

  • (list) (interval)

  • (str (bkg)

  • optional) (Minimum distance between the peaks. Default is 35.)

  • (float (distance)

  • optional)

  • (float

  • optional)

Returns:

  • dois_theta_0 (list) (Peak centers.)

  • fwhm (list) (Full Width at Half Maximum.)

  • area (list) (Area under the peaks.)

  • r_squared (float) (R-squared value of the fit.)

  • out (lmfit.ModelResult) (ModelResult. Inherited from the lmfit package.)

  • comps (dict) (Fitting components such as the backgroud and model function. Inherited from the lmfit package.)

  • theta_fit (np.array) (2theta array for the fitting interval.)

Iguape.Monitor.pseudo_voigt(x, amplitude, center, sigma, eta)[source]

PseudoVoigt function, a linear combination of a Gaussian and a Lorentzian function.

x (np.array): 2theta array. amplitude (float): Peak amplitude. center (float): Peak center. sigma (float): Sigma value or standard deviation. eta (float): Eta value (mixing parameter).

np.array: PseudoVoigt function.

The PseudoVoigt function is defined as: .. math:

PV(x; A, \mu, \sigma, \eta) = \eta L(x; A, \mu, \sigma) + (1 - \eta) G(x; A, \mu, \sigma)
where:
- L(x; A, \mu, \sigma) is the Lorentzian function
- G(x; A, \mu, \sigma) is the Gaussian function
Iguape.Monitor.split_pseudo_voigt(x, amp1, cen1, sigma1, eta1, amp2, cen2, sigma2, eta2)[source]

Split PseudoVoigt function, a linear combination of two PseudoVoigt functions.

x (np.array): 2theta array. amp1 (float): Peak amplitude for the first peak. cen1 (float): Peak center for the first peak. sigma1 (float): Sigma value or standard deviation for the first peak. eta1 (float): Eta value for the first peak (mixing parameter). amp2 (float): Peak amplitude for the second peak. cen2 (float): Peak center for the second peak. sigma2 (float): Sigma value or standard deviation for the second peak. eta2 (float): Eta value for the second peak (mixing parameter).

np.array: Split PseudoVoigt function.

The Split PseudoVoigt function is defined as:
\[SPV(x; A1, \mu1, \sigma1, \eta1, A2, \mu2, \sigma2, \eta2) = PV1(x; A1, \mu1, \sigma1, \eta1) + PV2(x; A2, \mu2, \sigma2, \eta2)\]

Iguape.iguape module

This is the main script for the excution of the Paineira Graphical User Interface, a GUI for visualization and data processing during in situ experiments at Paineira. In this script, both GUIs used by the program are called and all of the backend functions and processes are defined.

class Iguape.iguape.FitWindow(parent=None)[source]

Bases: QDialog, Ui_pk_window

Fit Window Class. It creates a new window for the Peak Fitting routine. It allows the user to select the fitting model, the fitting interval and the fitting parameters. It inherits the QDialog class from PyQt.

__init__(parent=None)[source]

Constructor for the FitWindow class. It initializes the window and sets up the layout.

Parameters:

(QWidget) (parent)

clear_plot()[source]

Clears the plot on the FitWindow.

fit()[source]

Routine for starting the Peak Fitting process. It sets the fitting interval, the fitting model, the distance and the height for the Split Pseudo-Voigt Model. It starts the Worker thread for the Peak Fitting process.

onChanged_bkg_combo_box(text)[source]

Routine for selecting the Background Model via the ComboBox.

Parameters:

(str) (text)

onChanged_distance_spinbox(value)[source]

Method for setting the distance between the two peaks for the Split Pseudo-Voigt Model.

Parameters:

(int) (value)

onChanged_height_spinbox(value)[source]

Method for setting the height for the peak search for the Split Pseudo-Voigt Model.

Parameters:

(int) (value)

onChanged_pk_combo_box(text)[source]

Routine for selecting the Peak Fitting Model via the ComboBox.

Parameters:

(str) (text)

onChanged_xrd_combo_box(text)[source]

Routine for selecting the XRD pattern to be displayed on the plot via the ComboBox.

Parameters:

(str) (text)

onselect(xmin, xmax)[source]

Routine for selecting the fitting interval. It updates the fit_interval attribute and the interval_label label.

Parameters:
  • (float) (xmax)

  • (float)

peak_fitting_error(error_message)[source]

Routine for handling the Peak Fitting process error. It displays a message box with the error message.

Parameters:

(str) (error_message)

peak_fitting_finished(time)[source]

Routine for handling the Peak Fitting process completion. It updates the graphs and displays a message box with the elapsed time.

Parameters:

(float) (time)

preview()[source]

Returns a Preview of the Peak Fitting for the selected Model and 2theta Interval.

setup_layout()[source]

Routine for setting up the layout of the FitWindow. It creates the Figure and the layout for the Peak Fitting plot.

update_progress(value)[source]

Routine for updating the progress bar on the Peak Fitting process.

Parameters:

(int) (value)

class Iguape.iguape.Window(parent=None)[source]

Bases: QMainWindow, Ui_MainWindow

Main window Class

_create_double_peak_dataframe()[source]

Creates a DataFrame with the fitting data for the Split PseudoVoigt model (2x PseudoVoigt).

Returns:

DataFrame

Return type:

DataFrame with the fitting data

_create_single_peak_dataframe()[source]

Creates a DataFrame with the fitting data for the PseudoVoigt model.

Returns:

DataFrame

Return type:

DataFrame with the fitting data

_get_mask(i)[source]

Creates a mask, based on the interval selected by the user, for the i-th XRD measure. If no interval is selected, returns None.

Parameters:

(int) (i)

Returns:

slice

Return type:

Slice object for the mask

_plot_double_peak()[source]

Based on the x data type flag (temperature/XRD measure order), plots the fitting parameters (Peak Postion, Integrated Area and FWHM) as a function of x. In this version, the fitting model is the Split Pseudo-Voigt Model (2x Pseudo-Voigt)

_plot_fitting_parameters()[source]

Calls the fitting parameters plotting routines (_plot_single_peak or _plot_double_peak)

_plot_parameter(ax, x, y, ylabel, xlabel, label=None, color=None, marker='o')[source]

Routine for plotting x and y on given axis (ax)

_plot_single_peak()[source]

Based on the x data type flag (temperature/XRD measure order), plots the fitting parameters (Peak Postion, Integrated Area and FWHM) as a function of x.

_update_main_figure()[source]

Main Figure (XRD Data) refreshing routine. It plots the XRD patterns, with the customizations selected by the user (2theta mask, temperature mask, XRD index, etc.)

about()[source]

Displays the About message box from PyQt.

apply_temp_mask()[source]

Applies the temperature mask to the data. It validates the temperature selected at the SpinBoxes and updates the plot_data DataFrame.

create_graphs_layout()[source]

Routine to create the layout for the XRD and Fitting Data Graphs

handle_new_data(new_data)[source]

Handles new data received from the FolderMonitor object. It updates the plot_data DataFrame and calls the update_graphs routine.

Parameters:

(DataFrame) (new_data)

measure_order_index(checked)[source]

Routine for selecting the XRD measure order index. It updates the plot_with_temp flag and calls the update_graphs routine.

Parameters:

(bool) (checked)

on_mouse_move(event)[source]

Tracks the mouse motion and updates the toolbar with the event information.

Parameters:

(MouseEvent) (event)

onselect(xmin, xmax)[source]

Routine for selecting the fitting interval. It updates the selected_interval attribute and calls the update_graphs routine.

Parameters:
  • (float) (xmax)

  • (float)

reset_interval()[source]

Routine for resetting the selected interval. It sets the selected_interval attribute to None and calls the update_graphs routine.

save_data_frame()[source]

Saves the fitting data to a CSV file. The user is prompted to select the file path.

select_fit_interval()[source]

Routine for selecting the fitting interval. It checks if the monitor has been initialized and calls the FitWindow object.

select_folder()[source]

Routine for selecting the folder to be monitored. It creates a FolderMonitor object and starts the monitoring process.

temp_index(checked)[source]

Routine for selecting the temperature index. It updates the plot_with_temp flag and calls the update_graphs routine.

Parameters:

(bool) (checked)

update_colormap(color_map_type, label)[source]

Updates the colormap based on the selected color map type (temperature or XRD measure order)

Parameters:
  • (str) (label)

  • (str)

update_graphs()[source]

Clears plotted axis, updates the colormap normalization and calls refreshing routines (_update_main_figure and _plot_fitting_parameters)

validate_temp(min_value, max_value)[source]

Validates the temperature selected at the SpinBoxes.

Parameters:
  • (float) (max_value)

  • (float)

Returns:

tuple

Return type:

Tuple with the minimum and maximum temperature values

class Iguape.iguape.Worker(interval)[source]

Bases: QThread

QThread Class for performing the Peak Fit. It emits signals for progress, finished and error.

Parameters:

(list) (interval)

error

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

finished

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

progress

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

run()[source]

Peak Fitting routine. It calls the peak_fit or peak_fit_split_gaussian routine based on the selected fitting model.

Iguape.launcher module

Execution script. It goes to the directory where Iguape is installed and it executes the program (iguape.py)

Iguape.launcher.main()[source]

Module contents

This is the main script for the excution of the Paineira Graphical User Interface, a GUI for visualization and data processing during in situ experiments at Paineira. In this script, both GUIs used by the program are called and all of the backend functions and processes are defined.