pyrolite

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

pyrolite - Geochemistry Analysis

pyrolite - 地球化学分析

Quick Reference

快速参考

python
import 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
python
import pandas as pd
import matplotlib.pyplot as plt
from pyrolite.geochem.norm import get_reference_composition

df = pd.read_csv('samples.csv')
df.pyrochem   # 地球化学相关方法
df.pyrocomp   # 成分相关方法

Normalize and plot REE

归一化并绘制REE图

chondrite = get_reference_composition('Chondrite_McDonough1995') ax = df.pyrochem.normalize_to(chondrite, units='ppm').pyroplot.REE(unity_line=True)
undefined
chondrite = get_reference_composition('Chondrite_McDonough1995') ax = df.pyrochem.normalize_to(chondrite, units='ppm').pyroplot.REE(unity_line=True)
undefined

Key Modules

核心模块

ModulePurpose
pyrolite.plot
Ternary, spider diagrams
pyrolite.geochem.norm
Normalization references
pyrolite.comp
CLR, ALR, ILR transforms
pyrolite.plot.templates
TAS, Pearce diagrams
pyrolite.mineral.normative
CIPW norm
模块用途
pyrolite.plot
绘制ternary diagrams、spider diagrams
pyrolite.geochem.norm
提供归一化参考标准
pyrolite.comp
实现CLR、ALR、ILR转换
pyrolite.plot.templates
提供TAS、Pearce图模板
pyrolite.mineral.normative
计算CIPW norm

Essential Operations

关键操作

Ternary Diagram

Ternary Diagram

python
ax = df[['SiO2', 'CaO', 'Na2O']].pyroplot.scatter(c='k', s=50)
python
ax = df[['SiO2', 'CaO', 'Na2O']].pyroplot.scatter(c='k', s=50)

TAS Diagram

TAS Diagram

python
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)
python
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)

REE Pattern

REE Pattern

python
chondrite = get_reference_composition('Chondrite_McDonough1995')
ax = df.pyrochem.normalize_to(chondrite, units='ppm').pyroplot.REE(unity_line=True)
python
chondrite = get_reference_composition('Chondrite_McDonough1995')
ax = df.pyrochem.normalize_to(chondrite, units='ppm').pyroplot.REE(unity_line=True)

Trace Element Spider

Trace Element Spider

python
pm = get_reference_composition('PM_McDonough1995')
ax = df.pyrochem.normalize_to(pm).pyroplot.spider(unity_line=True)
python
pm = get_reference_composition('PM_McDonough1995')
ax = df.pyrochem.normalize_to(pm).pyroplot.spider(unity_line=True)

Compositional Transforms

成分转换

python
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-ratio
python
df_closed = df.pyrocomp.renormalise(scale=100)  # 闭合处理
df_clr = df.pyrocomp.CLR()   # 中心对数比转换
df_alr = df.pyrocomp.ALR()   # 加法对数比转换
df_ilr = df.pyrocomp.ILR()   # 等距对数比转换

Element Ratios and Anomalies

元素比值与异常值

python
df['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 shape
python
df['La_Yb'] = df['La'] / df['Yb']                        # LREE/HREE比值
df['Eu_Eu*'] = df['Eu'] / (df['Sm'] * df['Gd']) ** 0.5   # Eu异常值
lambdas = df.pyrochem.lambda_lnREE()                      # REE形态参数

CIPW Norm

CIPW Norm

python
from pyrolite.mineral.normative import CIPW_norm
norm = CIPW_norm(df)  # df must have major oxides in wt%
python
from pyrolite.mineral.normative import CIPW_norm
norm = CIPW_norm(df)  # df需包含以wt%为单位的主量氧化物数据

Harker Diagrams

Harker Diagrams

python
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%)')
python
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%)')

Pearce Discrimination

Pearce Discrimination

python
from pyrolite.plot.templates import pearce_templates
ax = pearce_templates.YNb()
ax.scatter(df['Nb'], df['Y'], c='red', s=50)
python
from pyrolite.plot.templates import pearce_templates
ax = pearce_templates.YNb()
ax.scatter(df['Nb'], df['Y'], c='red', s=50)

Common Normalization References

常用归一化参考标准

ReferenceCodeUse For
Chondrite
Chondrite_McDonough1995
REE patterns
Primitive Mantle
PM_McDonough1995
Trace elements
N-MORB
NMORB_SunMcDonough1989
Ocean basalts
Upper Crust
UCC_RudnickGao2003
Crustal rocks
参考标准代码适用场景
Chondrite
Chondrite_McDonough1995
REE模式分析
Primitive Mantle
PM_McDonough1995
微量元素分析
N-MORB
NMORB_SunMcDonough1989
洋玄武岩分析
Upper Crust
UCC_RudnickGao2003
地壳岩石分析

When to Use vs Alternatives

适用场景与替代工具对比

ToolBest ForLimitations
pyrolitePython-native geochemistry, pandas integration, compositional transformsFewer built-in classification templates than GCDkit
GCDkitComprehensive classification diagrams, R ecosystemR-based, not Python
PetroGraphQuick GUI-based classification and plottingNot scriptable, limited customization
Custom matplotlibFull control over plot appearanceNo built-in normalization or templates
Use pyrolite when you need geochemistry analysis integrated with pandas workflows, compositional log-ratio transforms, or REE normalization in Python.
Consider alternatives when you need extensive petrographic classification templates (use GCDkit), a quick GUI for classification (use PetroGraph), or only need simple scatter plots without normalization (use matplotlib directly).
工具最佳适用场景局限性
pyrolite原生Python环境下的地球化学分析、与pandas集成、成分对数比转换内置分类模板数量少于GCDkit
GCDkit全面的分类图、R生态系统支持基于R语言,非Python环境
PetroGraph快速GUI分类与绘图不可编写脚本,自定义能力有限
Custom matplotlib完全控制绘图外观无内置归一化功能或模板
当你需要在Python环境中集成pandas工作流、进行成分对数比转换或REE归一化分析时,使用pyrolite。
当你需要大量岩石学分类模板时(使用GCDkit)、需要快速GUI分类工具时(使用PetroGraph)、或仅需简单散点图无需归一化时(直接使用matplotlib),考虑替代工具。

Common Workflows

常见工作流

Geochemical classification and REE pattern analysis

地球化学分类与REE模式分析

  • Load sample data into pandas DataFrame
  • Close compositions with
    df.pyrocomp.renormalise(scale=100)
  • Plot TAS diagram with
    TAS()
    and overlay sample data
  • Normalize REE to chondrite with
    df.pyrochem.normalize_to()
  • Plot REE spider diagram with
    df.pyroplot.REE()
  • Calculate Eu anomaly and La/Yb ratio
  • Generate Harker variation diagrams for major elements
  • Export figures for publication
  • 将样本数据加载至pandas DataFrame
  • 使用
    df.pyrocomp.renormalise(scale=100)
    进行成分闭合处理
  • 使用
    TAS()
    绘制TAS图并叠加样本数据
  • 使用
    df.pyrochem.normalize_to()
    将REE归一化至球粒陨石标准
  • 使用
    df.pyroplot.REE()
    绘制REE蛛网图
  • 计算Eu异常值与La/Yb比值
  • 为主量元素生成Harker变异图
  • 导出用于发表的图件

Tips

小贴士

  1. Close compositions before analysis (ensure sum to 100%)
  2. Use log-ratios (CLR/ALR/ILR) for statistical analysis
  3. Choose appropriate normalization for spider diagrams
  4. Check for Eu anomaly (positive = cumulate, negative = fractionation)
  1. 分析前先进行成分闭合处理(确保总和为100%)
  2. 统计分析时使用对数比转换(CLR/ALR/ILR)
  3. 为蛛网图选择合适的归一化标准
  4. 检查Eu异常值(正异常=堆积岩,负异常=分异作用)

References

参考资料

  • Normalization References - Reference compositions and values
  • Classification Schemes - TAS, Pearce, AFM diagrams
  • 归一化参考标准 - 参考成分及数值
  • 分类方案 - TAS、Pearce、AFM图相关内容

Scripts

脚本

  • scripts/geochemistry_plots.py - Generate common plots
  • scripts/geochemistry_plots.py - 生成常用图件