将三维钻孔轨迹转换为笛卡尔坐标,并使用matplotlib进行打印

2024-06-02 02:31:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我想能够用方向和距离来画两条线。这是一个钻孔轨迹,所以我现在有这个格式的数据

enter image description here

深度实际上是孔下的距离,而不是垂直深度。方位角是从磁北来的。倾角基于0表示水平。我想从同一点画两条线(0,0,0很好),看看它们有什么不同,基于这种信息。在

我没有Matplotlib的经验,但是对Python很熟悉,我想了解一下这个绘图工具。我已经找到了this page,它有助于理解框架,但我仍然不知道如何用3d向量绘制线。有人能给我一些指点,告诉我该怎么做或者在哪里找到我需要的方向吗?谢谢你


Tags: 工具数据信息绘图距离matplotlib轨迹格式
2条回答

对于500米的钻孔,可采用最小曲率法,否则位置误差会很大。在pygsi模块中实现的pygsi。示例显示了真实钻孔数据库的完整解测过程,包括化验/岩性间隔的位置,如下所示:

http://nbviewer.ipython.org/github/opengeostat/pygslib/blob/master/pygslib/Ipython_templates/demo_1.ipynb

这也展示了如何将VTK格式的钻孔导出到paraview中的lad。在

Results shown in Paraview

Cython中去测一个区间的代码如下:

cpdef dsmincurb( float len12,
                 float azm1,
                 float dip1,
                 float azm2,
                 float dip2):

    """    
    dsmincurb(len12, azm1, dip1, azm2, dip2)

    Desurvey one interval with minimum curvature 

    Given a line with length ``len12`` and endpoints p1,p2 with 
    direction angles ``azm1, dip1, azm2, dip2``, this function returns 
    the differences in coordinate ``dz,dn,de`` of p2, assuming
    p1 with coordinates (0,0,0)

    Parameters
         
    len12, azm1, dip1, azm2, dip2: float
        len12 is the length between a point 1 and a point 2.
        azm1, dip1, azm2, dip2 are direction angles azimuth, with 0 or 
        360 pointing north and dip angles measured from horizontal 
        surface positive downward. All these angles are in degrees.


    Returns
       -
    out : tuple of floats, ``(dz,dn,de)``
        Differences in elevation, north coordinate (or y) and 
        east coordinate (or x) in an Euclidean coordinate system. 

    See Also
        
    ang2cart, 

    Notes
      -
    The equations were derived from the paper: 
        http://www.cgg.com/data//1/rec_docs/2269_MinimumCurvatureWellPaths.pdf

    The minimum curvature is a weighted mean based on the
    dog-leg (dl) value and a Ratio Factor (rf = 2*tan(dl/2)/dl )
    if dl is zero we assign rf = 1, which is equivalent to  balanced 
    tangential desurvey method. The dog-leg is zero if the direction 
    angles at the endpoints of the desurvey intervals are equal.  

    Example
        

    >>> dsmincurb(len12=10, azm1=45, dip1=75, azm2=90, dip2=20)
    (7.207193374633789, 1.0084573030471802, 6.186459064483643)

    """

    # output
    cdef:
        float dz
        float dn
        float de 


    # internal 
    cdef:
        float i1
        float a1
        float i2
        float a2
        float DEG2RAD
        float rf
        float dl

    DEG2RAD=3.141592654/180.0

    i1 = (90 - dip1) * DEG2RAD
    a1 = azm1 * DEG2RAD

    i2 = (90 - dip2) * DEG2RAD
    a2 = azm2 * DEG2RAD

    # calculate the dog-leg (dl) and the Ratio Factor (rf)
    dl = acos(cos(i2-i1)-sin(i1)*sin(i2)*(1-cos(a2-a1))) 

    if dl!=0.: 
        rf = 2*tan(dl/2)/dl  # minimum curvature
    else:
        rf=1                 # balanced tangential



    dz = 0.5*len12*(cos(i1)+cos(i2))*rf
    dn = 0.5*len12*(sin(i1)*cos(a1)+sin(i2)*cos(a2))*rf
    de = 0.5*len12*(sin(i1)*sin(a1)+sin(i2)*sin(a2))*rf

    return dz,dn,de

将坐标转换为笛卡尔坐标并使用matplotlib打印的脚本,其中包含以下注释:

import numpy as np
import matplotlib.pyplot as plt
# import for 3d plot
from mpl_toolkits.mplot3d import Axes3D
# initializing 3d plot
fig = plt.figure()
ax = fig.add_subplot(111, projection = '3d')
# several data points 
r = np.array([0, 14, 64, 114])
# get lengths of the separate segments 
r[1:] = r[1:] - r[:-1]
phi = np.array([255.6, 255.6, 261.7, 267.4])
theta = np.array([-79.5, -79.5, -79.4, -78.8])
# convert to radians
phi = phi * 2 * np.pi / 360.
# in spherical coordinates theta is measured from zenith down; you are measuring it from horizontal plane up 
theta = (90. - theta) * 2 * np.pi / 360.
# get x, y, z from known formulae
x = r*np.cos(phi)*np.sin(theta)
y = r*np.sin(phi)*np.sin(theta)
z = r*np.cos(theta)
# np.cumsum is employed to gradually sum resultant vectors 
ax.plot(np.cumsum(x),np.cumsum(y),np.cumsum(z))

相关问题 更多 >