Hi experts,
I need your kind suggestion. I have a hdf5 file and I can able to read the file in python. The h5 file contains a large number of data and these are the values of potential (depends on position (x, y, z) ). I am also able to interpolate my 3D regular grid data by using RegularGridInterpolator. Now, my question is: how I can define my h5 file data as a function of x, y, z so that it can able to update my a_1 (x,y,z) , a_2(x,y,z)… values in my code. Here is my h5 file: https://drive.google.com/open?id=1OFIg7pjfpfjq3Vnvqaj2uyCFjiTwZ9QK
import numpy as np
from numpy import gradient
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.shap
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([100, 5, -10])
my_interpolating_function(pts)
# Apply gradient function
gradx, grady, gradz = np.gradient(dset.value)
gradx.shape
# To find the gradient at any point
gradx_interpol = RegularGridInterpolator((x, y, z), gradx)
grady_interpol = RegularGridInterpolator((x, y, z), grady)
gradz_interpol = RegularGridInterpolator((x, y, z), gradz)
def get_val_and_grads(pts):
v1, x1, y1, z1 = my_interpolating_function(pts), gradx_interpol(
pts), grady_interpol(pts), gradz_interpol(pts)
return v1, x1, y1, z1
##getting_interpolated_values
k1 = my_interpolating_function(pts)
k_dx = gradx_interpol(pts)
k_dy = grady_interpol(pts)
k_dz = gradz_interpol(pts)
def a_1(x,y,z):
return -(adot/a**2)*k1
def a_2(x,y,z):
return (1/a)*k_dx
.
.
.
.