Package ivs :: Package sigproc :: Module interpol
[hide private]
[frames] | no frames]

Module interpol

source code

Non-standard interpolation methods.

Functions [hide private]
 
__df_dx(oldx, oldy, index, sharp=False)
Preliminary estimation of df/dx
source code
 
__P1(x, x0, x1) source code
 
__P2(x, x0, x1) source code
 
__P3(x, x0, x1) source code
 
__P4(x, x0, x1) source code
ndarray(,ndarray)
local_interpolation(newx, oldx, oldy, full_output=False)
A local interpolation method by a polynomial of degree 3.
source code
 
local_interpolation_ND(newx, oldx, oldy) source code
 
create_pixeltypegrid(grid_pars, grid_data)
Creates pixelgrid and arrays of axis values.
source code
array
interpolate(p, axis_values, pixelgrid)
Interpolates in a grid prepared by create_pixeltypegrid().
source code
Function Details [hide private]

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#np.random.uniform(size=10)
>>> 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)

create_pixeltypegrid(grid_pars, grid_data)

source code 

Creates pixelgrid and arrays of axis values.

Starting from:
    * grid_pars: 2D numpy array, 1 column per parameter, unlimited number of cols
    * grid_data: 2D numpy array, 1 column per variable, data corresponding to the rows in grid_pars

The grid should be rectangular and complete, i.e. every combination of the unique values in the 
parameter columns should exist. If not, a nan value will be inserted.

@param grid_pars: Npar x Ngrid array of parameters
@type grid_pars: array
@param grid_data: Ndata x Ngrid array of data
@type grid_data:array
@return: axis values and pixelgrid
@rtype: array, array

interpolate(p, axis_values, pixelgrid)

source code 

Interpolates in a grid prepared by create_pixeltypegrid().

p is an array of parameter arrays

Parameters:
  • p (array) - Npar x Ninterpolate array
Returns: array
Ndata x Ninterpolate array