1
0
Fork 0
mirror of https://github.com/Findus23/collision-analyisis-and-interpolation.git synced 2024-09-19 15:13:50 +02:00

improve RBF interpolator

This commit is contained in:
Lukas Winkler 2019-07-31 13:13:24 +02:00
parent 758be79f30
commit b33121e428
Signed by: lukas
GPG key ID: 54DE4D798D244853

View file

@ -1,3 +1,5 @@
from typing import Union
import numpy as np
from numpy import ndarray
from scipy.interpolate import Rbf
@ -10,17 +12,12 @@ class RbfInterpolator(BaseInterpolator):
super().__init__(*args, **kwargs)
self.rbfi = Rbf(*self.points.T, self.values, function="linear")
def interpolate(self, alpha, v, mcode, gamma, wt, wp) -> ndarray:
results = np.zeros_like(alpha)
# print(v[30][0])
# exit()
for x in range(alpha.shape[0]):
for y in range(alpha.shape[0]):
results[99 - x][99 - y] = self.rbfi(alpha[0][x], v[y][0], mcode, gamma, wt, wp)
# print(alpha[0][x], v[y][0])
# print(results)
# print(self.rbfi(alpha[0][99], v[30][0], mcode, gamma, wt, wp))
# print(self.rbfi(60, 2.2, mcode, gamma, wt, wp))
# exit()
return results
def interpolate(self, alpha, v, mcode, gamma, wt, wp) -> Union[ndarray, float]:
if not alpha.shape:
return self.rbfi(alpha, v, mcode, gamma, wt, wp)
else:
results = np.zeros_like(alpha)
for x in range(alpha.shape[0]):
for y in range(alpha.shape[0]):
results[99 - x][99 - y] = self.rbfi(alpha[0][x], v[y][0], mcode, gamma, wt, wp)
return results