This page was generated from
docs/Examples/Cpx_Cpx_Liq_Thermobarometry/MachineLearning_Cpx_Liq_Thermobarometry.ipynb.
Interactive online version:
.
Machine-Learning-based Clinopyroxene-only and Clinopyroxene-Liquid Thermobarometry.¶
This notebook goes through the options for clinopyroxene-Liquid thermobarometry and clinopyroxene-only thermobarometry
Cpx-Liq matching is not covered in this tutorial, there is a separate folder “Cpx_Liquid_melt_matching” for that
You can download the excel spreadsheet from: https://github.com/PennyWieser/Thermobar/blob/main/docs/Examples/Cpx_Cpx_Liq_Thermobarometry/Cpx_Liq_Example.xlsx
You need to install Thermobar once on your machine, if you haven’t done this yet, uncomment the line below (remove the #)¶
[1]:
!pip install Thermobar
For Machine learning, you also need to pip install the .pkl files that have saved the pretrained model. This is to keep Thermobar smaller so we can still release on Pip¶
[2]:
!pip install "https://github.com/PennyWieser/Thermobar_onnx/archive/refs/tags/0.02.zip"
First, load the necessary python things¶
[3]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import Thermobar as pt
Now, load the data¶
[4]:
out=pt.import_excel('Cpx_Liq_Example.xlsx', sheet_name="Sheet1")
my_input=out['my_input']
Liqs=out['Liqs']
Cpxs=out['Cpxs']
Using saved models¶
This uses pickles, the model will change with different versions of python
But, it does give you the voting approach of Jorgenson, with the median and standard deviation of the trees
[13]:
P_T_EqTests_pkl=pt.calculate_cpx_liq_press_temp(cpx_comps=Cpxs, liq_comps=Liqs,
equationP="P_Petrelli2020_Cpx_Liq",
equationT="T_Petrelli2020_Cpx_Liq",
T=1300,
H2O_Liq=0, eq_tests=True)
P_T_EqTests_pkl
Youve selected a P-independent function
Youve selected a T-independent function
Youve selected a T-independent function
Using Fe3FeT from input file to calculate Kd Fe-Mg
[13]:
P_kbar_calc | T_K_calc | Median_Trees_P | Std_Trees_P | IQR_Trees_P | Median_Trees_T | Std_Trees_T | IQR_Trees_T | Eq Tests Neave2017? | Delta_Kd_Put2008 | ... | Delta_EnFs_I_M_Mollo13 | CaTs_Pred_Put1999 | Delta_CaTs_I_M_Put1999 | CrCaTs_Pred_Put1999 | Delta_CrCaTs_I_M_Put1999 | CaTi_Pred_Put1999 | Delta_CaTi_I_M_Put1999 | Jd_Pred_Put1999 | Delta_Jd_Put1999 | Delta_Jd_I_M_Put1999 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 2.012874 | 1436.353636 | 2.0 | 2.014248 | 2.014248 | 1434.15 | 37.734604 | 37.734604 | False | 0.047419 | ... | 0.001449 | 0.013801 | -0.016574 | 0.0 | 0.009562 | 0.042741 | 0.001728 | 0.016176 | 0.000880 | 0.000880 |
1 | 2.385743 | 1422.872182 | 2.0 | 2.516823 | 2.516823 | 1423.15 | 58.692923 | 58.692923 | False | 0.045964 | ... | 0.006055 | 0.013802 | -0.023015 | 0.0 | 0.004122 | 0.055375 | 0.010437 | 0.017422 | 0.000092 | 0.000092 |
2 | 2.031163 | 1388.809636 | 2.0 | 1.335548 | 1.335548 | 1398.15 | 100.495001 | 100.495001 | False | 0.048797 | ... | 0.066580 | 0.017510 | -0.074375 | 0.0 | 0.003245 | 0.028704 | 0.042963 | 0.018321 | 0.000236 | 0.000236 |
3 | 2.175246 | 1418.986727 | 2.0 | 2.290651 | 2.290651 | 1423.15 | 62.539834 | 62.539834 | False | 0.042372 | ... | 0.002781 | 0.015006 | -0.030821 | 0.0 | 0.003909 | 0.049805 | 0.008608 | 0.019322 | 0.002988 | 0.002988 |
4 | 2.194894 | 1358.247818 | 2.0 | 2.305614 | 2.305614 | 1373.15 | 80.220643 | 80.220643 | False | 0.030098 | ... | -0.007655 | 0.011571 | -0.031539 | 0.0 | 0.001315 | 0.049482 | 0.013529 | 0.027939 | 0.005724 | 0.005724 |
5 rows × 136 columns
Using onnx models¶
-Using Onnx means you will always get the same answer. But, you dont get the voting results.
[14]:
P_T_EqTests_onnx=pt.calculate_cpx_liq_press_temp(cpx_comps=Cpxs, liq_comps=Liqs,
equationP="P_Petrelli2020_Cpx_Liq",
equationT="T_Petrelli2020_Cpx_Liq",
T=1300,
H2O_Liq=0, eq_tests=True)
P_T_EqTests_onnx
Youve selected a P-independent function
Youve selected a T-independent function
Youve selected a T-independent function
Using Fe3FeT from input file to calculate Kd Fe-Mg
[14]:
P_kbar_calc | T_K_calc | Median_Trees_P | Std_Trees_P | IQR_Trees_P | Median_Trees_T | Std_Trees_T | IQR_Trees_T | Eq Tests Neave2017? | Delta_Kd_Put2008 | ... | Delta_EnFs_I_M_Mollo13 | CaTs_Pred_Put1999 | Delta_CaTs_I_M_Put1999 | CrCaTs_Pred_Put1999 | Delta_CrCaTs_I_M_Put1999 | CaTi_Pred_Put1999 | Delta_CaTi_I_M_Put1999 | Jd_Pred_Put1999 | Delta_Jd_Put1999 | Delta_Jd_I_M_Put1999 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 2.012874 | 1436.353636 | 2.0 | 2.014248 | 2.014248 | 1434.15 | 37.734604 | 37.734604 | False | 0.047419 | ... | 0.001449 | 0.013801 | -0.016574 | 0.0 | 0.009562 | 0.042741 | 0.001728 | 0.016176 | 0.000880 | 0.000880 |
1 | 2.385743 | 1422.872182 | 2.0 | 2.516823 | 2.516823 | 1423.15 | 58.692923 | 58.692923 | False | 0.045964 | ... | 0.006055 | 0.013802 | -0.023015 | 0.0 | 0.004122 | 0.055375 | 0.010437 | 0.017422 | 0.000092 | 0.000092 |
2 | 2.031163 | 1388.809636 | 2.0 | 1.335548 | 1.335548 | 1398.15 | 100.495001 | 100.495001 | False | 0.048797 | ... | 0.066580 | 0.017510 | -0.074375 | 0.0 | 0.003245 | 0.028704 | 0.042963 | 0.018321 | 0.000236 | 0.000236 |
3 | 2.175246 | 1418.986727 | 2.0 | 2.290651 | 2.290651 | 1423.15 | 62.539834 | 62.539834 | False | 0.042372 | ... | 0.002781 | 0.015006 | -0.030821 | 0.0 | 0.003909 | 0.049805 | 0.008608 | 0.019322 | 0.002988 | 0.002988 |
4 | 2.194894 | 1358.247818 | 2.0 | 2.305614 | 2.305614 | 1373.15 | 80.220643 | 80.220643 | False | 0.030098 | ... | -0.007655 | 0.011571 | -0.031539 | 0.0 | 0.001315 | 0.049482 | 0.013529 | 0.027939 | 0.005724 | 0.005724 |
5 rows × 136 columns
[ ]: