Loading...
Loading...
Geochemistry data analysis and visualization for igneous, metamorphic, and sedimentary rocks. Use when Claude needs to: (1) Create ternary diagrams for compositional data, (2) Plot REE spider diagrams with normalization, (3) Build TAS or other classification diagrams, (4) Apply log-ratio transforms to compositional data, (5) Calculate CIPW norms, (6) Generate Harker variation diagrams, (7) Compute element ratios and anomalies.
npx skill4agent add steadfastasart/geoscience-skills pyroliteimport pandas as pd
import matplotlib.pyplot as plt
from pyrolite.geochem.norm import get_reference_composition
df = pd.read_csv('samples.csv')
df.pyrochem # Geochemistry methods
df.pyrocomp # Compositional methods
# Normalize and plot REE
chondrite = get_reference_composition('Chondrite_McDonough1995')
ax = df.pyrochem.normalize_to(chondrite, units='ppm').pyroplot.REE(unity_line=True)| Module | Purpose |
|---|---|
| Ternary, spider diagrams |
| Normalization references |
| CLR, ALR, ILR transforms |
| TAS, Pearce diagrams |
| CIPW norm |
ax = df[['SiO2', 'CaO', 'Na2O']].pyroplot.scatter(c='k', s=50)from pyrolite.plot.templates import TAS
df['Na2O_K2O'] = df['Na2O'] + df['K2O']
ax = TAS()
ax.scatter(df['SiO2'], df['Na2O_K2O'], c='red', s=50)chondrite = get_reference_composition('Chondrite_McDonough1995')
ax = df.pyrochem.normalize_to(chondrite, units='ppm').pyroplot.REE(unity_line=True)pm = get_reference_composition('PM_McDonough1995')
ax = df.pyrochem.normalize_to(pm).pyroplot.spider(unity_line=True)df_closed = df.pyrocomp.renormalise(scale=100) # Closure
df_clr = df.pyrocomp.CLR() # Centered log-ratio
df_alr = df.pyrocomp.ALR() # Additive log-ratio
df_ilr = df.pyrocomp.ILR() # Isometric log-ratiodf['La_Yb'] = df['La'] / df['Yb'] # LREE/HREE
df['Eu_Eu*'] = df['Eu'] / (df['Sm'] * df['Gd']) ** 0.5 # Eu anomaly
lambdas = df.pyrochem.lambda_lnREE() # REE shapefrom pyrolite.mineral.normative import CIPW_norm
norm = CIPW_norm(df) # df must have major oxides in wt%fig, axes = plt.subplots(2, 3, figsize=(12, 8))
for ax, elem in zip(axes.flatten(), ['TiO2', 'Al2O3', 'FeO', 'MgO', 'CaO', 'Na2O']):
ax.scatter(df['SiO2'], df[elem], c='blue', s=50)
ax.set_xlabel('SiO2 (wt%)'); ax.set_ylabel(f'{elem} (wt%)')from pyrolite.plot.templates import pearce_templates
ax = pearce_templates.YNb()
ax.scatter(df['Nb'], df['Y'], c='red', s=50)| Reference | Code | Use For |
|---|---|---|
| Chondrite | | REE patterns |
| Primitive Mantle | | Trace elements |
| N-MORB | | Ocean basalts |
| Upper Crust | | Crustal rocks |
| Tool | Best For | Limitations |
|---|---|---|
| pyrolite | Python-native geochemistry, pandas integration, compositional transforms | Fewer built-in classification templates than GCDkit |
| GCDkit | Comprehensive classification diagrams, R ecosystem | R-based, not Python |
| PetroGraph | Quick GUI-based classification and plotting | Not scriptable, limited customization |
| Custom matplotlib | Full control over plot appearance | No built-in normalization or templates |
df.pyrocomp.renormalise(scale=100)TAS()df.pyrochem.normalize_to()df.pyroplot.REE()