improve RBF interpolator
This commit is contained in:
parent
758be79f30
commit
b33121e428
1 changed files with 11 additions and 14 deletions
|
@ -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
|
||||
|
|
Reference in a new issue