[Numpy-discussion] calcul of phase (dividing by 0)

Andrea Riciputi ariciputi at pito.com
Thu Feb 10 06:42:53 EST 2005

Why not arctan2(ff.imag, ff.real)?


On 10 Feb 2005, at 15:16, Jean-Luc Menut wrote:

> Hello,
> 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?
> Thanks,
> Jean-Luc Menut
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real 
> users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion

More information about the NumPy-Discussion mailing list