# stockwelltransform / examples / synthetic2.py

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71``` ```# -*- coding: utf-8 -*- """ Created on Mon Jan 03 19:19:16 2011 @author: Chris Lee-Messer """ import numpy as np import stockwell.smt as smt import stockwell Fs = 200 P = 1.0/Fs T = 10.0 t = np.arange(0,T,P) L = len(t) twopi = 2*3.1415 # create a list of different sin waves at different frequencies ss = [np.sin(twopi*f*t) for f in [5,10,20,30,40,50,100,200,400]] y = np.zeros(L,dtype='float64') for s in ss: y+= s sy = smt.st(y) rsy = abs(sy) sy10 = smt.st(y,0,100) rsy10 = abs(sy10) K=4 lowf, hif = 0,500 tapers = smt.calc_tapers(K,L) mty = smt.mtst(K, tapers, y, lowf,hif) # dsplay with # figure(); imshow(mty); axis('auto') # which rows have which frequencies? freqticks = [stockwell.st_rowfreq(rr, Fs, L) for rr in [100,200,300,400,500]] # visualization import matplotlib.pyplot as plt from matplotlib.offsetbox import TextArea, DrawingArea, OffsetImage, \ AnnotationBbox from matplotlib.cbook import get_sample_data f = plt.figure() fa = plt.subplot(211) plt.plot(y) ax=plt.subplot(212) # plt.setp(ax, yticks=[10,25,50]) plt.imshow(rsy,aspect='auto') plt.ylabel('frequency(Hz)') yloc,ylab=plt.yticks() plt.title('Stockwell transform spectrogram') f2 = plt.figure() fa2 = plt.subplot(211) plt.plot(y) ax2_212=plt.subplot(212) # plt.setp(ax, yticks=[10,25,50]) plt.imshow(mty,aspect='auto') plt.ylabel('frequency(Hz)') yloc2,ylab2=plt.yticks() plt.title("multi-taper stockwell transform spectrogram") from mpl_toolkits.axes_grid1 import make_axes_locatable # divider = make_axes_locatable(ax) #cax = divider.append_axes("right", size="5%", pad=0.05) from mpl_toolkits.axes_grid1 import host_subplot ```