I want to generate a sinewave with Gaussian noise and save the generated waveform data as a data set. in the next step, I want to find the frequency of the waveform. here is my code(but i don't know why the code isn't working)?
import numpy as np
import scipy as sy
import scipy.fftpack as syfp
import pylab as pyl
import matplotlib.pyplot as plt
import pandas as pd
import sys
import math
import scipy.stats as stats
import serial
dt = 0.03071
t = dt*np.arange(100000) ## time at the same spacing of your data
u = np.sin(2*np.pi*t*.01)
df= pd.dataframe(u, columns=['data'])
np.random.seed(0)
ds = np.random.randn(1000)
rd = [0]
for i in ds:
rd.append( np.sin(i*0.7 )+ i)
df = pd.DataFrame(rd, columns=['data'])
# Do FFT analysis of array
FFT = sy.fft(u)
# Getting the related frequencies
freqs = syfp.fftfreq(len(u), dt) ## added dt, so x-axis is in meaningful units
# Create subplot windows and show plot
pyl.subplot(211)
pyl.plot(t, u)
pyl.xlabel('Time')
pyl.ylabel('Amplitude')
pyl.subplot(212)
pyl.plot(freqs, sy.log10(abs(FFT)), '.') ## it's important to have the abs here
pyl.xlim(-.05, .05) ## zoom into see what's going on at the peak
pyl.show()