1

此 h5 文件包含常规 3D 网格上的分析函数的信息。出于插值目的,我在这里使用 Regulargridinterpolator 得到了非常糟糕的结果。现在,我想scipy.interpolate.Rbf为我的数据集测试插值器。谁能帮我做到这一点?我查看了这个插值器的文档,但没有正确理解。

我创建了一个这样的 h5 文件:

import numpy as np
from numpy import gradient
import h5py
from scipy.interpolate import Rbf

def f(x,y,z):
    return ( -1 / np.sqrt(x**2 + y**2 + z**2))

#grid
x = np.linspace(0, 100, 32)  # since the boxsize is 320 Mpc/h
y = np.linspace(0, 100, 32)
z = np.linspace(0, 100, 32)


mesh_data = phi_an(*np.meshgrid(x, y, z, indexing='ij', sparse=True))


#create h5 file
h5file = h5py.File('analytic.h5', 'w')
h5file.create_dataset('/x', data=x)
h5file.create_dataset('/y', data=y)
h5file.create_dataset('/z', data=z)
h5file.create_dataset('/mesh_data', data=mesh_data)

h5file.close()
4

0 回答 0