0

我在网格上有一个 3D numpy 温度值数组。由此我可以使用dTdx, dTdy, dYdz = np.gradient(T). 现在我只对温度为 900 的等值面上的梯度值感兴趣。我想做的是(伪 codish):

import nympy as np
def regular(x,y,z,q=100,k=175,a=7.1e-5):
    R = np.sqrt(x**2+y**2+z**2)
    return 100 / (2*np.pi*k) * (1/R) * np.exp(-0.5/a*(R+x))
x = np.arange(-1.5,0.5+res/2,res)*1e-3
y = np.arange(-1.0,1.0+res/2,res)*1e-3
z = np.arange(0.0,0.5+res/2,res)*1e-3
Y,X,Z = np.meshgrid(y,x,z)
T = regular(X,Y,Z)
dTdx, dTdy, dYdz = np.gradient(T)

(xind,yind,zind) = <package>.get_contour_indices(X,Y,Z,T,value=900)
x_gradients_at_isosurface = dTdx[xind,yind,zind]
...

我试过了:

import numpy as np
from skimage import measure
contour_data = measure.find_contours(T[:,:,0],900)
contour_data = np.int_(np.round(contour_data[0]))
xs,ys = contour_data[:,0],contour_data[:,1]
gradients_of_interest = np.array([G[x,y,0] for x,y in zip( xs,ys )])

效果很好,但仅适用于 2D 数据。我正在寻找3D等价物。我发现了以下内容:

import plotly.graph_objects as go
surf = go.Isosurface(x=X.flatten(),y=Y.flatten(),z=Z.flatten(),value=T.flatten(),isomin=900,isomax=900)
fig = go.Figure(data=surf)
plt.show()

但我对绘制它不感兴趣。我想知道温度为 T=900 的指数,以便我可以在梯度上使用它。有任何想法吗?

4

1 回答 1

1

你需要skimage.measure.marching_cubes.

于 2021-05-25T11:40:59.490 回答