关于 striplog
striplog 是用于将岩性等地质数据表示为深度区间的 Python 库,适合地质和测井工作流。它支持查询、统计、绘图及结构化日志导出。
主要功能
- 01从 CSV 或文本创建日志
- 02查询和截取深度区间
- 03计算净毛比统计
- 04绘制并对比测井日志
- 05导出为 CSV、LAS 和 JSON
适用场景
- 01根据井数据创建岩性日志
- 02比较多口井的地层区间
- 03计算各类岩性的比例
- 04导出日志供后续分析
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ steadfastasart/ geoscience-skills --skill striplog安装后在 Claude Code 中输入/striplog确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
references/components.mdlexicon.mdscripts/create_striplog.py详细介绍
striplog - 岩性柱状图
快速参考
from striplog import Striplog, Interval, Component
# Create from intervals
intervals = [
Interval(top=0, base=10, components=[Component({'lithology': 'sandstone'})]),
Interval(top=10, base=25, components=[Component({'lithology': 'shale'})]),
Interval(top=25, base=40, components=[Component({'lithology': 'limestone'})]),
]
strip = Striplog(intervals)
# Load from file
strip = Striplog.from_csv('lithology.csv') # Columns: top, base, lithology
# Access and display
print(strip)
strip.plot()
df = strip.to_dataframe()
主要类
| 类 | 用途 |
|---|---|
Striplog | 主要柱状图容器——保存多个层段 |
Interval | 深度层段,包含顶界、底界和组成成分 |
Component | 带有属性的岩石类型定义 |
Lexicon | 带有同义词的岩石类型词典 |
Legend | 可视化样式(颜色、图案) |
基本操作
从 CSV 创建
# CSV format: top,base,lithology
strip = Striplog.from_csv('lithology.csv')
strip.plot()
从描述文本创建
from striplog import Striplog, Lexicon
description = """
0.0 - 5.5 m: Fine to medium sandstone
5.5 - 12.0 m: Grey shale with silt laminations
12.0 - 18.5 m: Massive limestone, fossiliferous
"""
strip = Striplog.from_description(description, lexicon=lexicon)
查询和提取
# Get interval at depth
interval = strip.read_at(z=15)
print(interval.primary.lithology)
# Crop to depth range
subset = strip.crop((10, 30))
# Unique lithologies
lithologies = strip.unique('lithology')
统计
# Net-to-gross for specific lithology
ntg = strip.net_to_gross(pattern={'lithology': 'sandstone'})
print(f"Sandstone: {ntg * 100:.1f}%")
# Merge adjacent same-lithology intervals
merged = strip.merge_neighbours()
井间对比
import matplotlib.pyplot as plt
wells = [Striplog.from_csv(f'well{i}.csv') for i in range(1, 4)]
fig, axes = plt.subplots(1, 3, figsize=(10, 8), sharey=True)
for ax, well, name in zip(axes, wells, ['Well 1', 'Well 2', 'Well 3']):
well.plot(ax=ax, legend=legend)
ax.set_title(name)
plt.tight_layout()
plt.savefig('correlation.png')
导出
strip.to_csv('output.csv')
strip.to_las('output.las')
strip.to_json('output.json')
df = strip.to_dataframe()
填充图案
| 图案 | 代码 | 典型用途 |
|---|---|---|
| 点 | ... | 砂岩 |
| 短线 | --- | 页岩 |
| 加号 | +++ | 石灰岩 |
| X | xxx | 白云岩 |
| V | vvv | 火山岩 |
何时使用及替代方案
| 工具 | 最适用场景 |
|---|---|
| striplog | 结构化岩性柱状图、基于层段的数据、NTG、井间对比 |
| welly | 测井曲线(连续数据)、多井项目 |
| custom matplotlib | 无需层段逻辑的简单一次性地层柱状图 |
需要将地质层段(岩性、相)表示为支持查询、统计和井间对比的结构化对象时,使用 striplog。
处理连续测井曲线(GR、RHOB)时,改用 welly。Welly 和 striplog 相辅相成——welly 用于曲线,striplog 用于岩性层段。
不需要层段查询或净毛比计算,仅需简单的一次性地层柱状图时,改用 custom matplotlib。
常见工作流
从 CSV 数据创建岩性柱状图
- [ ] Prepare CSV with columns: top, base, lithology (optionally color)
- [ ] Load with `Striplog.from_csv('lithology.csv')`
- [ ] Define Legend with colors and hatch patterns for each lithology
- [ ] Verify intervals: check for gaps or overlaps
- [ ] Merge adjacent same-lithology intervals with `merge_neighbours()`
- [ ] Compute statistics: `net_to_gross()`, `unique()`
- [ ] Plot with legend and export to desired format
常见问题
| 问题 | 解决方案 |
|---|---|
| 文本无法解析 | 使用同义词定义 Lexicon |
| 颜色不正确 | 使用 Decor 对象创建自定义 Legend |
| 柱状图中有空隙 | 检查层段的顶界和底界数值是否匹配 |
| 绘图效果不正确 | 确认深度方向(向下递增) |
参考资料
- Lexicon Configuration - 岩石类型词典和同义词
- Component Definitions - 属性和多属性层段
脚本
- scripts/create_striplog.py - 从 CSV 或文本数据创建 striplog
评论
支持 Markdown