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

25 lines
848 B
Python
Raw Normal View History

2019-07-31 13:13:24 +02:00
from typing import Union
2019-05-02 11:30:33 +02:00
import numpy as np
from numpy import ndarray
from scipy.interpolate import Rbf
from interpolators.base import BaseInterpolator
class RbfInterpolator(BaseInterpolator):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.rbfi = Rbf(*self.points.T, self.values, function="linear")
2019-07-31 13:13:24 +02:00
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:
2019-08-01 15:23:20 +02:00
size = alpha.shape[0]
2019-07-31 13:13:24 +02:00
results = np.zeros_like(alpha)
for x in range(alpha.shape[0]):
for y in range(alpha.shape[0]):
2019-08-01 15:23:20 +02:00
results[size - 1 - x][size - 1 - y] = self.rbfi(alpha[0][x], v[y][0], mcode, gamma, wt, wp)
2019-07-31 13:13:24 +02:00
return results