我很确定这是一个关于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 gridLAS文件看起来很像这样,我想在其中创建一个图,其中最左边的列"DEPT“应该是X轴。但是,"DEPT“或”depth“列无法转换为允许我绘制它的格式。**注意:右侧有一个GR列,不在此图中,请不要担心。任何提示都会有很大的帮助。

发布于 2021-02-28 16:06:11
简短的回答:
plt.plot期望"GR"和"DEPT"都是df中的列,但是后者(DEPT)不是列,它是索引。您可以通过将df中的索引转换为列来解决此问题:
df2 = df.reset_index()
ax1.plot("GR", "DEPT", data = df2, color = "green")发布于 2021-12-01 00:47:37
当使用lasio库读取.las文件并将其转换为pandas数据帧时,它会自动将DEPT设置为数据帧的索引。
这个问题有两种解决方案:
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的值。
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)https://stackoverflow.com/questions/66175870
复制相似问题