In [2]:
%pylab inline
import math
Test scaling of spectral values. We can directly scale .r and .i instead of calculating magnitude and phase. This avoids trouble with atan2() computations which are sensitive to float precission.
In [3]:
def scale(r,i,f):
m = math.sqrt(r*r+i*i)
p = math.atan2(i,r)
print "%5.3f, %5.3f" % (f * m * math.cos(p), f * m * math.sin(p))
print "%5.3f, %5.3f" % (f * r, f * i)
In [4]:
scale(1,1,2)
In [5]:
scale(1,0,2)
In [6]:
scale(1,-1,2)
In [7]:
scale(0,1,2)
In [ ]: