lasio
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineselasio - LAS Well Log Files
lasio - LAS测井文件
Quick Reference
快速参考
python
import lasiopython
import lasioRead
读取文件
las = lasio.read("well.las")
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']
df = las.df() # DataFrame(以深度为索引)
gr = las['GR'] # 单条曲线,格式为numpy数组
depth = las['DEPT']
Well info
井信息
well_name = las.well['WELL'].value
uwi = las.well['UWI'].value
well_name = las.well['WELL'].value
uwi = las.well['UWI'].value
Write
写入文件
las.write('output.las')
undefinedlas.write('output.las')
undefinedKey Classes
核心类
| Class | Purpose |
|---|---|
| Main container - holds headers, curves, data |
| Single curve with mnemonic, unit, data array |
| Header 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 infopython
las = lasio.read("well.las")
print(las.curves.keys()) # 查看可用曲线
print(las.well) # 查看井段头信息
print(las.version) # 查看LAS版本信息Access Curve Data
访问曲线数据
python
undefinedpython
undefinedAs numpy arrays
以numpy数组形式获取
gr = las['GR']
depth = las['DEPT']
gr = las['GR']
depth = las['DEPT']
With metadata
获取包含元数据的曲线
curve = las.curves['GR']
print(curve.unit, curve.descr) # 'GAPI', 'Gamma Ray'
undefinedcurve = las.curves['GR']
print(curve.unit, curve.descr) # 输出 'GAPI', 'Gamma Ray'
undefinedCreate New LAS
创建新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')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
修改现有LAS文件
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')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
undefinedpython
undefinedIgnore header errors
忽略井头错误
las = lasio.read("messy.las", ignore_header_errors=True)
las = lasio.read("messy.las", ignore_header_errors=True)
Check null value
检查空值
null_val = las.well['NULL'].value # Usually -999.25
undefinednull_val = las.well['NULL'].value # 通常为 -999.25
undefinedNull 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)LAS文件使用特定的空值(通常为-999.25)。请务必检查并处理:
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...python
from pathlib import Path
for path in Path('wells/').glob('*.las'):
las = lasio.read(path)
df = las.df()
# 数据处理...When to Use vs Alternatives
适用场景与替代工具对比
| Tool | Best For |
|---|---|
| lasio | Direct LAS file I/O, header manipulation, format conversion |
| welly | Higher-level well analysis, curve processing, multi-well projects |
| dlisio | DLIS/RP66 binary format files (not LAS) |
Use lasio when you need low-level control over LAS file reading/writing,
need to handle malformed files, or want to programmatically build LAS files.
Use welly instead when you need curve processing (despike, normalize),
multi-well project management, or formation tops. Welly uses lasio internally.
Use dlisio instead when your data is in DLIS format. DLIS files are binary,
support multi-frame data and array logs -- lasio cannot read them.
| 工具 | 最佳适用场景 |
|---|---|
| lasio | LAS文件直接读写、井头操作、格式转换 |
| welly | 高阶测井分析、曲线处理、多井项目管理 |
| dlisio | DLIS/RP66二进制格式文件(非LAS格式) |
当你需要以下操作时选择lasio:对LAS文件读写进行底层控制、处理格式错误的文件、或以编程方式构建LAS文件。
当你需要以下操作时选择welly:曲线处理(去尖峰、归一化)、多井项目管理、或地层顶部分析。Welly内部基于lasio实现。
当你需要处理DLIS格式数据时选择dlisio。DLIS文件是二进制格式,支持多帧数据和数组测井——lasio无法读取此类文件。
Common Workflows
常见工作流
Read, QC, and export well log data
读取、质量控制并导出测井数据
- [ ] Read LAS file with `lasio.read()`, handle encoding if needed
- [ ] Inspect curves: `las.curves.keys()` and well headers
- [ ] Replace null values: `df.replace(null_val, np.nan)`
- [ ] Validate depth range and sample interval
- [ ] Check for missing curves or anomalous values
- [ ] Export to DataFrame with `las.df()` or write cleaned LAS- [ ] 使用`lasio.read()`读取LAS文件,必要时指定编码
- [ ] 检查曲线:`las.curves.keys()`和井头信息
- [ ] 替换空值:`df.replace(null_val, np.nan)`
- [ ] 验证深度范围和采样间隔
- [ ] 检查缺失曲线或异常值
- [ ] 使用`las.df()`导出为DataFrame,或写入清理后的LAS文件Common Issues
常见问题
| Issue | Solution |
|---|---|
| Encoding errors | |
| Missing curves | Check |
| Header errors | Use |
| Wrong null value | Check |
| 问题 | 解决方案 |
|---|---|
| 编码错误 | |
| 曲线缺失 | 先检查 |
| 井头错误 | 使用 |
| 空值不正确 | 检查 |
References
参考资料
- Curve Mnemonics - Standard curve names and units
- Troubleshooting - Common problems and solutions
- LAS File Structure - Detailed format specification
- Curve Mnemonics - 标准曲线名称与单位
- Troubleshooting - 常见问题与解决方案
- LAS File Structure - 详细格式规范
Scripts
脚本
- scripts/validate_las.py - Validate LAS file format
- scripts/las_to_csv.py - Convert LAS to CSV
- scripts/merge_curves.py - Merge curves from multiple files
- scripts/validate_las.py - 验证LAS文件格式
- scripts/las_to_csv.py - 将LAS转换为CSV格式
- scripts/merge_curves.py - 合并多个文件中的曲线