def threeD_MM(a, res, o, nAngles=2, verboseLvl=1, tmp='/tmp/'): import Mrc if o < 1: raise ValueError, "order need to >= 1" if nAngles < 1: raise ValueError, "nAngles need to >= 1" if verboseLvl >=1: import time startTime = time.clock() res[:] = 0 # aWV = Mrc.bindNew(tmp+"wvl_aWV", N.float32, a.shape) # aRot= Mrc.bindNew(tmp+"wvl_aRot", N.float32, a.shape) # c = Mrc.bindNew(tmp+"wvl_c", N.float32, a.shape) aWV = F.zeroArrF(a.shape) angles = N.arange(90./nAngles, 90., 90./nAngles) nOffAngles = len(angles) # = nAngles -1 # do first fastwv6 on original data if verboseLvl >=1: print "begin angle 0" if verboseLvl >=2: print print " perm " Y.refresh() for i in range(len(_perm)): if verboseLvl >=2: print " ", i Y.refresh() tmpTrans = N.transpose(a, _perm[i]).copy() # force contiguous! aWV.shape = tmpTrans.shape W.fastwv6(tmpTrans,aWV, o,o,o, verboseLvl>=3) tmpTrans = N.transpose(aWV,_invperm[i]) tmpTrans /= len(_perm) * (1 + (nOffAngles * 3)) res += tmpTrans # now do it for a bunch of angles if len(angles): c = Mrc.bindNew(tmp+"wvl_c", N.float32, a.shape) for angle in angles: for axis in (0,1,2): if verboseLvl >=1: print "begin angle ",angle print " axis:", axis Y.refresh() aRot = aWV U.rot3d(a,aRot, angle, axis) if verboseLvl >=2: print " perm " c[:] = 0 for i in range(len(_perm)): #dbg print " perm:", i if verboseLvl >=2: print " ", i Y.refresh() tmpTrans = N.transpose(aRot, _perm[i]).copy() # force contiguous! aWV.shape = tmpTrans.shape W.fastwv6(tmpTrans,aWV, o,o,o, verboseLvl>=3) tmpTrans = N.transpose(aWV,_invperm[i]) tmpTrans /= len(_perm) * (1 + (nOffAngles * 3)) c += tmpTrans U.rot3d(c,aRot,-angle,axis) res += aRot if verboseLvl >=1: print if verboseLvl >=1: import time d = time.clock()-startTime print "time: %.2lf secs - %.2lf min - %.2lf h " % (d, d/60., d/60./60.)