def _find_rOptimal(self,outputOffsetFactArr,errorArr):
     test=errorArr.copy()[1:]
     test=np.append(test,errorArr[0])
     numValidSolutions=np.sum(~np.isnan(errorArr))
     numNanInitial=np.sum(np.isnan(errorArr))
     numNanAfter=np.sum(np.isnan(test+errorArr))
     valid=True
     if numNanAfter-numNanInitial>1:
         valid=False
     elif numValidSolutions<4:
         valid=False
     elif numNanInitial>0:
         if (np.isnan(errorArr[0])==False and np.isnan(errorArr[-1])==False):
             valid=False
     if valid==False:
         return None
     #trim out invalid points
     outputOffsetFactArr=outputOffsetFactArr[~np.isnan(errorArr)]
     errorArr=errorArr[~np.isnan(errorArr)]
     fit=spi.RBFInterpolator(outputOffsetFactArr[:,np.newaxis],errorArr)
     outputOffsetFactArrDense=np.linspace(outputOffsetFactArr[0],outputOffsetFactArr[-1],10_000)
     errorArrDense=fit(outputOffsetFactArrDense[:,np.newaxis])
     rOptimal=outputOffsetFactArrDense[np.argmin(errorArrDense)]
     rMinDistFromEdge=np.min(outputOffsetFactArr[1:]-outputOffsetFactArr[:-1])/4
     if rOptimal>outputOffsetFactArr[-1]-rMinDistFromEdge or rOptimal<outputOffsetFactArr[0]+rMinDistFromEdge:
         # print('Invalid solution, rMin very near edge. ')
         return None
     return rOptimal
Ejemplo n.º 2
0
 def time_rbf_interpolator(self, neighbors, n_samples, kernel):
     interp = interpolate.RBFInterpolator(self.y,
                                          self.d,
                                          neighbors=neighbors,
                                          epsilon=5.0,
                                          kernel=kernel)
     interp(self.x)
Ejemplo n.º 3
0
 def __init__(self, coords, values, neighbors=None, smoothing=0, **kwargs):
     super().__init__(coords, values)
     self.rbf_interpolator = interpolate.RBFInterpolator(self.coords, self.values, neighbors=neighbors,
                                                         smoothing=smoothing, **kwargs)