pyTGA package

Submodules

pyTGA.pyTGA module

class pyTGA.pyTGA.TGA_exp(stage_files=None)[source]

Bases: object

A class to represent a TGA experiment

stages

A dictionary containing the stages of the TGA experiment

Type:

dict

method

A string containing the method used for the TGA experiment

Type:

str

calibration

A string containing the calibration information for the TGA experiment

Type:

str

manufacturer

A string containing the manufacturer of the TGA machine

Type:

str

details

Additional metadata of the TGA experiment, only read for TA Instruments Excel files.

default_weight

The default column name for the weight data

Type:

str

default_temp

The default column name for the temperature data

Type:

str

default_time

The default column name for the time data

Type:

str

time_unit

The unit of time used in the TGA experiment, default is ‘min’

Type:

str

weight_unit

The unit of weight used in the TGA experiment, default is ‘mg’

Type:

str

temp_unit

The unit of temperature used in the TGA experiment, default is ‘°C’

Type:

str

add_stage(stage_name, data)[source]

Adds a stage to the TGA experiment

get_stage(stage)[source]

Returns the data for a specific stage

stage_names()[source]

Returns the names of the stages

trim_stage(stage, temp_range)[source]

Trims a stage to a specified temperature range

add_method(method)[source]

Adds a method to the TGA experiment

combine_stages(stage_names, new_stage_name='comb_stage')[source]

Combines a list of stages in the TGA experiment into a new stage

quickplot()[source]

Generates a simple plot of the TGA data with time as x axis and weight and temperature as y axes. Uses the full data if available, otherwise combines stages to create it.

add_stage(stage_name, data)[source]

Adds a stage to the TGA experiment

param stage:

The name of the stage

type stage:

str

param data:

The data for the stage

type data:

pandas.DataFrame

get_stage(stage)[source]

Returns the data for a specific stage

param stage:

The name of the stage to return

type stage:

str

stage_names()[source]

Returns the names of the stages

trim_stage(stage: str, temp_range: list)[source]

Trims a stage to a specified temperature range

param stage:

The name of the stage to trim

type stage:

str

param temp_range:

A list containing the minimum and maximum temperature e.g. [200,800]

type temp_range:

list

add_method(method)[source]
combine_stages(stage_names, new_stage_name='comb_stage')[source]

Combine a list of stages in a TGA_exp object into a new stage. Use ‘all’ to combine all base stages in the experiment including the label ‘stage’. # To-do: This needs to be done better

quickplot()[source]
class pyTGA.pyTGA.TGA_pyro(stage_files=None, **kwargs)[source]

Bases: TGA_exp

Represents a TGA pyrolysis experiment.

Tmax

The temperature at which the maximum rate of weight loss occurs.

Type:

float

T50

The temperature at which 50% of the weight has been lost.

Type:

float

cracking_stage_name

The name of the cracking stage, e.g. ‘stage4’.

Type:

str

burnoff_stage_name

The name of the burnoff stage, e.g. ‘stage8’.

Type:

str

cracking()[source]

Returns the cracking stage data.

Returns:

The cracking stage data.

Return type:

pandas.DataFrame

burnoff()[source]

Returns the burnoff stage data.

Returns:

The burnoff stage data.

Return type:

pandas.DataFrame

m_cat()[source]

Returns the amount of catalyst in mg.

Returns:

The amount of catalyst in mg.

Return type:

float

m_poly()[source]

Returns the amount of polymer.

Returns:

The amount of polymer.

Return type:

float

m_coke()[source]

Returns the amount of coke.

Returns:

The amount of coke in mg.

Return type:

float

pct_loss()[source]

Returns the relative loss of polymer.

Returns:

The loss of polymer as decimal.

Return type:

float

P_C_ratio()[source]

Returns the polymer-to-catalyst ratio.

Returns:

The polymer-to-catalyst ratio.

Return type:

float

coke_yield()[source]

Returns the coke yield.

Returns:

The coke yield.

Return type:

float

class pyTGA.pyTGA.TGA_pyro_iso(stage_files=None)[source]

Bases: TGA_exp

cracking()[source]
burnoff()[source]
m_cat()[source]
m_poly()[source]
m_coke()[source]
pct_loss()[source]
P_C_ratio()[source]
temp()[source]
pyTGA.pyTGA.infer_manufacturer(filepath)[source]

Infers the manufacturer of the TGA file. Returns ‘Perkin Elmer’, ‘Mettler Toledo’, ‘TA Instruments (Excel)’, ‘TA Instruments (txt)’, or ‘TA Instruments (txt_old)’

pyTGA.pyTGA.parse_TGA(filepath, manufacturer='infer', **kwargs)[source]

Parses a TGA file and returns a TGA_exp object. Infers the manufacturer if not specified, if the type is known ideally use the specific parsing function. Currently Supported: - Perkin Elmer - Mettler Toledo - TA Instruments (Excel) - TA Instruments (txt) - TRIOS software format - TA Instruments (txt_old) - Q500 format - Netzsch

Optional Parameters: General: - exp_type: str, the type of TGA experiment. Must be ‘general’, ‘pyro’ or ‘pyro_iso’. Default is ‘general’

For PE TGA files: - calculate_DTGA: bool, whether to calculate the derivative of the TGA curve. Default is False

For MT TGA files: - rename_columns: bool, whether to rename the columns to the default ones used in this library (as in Perkin Elmer TGA files). Default is True. - calculate_DTGA: bool, whether to calculate the derivative of the TGA curve. Default is False - stage split: str or dict or None

Specifies whether and how to split the TGA experiment into stages. If a string, it should be the path to a csv file containing the stage split information. File formating: stage, start_index, end_index stage1, 0, 100 stage2, 101, 300 etc. If a dictionary, it should be a dictionary with stage names as keys and indices as values.

Parameters:
  • filepath (str) – The path to the TGA file

  • manufacturer (str) – The manufacturer of the TGA machine. Must be ‘Perkin Elmer’ or ‘Mettler Toledo’. Default is ‘infer’

  • **kwargs – Additional keyword arguments to pass to the parsing function

Returns:

The TGA_exp object

Return type:

TGA_exp

pyTGA.pyTGA.parse_txt(filepath, exp_type='general', calculate_DTGA=False, **kwargs)[source]

Parses a perkin Elmer ASCII TGA file and returns a TGA_exp object

Parameters:
  • filepath (str) – The path to the TGA file

  • exp_type (str) – The type of TGA experiment. Must be ‘general’, ‘pyro’ or ‘pyro_iso’. Default is ‘general’

  • calculate_DTGA (bool) – Whether to calculate the derivative of the TGA curve. Default is False

Returns:

The TGA_exp object

Return type:

TGA_exp

pyTGA.pyTGA.parse_PE(filepath, exp_type='general', calculate_DTGA=False, **kwargs)

Parses a perkin Elmer ASCII TGA file and returns a TGA_exp object

Parameters:
  • filepath (str) – The path to the TGA file

  • exp_type (str) – The type of TGA experiment. Must be ‘general’, ‘pyro’ or ‘pyro_iso’. Default is ‘general’

  • calculate_DTGA (bool) – Whether to calculate the derivative of the TGA curve. Default is False

Returns:

The TGA_exp object

Return type:

TGA_exp

pyTGA.pyTGA.parse_MT(filepath, exp_type='general', rename_columns=True, stage_split=None, calculate_DTGA=False, **kwargs)[source]

Parses a Mettler Toldeo TGA file and returns a TGA_exp object

Parameters:
  • filepath (str) – The path to the TGA file

  • exp_type (str) – The type of TGA experiment. Must be ‘general’, ‘pyro’ or ‘pyro_iso’. Default is ‘general’

  • rename_columns (bool) – Whether to rename the columns to the default ones used in this library (as in Perkin Elmer TGA files). Default is True. When False, the original column names of the Mettler Toledo file are used.

  • split (stage) – Specifies whether or how to split the TGA experiment into stages. If a string, it should be the path to a csv file containing the stage split information. File formating: stage, start_index, end_index stage1, 0, 100 stage2, 101, 300 etc. If a dictionary, it should be a dictionary with stage names as keys and indices as values.

  • calculate_DTGA (bool) – Whether to calculate the derivative of the TGA curve. Default is False

Returns:

The TGA_exp object

Return type:

TGA_exp

pyTGA.pyTGA.parse_TA_excel(filepath, exp_type='general', calculate_DTGA=False)[source]

Parses a TA Instruments excel TGA file and returns a TGA_exp object

Parameters:
  • filepath (str) – The path to the TGA file

  • exp_type (str) – The type of TGA experiment. Must be ‘general’, ‘pyro’ or ‘pyro_iso’. Default is ‘general’ Presently only ‘general’ is supported for this format

  • calculate_DTGA (bool) – Whether to calculate the derivative of the TGA curve. Default is False Currently not supported for TA Instruments.

Returns:

The TGA_exp object

Return type:

TGA_exp

pyTGA.pyTGA.parse_TA_txt(filepath, exp_type='general', **kwargs)[source]

Parses a TA Instruments TRIOS text file (.txt, UTF-8) and returns a TGA_exp object. This format is produced by the TRIOS software (e.g. HP-TGA75).

Parameters:
  • filepath (str) – Path to the TGA file

  • exp_type (str) – ‘general’, ‘pyro’, or ‘pyro_iso’. Default is ‘general’

Return type:

TGA_exp

pyTGA.pyTGA.parse_TA_txt_old(filepath, exp_type='general', **kwargs)[source]

Parses an older TA Instruments text file (UTF-16, e.g. TGA Q500) and returns a TGA_exp object.

Parameters:
  • filepath (str) – Path to the TGA file

  • exp_type (str) – ‘general’, ‘pyro’, or ‘pyro_iso’. Default is ‘general’

Return type:

TGA_exp

pyTGA.pyTGA.read_Netzsch_metadata(filepath) dict[source]

Reads metadata from a Netzsch TGA file.

Parameters: filepath (str): Path to the Netzsch TGA file

Returns: dict: Dictionary containing all metadata entries

pyTGA.pyTGA.parse_Netzsch(filepath, exp_type='general', calculate_DTGA=False, **kwargs)[source]

Parses a Netzsch txt file and returns a TGA_exp object

Parameters:
  • filepath (str) – The path to the TGA file

  • exp_type (str) – The type of TGA experiment. Must be ‘general’, ‘pyro’ or ‘pyro_iso’. Default is ‘general’ Presently only ‘general’ is supported for this format

  • calculate_DTGA (bool) – Whether to calculate the derivative of the TGA curve. Default is False

Returns:

The TGA_exp object

Return type:

TGA_exp

pyTGA.pyTGA.calc_DTGA_pyro(tga_exp)[source]
pyTGA.pyTGA.calc_DTGA_stage(tga_exp: TGA_exp, stage_name: str, x='Temp', y='relative', avering_window: int = 30) TGA_exp[source]

Calculate the derivative the TGA curve for each stage in the TGA_exp object, average over window

Parameters:
  • tga_exp (TGA_exp) – The TGA_exp object

  • stage_name (str) – The name of the stage to calculate the derivative for

  • x (str) – The x-axis to use for the derivative calculation. Must be ‘Time’ or ‘Temp’

  • y (str) – The y-axis to use for the derivative calculation. Must be ‘relative’ or ‘absolute’

  • avering_window (int) – The window to average the derivative over. Default is 30

Returns:

The TGA_exp object with the derivative added to the stage

Return type:

TGA_exp

pyTGA.pyTGA.combine_stages(tga_exp: TGA_exp, stage_names, new_stage_name: str) TGA_exp[source]

Combines a list of stages in a TGA_exp object into a new stage

Parameters:
  • tga_exp (TGA_exp) – The TGA_exp object

  • stage_names (list or 'all') – The names of the stages to combine, e.g. [‘stage1’, ‘stage2’] Use ‘all’ to combine all base stages in the experiment including the label ‘stage’.

  • new_stage_name (str) – The name of the new stage e.g. ‘full’

pyTGA.pyTGA.trim_stage(tga_exp: TGA_exp, stage_name: str, min_temp: float, max_temp: float) TGA_exp[source]

Trim a stage in a TGA_exp object to a specified temperature range

pyTGA.pyTGA.calc_Tmax_exp(tga_exp, stage='cracking')[source]
pyTGA.pyTGA.calc_T50_old(tga_exp, stage='cracking')[source]
pyTGA.pyTGA.quickplot(tga_exp, show=True)[source]

Generates a simple plot of the TGA data with time as x axis and weight and temperature as y axes. Uses the full data if available, otherwise combines stages to create it.

Parameters:
  • tga_exp (TGA_experiment) – The TGA experiment object to plot

  • show (bool, optional) – Whether to display the plot, default True. Set to False for testing.

Returns:

fig – The figure object containing the plot

Return type:

matplotlib.figure.Figure

pyTGA.pyTGA.calc_Tmax(stage, temp_col='Sample Temp.')[source]

For a stage in the experiment, returns the temperature at which the derivative of the TGA curve is max. For non-PE TGA files, the temp_col must be specified manually. Parameters: ———- stage : pd.DataFrame

Stage of the experiment or ‘full’

temp_colstr

Name of the temperature column

pyTGA.pyTGA.calc_T50(stage: DataFrame) float[source]

For a stage in the experiment, returns the temperature at which 50% of the weight has been lost.

pyTGA.pyTGA.get_color(min_rel_weight, cmap='viridis')[source]

Returns a color for the TGA plot based on the minimum relative weight. Parameters: ———- min_rel_weight : float

The minimum relative weight of the sample

cmapstr

The colormap to use. Default is ‘viridis’

Returns:

colortuple

The color for the TGA plot

pyTGA.pyTGA.get_coke_content(stage, weight_col='Unsubtracted weight')[source]

For a stage in the experiment, returns the coke content as a fraction of the total weight.

Module contents