簡體   English   中英

當從 2d 過渡到 3d 時,z 值似乎映射到不正確的 x 和 y 值

[英]z values appear to be mapping to the incorrect x and y values when transition from 2d to 3d

我有一個函數可以根據空間中給定的 xy 值計算 az 值。 我試圖將所有數據組合到一個 3D 網格中,但是我注意到 z 值沒有正確映射。 換句話說,當打印 xyz 並在 excel 中執行計算作為檢查時,我沒有得到正確的 z 值,但我確信我的函數計算正確。 如果我單獨檢查它,它會給出我正在尋找的結果。 所以我很確定 z 值被映射到不正確的 x,y。

僅供參考,我需要將網格作為 XYZ 一起使用的原因是:一旦我運行該函數,我需要對生成的網格執行網格數學運算。 例如,我需要根據給定的 X 和 Y 找到某些位置,然后找到對應於某個 z 值的節點並對節點的面積求和......等等。 我顯然還沒有到達那里。 我是 python 的新手並在那里工作。

我在這里做錯了什么? 注意我沒有收到任何錯誤。

任何幫助是極大的贊賞。

我究竟做錯了什么?

import pandas as pd
import math
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.tri as tri
import matplotlib.pyplot as plt
from matplotlib import rcParams

#define the flow potential equation where X,Y is the injection well locations and x,y is the point of interest, Q is flow rate
def func(X, Y, x, y, Q):
    return (Q / (2 * np.pi)) * np.arctan((y-Y)/(x-X))

# necessary data
X1=2318743.658
Y1=797346.704
Q1=5
X2=2318690.718
Y2=797343.693
Q2=5
X3=2318715.221
Y3=797309.685
Q3=5

#initiate the XY grid - this will be a standard that will encompass all IW and MW
xi = np.linspace(2318675,2318800,625)
yi = np.linspace(797300,797375,375)

#mesh the grid in to x,y space
x,y = np.meshgrid(xi,yi)

#calculate the valus over the grid at every x,y using the defined function above
zi = (func(X1,Y1,x,y,Q1)+func(X2,Y2,x,y,Q2)+func(X3,Y3,x,y,Q3))

#reshape the xy space into 3d space
xy = np.array([[(x, y) for y in yi] for x in xi])

#reshape z into 3d space
z = np.array(zi).reshape(xy.shape[0],xy.shape[1], -1)

#combined xyz into a single grid
xyz = np.concatenate((xy, z), axis = -1)

我相信我能夠通過更改這行代碼來解決這個問題:

xy = np.array([[(x, y) for y in yi] for x in xi])

對此:

xy = np.array([[(x, y) for x in xi] for y in yi])

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM