-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathload_las.py
34 lines (28 loc) · 885 Bytes
/
load_las.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import glob
import os
import lasio as lasio
import numpy as np
import platform
my_os = platform.system()
if my_os == 'Windows':
path = ".\data"
elif my_os == 'Linux':
path = './data'
elif my_os == 'Darwin':
path = './data'
# get all paths and alphabetically ordered
paths = sorted(glob.glob(os.path.join(path, "*.las")))
def load():
well_df = [0] * len(paths)
for i in range(len(paths)):
# read with lasio
well = lasio.read(paths[i])
# convert to dataframe
df = well.df()
# in this dataframe, depth is positioned as index, not as column
# so better to change depth index to column
well_df[i] = df.reset_index()
well_df[i].rename(columns={'DEPT': 'DEPTH'}, inplace=True)
# replace null values (-9999.0) with NaN
well_df[i] = well_df[i].replace(-9999.0, np.NaN)
return well_df