[SciPy-dev] Arbitrary n-dimensional rebin routine
Angus McMorland
a.mcmorland at auckland.ac.nz
Wed Apr 12 00:48:24 CDT 2006
Okay, my first reply is to myself, with all the bits I forgot to add.
Angus McMorland wrote:
>
[snip]
import numpy as n
import scipy.interpolate
def nvals(n, dims):
'''Returns xvals-like volumes, indexing over any dimension n.
Will probably crash and burn if n >= len(dims).'''
evList = ''
for i in range( len(dims) - 1):
if i < n:
evList = evList + '%d' % dims[i]
else:
evList = evList + '%d' % dims[i + 1]
if i < len(dims) - 2:
evList = evList + ', '
evList = 'xvals( (%d,' % dims[n] + evList + ')' + ')'
xs = eval( evList )
evList = ''
for i in range( len(dims) ):
if i < n:
ind = i + 1
elif i == n:
ind = 0
else:
ind = i
evList = evList + '%d' % ind
if i < len(dims) - 1:
evList = evList + ', '
evList = 'xs.transpose(' + evList + ')'
return eval( evList )
> def congrid(a, nud, method='neighbour', centre=False, minusone=False):
> '''Arbitrary resampling of source array to new dimension sizes.
[snip]
Also the docstring should have something about the first couple of params:
Usage:
arg0: input array
arg1: tuple of resulting dimensions
Example:
rebinned = rebin.congrid( raw, (2,2,2), \
method=[neighbour|linear|cubic|spline], \
minusone=[True|False], \
centre=[True|False])
Let's try again.
--
Angus McMorland
email a.mcmorland at auckland.ac.nz
mobile +64-21-155-4906
PhD Student, Neurophysiology / Multiphoton & Confocal Imaging
Physiology, University of Auckland
phone +64-9-3737-599 x89707
Armourer, Auckland University Fencing
Secretary, Fencing North Inc.
More information about the Scipy-dev
mailing list