在Python上的3D插值用于整数深度层
我是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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论