# PYME.contrib.congrid module¶

PYME.contrib.congrid.congrid(a, newdims, method='linear', centre=False, minusone=False)

Arbitrary resampling of source array to new dimension sizes. Currently only supports maintaining the same number of dimensions. To use 1-D arrays, first promote them to shape (x,1).

Uses the same parameters and creates the same co-ordinate lookup points as IDL’’s congrid routine, which apparently originally came from a VAX/VMS routine of the same name.

method: neighbour - closest value from original data nearest and linear - uses n x 1-D interpolations using

scipy.interpolate.interp1d

(see Numerical Recipes for validity of use of n 1-D interpolations) spline - uses ndimage.map_coordinates

centre: True - interpolation points are at the centres of the bins False - points are at the front edge of the bin

minusone: For example- inarray.shape = (i,j) & new dimensions = (x,y) False - inarray is resampled by factors of (i/x) * (j/y) True - inarray is resampled by(i-1)/(x-1) * (j-1)/(y-1) This prevents extrapolation one element beyond bounds of input array.