AgentSkillsCN

lasio

读取、写入并操作LAS(测井ASCII标准)测井文件,用于钻孔地球物理与岩石物理数据的处理。当Claude需要执行以下操作时使用:(1) 读取/解析LAS 1.2或2.0文件;(2) 提取测井头信息或曲线数据;(3) 将LAS转换为DataFrame/CSV/Excel格式;(4) 从数组创建新的LAS文件;(5) 修改现有LAS文件;(6) 处理存在异常或格式错误的LAS文件;(7) 批量处理多口测井数据。

SKILL.md
--- frontmatter
name: lasio
description: |
  Read, write, and manipulate LAS (Log ASCII Standard) well log files for borehole
  geophysical and petrophysical data. Use when Claude needs to: (1) Read/parse LAS
  1.2 or 2.0 files, (2) Extract well headers or curve data, (3) Convert LAS to
  DataFrame/CSV/Excel, (4) Create new LAS files from arrays, (5) Modify existing
  LAS files, (6) Handle problematic or malformed LAS files, (7) Batch process
  multiple well files.

lasio - LAS Well Log Files

Quick Reference

python
import lasio

# Read
las = lasio.read("well.las")

# Access data
df = las.df()                    # DataFrame (depth as index)
gr = las['GR']                   # Single curve as numpy array
depth = las['DEPT']

# Well info
well_name = las.well['WELL'].value
uwi = las.well['UWI'].value

# Write
las.write('output.las')

Key Classes

ClassPurpose
LASFileMain container - holds headers, curves, data
CurveItemSingle curve with mnemonic, unit, data array
HeaderItemHeader entry (mnemonic, unit, value, descr)

Essential Operations

Read and Inspect

python
las = lasio.read("well.las")
print(las.curves.keys())         # Available curves
print(las.well)                  # Well section headers
print(las.version)               # LAS version info

Access Curve Data

python
# As numpy arrays
gr = las['GR']
depth = las['DEPT']

# With metadata
curve = las.curves['GR']
print(curve.unit, curve.descr)   # 'GAPI', 'Gamma Ray'

Create New LAS

python
import numpy as np

las = lasio.LASFile()
las.well['WELL'] = lasio.HeaderItem('WELL', value='Test-1')
las.well['UWI'] = lasio.HeaderItem('UWI', value='12345678901234')

depth = np.arange(1000, 2000, 0.5)
las.append_curve('DEPT', depth, unit='M', descr='Depth')
las.append_curve('GR', gr_data, unit='GAPI', descr='Gamma Ray')
las.write('output.las')

Modify Existing

python
las = lasio.read("well.las")
las.append_curve('GR_NORM', las['GR'] / 150, unit='V/V')
del las.curves['BAD_CURVE']
las.well['WELL'].value = 'New Name'
las.write('modified.las')

Handle Problematic Files

python
# Ignore header errors
las = lasio.read("messy.las", ignore_header_errors=True)

# Check null value
null_val = las.well['NULL'].value  # Usually -999.25

Null Value Handling

LAS files use a specific null value (typically -999.25). Always check and handle:

python
import numpy as np
null_val = float(las.well['NULL'].value)
df = las.df().replace(null_val, np.nan)

Batch Processing

python
from pathlib import Path

for path in Path('wells/').glob('*.las'):
    las = lasio.read(path)
    df = las.df()
    # Process...

Common Issues

IssueSolution
Encoding errorslasio.read(f, encoding='latin-1')
Missing curvesCheck las.curves.keys() first
Header errorsUse ignore_header_errors=True
Wrong null valueCheck las.well['NULL'].value

References

Scripts