【发布时间】:2019-06-27 18:32:08
【问题描述】:
我是python的新用户。我有一个 3D 常规网格数据作为 h5 文件格式。我可以使用 RegularGridInterpolator 对我的数据进行插值(三线性插值)。但是,我不知道如何从我的插值函数中获取导数。
(我的问题与How to get special derivative from an interpolated function类似,但那里似乎没有合适的解决方案,所以我想我会再问一次。)
实际上,我正在尝试将这个问题的相同代码 (How to get special derivative from an interpolated function) 用于我的 h5 文件。我的 h5 文件可以从这个链接 (https://drive.google.com/open?id=1cpnZBGDgbijAH0kJchcecTM5lKasiflp) 下载。
期待专家的帮助。
我的代码:
import numpy as np
import h5py
import matplotlib.pyplot as plt
from scipy.interpolate import RegularGridInterpolator
f = h5py.File('k.h5', 'r')
list(f.keys())
dset = f[u'data']
dset.shape
dset.value.shape
dset[0:64,0:64,0:64]
x = np.linspace(-160, 160, 64)
y = np.linspace(-160, 160, 64)
z = np.linspace(-160, 160, 64)
my_interpolating_function = RegularGridInterpolator((x, y, z), dset.value)
pts = np.array([4.5, 15.3, 18.8])
my_interpolating_function(pts)
【问题讨论】:
标签: python numpy scipy interpolation hdf5