tga_data_analysis.tga

class tga_data_analysis.tga.Project(folder_path, name=None, column_name_mapping=None, load_skiprows=0, time_moist=38.0, time_vm=147.0, temp_initial_celsius=40, temp_lim_dtg_celsius=None, temp_unit='C', plot_font='Dejavu Sans', temp_i_temp_b_threshold=0.01, soliddist_steps_min=None, resolution_sec_deg_dtg=5, dtg_window_filter=51, plot_grid=False, auto_save_reports=True)[source]

Bases: object

Represents a project (identified by the folder where the data is stored) for TGA data analysis.

Initialize a new Project instance with various parameters for analysis.

Parameters:
  • folder_path (plib.Path) – The path to the folder containing the project data.

  • name (str, optional) – The name of the project. Defaults to the last part of the folder path if None.

  • temp_unit (Literal["C", "K"]) – The unit of temperature used in the project (‘C’:Celsius, ‘K’:Kelvin).

  • plot_font (Literal["Dejavu Sans", "Times New Roman"]) – The font used in plots, either ‘Dejavu Sans’ or ‘Times New Roman’.

  • temp_i_temp_b_threshold (float) – The threshold for Ti and Tb calculation in DTG analysis.

  • soliddist_steps_min (list[float], optional) – Temperature steps (in minutes) at which the weight loss is calculated. If None, default steps are used.

  • resolution_sec_deg_dtg (int) – The resolution in seconds or degrees for DTG analysis.

  • dtg_window_filter (int) – The window size for the Savitzky-Golay filter in DTG analysis.

  • plot_grid (bool) – Whether to display a grid in the plots.

  • column_name_mapping (dict[str, str], optional) – Mapping of column names from file to standard names used in the analysis.

  • load_skiprows (int) – The number of rows to skip when loading data files.

  • time_moist (float) – The time considered for the moisture analysis.

  • time_vm (float) – The time considered for the volatile matter analysis.

  • temp_initial_celsius (float) – The initial temperature for certain calculations, in Celsius.

  • temp_lim_dtg_celsius (tuple[float], optional) – The temperature limits for DTG analysis, in Celsius.

  • auto_save_reports (bool) – Whether to automatically save generated reports.

add_sample(samplename, sample)[source]

Add a sample to the project.

Parameters:
  • samplename (str) – The name of the sample to add.

  • sample (Sample) – The sample object to add.

multireport(samples=None, labels=None, report_type='proximate', report_style='ave_std', decimals_in_ave_pm_std=2, filename=None)[source]

Generate a multi-sample report based on the specified report type and style.

Parameters:
  • samples (list[Sample], optional) – A list of Sample objects to include in the report. If None, uses all samples in the project.

  • labels (list[str], optional) – A list of labels corresponding to each sample. If None, sample names are used as labels.

  • report_type (Literal["proximate", "oxidation", "oxidation_extended", "soliddist", "soliddist_extended"]) – The type of report to generate, choices include ‘proximate’, ‘oxidation’, ‘oxidation_extended’, ‘soliddist’, and ‘soliddist_extended’.

  • report_style (Literal["repl_ave_std", "ave_std", "ave_pm_std"]) – The style of the report, choices are ‘repl_ave_std’, ‘ave_std’, and ‘ave_pm_std’.

  • decimals_in_ave_pm_std (int) – The number of decimal places to use for the average plus-minus standard deviation format.

  • filename (str, optional) – The name of the file to save the report. If None, the report is not saved.

Returns:

A pandas DataFrame containing the generated report.

Return type:

pd.DataFrame

plot_multi_dtg(filename='plot', samples=None, labels=None, **kwargs)[source]

Plot multiple derivative thermogravimetric (DTG) curves for the given samples.

Parameters:
  • filename (str) – The name of the file to save the plot. Defaults to “plot”.

  • samples (list[Sample], optional) – A list of Sample objects to be plotted. If None, plots all samples in the project.

  • labels (list[str], optional) – Labels for each sample in the plot. If None, sample names are used.

  • kwargs (dict) – Additional keyword arguments for plotting customization.

Returns:

A MyFigure instance containing the plot.

Return type:

MyFigure

plot_multi_soliddist(filename='plot', samples=None, labels=None, cut_curves_at_last_step=True, **kwargs)[source]

Plot multiple solid distribution curves for the given samples.

Parameters:
  • filename (str) – The name of the file to save the plot. Defaults to “plot”.

  • samples (list[Sample], optional) – A list of Sample objects to be plotted. If None, plots all samples in the project.

  • labels (list[str], optional) – Labels for each sample in the plot. If None, sample names are used.

  • cut_curves_at_last_step (bool, optional) – whether to cut the dtg curves at the end of the last segment.

  • kwargs (dict) – Additional keyword arguments for plotting customization.

Returns:

A MyFigure instance containing the plot.

Return type:

MyFigure

plot_multi_tg(filename='plot', samples=None, labels=None, **kwargs)[source]

Plot multiple thermogravimetric (TG) curves for the given samples.

Parameters:
  • filename (str) – The name of the file to save the plot. Defaults to “plot”.

  • samples (list[Sample], optional) – A list of Sample objects to be plotted. If None, plots all samples in the project.

  • labels (list[str], optional) – Labels for each sample in the plot. If None, sample names are used.

  • kwargs (dict) – Additional keyword arguments for plotting customization.

Returns:

A MyFigure instance containing the plot.

Return type:

MyFigure

plot_multireport(filename='plot', samples=None, labels=None, report_type='proximate', bar_labels=None, **kwargs)[source]

Generate a plot for the multi-sample report.

Parameters:
  • filename (str) – The name of the file to save the plot. Defaults to “plot”.

  • samples (list[Sample], optional) – A list of Sample objects to include in the plot. If None, uses all samples in the project.

  • labels (list[str], optional) – A list of labels corresponding to each sample. If None, sample names are used as labels.

  • report_type (Literal["proximate", "oxidation", "soliddist"]) – The type of report to plot, choices include ‘proximate’, ‘oxidation’, and ‘soliddist’.

  • bar_labels (list[str], optional) – Labels for the bars in the plot. If None, default labels based on the report type are used.

  • kwargs (dict) – Additional keyword arguments to pass to the plotting function.

Returns:

An instance of MyFigure containing the generated plot.

Return type:

MyFigure

class tga_data_analysis.tga.Sample(project, name, filenames, folder_path=None, label=None, correct_ash_mg=None, correct_ash_fr=None, column_name_mapping=None, load_skiprows=None, time_moist=None, time_vm=None, heating_rate_deg_min=None, temp_i_temp_b_threshold=None, soliddist_steps_min=None)[source]

Bases: object

A class representing a sample in the project, containing methods for loading, processing, and analyzing thermogravimetric analysis (TGA) data associated with the sample.

Initialize a new Sample instance with parameters for TGA data analysis.

Parameters:
  • project (Project) – The Project object to which this sample belongs.

  • name (str) – The name of the sample.

  • filenames (list[str]) – A list of filenames associated with the sample.

  • folder_path (plib.Path, optional) – The path to the folder containing the sample data. If None, the project’s folder path is used.

  • label (str, optional) – A label for the sample. If None, the sample’s name is used as the label.

  • correct_ash_mg (list[float], optional) – A list of ash correction values in milligrams, one per file.

  • correct_ash_fr (list[float], optional) – A list of ash correction values as a fraction, one per file.

  • column_name_mapping (dict[str, str], optional) – A dictionary mapping file column names to standardized column names for analysis.

  • load_skiprows (int) – The number of rows to skip at the beginning of the files when loading.

  • time_moist (float) – The time considered for the moisture analysis.

  • time_vm (float) – The time considered for the volatile matter analysis.

  • heating_rate_deg_min (float, optional) – The heating rate in degrees per minute, used for certain calculations.

  • temp_i_temp_b_threshold (float, optional) – The threshold percentage used for calculating initial and final temperatures in DTG analysis.

  • soliddist_steps_min (list[float], optional) – Temperature steps (in minutes) at which the weight loss is calculated. If None, default steps are used.

correct_file_values(file, correct_ash_fr, correct_ash_mg)[source]

Apply corrections to the loaded file data.

This method adjusts the mass measurements in the file based on provided ash correction values.

Parameters:
  • file (pd.DataFrame) – The data file to be corrected.

  • correct_ash_mg (float, optional) – The correction value for ash in milligrams. If None, no correction is applied.

  • correct_ash_fr (float, optional) – The correction value for ash as a fraction. If None, no correction is applied.

Returns:

The corrected data as a pandas DataFrame.

Return type:

pd.DataFrame

deconv_analysis(centers, sigmas=None, amplitudes=None, center_mins=None, center_maxs=None, sigma_mins=None, sigma_maxs=None, amplitude_mins=None, amplitude_maxs=None)[source]

Perform deconvolution analysis on the sample’s DTG data.

This method fits multiple Gaussian peaks to the DTG curve to identify and analyze individual decomposition steps within the sample.

Parameters:
  • centers (list[float]) – Initial guesses for the centers of the Gaussian peaks.

  • sigmas (list[float], optional) – Initial guesses for the standard deviations of the Gaussian peaks. If None, defaults are used.

  • amplitudes (list[float], optional) – Initial guesses for the amplitudes of the Gaussian peaks. If None, defaults are used.

  • center_mins (list[float], optional) – Minimum allowed values for the centers of the Gaussian peaks. If None, no bounds are applied.

  • center_maxs (list[float], optional) – Maximum allowed values for the centers of the Gaussian peaks. If None, no bounds are applied.

  • sigma_mins (list[float], optional) – Minimum allowed values for the standard deviations of the Gaussian peaks. If None, no bounds are applied.

  • sigma_maxs (list[float], optional) – Maximum allowed values for the standard deviations of the Gaussian peaks. If None, no bounds are applied.

  • amplitude_mins (list[float], optional) – Minimum allowed values for the amplitudes of the Gaussian peaks. If None, no bounds are applied.

  • amplitude_maxs (list[float], optional) – Maximum allowed values for the amplitudes of the Gaussian peaks. If None, no bounds are applied.

dtg_analysis()[source]

Compute the derivative thermogravimetric (DTG) data for the sample.

This method calculates the DTG data based on the thermogravimetric data and stores the results in the instance’s attributes for later use.

load_files()[source]

Load all files associated with this sample, applying necessary corrections and adjustments.

This method loads and processes each file, ensuring consistent data structure and applying corrections such as ash content adjustments.

Returns:

A dictionary where keys are filenames and values are the corresponding corrected data as pandas DataFrames.

Return type:

dict[str, pd.DataFrame]

load_single_file(filename, folder_path=None, load_skiprows=None, column_name_mapping=None)[source]

Load data from a single file associated with the sample.

Parameters:
  • filename (str) – The name of the file to be loaded.

  • folder_path (plib.Path, optional) – The folder path where the file is located. If None, uses the sample’s folder path.

  • load_skiprows (int, optional) – The number of rows to skip at the beginning of the file. If None, uses the sample’s default.

  • column_name_mapping (dict, optional) – A mapping of file column names to standardized column names. If None, uses the sample’s default.

Returns:

The loaded data as a pandas DataFrame.

Return type:

pd.DataFrame

oxidation_analysis()[source]

Conduct oxidation analysis on the sample’s data.

This method calculates various oxidation parameters such as the initial oxidation temperature (Ti), peak oxidation temperature (Tp), and final oxidation temperature (Tb). It also computes derivative parameters like maximum and average rates of weight loss. The results are stored in the instance’s attributes for further analysis.

plot_deconv(**kwargs)[source]

Generate a plot showing the deconvolution analysis results.

This method visualizes the Gaussian peak fitting performed on the DTG data, illustrating the identified decomposition steps within the sample.

Parameters:

kwargs (dict) – Additional keyword arguments for plot customization.

Returns:

A MyFigure instance containing the deconvolution analysis plot.

Return type:

MyFigure

plot_soliddist(**kwargs)[source]

Generate a plot illustrating the solid distribution analysis results.

This method plots the weight loss of the sample at specified temperature steps, showing the distribution of solid components within the sample.

Parameters:

kwargs (dict) – Additional keyword arguments for plot customization.

Returns:

A MyFigure instance containing the generated plot.

Return type:

MyFigure

plot_tg_dtg(**kwargs)[source]

Generate a plot combining thermogravimetric (TG) and derivative thermogravimetric (DTG) data.

This method creates a figure showing the TG and DTG curves, providing a visual representation of the sample’s thermal decomposition behavior.

Parameters:

kwargs (dict) – Additional keyword arguments for plot customization.

Returns:

A MyFigure instance containing the generated plot.

Return type:

MyFigure

proximate_analysis()[source]

Perform proximate analysis on the loaded data for the sample.

This analysis calculates moisture content, ash content, volatile matter, and fixed carbon based on the thermogravimetric data. The results are stored in the instance’s attributes for later use.

report(report_type='proximate')[source]

Generate a report based on the specified analysis type.

This method provides detailed insights into the sample’s properties, such as proximate analysis, oxidation characteristics, and solid distribution, based on the selected report type.

Parameters:

report_type (Literal["proximate", "oxidation", "oxidation_extended", "soliddist", "soliddist_extended"]) – The type of report to generate. Options include ‘proximate’, ‘oxidation’, ‘oxidation_extended’, ‘soliddist’, and ‘soliddist_extended’.

Returns:

A pandas DataFrame containing the analysis results.

Return type:

pd.DataFrame

soliddist_analysis()[source]

Perform solid distribution analysis on the sample’s data.

This analysis calculates the weight loss at specified temperature steps, providing insight into the solid decomposition process. The results are used for generating solid distribution plots.