This page was generated from docs/Examples/Other_features/oxide_to_wtperc.ipynb. Interactive online version: .

# This notebook shows how to convert from Oxide wt% to element wt% and back again

[1]:

import numpy as np
import pandas as pd
import Thermobar as pt#
pd.options.display.max_columns = None
pd.options.display.max_rows = None
import matplotlib.pyplot as plt


## Load in oxide wt % values (in this case, from plag)

[2]:

ExcelIn_TB=pt.import_excel('Ox_to_element.xlsx', sheet_name="Plag")
ExcelIn_Plag=ExcelIn_TB['Plags']
Excel_In=ExcelIn_TB['my_input']

SiO2_Plag TiO2_Plag Al2O3_Plag FeOt_Plag MnO_Plag MgO_Plag CaO_Plag Na2O_Plag K2O_Plag Cr2O3_Plag Sample_ID_Plag
0 54.67 0.24 26.81 1.47 0.0 0.42 10.59 4.55 0.35 0.0 0
1 52.05 0.07 29.26 0.81 0.0 0.15 12.26 4.07 0.17 0.0 1
2 52.73 0.07 28.73 0.77 0.0 0.13 11.44 4.58 0.18 0.0 2
3 56.89 0.01 26.88 0.21 0.0 0.01 8.55 6.06 0.16 0.0 3
4 54.54 0.02 26.92 0.19 0.0 0.04 8.42 6.03 0.18 0.0 4

## Convert to element wt%

• You have to specify the suffix on the data, so that Thermobar knows how to strip it off to do the processing, e.g. in this case _Plag

• By default, it includes oxygen, this means that O is added to sum to 100

[3]:

wt_calc_withO=pt.convert_oxide_percent_to_element_weight_percent(df=ExcelIn_Plag,
suffix="_Plag", without_oxygen=False)

[3]:

Si_wt Mg_wt Fe_wt Ca_wt Al_wt Na_wt K_wt Mn_wt Ti_wt Cr_wt P_wt F_wt H_wt Cl_wt O_wt_make_to_100
0 25.554795 0.253278 1.142613 7.568359 14.189250 3.375448 0.290555 0.0 0.143784 0.0 0.0 0.0 0.0 0.0 47.481919
1 24.330109 0.090456 0.629603 8.761859 15.485918 3.019357 0.141127 0.0 0.041937 0.0 0.0 0.0 0.0 0.0 47.499635
2 24.647966 0.078395 0.598511 8.175829 15.205414 3.397704 0.149428 0.0 0.041937 0.0 0.0 0.0 0.0 0.0 47.704814
3 26.592505 0.006030 0.163230 6.110432 14.226298 4.495652 0.132825 0.0 0.005991 0.0 0.0 0.0 0.0 0.0 48.267037
4 25.494028 0.024122 0.147685 6.017525 14.247468 4.473396 0.149428 0.0 0.011982 0.0 0.0 0.0 0.0 0.0 49.434367

## Lets compare this to that calculated by EPMA software

### Without oxygen

[4]:

wt_calc_withoutO=pt.convert_oxide_percent_to_element_weight_percent(df=ExcelIn_Plag,
suffix="_Plag", without_oxygen=True)

[4]: