local_interpolation(newx,
oldx,
oldy,
full_output=False)
| source code
|
A local interpolation method by a polynomial of degree 3.
After Marc-Antoine Dupret, 2002 (extended version of PhD thesis).
Cannot extrapolate!
>>> np.random.seed(1114)
>>> oldx = np.sort(np.random.uniform(size=10))
>>> oldy = oldx**2
>>> oldy[5:] = -oldx[5:]**2
>>> newx = np.linspace(oldx.min(),oldx.max(),1000)
>>> newy,disconts = local_interpolation(newx,oldx,oldy,full_output=True)
>>> newy_ = local_interpolation(newx,oldx,oldy)
>>> sharpy = newy.copy()
>>> sharpy[disconts] = np.nan
>>> smoothy = newy.copy()
>>> smoothy[-disconts] = np.nan
>>> p = pl.figure()
>>> p = pl.plot(oldx,oldy,'ks-',ms=10)
>>> p = pl.plot(newx,smoothy,'go-',lw=2,ms=2,mec='g')
>>> p = pl.plot(newx,sharpy,'ro-',lw=2,ms=2,mec='r')
>>> p = pl.plot(newx,newy_,'bo--',lw=2,ms=2,mec='b')
- Parameters:
newx (ndarray) - new x-array to interpolate on
oldx (ndarray) - old x-array to interpolate from
oldy (ndarray) - old y-array to interpolate from
full_output (boolean) - also return points where discontinuities were detected
- Returns: ndarray(,ndarray)
- interpolated array(, discontinuities)
|