pyrolite
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesepyrolite - 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 methodspython
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)
undefinedchondrite = get_reference_composition('Chondrite_McDonough1995')
ax = df.pyrochem.normalize_to(chondrite, units='ppm').pyroplot.REE(unity_line=True)
undefinedKey Modules
核心模块
| Module | Purpose |
|---|---|
| Ternary, spider diagrams |
| Normalization references |
| CLR, ALR, ILR transforms |
| TAS, Pearce diagrams |
| CIPW norm |
| 模块 | 用途 |
|---|---|
| 绘制ternary diagrams、spider diagrams |
| 提供归一化参考标准 |
| 实现CLR、ALR、ILR转换 |
| 提供TAS、Pearce图模板 |
| 计算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-ratiopython
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 shapepython
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
常用归一化参考标准
| Reference | Code | Use For |
|---|---|---|
| Chondrite | | REE patterns |
| Primitive Mantle | | Trace elements |
| N-MORB | | Ocean basalts |
| Upper Crust | | Crustal rocks |
| 参考标准 | 代码 | 适用场景 |
|---|---|---|
| Chondrite | | REE模式分析 |
| Primitive Mantle | | 微量元素分析 |
| N-MORB | | 洋玄武岩分析 |
| Upper Crust | | 地壳岩石分析 |
When to Use vs Alternatives
适用场景与替代工具对比
| 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 |
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 and overlay sample data
TAS() - 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() - 使用将REE归一化至球粒陨石标准
df.pyrochem.normalize_to() - 使用绘制REE蛛网图
df.pyroplot.REE() - 计算Eu异常值与La/Yb比值
- 为主量元素生成Harker变异图
- 导出用于发表的图件
Tips
小贴士
- Close compositions before analysis (ensure sum to 100%)
- Use log-ratios (CLR/ALR/ILR) for statistical analysis
- Choose appropriate normalization for spider diagrams
- Check for Eu anomaly (positive = cumulate, negative = fractionation)
- 分析前先进行成分闭合处理(确保总和为100%)
- 统计分析时使用对数比转换(CLR/ALR/ILR)
- 为蛛网图选择合适的归一化标准
- 检查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 - 生成常用图件