使用 lasio 处理 .las 文件
文章目录
- 使用 lasio 处理 .las 文件
- 1. 简述
- 2. lasio 的安装
- 3. lasio的使用
- 3.1. 显示 lasio 的版本
- 3.2. 显示曲线名
- 3.3. 输出参数
- 3.4. 输出数据
- 3.5 lasio转为csv
- 3.6. lasio 转为xlsx
1. 简述
对于地球物理,地质,岩石物理日志,钻孔数据是不可避免的一个问题。.las 文件的数据格式比较奇特,如果将其看成 .txt 的数据,在使用 python 的 numpy, pandas 模块进行处理的时候就比较繁琐。所幸,python 的 lasio 模块能够解决这个问题。
lasio 模块的官网链接如下:https://lasio.readthedocs.io/en/latest/
lasio 支持的python版本是3.6+
2. lasio 的安装
lasio 推荐使用 pip 进行安装
在此之前要确认已经安装好了 numpy
如果安装速度比较慢,可能是 pip 镜像源的问题,可以设置镜像为清华镜像
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
安装numpy
pip install numpy
numpy 安装好之后再安装 lasio
pip install lasio
lasio 安装完成后显示:
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting lasio
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/82/0e/9613fcc757533d613fe969370fb054c0e81293b39d2eb1be25e4b4c1a85a/lasio-0.30-py2.py3-none-any.whl (43 kB)
|████████████████████████████████| 43 kB 3.2 MB/s
Requirement already satisfied: numpy in c:\software\anaconda3\envs\pytorch1.11.0_py3.8\lib\site-packages (from lasio) (1.22.3)
3. lasio的使用
首先引用 lasio
import
lasio 还有一个样例库可以来帮助使用者来熟悉 lasio
import lasio.examples
las = lasio.examples.open("1001178549.las")
3.1. 显示 lasio 的版本
las.version
# 输出
[HeaderItem(mnemonic="VERS", unit="", value="2.0", descr="CWLS Log ASCII Standa"),
HeaderItem(mnemonic="WRAP", unit="", value="YES", descr="Multiple lines per de")]
3.2. 显示曲线名
print(las.curves)
# 输出
Mnemonic Unit Value Description
-------- ---- ----- -----------
DEPT FT 0 1 0 0 1 DEPTH
GSGR API 31 310 0 0 2 GAMMA RAY
GSTK API 31 797 0 0 3 ????????
GST API 99 999 99 0 4 ????????
GSK PERCNT 31 721 1 0 5 ????????
GSTH PPM 31 790 0 0 6 THORIUM
GSUR PPM 31 792 0 0 7 URANIUM
NCNPL PERCNT 42 890 1 0 8 NEUTRON POROSITY (LIMESTONE)
DLDPL PERCNT 43 890 10 0 9 DENSITY POROSITY (LIMESTONE)
DLDC GM/CC 43 356 0 0 10 DENSITY CORRECTION
DLPE B/E 43 358 0 0 11 PHOTO-ELECTRIC EFFECT
DLDN GM/CC 43 350 0 0 12 BULK DENSITY
DLCL INCHES 43 280 0 0 13 CALIPER
DLTN LBS 43 635 0 0 14 ????????
IDGR API 7 310 0 0 15 GAMMA RAY
ACCL1 INCHES 60 280 1 0 16 DENSITY CALIPER
ACCL2 INCHES 60 280 2 0 17 NEUTRON CALIPER
ACTC US/FT 60 520 0 0 18 SONIC INTERVAL TRANSIT TIME (COMPENSATED)
ACAPL PERCNT 60 890 20 0 19 POROSITY
IDIM OHMM 7 120 44 0 20 MEDIUM INDUCTION
IDID OHMM 7 120 46 0 21 DEEP INDUCTION
IDIDC MMHOS 7 110 46 0 22 INDUCTION (CONDUCTIVITY UNITS)
IDL3 OHMM 7 220 3 0 23 FOCUSSED RESISTIVITY
IDTN LBS 7 635 0 0 24 ????????
IDSP MVOLT 7 10 0 0 25 SPONTANEOUS POTENTIAL
MEL1 OHMM 15 250 2 0 26 MICRO INVERSE 1"
ME OHMM 15 252 2 0 27 MICRO NORMAL 2"
3.3. 输出参数
las.params
# 输出
[HeaderItem(mnemonic="RUN", unit="", value="99", descr="Run Number"),
HeaderItem(mnemonic="GL", unit="FT", value="3190.0", descr="Ground Level Eleva"),
HeaderItem(mnemonic="DREF", unit="", value="KB", descr="Depth Reference"),
HeaderItem(mnemonic="EREF", unit="FT", value="3210.0", descr="Elevation of Dep"),
HeaderItem(mnemonic="CSGL", unit="FT", value="1791.0", descr="Casing Bottom Lo"),
HeaderItem(mnemonic="CSGD", unit="FT", value="0.0", descr="Casing Bottom Drill"),
HeaderItem(mnemonic="CSGS", unit="IN", value="8.625", descr="Casing Size"),
HeaderItem(mnemonic="CSGW", unit="LBS", value="0.0", descr="Casing Weight"),
HeaderItem(mnemonic="BHT", unit="DEGF", value="125.0", descr="Bottom Hole Temp"),
HeaderItem(mnemonic="BS", unit="IN", value="7.875", descr="Bit Size"),
HeaderItem(mnemonic="RM", unit="OHMM", value="2.11", descr="Mud Resistivity"),
HeaderItem(mnemonic="RMT", unit="DEGF", value="80.0", descr="Mud Resistivity T"),
HeaderItem(mnemonic="RMF", unit="OHMM", value="1.58", descr="Mud Filtrate Resi"),
HeaderItem(mnemonic="RMFT", unit="DEGF", value="80.0", descr="RMF Temperature"),
HeaderItem(mnemonic="RMC", unit="OHMM", value="2.74", descr="Mud Cake Resistiv"),
HeaderItem(mnemonic="RMCT", unit="DEGF", value="80.0", descr="RMC Temperature"),
HeaderItem(mnemonic="LAT", unit="", value="37.41565", descr="Latitude"),
HeaderItem(mnemonic="LONG", unit="", value="-101.58701", descr="Longitude")]
3.4. 输出数据
las.data
# 输出
array([[1.7835000e+03, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, 5.0646500e+01, 8.3871000e+00,
8.4396000e+00, 5.5100000e+01, 5.6900000e-02, 5.6000000e+02,
1.7500000e+02, 5.0000000e-02, 4.5330000e-01, 1.8930420e+03,
9.2605000e+01, nan, nan],
[1.7837500e+03, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, 4.9676700e+01, 8.3951000e+00,
8.4460000e+00, 5.4355500e+01, 5.9000000e-02, 5.6000000e+02,
1.7500000e+02, 5.0000000e-02, 4.5340000e-01, 1.8523320e+03,
9.2778000e+01, nan, nan],
[1.7840000e+03, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, 4.8631300e+01, 8.4052000e+00,
8.4460000e+00, 5.4444400e+01, 5.8100000e-02, 5.6000000e+02,
1.7500000e+02, 5.0000000e-02, 4.5370000e-01, 1.8319766e+03,
9.2948200e+01, nan, nan],
[1.7842500e+03, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, 4.7771700e+01, 8.4173000e+00,
8.4438000e+00, 5.5311100e+01, 5.7700000e-02, 5.6000000e+02,
1.7500000e+02, 5.0000000e-02, 4.5380000e-01, 1.8319766e+03,
9.3110300e+01, nan, nan],
[1.7845000e+03, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, 4.8114900e+01, 8.4253000e+00,
8.4460000e+00, 5.6322200e+01, 5.8500000e-02, 5.6000000e+02,
1.7500000e+02, 5.0000000e-02, 4.5390000e-01, 1.8116211e+03,
9.3267100e+01, nan, nan]])
3.5 lasio转为csv
>>> import lasio.examples
>>> from sys import stdout
>>> las = lasio.examples.open('sample.las')
>>> las.to_csv(stdout)
DEPT,DT,RHOB,NPHI,SFLU,SFLA,ILM,ILD
M,US/M,K/M3,V/V,OHMM,OHMM,OHMM,OHMM
1670.0,123.45,2550.0,0.45,123.45,123.45,110.2,105.6
1669.875,123.45,2550.0,0.45,123.45,123.45,110.2,105.6
1669.75,123.45,2550.0,0.45,123.45,123.45,110.2,105.6
3.6. lasio 转为xlsx
pip install
las.to_excel('sample.xlsx')