一个用于读取/解析加拿大日志文件(.LAS文件)的零依赖性Python库
las-p的Python项目详细描述
las py
las py是一个零依赖的python库,用于解析.las文件(地球物理/加拿大测井文件)。
目前只支持LAS规范的2.0版。有关此格式的详细信息,请参见加拿大测井协会web page
1.1.0中的新增功能
- 导出到CSV
- 导出到csv,但不包含包含空值的行
- 错误修复
安装
$pip insatll las-py
用法
fromlas_pyimportLaspy
my_las=Laspy('path_to_las_file.las')
读取数据
data=my_las.dataprint(data)#[[2650.0, 177.825, -999.25, -999.25], [2650.5, 182.5, -999.25,-999.25], [2651.0,180.162, -999.25, -999.25], [2651.5, 177.825, -999.25, -999.25], [2652.0, 177.825, -999.25, -999.25] ...]
# get data with rows that has null value strippeddata=my_las.data_strippedprint(data)#[[2657.5, 212.002, 0.16665, 1951.74597], [2658.0, 201.44, 0.1966, 1788.50696], [2658.5, 204.314, 0.21004, 1723.21204], [2659.0, 212.075, 0.22888, 1638.328], [2659.5, 243.536, 0.22439, 1657.91699]...]
获取日志标题
headers=my_las.headerprint(headers)# ['DEPTH', 'GR', 'NPHI', 'RHOB']
获取日志标题说明
hds_and_desc=my_las.header_and_descrprint(hds_and_desc)# {DEPTH': 'DEPTH', 'GR': 'Gamma Ray', 'NPHI': 'Neutron Porosity','RHOB': 'Bulk density'}
获取特定列,例如伽马射线测井
GR=my_las.column('GR')print(GR)# [-999.25, -999.25, -999.25, -999.25, -999.25, 122.03, 123.14, ...]
# get column with null values strippedGR=my_las.column_stripped('GR')print(GR)# [61.61, 59.99, 54.02, 50.87, 54.68, 64.39, 77.96, ...]
Note this returns the column, after all the data has been stripped off their null values, which means that valid data in a particular column would be stripped off if there is another column that has a null value at that particular row
获取油井参数
提供了一种获取各油井参数详情的方法。
详情如下:
1. descr - Description/ Full name of the well parameter 2. units - Its unit measurements 3. value - Value
start=my_las.well.STRT.value# 1670.0stop=my_las.well.STOP.value# 1669.75null_value=my_las.well.NULL.value# -999.25# Any other well parameter present in the file, canbe gotten with the same syntax above
获取曲线参数
提供一种访问各个日志列的详细信息的方法。
详情如下:
1. descr - Description/ Full name of the log column 2. units - Unit of the log column measurements 3. value - API value of the log column
NPHI=my_las.curve.NPHI.descr# 'Neutron Porosity'RHOB=my_las.curve.RHOB.descr# 'Bulk density'# This is the same for all log column present in the file
获取井的参数
详情如下:
1. descr - Description/ Full name of the log column 2. units - Unit of the log column measurements 3. value - API value of the log column
BHT=my_las.param.BHT.descr# 'BOTTOM HOLE TEMPERATURE'BHT_valaue=my_las.param.BHT.value# 35.5BHT_units=my_las.param.BHT.units# 'DEGC'# This is the same for all well parameters present in the file
获取行数和列数
rows=my_las.row_counts# 4columns=my_las.column_counts# 3081
获取版本并包装
version=my_las.version# '2.0'wrap=my_las.wrap# 'YES'
获取其他信息
other=my_las.otherprint(other)# Note: The logging tools became stuck at 625 metres causing the data# between 625 metres and 615 metres to be invalid.
导出到CSV
这将向当前工作目录写入一个csv文件,其中仅包含井和数据部分的标题。
my_las.to_csv('result')# result.csv has been created Successfully!
result.csv
DEPT RHOB GR NPHI 0.5 -999.25 -999.25 -0.08 1.0 -999.25 -999.25 -0.08 1.5 -999.25 -999.25 -0.04 ... ... ... ... 1.3 -999.25 -999.25 -0.08 或者获取去掉空值的csv版本
my_las.to_csv_stripped('clean')# clean.csv has been created Successfully!
clean.csv
DEPT RHOB GR NPHI 80.5 2.771 18.6 -6.08 81.0 2.761 17.4 -6.0 81.5 2.752 16.4 -5.96 ... ... ... ... 80.5 2.762 16.2 -5.06 支架
las py是麻省理工学院授权的开源项目。你可以通过成为赞助商/支持者来帮助它成长。在Patreon