在Python上的3D插值用于整数深度层

发布于 2025-02-06 00:11:43 字数 1048 浏览 2 评论 0原文

我是Python和插值的新手。我有一个类似4列的dataFrame :(实际的DF很大,并在我的github上上传: https://github.com/soniabazargan/3d-interpolation/blob/main/mit_absvalue.csv

lat    lon   depth   velocity
5.27    -104.41   22.6.    5.6
5.27    -104.41   22.6.    5.7
.
.    
24.96    -80.51   67.8.    6.1
24.96    -80.51   67.8.    6.2

,我想在相同的纬度和经度上找到速度值不同的任意深度。 这是我的代码:

import numpy as np
import pandas as pd
from scipy.interpolate import griddata as gd
MIT = pd.read_csv('MIT_absvalue.csv', delim_whitespace=True, header = None)
MIT.columns = ['Lat', 'Long', 'Depth', 'Vabs']
x=MIT['Lat']
y=MIT['Long']
z=MIT['Depth']
v=MIT['Vabs']
xi,yi,zi=np.ogrid[5.27:24.96:29j, -104.41:-80.51:35j, 0:80:8j]
xx, yy, zz = np.meshgrid(xi, yi, zi)
V = gd((x,y,z), v, (xx, yy, zz), method='linear')

问题是:使用np.grid,我得到的深度层不一定是整数,我需要在任意整数深度层中获得V。我该怎么做? 任何帮助将不胜感激。谢谢。

I am new to python and interpolation. I have a DataFrame having 4 columns like this: (the actual df is big and is uploaded on my GitHub: https://github.com/SoniaBazargan/3D-interpolation/blob/main/MIT_absvalue.csv)

lat    lon   depth   velocity
5.27    -104.41   22.6.    5.6
5.27    -104.41   22.6.    5.7
.
.    
24.96    -80.51   67.8.    6.1
24.96    -80.51   67.8.    6.2

and I would like to find the velocity values at the same latitude and longitude but at different arbitrary depths.
This is my code:

import numpy as np
import pandas as pd
from scipy.interpolate import griddata as gd
MIT = pd.read_csv('MIT_absvalue.csv', delim_whitespace=True, header = None)
MIT.columns = ['Lat', 'Long', 'Depth', 'Vabs']
x=MIT['Lat']
y=MIT['Long']
z=MIT['Depth']
v=MIT['Vabs']
xi,yi,zi=np.ogrid[5.27:24.96:29j, -104.41:-80.51:35j, 0:80:8j]
xx, yy, zz = np.meshgrid(xi, yi, zi)
V = gd((x,y,z), v, (xx, yy, zz), method='linear')

The question is that: Using np.ogrid, I get depth layers that are not necessarily integer, and I need to get the V at arbitrary integer depth layers. How can I do that?
Any help would be appreciated. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文