关于 mplstereonet
mplstereonet 是用于在 Matplotlib 中绘制立体网图并分析地质方位数据的 Python 库,适合结构地质绘图和批量处理。它提供平面、极点、线理绘制,以及密度等值线和方位拟合功能。
主要功能
- 01创建 Matplotlib 立体网图
- 02绘制平面、极点与线理
- 03生成方位密度等值线
- 04拟合大圆并计算平均方位
- 05转换方位数据格式
适用场景
- 01绘制地层产状立体网图
- 02分析褶皱轴与节理组
- 03生成可复现的结构地质图
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ steadfastasart/ geoscience-skills --skill mplstereonet安装后在 Claude Code 中输入/mplstereonet确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
references/plotting_options.mdprojections.mdscripts/structural_analysis.py详细介绍
mplstereonet - Matplotlib 立体网
快速参考
import mplstereonet
import matplotlib.pyplot as plt
# Create stereonet
fig, ax = mplstereonet.subplots()
# Plot plane and pole (strike/dip, right-hand rule)
ax.plane(315, 45, 'b-') # Great circle
ax.pole(315, 45, 'ko') # Pole to plane
# Plot lineation (trend/plunge)
ax.line(120, 30, 'r^')
ax.grid()
plt.savefig('stereonet.png', dpi=150)
关键函数
| 函数 | 用途 |
|---|---|
mplstereonet.subplots() | 创建立体网图形和坐标轴 |
ax.plane(strike, dip) | 绘制大圆 |
ax.pole(strike, dip) | 绘制平面的极点 |
ax.line(trend, plunge) | 绘制线状构造点 |
ax.density_contourf() | 填充密度等值线 |
mplstereonet.fit_girdle() | 拟合最佳大圆 |
mplstereonet.find_mean_vector() | 平均方位 |
基本操作
使用等值线显示多组测量值
import numpy as np
strikes = [45, 52, 38, 48, 55, 41, 50, 43]
dips = [25, 30, 22, 28, 35, 24, 32, 27]
fig, ax = mplstereonet.subplots()
# Density contour of poles
ax.density_contourf(strikes, dips, measurement='poles', cmap='Reds')
ax.pole(strikes, dips, 'k.', markersize=5)
ax.grid()
ax.set_title('Bedding Orientations')
plt.savefig('density.png', dpi=150)
计算平均方位
# Fit best-fit plane (girdle)
mean_strike, mean_dip = mplstereonet.fit_girdle(strikes, dips)
# Or calculate mean pole for clustered data
lon, lat = mplstereonet.pole(strikes, dips)
mean_lon, mean_lat = mplstereonet.find_mean_vector(lon, lat)
mean_s, mean_d = mplstereonet.pole2strike(mean_lon, mean_lat)
Pi 图解(褶皱轴)
# Bedding measurements around a fold
strikes = np.array([20, 35, 50, 70, 90, 110, 130, 150, 165, 180])
dips = np.array([45, 40, 35, 30, 25, 30, 35, 40, 45, 50])
fig, ax = mplstereonet.subplots()
ax.pole(strikes, dips, 'ko', markersize=6)
# Fit girdle to poles - fold axis is pole to girdle
girdle_strike, girdle_dip = mplstereonet.fit_girdle(strikes, dips)
ax.plane(girdle_strike, girdle_dip, 'r-', linewidth=2)
fold_trend, fold_plunge = mplstereonet.pole(girdle_strike, girdle_dip)
ax.line(fold_trend, fold_plunge, 'r^', markersize=12, label='Fold axis')
ax.grid()
ax.legend()
断层面与滑动矢量
fault_strike, fault_dip = 45, 60
rake = 30 # Degrees from strike
# Convert rake to trend/plunge
slip_trend, slip_plunge = mplstereonet.rake(fault_strike, fault_dip, rake)
fig, ax = mplstereonet.subplots()
ax.plane(fault_strike, fault_dip, 'r-', linewidth=2)
ax.line(slip_trend, slip_plunge, 'r>', markersize=10)
ax.grid()
多组节理
set1 = {'strikes': [45, 50, 42, 48], 'dips': [70, 75, 68, 72]}
set2 = {'strikes': [135, 140, 130, 138], 'dips': [60, 65, 58, 62]}
fig, ax = mplstereonet.subplots()
ax.pole(set1['strikes'], set1['dips'], 'ro', label='Set 1')
ax.pole(set2['strikes'], set2['dips'], 'bs', label='Set 2')
ax.grid()
ax.legend()
测量约定
| 格式 | 描述 | 示例 |
|---|---|---|
| 走向/倾角 | 右手定则(倾向位于走向右侧) | 045/60 |
| 倾向/倾角 | 倾向的方位角 | 135/60 |
| 趋向/倾伏角 | 线状构造方位 | 180/30 |
格式转换
# Strike/dip to dip direction
strike, dip = 45, 60
dip_direction = (strike + 90) % 360
# Pole to strike/dip
lon, lat = mplstereonet.pole(strike, dip)
back_strike, back_dip = mplstereonet.pole2strike(lon, lat)
等值线方法
| 方法 | 描述 |
|---|---|
kamb | 统计显著性(默认) |
schmidt | 点计数 |
exponential_kamb | 平滑 Kamb |
何时使用及替代方案
| 工具 | 最适合的用途 | 局限性 |
|---|---|---|
| mplstereonet | 在 Python 中快速创建立体网、与 matplotlib 集成、脚本化工作流 | 不支持交互式旋转,3D 功能有限 |
| apsg | 高级构造分析、张量、方位统计 | 学习曲线较陡 |
| JTOPO | 交互式 GUI 探索、教学 | 基于 Java,无法编写脚本 |
在以下情况下使用 mplstereonet: 需要以编程方式生成立体网并与 matplotlib 集成、批量处理方位数据集,或生成可复现的构造图用于发表。
在以下情况下考虑替代方案: 需要对方位进行交互式 3D 可视化(使用 apsg)、用于教学或快速检查的 GUI(使用 JTOPO),或需要 mplstereonet 未提供的高级张量统计功能。
常见工作流
分析层理方位并确定褶皱轴
- 从 CSV 或数组加载走向/倾角测量值
- 使用
mplstereonet.subplots()创建立体网 - 使用
ax.pole(strikes, dips)绘制层理极点 - 使用
ax.density_contourf()生成密度等值线 - 使用
mplstereonet.fit_girdle()对极点拟合大圆 - 使用
mplstereonet.pole()将大圆的极点作为褶皱轴 - 使用
ax.line(trend, plunge)绘制褶皱轴 - 添加网格、图例并保存图形
参考资料
脚本
- scripts/structural_analysis.py - 分析构造数据并生成图形
评论
支持 Markdown