rebin ndarray data into a smaller ndarray of the same rank whose dimensions
are factors of the original dimensions. eg. An array with 6 columns and 4 rows
can be reduced to have 6,3,2 or 1 columns and 4,2 or 1 rows.
example usages:
>>> a=rand(6,4); b=rebin(a,3,2)
>>> a=rand(6); b=rebin(a,2)
Definition at line 2 of file arrays.py.
3 '''rebin ndarray data into a smaller ndarray of the same rank whose dimensions 4 are factors of the original dimensions. eg. An array with 6 columns and 4 rows 5 can be reduced to have 6,3,2 or 1 columns and 4,2 or 1 rows. 7 >>> a=rand(6,4); b=rebin(a,3,2) 8 >>> a=rand(6); b=rebin(a,2) 12 factor = numpy.asarray(shape)/numpy.asarray(args)
13 evList = [
'a.reshape('] + \
14 [
'args[%d],factor[%d],'%(i,i)
for i
in range(lenShape)] + \
15 [
')'] + [
'.sum(%d)'%(i+1)
for i
in range(lenShape)] + \
16 [
'/factor[%d]'%i
for i
in range(lenShape)]
18 return eval(
''.join(evList))