Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
Thermobar
https://thermobar.readthedocs.io/en/latest/
Admin
Thermobar is a Python package for thermobarometry calculations using mineral-melt and
...
Tokens:
91,226
Snippets:
803
Trust Score:
9.6
Update:
4 months ago
Context
Chat
Benchmark
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Example: Installing Thermobar Source: https://thermobar.readthedocs.io/en/latest A commented-out line showing how to install the Thermobar package. ```python # pip install -U thermobar ``` -------------------------------- ### Install Thermobar Source: https://thermobar.readthedocs.io/en/latest Instructions on how to install the Thermobar package. ```python # You need to install Thermobar once on your machine, if you haven’t done this yet, uncomment the line below (remove the #) # pip install Thermobar ``` -------------------------------- ### Install Thermobar Source: https://thermobar.readthedocs.io/en/latest Instructions on how to install the Thermobar package, with a commented-out line for uncommenting if installation is needed. ```python # You need to install Thermobar once on your machine, if you haven’t done this yet, uncomment the line below (remove the #) ``` -------------------------------- ### Install Pyrolite Source: https://thermobar.readthedocs.io/en/latest Instructions on how to install the pyrolite package, with a commented-out line for uncommenting if installation is needed. ```python # You will also need to install pyrolite for this example, if you haven’t done so already, uncomment the line below ``` -------------------------------- ### Get Thermobar version Source: https://thermobar.readthedocs.io/en/latest/Examples/Five_min_intro.html Retrieves and displays the installed version of the Thermobar package. ```python pt.__version__ ``` -------------------------------- ### Get help on specific equations Source: https://thermobar.readthedocs.io/en/latest/Examples/Five_min_intro.html Demonstrates how to use the `help()` function to get detailed information about a specific thermobarometry equation, including its parameters and documentation. ```python help(pt.T_Put2008_eq33) ``` -------------------------------- ### Example: Olivine-Liquid thermometry (All Models) Source: https://thermobar.readthedocs.io/en/latest Demonstrates calculating Olivine-Liquid temperatures using all available models. ```python from thermobar.calculate import calculate_ol_liquid # Assuming 'ol_liq_data' is a pandas DataFrame with appropriate columns temps_K = calculate_ol_liquid(data=ol_liq_data, equation= "all") ``` -------------------------------- ### Pip Install Thermobar Source: https://thermobar.readthedocs.io/en/latest Instructions on how to install Thermobar using pip. ```python # First, pip install Thermobar if you haven’t already ``` -------------------------------- ### Getting Help on a Function Source: https://thermobar.readthedocs.io/en/latest/Examples/Five_min_intro.html This snippet demonstrates how to use the help() function to get detailed information about a specific Thermobar function, in this case, calculate_cpx_liq_temp. ```python help(pt.calculate_cpx_liq_temp) ``` -------------------------------- ### Example: Cpx-Liq temps calculation Source: https://thermobar.readthedocs.io/en/latest Demonstrates calculating Cpx-Liq temperatures and shows the output as a pandas Series. ```python import pandas as pd from thermobar.calculate import calculate_cpx_liquid data = pd.read_excel("your_data.xlsx") # Load your data temps = calculate_cpx_liquid(data=data) print(temps.head()) ``` -------------------------------- ### Example: Calculating Mg# for liquids Source: https://thermobar.readthedocs.io/en/latest Shows how to calculate the Mg# for liquids. ```python from thermobar.calculate import calculate_liquid_compositions # Assuming 'liquid_data' is a pandas DataFrame with appropriate columns liquid_compositions = calculate_liquid_compositions(data=liquid_data) print(liquid_compositions['Mg_number'].head()) ``` -------------------------------- ### Example: Olivine-Liquid thermometry (Toplis, 2005) Source: https://thermobar.readthedocs.io/en/latest Demonstrates using Toplis, 2005 equation for Olivine-Liquid thermometry. ```python from thermobar.calculate import calculate_ol_liquid # Assuming 'ol_liq_data' is a pandas DataFrame with appropriate columns temps_K = calculate_ol_liquid(data=ol_liq_data, equation= "Toplis_2005") ``` -------------------------------- ### Example: Calculating Olivine Fo contents Source: https://thermobar.readthedocs.io/en/latest Shows how to calculate the Fo contents of olivines. ```python from thermobar.calculate import calculate_olivine_fo # Assuming 'olivine_data' is a pandas DataFrame with appropriate columns olivine_fo = calculate_olivine_fo(data=olivine_data) print(olivine_fo.head()) ``` -------------------------------- ### Example: Olivine-Liquid thermometry (Putirka, 2016) Source: https://thermobar.readthedocs.io/en/latest Demonstrates using Putirka, 2016 equation for Olivine-Liquid thermometry. ```python from thermobar.calculate import calculate_ol_liquid # Assuming 'ol_liq_data' is a pandas DataFrame with appropriate columns temps_K = calculate_ol_liquid(data=ol_liq_data, equation= "Putirka_2016") ``` -------------------------------- ### Install pyrolite Source: https://thermobar.readthedocs.io/en/latest/Examples/Error_propagation/Cpx_only_contour_plot.html Install the pyrolite library if you haven't already. ```shell #!pip install pyrolite ``` -------------------------------- ### Import Libraries and Install Thermobar Source: https://thermobar.readthedocs.io/en/latest/Examples/Cpx_Cpx_Liq_Thermobarometry/Cpx_Liquid_melt_matching/Cpx_MeltMatch1_Gleeson2020.html This code block imports necessary Python libraries (numpy, pandas, matplotlib) and installs Thermobar if not already present. It also shows the output of the installation. ```python import numpy as np import pandas as pd import matplotlib.pyplot as plt !pip install Thermobar import Thermobar as pt ``` -------------------------------- ### Example 2 - Kspar-Liquid calculations Source: https://thermobar.readthedocs.io/en/latest/Examples/Feldspar_Thermobarometry/Fspar_Liq_Matching.html Loads Kspar and liquid data from an Excel file and performs calculations. ```python # Load in the Kspars out_Kspar=pt.import_excel('Feldspar_Liquid.xlsx', sheet_name="Kspar_only") Kspars=out_Kspar['Kspars'] # Load in the liquids you want to match with out_Liq2=pt.import_excel('Feldspar_Liquid.xlsx', sheet_name="Evolved_Liq_only") Liqs=out_Liq2['Liqs'] ``` -------------------------------- ### Install Thermobar Source: https://thermobar.readthedocs.io/en/latest/Examples/Cpx_Cpx_Liq_Thermobarometry/Cpx_Liq_Thermobarometry.html This code snippet shows how to install the Thermobar package using pip. It is presented as a command to be uncommented and run. ```bash #!pip install Thermobar ``` -------------------------------- ### Install Thermobar Source: https://thermobar.readthedocs.io/en/latest/Examples/Cpx_Cpx_Liq_Thermobarometry/Pyroxene_Ternary_Cpx_Example.html Install the Thermobar package if you haven't already done so. ```python # if you havent already done it, pip install Thermobar #!pip install Thermobar ``` -------------------------------- ### Example: Olivine-Liquid thermometry (Roeder and Emslie, 1970) Source: https://thermobar.readthedocs.io/en/latest Demonstrates using the Roeder and Emslie, 1970 equation for Olivine-Liquid thermometry. ```python from thermobar.calculate import calculate_ol_liquid # Assuming 'ol_liq_data' is a pandas DataFrame with appropriate columns temps_K = calculate_ol_liquid(data=ol_liq_data, equation= "Roeder_Emslie_1970") ``` -------------------------------- ### Getting help for the calculation function Source: https://thermobar.readthedocs.io/en/latest/Examples/Cpx_Cpx_Liq_Thermobarometry/Cpx_Liquid_melt_matching/Cpx_MeltMatch1_Gleeson2020.html This code snippet demonstrates how to access the documentation for the `calculate_cpx_liq_press_temp_matching` function to understand its parameters and usage. ```python help(pt.calculate_cpx_liq_press_temp_matching) ``` -------------------------------- ### Example: Olivine-Liquid thermometry (Putirka eq 22) Source: https://thermobar.readthedocs.io/en/latest Demonstrates using Putirka's equation 22 for Olivine-Liquid thermometry. ```python from thermobar.calculate import calculate_ol_liquid # Assuming 'ol_liq_data' is a pandas DataFrame with appropriate columns temps_K = calculate_ol_liquid(data=ol_liq_data, equation= "Putirka_2008_22") ``` -------------------------------- ### Install ONNX models for Machine Learning Source: https://thermobar.readthedocs.io/en/latest/Examples/Cpx_Cpx_Liq_Thermobarometry/MachineLearning_Cpx_Liq_Thermobarometry.html Installs pre-trained machine learning models saved as .pkl files from a specific GitHub repository. This is done to keep the main Thermobar library smaller. ```python #!pip install "https://github.com/PennyWieser/Thermobar_onnx/archive/refs/tags/v.0.05.zip" ``` -------------------------------- ### Example: Cpx-Liq temps calculation with Eq_Tests=True Source: https://thermobar.readthedocs.io/en/latest Shows the output when performing the same calculation with 'Eq_Tests=True', resulting in a pandas DataFrame. ```python import pandas as pd from thermobar.calculate import calculate_cpx_liquid data = pd.read_excel("your_data.xlsx") # Load your data temps_df = calculate_cpx_liquid(data=data, eq_tests=True) print(temps_df.head()) ``` -------------------------------- ### Example 2d - Writing the Entire DataFrame to Excel Source: https://thermobar.readthedocs.io/en/latest/Examples/Exporting_to_Excel.html Demonstrates how to save an entire DataFrame to an Excel file. ```python Temp_eq33_5kbar_Eq_tests.to_excel('Calc4.xlsx') ``` -------------------------------- ### Example 1c - Iterating T and H2O for all possible Plag-Liq matches Source: https://thermobar.readthedocs.io/en/latest/Examples/Feldspar_Thermobarometry/Fspar_Liq_Matching.html Iterates through temperature and H2O content for all possible Plag-Liq matches. ```python T_H_Iter_dict=pt.calculate_fspar_liq_temp_hygr_matching(liq_comps=Liqs, plag_comps=RealPlags, equationT="T_Put2008_eq24a", equationH="H_Waters2015", P=5) T_H_Calc_Av=T_H_Iter_dict.get('Av_HTs') T_H_Calc_All=T_H_Iter_dict.get('All_HTs') T_H_Evol=T_H_Iter_dict.get('T_H_Evolution') ``` ```python # Maybe you want to plot a histogram of H2O contents plt.hist(T_H_Calc_Av['Mean_H2O_calc']) plt.xlabel('H$_2$O Calc (wt%)') ``` -------------------------------- ### Example 1a - All possible Liq-Plag matches, An-Ab equilibrium Source: https://thermobar.readthedocs.io/en/latest/Examples/Feldspar_Thermobarometry/Fspar_Liq_Matching.html Calculates Liq-Plag temperature matches using the An-Ab equilibrium test of Putirka (2008). ```python MM_dict=pt.calculate_fspar_liq_temp_matching(liq_comps=Liqs, plag_comps=RealPlags, equationT="T_Put2008_eq24a", P=5, Ab_An_P2008=True, H2O_Liq=2) Av_Matches=MM_dict['Av_PTs'] All_Matches=MM_dict['All_PTs'] ``` -------------------------------- ### Example 3: Displaying head of results Source: https://thermobar.readthedocs.io/en/latest/Examples/Cpx_Cpx_Liq_Thermobarometry/Cpx_Liquid_melt_matching/Cpx_MeltMatch1_Gleeson2020.html This code snippet displays the first few rows of the 'All_PTs' DataFrame from the `MM3` results, which contains detailed calculations for clinopyroxene-liquid melt matching using the Masotta Kd model. ```python MM3_All.head() ``` -------------------------------- ### Example 6: Plotting Pressures and Temperatures Source: https://thermobar.readthedocs.io/en/latest/Examples/Cpx_Cpx_Liq_Thermobarometry/Cpx_Liquid_melt_matching/Cpx_MeltMatch1_Gleeson2020.html This code snippet visualizes the calculated pressures and temperatures for Cpx-Liq matches. It compares results filtered at 1 sigma and 2 sigma, showing individual matches as faint dots and averaged results with error bars as diamonds. ```python fig, ((ax1, ax2)) = plt.subplots(1, 2, figsize=(12, 5)) # Subplot1 # This plots every Cpx-Liq match, with an opacity of 0.5 ax1.plot(MM1_All['T_K_calc']-273.15, MM1_All['P_kbar_calc'], '.c', alpha=0.5) # This plots a diamond and error bar for each Cpx averaged with as many liquids as it matches too ax1.errorbar(MM1_Av['Mean_T_K_calc']-273.15, MM1_Av['Mean_P_kbar_calc'], xerr=MM1_Av['Std_T_K_calc'].fillna(0), yerr=MM1_Av['Std_P_kbar_calc'].fillna(0), fmt='d', ecolor='k', elinewidth=0.8, mfc='cyan', ms=8, mec='k') ax1.set_xlabel('Temperature (°C)') ax1.set_ylabel('Pressure (kbar)') ax1.set_title('1 sigma') # Subplot2 - As above, butmatches with less stringent equilibrium filters ax2.plot(MM1_2s_All['T_K_calc']-273.15, MM1_2s_All['P_kbar_calc'], '.r', alpha=0.3) ax2.errorbar(MM1_2s_Av['Mean_T_K_calc']-273.15, MM1_2s_Av['Mean_P_kbar_calc'], xerr=MM1_2s_Av['Std_T_K_calc'].fillna(0), yerr=MM1_2s_Av['Std_P_kbar_calc'].fillna(0), fmt='d', ecolor='k', elinewidth=0.8, mfc='red', ms=8, mec='k') ax2.set_xlabel('Temperature (°C)') ax2.set_ylabel('Pressure (kbar)') ax2.set_title('2 sigma') ax1.invert_yaxis() ax2.invert_yaxis() ``` -------------------------------- ### Example 5: Plotting Equilibrium filters Source: https://thermobar.readthedocs.io/en/latest/Examples/Cpx_Cpx_Liq_Thermobarometry/Cpx_Liquid_melt_matching/Cpx_MeltMatch1_Gleeson2020.html This code snippet generates plots to compare the distribution of Kd, EnFs, DiHd, and CaTs values between matches filtered at 1 sigma (default) and 2 sigma. It uses matplotlib to create histograms showing probability density. ```python fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, figsize=(12, 10)) # This plots distribution of Kd in matches with probability on the y axis ax1.hist(MM1_2s_All['Delta_Kd_Put2008'], weights=np.ones_like(MM1_2s_All['Delta_Kd_Put2008']) / len(MM1_2s_All['Delta_Kd_Put2008']), label='pass at 2 sigma') ax1.hist(MM1_All['Delta_Kd_Put2008'], weights=np.ones_like(MM1_All['Delta_Kd_Put2008']) / len(MM1_All['Delta_Kd_Put2008']) , label='pass at 1 sigma', alpha=0.5) ax1.set_xlabel('ΔKd Putirka 2008') ax1.set_ylabel('Probability density') ax1.legend() # This plots distribution of EnFs with probability on the y axis ax2.hist(MM1_2s_All['Delta_EnFs_Mollo13'], weights=np.ones_like(MM1_2s_All['Delta_EnFs_Mollo13']) / len(MM1_2s_All['Delta_EnFs_Mollo13']) )#, label='All filters (2sigma)', color='salmon') ax2.hist(MM1_All['Delta_EnFs_Mollo13'], weights=np.ones_like(MM1_All['Delta_EnFs_Mollo13']) / len(MM1_All['Delta_EnFs_Mollo13']), alpha=0.5) ax2.set_xlabel('ΔEnFs') # This plots distribution of DiHd with probability on the y axis ax3.hist(MM1_2s_All['Delta_DiHd_Mollo13'], weights=np.ones_like(MM1_2s_All['Delta_DiHd_Mollo13']) / len(MM1_2s_All['Delta_DiHd_Mollo13']) )#, label='All filters (2sigma)', color='salmon') ax3.hist(MM1_All['Delta_DiHd_Mollo13'], weights=np.ones_like(MM1_All['Delta_DiHd_Mollo13']) / len(MM1_All['Delta_DiHd_Mollo13']) , alpha=0.5) ax3.set_xlabel('ΔDiHd') ax3.set_ylabel('Probability density') # This plots distribution of CaTs values with probability on the y axis ax4.hist(MM1_2s_All['Delta_CaTs_Put1999'], weights=np.ones_like(MM1_2s_All['Delta_CaTs_Put1999']) / len(MM1_2s_All['Delta_CaTs_Put1999']) )#, label='All filters (2sigma)', color='salmon') ax4.hist(MM1_All['Delta_CaTs_Put1999'], weights=np.ones_like(MM1_All['Delta_CaTs_Put1999']) / len(MM1_All['Delta_CaTs_Put1999']), alpha=0.5) ax4.set_xlabel('ΔCaTs') ``` -------------------------------- ### Example 1b - All possible Liq-Plag matches, no filter Source: https://thermobar.readthedocs.io/en/latest/Examples/Feldspar_Thermobarometry/Fspar_Liq_Matching.html Calculates all possible Liq-Plag temperature matches without applying an equilibrium filter, useful for developing custom filters. ```python MM_dict=pt.calculate_fspar_liq_temp_matching(liq_comps=Liqs, plag_comps=RealPlags, equationT="T_Put2008_eq24a", P=5, Ab_An_P2008=False, H2O_Liq=2) Av_Matches=MM_dict['Av_PTs'] All_Matches=MM_dict['All_PTs'] ``` -------------------------------- ### Cpx_MeltMatch2_ScruggsPutirka2018 Example Source: https://thermobar.readthedocs.io/en/latest/Examples/Cpx_Cpx_Liq_Thermobarometry/Cpx_Liquid_melt_matching/Cpx_MeltMatch2_ScruggsPutirka2018.html This code snippet visualizes calculated temperatures and pressures from the Cpx_MeltMatch2 model, comparing calculated values with averaged values and their standard deviations. ```python fig, ((ax1)) = plt.subplots(1, figsize=(8, 6)) ax1.plot(Syn_All['T_K_calc']-273.15, Syn_All['P_kbar_calc'], '.', color='red', alpha=0.1) ax1.errorbar(Syn_Avs['Mean_T_K_calc']-273.15, Syn_Avs['Mean_P_kbar_calc'], xerr=Syn_Avs['Std_T_K_calc'], yerr=Syn_Avs['Std_P_kbar_calc'], fmt='d', ecolor='k', elinewidth=0.8, mfc='red', ms=8, mec='k', label='Pennys code') ax1.set_xlim([700, 1200]) ax1.set_ylim([-2, 10]) ax1.invert_yaxis() ``` -------------------------------- ### Example 3: Alkaline Systems Source: https://thermobar.readthedocs.io/en/latest/Examples/Cpx_Cpx_Liq_Thermobarometry/Cpx_Liquid_melt_matching/Cpx_MeltMatch1_Gleeson2020.html This code snippet shows how to use the updated Kd model from Masotta (calibrated for trachyte and phonolitic magmas) by setting `Kd_Match` to 'Masotta'. It also specifies the pressure and temperature equations to 'P_Mas2013_Palk2012' and 'T_Mas2013_Talk2012' respectively, along with error parameters. ```python MM3=pt.calculate_cpx_liq_press_temp_matching(liq_comps=myLiquids1, cpx_comps=myCPXs1, equationP="P_Mas2013_Palk2012", equationT="T_Mas2013_Talk2012", Kd_Match="Masotta", Kd_Err=0.08, Fe3Fet_Liq=0.15, CaTs_Err=0.06, DiHd_Err=0.12, EnFs_Err=0.06) MM3_All=MM3['All_PTs'] MM3_Av=MM3['Av_PTs'] ``` -------------------------------- ### Install and Import Ternary Plot Package Source: https://thermobar.readthedocs.io/en/latest/Examples/Cpx_Cpx_Liq_Thermobarometry/Pyroxene_Ternary_Cpx_Example.html Install the python-ternary package and import it. It's recommended to use conda for installation to avoid conflicts with other 'ternary' packages. ```python # pip install python-ternary import ternary # We tested using ternary V.1.0.8 print(ternary.__version__) ``` -------------------------------- ### Import Thermobar Source: https://thermobar.readthedocs.io/en/latest/Examples/Five_min_intro.html Imports the Thermobar library and assigns it the alias 'pt' for easier use. ```python import Thermobar as pt ``` -------------------------------- ### Install Thermobar Source: https://thermobar.readthedocs.io/en/latest/Examples/Amphibole/Amphibole_Classification_Diagrams.html Command to install the Thermobar package using pip. This is commented out by default. ```Shell #!pip install Thermobar ``` -------------------------------- ### Load data from Excel with single phase Source: https://thermobar.readthedocs.io/en/latest/Examples/Five_min_intro.html Demonstrates loading data from an Excel file ('Five_min_intro.xlsx') from a sheet named 'Liq_noheader', specifying '_Liq' as the suffix for a single phase (Liquid). ```python out_noheads=pt.import_excel('Five_min_intro.xlsx', sheet_name="Liq_noheader", suffix="_Liq") Liqs_noheads=out_noheads['Liqs'] ``` -------------------------------- ### Print Ternary Version Source: https://thermobar.readthedocs.io/en/latest/Examples/Feldspar_Thermobarometry/Fspar_Ternary_Plot.html Prints the installed version of the ternary library. ```python import ternary # We tested using ternary V.1.0.8 print(ternary.__version__) ``` -------------------------------- ### Loading Published Barometry Source: https://thermobar.readthedocs.io/en/latest/Examples/Cpx_Cpx_Liq_Thermobarometry/Cpx_Liquid_melt_matching/Cpx_MeltMatch1_Gleeson2020.html Loads published barometry data from an Excel file. ```python Published=pd.read_excel('Gleeson2020JPET_Input_Pyroxene_Melts.xlsx', sheet_name="NP_Out") ``` -------------------------------- ### Iterate for both pressure and temperature Source: https://thermobar.readthedocs.io/en/latest/Examples/Five_min_intro.html Demonstrates how to simultaneously calculate both pressure and temperature when neither is known beforehand, by iterating two specified equations. ```python PT_iter_30_33=pt.calculate_cpx_liq_press_temp(cpx_comps=Cpxs, liq_comps=Liqs, equationP="P_Put2008_eq30", equationT="T_Put2008_eq33") PT_iter_30_33 ``` -------------------------------- ### Example: Appending calculated column Source: https://thermobar.readthedocs.io/en/latest Illustrates how to append a calculated column to a DataFrame in a specific position. ```python import pandas as pd from thermobar.calculate import calculate_cpx_liquid data = pd.read_excel("your_data.xlsx") # Load your data temps = calculate_cpx_liquid(data=data) data.insert(1, 'Cpx_Liq_T_K', temps) # Insert the temps column at index 1 print(data.head()) ``` -------------------------------- ### Loading Liquids Source: https://thermobar.readthedocs.io/en/latest/Examples/Cpx_Cpx_Liq_Thermobarometry/Cpx_Liquid_melt_matching/Cpx_MeltMatch1_Gleeson2020.html Loads liquid data from an Excel file and assigns it to variables. ```python out=pt.import_excel('Gleeson2020JPET_Input_Pyroxene_Melts.xlsx', sheet_name="Melts") my_input_Liqs=out['my_input'] myLiquids1=out['Liqs'] ``` -------------------------------- ### Loading Cpx-Liq data from Excel Source: https://thermobar.readthedocs.io/en/latest/Examples/Exporting_to_Excel.html Loads Cpx-Liq data from an Excel file named 'Five_min_intro.xlsx'. ```python out=pt.import_excel('Five_min_intro.xlsx', sheet_name="Sheet1") my_input=out['my_input'] Liqs=out['Liqs'] Cpxs=out['Cpxs'] my_input=out['my_input'] ``` -------------------------------- ### Check scikit-learn version Source: https://thermobar.readthedocs.io/en/latest/Examples/Cpx_Cpx_Liq_Thermobarometry/MachineLearning_Cpx_Liq_Thermobarometry.html Prints the installed version of the scikit-learn library, which is often a dependency for machine learning functionalities. ```python import sklearn print(sklearn.__version__) ``` -------------------------------- ### Displaying Head of DataFrame Source: https://thermobar.readthedocs.io/en/latest/Examples/Cpx_Cpx_Liq_Thermobarometry/Cpx_Liquid_melt_matching/Cpx_MeltMatch1_Gleeson2020.html This command displays the first few rows of the MM1_All_fixedT DataFrame, showing the calculated pressure, temperature, and various equilibrium test results. ```python MM1_All_fixedT.head() ``` -------------------------------- ### Example 1a - Default Classification Diagram Source: https://thermobar.readthedocs.io/en/latest/Examples/Feldspar_Thermobarometry/Fspar_Ternary_Plot.html Generates a basic feldspar ternary classification diagram using all default settings. ```python fig, tax = pt.plot_fspar_classification() fig.tight_layout() ``` -------------------------------- ### Load data from Excel Source: https://thermobar.readthedocs.io/en/latest/Examples/Five_min_intro.html Loads data from an Excel file named 'Five_min_intro.xlsx' from the 'Sheet1' sheet. It then extracts and assigns dataframes for 'my_input', 'Liqs', and 'Cpxs' from the output dictionary. ```python out=pt.import_excel('Five_min_intro.xlsx', sheet_name="Sheet1") my_input=out['my_input'] Liqs=out['Liqs'] Cpxs=out['Cpxs'] ``` -------------------------------- ### Example 1g - Disabling Ticks Source: https://thermobar.readthedocs.io/en/latest/Examples/Feldspar_Thermobarometry/Fspar_Ternary_Plot.html Generates a feldspar ternary classification diagram with major and minor grid lines, but without ticks. ```python fig, tax = pt.plot_fspar_classification(labels=True, major_grid=True, minor_grid=True, ticks=False) fig.tight_layout() ``` -------------------------------- ### Example 1c - Customizing Label Text Source: https://thermobar.readthedocs.io/en/latest/Examples/Feldspar_Thermobarometry/Fspar_Ternary_Plot.html Generates a feldspar ternary classification diagram with custom labels, changing 'San' to 'Sanidine'. ```python fig, tax = pt.plot_fspar_classification(labels=True, Sanidine_label='Sanidine') fig.tight_layout() ``` -------------------------------- ### Import Thermobar and VESIcal Source: https://thermobar.readthedocs.io/en/latest Importing both Thermobar and VESIcal libraries for integrated use. ```python import Thermobar as tb import VESIcal as v ``` -------------------------------- ### Plot Temperature in Celsius Source: https://thermobar.readthedocs.io/en/latest/Examples/Five_min_intro.html Demonstrates how to plot temperature in Celsius by subtracting 273.15 from the calculated temperature values before plotting. ```python plt.plot(PT_iter_30_33['P_kbar_calc'], PT_iter_30_33['T_K_calc']-273.15, 'ok') plt.xlabel('P (kbar)') plt.ylabel('T (C)') ``` -------------------------------- ### Example 1d - Adding Major Grid Lines Source: https://thermobar.readthedocs.io/en/latest/Examples/Feldspar_Thermobarometry/Fspar_Ternary_Plot.html Generates a feldspar ternary classification diagram with default major grid lines enabled. ```python fig, tax = pt.plot_fspar_classification(labels=True, major_grid=True) fig.tight_layout() ``` -------------------------------- ### Example 1b - With Default Compositional Labels Source: https://thermobar.readthedocs.io/en/latest/Examples/Feldspar_Thermobarometry/Fspar_Ternary_Plot.html Generates a feldspar ternary classification diagram with default compositional labels (e.g., An, Ab, Ol). ```python fig, tax = pt.plot_fspar_classification(labels=True) fig.tight_layout() ``` -------------------------------- ### Loading Cpxs Source: https://thermobar.readthedocs.io/en/latest/Examples/Cpx_Cpx_Liq_Thermobarometry/Cpx_Liquid_melt_matching/Cpx_MeltMatch1_Gleeson2020.html Loads Cpx data from a different sheet in the same Excel file and assigns it to variables. ```python out2=pt.import_excel('Gleeson2020JPET_Input_Pyroxene_Melts.xlsx', sheet_name="Cpxs") my_input_Cpxs=out2['my_input'] myCPXs1=out2['Cpxs'] ``` -------------------------------- ### Calculate pressure at a known temperature Source: https://thermobar.readthedocs.io/en/latest/Examples/Five_min_intro.html Shows how to calculate pressure using a clinopyroxene-liquid barometer when the temperature is known. It specifies the composition dataframes and the pressure equation to use. ```python # Here performing calculations at 1300 K Press_eq30_1300K=pt.calculate_cpx_liq_press(cpx_comps=Cpxs, liq_comps=Liqs, equationP="P_Put2008_eq30", T=1300) ``` -------------------------------- ### Example 2c - Appending Multiple Columns to a DataFrame Source: https://thermobar.readthedocs.io/en/latest/Examples/Exporting_to_Excel.html Shows how to append multiple columns from one DataFrame to another and save the result to an Excel file. ```python # First, make a copy my_input_c3=my_input.copy() # Allocate a new column to this dataframe, LHS give whatever you to call it, #RHS is the variable, but now your must specify the colum my_input_c3['Temp_eq33_5kbar']=Temp_eq33_5kbar_Eq_tests['T_K_calc'] # Append a second column my_input_c3['Eq Tests Neave2017?']=Temp_eq33_5kbar_Eq_tests['Eq Tests Neave2017?'] # Save to an Excel sheet called "Calc1" using the pandas to excel function my_input_c3.to_excel('Calc3.xlsx') ```