2

我很确定这是一个关于 LAS 文件的非常琐碎的问题,但我不完全确定如何在谷歌上搜索它。对于上下文,我正在尝试根据 LAS 文件中的信息创建一个绘图。

import lasio as ls
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

well = ls.read(r'1051325649.las')
df = well.df() 

fig = plt.subplots(figsize=(10,10))

#Set up the plot axes
ax1 = plt.subplot2grid((1,3), (0,0), rowspan=1, colspan = 1) 
ax2 = plt.subplot2grid((1,3), (0,1), rowspan=1, colspan = 1)
ax3 = plt.subplot2grid((1,3), (0,2), rowspan=1, colspan = 1)

ax1.plot("GR", "DEPT", data = df, color = "green") # Call the data from the well dataframe
ax1.set_title("Gamma") # Assign a track title
ax1.set_xlim(0, 200) # Change the limits for the curve being plotted
ax1.set_ylim(400, 1000) # Set the depth range
ax1.grid() # Display the grid

LAS 文件看起来很像这样,我想创建一个图,其中最左边的列“DEPT”应该是 X 轴。但是,“DEPT”或深度列无法制作成允许我绘制的格式。**注意:右边有GR柱不在这张图里,不用担心。任何提示都会有很大帮助。

在此处输入图像描述

4

2 回答 2

1

简短的回答:

plt.plot期望"GR""DEPT"都是 中的列df,但是后者 ( DEPT) 不是列,它是索引。您可以通过将索引转换df为列来解决它:

df2 = df.reset_index()
ax1.plot("GR", "DEPT", data = df2, color = "green")
于 2021-02-28T08:06:11.227 回答
0

当使用库读取.las文件lasio并将它们转换为pandas数据框时,它会自动设置DEPT为数据框的索引。

这个问题有两种解决方案:

  1. 按原样使用数据:
import matplotlib.pyplot as plt
import lasio

well = lasio.read('filename.las')
well_df = well.df()

plt.plot(well_df.GR, well_df.index)

并且well_df.index将是DEPT价值观。

  1. 重置索引并DEPT用作列
import matplotlib.pyplot as plt
import lasio

well = lasio.read('filename.las')
well_df = well.df()

well_df = well_df.reset_index()

plt.plot(well_df.GR, well_df.DEPT)
于 2021-12-01T00:47:36.800 回答