from yafdtd.utils import fft
from math import sin, cos, pi


time = numpy.arange(0,20,0.01)

no_module = [gaussian(t, 10, 3) for t in time]
pylab.subplot(2,2,1)
pylab.plot(time, no_module)

cos_module = [cos(2*pi*0.5*t)*gaussian(t, 10, 3) for t in time]
sin_module = [sin(2*pi*0.5*t)*gaussian(t, 10, 3) for t in time]
pylab.subplot(2,2,2)
pylab.plot(time, cos_module)
pylab.plot(time, sin_module)

pylab.subplot(2,2,3)
freq, no_module_spec = fft(time, no_module, 0.01)
pylab.plot(freq[990:1010], no_module_spec[990:1010])

pylab.subplot(2,2,4)
freq, cos_module_spec = fft(time, cos_module, 0.01)
freq, sin_module_spec = fft(time, sin_module, 0.01)
pylab.plot(freq[980:1020], cos_module_spec[980:1020])
pylab.plot(freq[980:1020], sin_module_spec[980:1020])


pylab.show()


Exemple #2
0
dx = 10**-9
dt = dx/(2*c)
freq = c/200e-9

print freq


pylab.subplot(2,1,1)

time = numpy.arange(20001)
g = [cos(2*pi*freq*t*dt) for t in time]
pylab.plot(time, g)

g = [gaussian(t*dt, center*dt, width*dt) for t in time] # timing dt isn't necessary due to perfect scaling
pylab.plot(time, g)

g = [cos(2*pi*freq*t*dt)*gaussian(t*dt, center*dt, width*dt) for t in time]
pylab.plot(time, g)



pylab.subplot(2,1,2)

freq, spectrum = fft(time, g, dt)
pylab.plot(freq, spectrum)
pylab.xlim(0,4e15)

pylab.show()

Exemple #3
0
sys.path.append(".")
from yafdtd.source import gaussian
from yafdtd.utils  import fft
from math import pi, sin, cos

DEBUG = 0

n = numpy.float(2**10)
freq = 25

dt = 1./1024

t = numpy.arange(n)*dt
timedomain = numpy.cos(2*numpy.pi*freq*t)

f, freqdomain = fft(t, timedomain, dt)

if DEBUG:
  for item in zip(f,freqdomain.round()):
    print item

pylab.subplot(2,2,1)
pylab.plot(t,timedomain)
pylab.xlim(0, n*dt)

pylab.subplot(2,2,3)
pylab.plot(f,freqdomain)
pylab.xlim(-n/2,n/2)


n = numpy.float(2**18)