def simpleExample(): # Create a signal N = 256 signal = numpy.zeros(N,numpy.complex128) # Make our signal 1 in the middle, zero elsewhere signal[N/2] = 1.0 # plot our signal pylab.figure() pylab.plot(abs(signal)) # Do the GFT on the signal SIGNAL = gft.gft1d(signal,'gaussian') # plot the magnitude of the signal pylab.figure() pylab.plot(abs(SIGNAL),'b') # get the partitions partitions = gft.partitions(N) # for each partition, draw a line on the graph. Since the partitions only indicate the # positive frequencies, we need to draw partitions on both sides of the DC for i in partitions[0:len(partitions)/2]: pylab.axvline((N/2+i),color='r',alpha=0.2) pylab.axvline((N/2-i),color='r',alpha=0.2) # finally, interpolate the GFT spectrum and plot a spectrogram pylab.figure() pylab.imshow(abs(gft.gft1dInterpolateNN(SIGNAL)))
def plot1D(signal,window,figTitle=None): N = len(signal) x = numpy.arange(0,1,1./N) transform = gft.gft1d(signal,window) pylab.figure() pylab.subplot(211) if figTitle: pylab.title(figTitle) pylab.plot(x,signal.real,'b') pylab.plot(x,signal.imag,'b--') ax = pylab.axis() pylab.subplot(212) pylab.plot(x,transform.real,'b') pylab.plot(x,transform.imag,'g--') partitions = gft.partitions(N) for i in partitions[0:len(partitions)/2]: pylab.axvline((N/2+i)/float(N),color='r',alpha=0.2) pylab.axvline((N/2-i)/float(N),color='r',alpha=0.2)