【问题标题】:LAS files - PythonLAS 文件 - Python
【发布时间】:2021-05-16 10:35:45
【问题描述】:

我很确定这是一个关于 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柱不在此图,不用担心。任何提示都会有很大帮助。

【问题讨论】:

    标签: python las log-ascii-standard


    【解决方案1】:

    简答:

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

    df2 = df.reset_index()
    ax1.plot("GR", "DEPT", data = df2, color = "green")
    

    【讨论】:

      【解决方案2】:

      当使用lasio 库读取.las 文件并将它们转换为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-09-03
        • 2023-01-03
        • 2021-02-10
        • 1970-01-01
        • 2017-11-08
        • 2015-12-21
        • 2019-08-27
        • 2020-07-31
        • 2018-11-21
        相关资源
        最近更新 更多