[Numpy-discussion] calcul of phase (dividing by 0)
Alexandre.Fayolle at logilab.fr
Thu Feb 10 07:27:41 CST 2005
On Thu, Feb 10, 2005 at 03:16:23PM +0100, Jean-Luc Menut wrote:
> I'm want to have the modulus and the phase of a fourier transform of 2D
> array, so I use the numarray FFT to compute the FT of the array (let's
> call it ff) and I use abs(ff) for the modulus and atan(ff.imag/ff.real)
> for the phase.
> My problem comes when ff.real = 0, I have either inf or nan as result
> (which is perfectly good and useful). I looking for a function which
> replace atan(ff.imag/ff.real) by 0 when ff.real is 0.
> I'm currently using a loop, and I think it's not very good (I call this
> function very often). Since the determination of the phase is something
> really useful and often used, I think there is probably a lot of people
> who had the same problem.
> So what solutions do you use?
Maybe you could try:
from Numeric import *
>>> a = array([1, 1j,])
array([ 0. , 1.57079633])
Alexandre Fayolle LOGILAB, Paris (France).
http://www.logilab.com http://www.logilab.fr http://www.logilab.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: Digital signature
Url : http://projects.scipy.org/pipermail/numpy-discussion/attachments/20050210/b339f54c/attachment-0001.bin
More information about the Numpy-discussion