mcpField
S
striplog

striplog

github.com/steadfastasart数据与数据库7363 次安装6 周前更新
代码仓库

关于 striplog

striplog 是用于将岩性等地质数据表示为深度区间的 Python 库,适合地质和测井工作流。它支持查询、统计、绘图及结构化日志导出。

主要功能

  1. 01从 CSV 或文本创建日志
  2. 02查询和截取深度区间
  3. 03计算净毛比统计
  4. 04绘制并对比测井日志
  5. 05导出为 CSV、LAS 和 JSON

适用场景

  1. 01根据井数据创建岩性日志
  2. 02比较多口井的地层区间
  3. 03计算各类岩性的比例
  4. 04导出日志供后续分析

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/steadfastasart/geoscience-skills --skill striplog

安装后在 Claude Code 中输入/striplog确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

references/
components.md
lexicon.md
scripts/
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()

填充图案

图案代码典型用途
点...砂岩
短线---页岩
加号+++石灰岩
Xxxx白云岩
Vvvv火山岩

何时使用及替代方案

工具最适用场景
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
柱状图中有空隙检查层段的顶界和底界数值是否匹配
绘图效果不正确确认深度方向(向下递增)

参考资料

脚本

评论

支持 Markdown