[Numpy-discussion] Detecting phase windings
Gary Ruben
gruben@bigpond.net...
Fri Jun 20 04:09:49 CDT 2008
Hi Anne,
Thanks for the approach ideas - I'll take a look at this soon to try to
understand it. Currently I'm visiting a LabView-based lab who already
have something that works, and works fast, so I'm being encouraged to
use LabView, but I'd like to show them more of the joys of Python. The
memory requirements aren't yet an issue with the data sets I'm using,
but they could be later.
Anne Archibald wrote:
> 2008/6/16 gruben@bigpond.net.au <gruben@bigpond.net.au>:
>> I have a speed problem with the approach I'm using to detect phase
>> wrappings in a 3D data set.
<big snip>
> I'd start by looking at the problem one face at a time:
> def find_vortices(X, axis=0):
> XX = np.rollaxis(X,axis)
> loop = np.concatenate((XX[np.newaxis,:-1,:-1,...],
> XX[np.newaxis,1:,:-1,...],
> XX[np.newaxis,1:,1:,...],
> XX[np.newaxis,:-1,1:,...],
> XX[np.newaxis,:-1,:-1,...]),axis=0)
> loop = np.unwrap(loop)
> r = np.abs(loop[0,...]-loop[-1,...])<np.pi/2
> return np.rollaxis(r,0,axis+1)
<snip>
> standard trick for cutting down on temporary sizes: use a for loop
> along the smallest dimension and a vector along the rest. In fact in
> this case I'd use a 2D vortex finder and iterate along the remaining
> axis; do this three times and you're done.
I might also try three 1D finders, keeping three temporary boolean
result arrays, then logically OR them.
thanks,
Gary R.
More information about the Numpy-discussion
mailing list