SuperAPI AI 工具集

dlisio

数据与分析

查看项目

更新于 10-16 02:14

技能介绍

用途

dlisio 用于读取和解析 DLIS(Digital Log Interchange Standard)与 LIS(Log Information Standard)测井文件,并支持受控的 LAS 导出。它面向二进制 RP66 DLIS 和 LIS79 输入,返回结构化的 NumPy 数组与元数据对象。该工具不写入 DLIS;如需处理 LAS,应使用 lasio。

主要能力

选择逻辑文件与帧

在选取数据前应先检查物理文件。不同逻辑文件与帧可能具有不同的深度、采样率和通道标识。dlis.load() 返回的是 PhysicalFile 上下文管理器,而不是生成器。应在上下文内读取数组数据,关闭上下文后再保留已复制的数组或 DataFrame。

from dlisio import dlis

def inventory(path):
    items = []
    with dlis.load(str(path)) as files:
        for logical_index, logical in enumerate(files):
            for frame_index, frame in enumerate(logical.frames):
                items.append({
                    'logical_file': logical_index, 'frame': frame_index,
                    'fingerprint': frame.fingerprint,
                    'index_type': frame.index_type, 'index': frame.index,
                    'channels': [(ch.fingerprint, ch.units, ch.dimension)
                                 for ch in frame.channels],
                })
    return items

通道身份包含类型、助记符、来源和副本编号,仅名称不一定唯一。应使用 channel.fingerprint 访问其数组字段;frame.curves() 即使在名称被消歧后,仍以指纹作为 dtype 标题。FRAMENO 字段记录的是帧序号,而非测量深度。

读取标量与数组通道

from dlisio import dlis
import pandas as pd

def read_frame(path, logical_file_index=0, frame_index=0):
    with dlis.load(str(path)) as files:
        if not 0 <= logical_file_index < len(files):
            raise ValueError('Logical file index out of range')
        logical = files[logical_file_index]
        if not 0 <= frame_index < len(logical.frames):
            raise ValueError('Frame index out of range')
        frame = logical.frames[frame_index]
        records = frame.curves()
        scalar = {name: records[name].copy() for name in records.dtype.names
                  if records[name].ndim == 1}
        arrays = {ch.fingerprint: records[ch.fingerprint].copy()
                  for ch in frame.channels if records[ch.fingerprint].ndim > 1}
        metadata = {'frame': frame.fingerprint, 'index_type': frame.index_type,
                    'index': frame.index,
                    'channels': {ch.fingerprint: {'name': ch.name, 'units': ch.units,
                                                  'dimension': ch.dimension} for ch in frame.channels}}
        return pd.DataFrame(scalar), arrays, metadata

数组/图像通道应保持为数组,并保留所有尾部维度。结构化数组具有 dtype.names,而非 .items()。当其包含多维字段时,直接转换为 DataFrame 会失败。除非有明确要求且有记录的降维操作,否则不要把图像通道平均为标量。

深度、缺失值与转换

在把某个索引判定为深度之前,应检查 frame.index_type 以及第一个通道的单位。时间通道或 FRAMENO 不能替代深度。

应保留深度递增或递减的顺序。重复或非单调深度需要显式处理;不要在不同测次之间静默排序或重采样。

DLIS 没有通用的 LAS 式空值哨兵。应保留 NaN,仅在其含义有文档说明时才应用厂商空值标记。导出过程中应保留掩码。

帧与通道处理

帧和通道的处理涉及身份识别、搜索以及独立的无损数组导出。文件结构与 LIS 的处理涉及元数据、编码以及独立的 LIS API。

DLIS 转 LAS 辅助脚本

内置的 DLIS 转 LAS 辅助脚本始终首先包含一条经过验证的深度曲线,即使 --curves 只请求测量曲线也是如此。它接受唯一助记符或完整指纹,保留 m/ft 单位与深度顺序,并对不规则采样写入 STEP=0。数组默认被排除并给出诊断信息;显式请求数组时会失败,而不是将其丢弃。LAS 是对 DLIS 元数据和多维样本的有损表示。

python scripts/dlis_to_las.py well.dlis --list
python scripts/dlis_to_las.py well.dlis scalar.las --logical-file 0 --frame 0 --curves GR

应相对于已安装的 skill 目录解析脚本路径。对于非深度索引的帧,需要显式指定 --depth-channel。支持的导出深度单位为 m 和 ft;其他单位需要记录转换关系。--null-value 记录操作者所选定的已知厂商哨兵值。

适用场景

  • 需要读取或解析 DLIS/LIS 测井文件时;
  • 需要检查测井文件的物理结构、逻辑文件、帧和通道时;
  • 需要将 DLIS 中的标量测井曲线以受控方式导出为 LAS 时;
  • 需要在多逻辑文件/多帧、重复助记符、标量/数组通道、NaN 等情况下保持数据完整性的场景。

限制

  • 不写入 DLIS;LAS 处理需使用 lasio。
  • LIS、损坏文件恢复以及厂商特定记录需要各自的测试夹具;不应声称这些分支已被 DLIS 测试覆盖。
  • 验证使用 dlisio 1.0.4,配合项目生成的二进制 DLIS,包括多逻辑文件/帧、重复助记符、标量/数组通道、NaN 和 LAS 往返。这些合成文件为项目所有,并非分发的实测测井数据。
  • 官方 DLIS API 检查日期为 2026-09-14。除非有明确且有记录的恢复决策支持放宽,否则应使用严格解析;错误不得被报告为成功的空导出。