Noised Sine wave


In [1]:
%matplotlib inline

In [3]:
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import medfilt
# Add a new path with needed .py files.
sys.path.insert(0, 'C:\Users\Dowa\Desktop\Hiwi\kt-2015-DSPHandsOn\MedianFilter\Python') 

import functions

In [32]:
from pylab import *
def parameters():
    params = {
   'axes.labelsize': 14,
   'text.fontsize': 8,
   'legend.fontsize': 15,
   'xtick.labelsize': 12,
   'ytick.labelsize': 12,
   'text.usetex': False,
   'figure.figsize': [10, 5]
   }
    rcParams.update(params)

In [33]:
x = np.linspace(0, 2, 16*128)
data = np.sin(16*np.pi*x)
data = data[128*5+1: -128*5-1]
noise = np.random.normal(0,0.3, len(data))

In [38]:
plt.figure()
parameters()
ax = plt.subplot()
xticks = np.arange(0, len(data)+1, 128)
ax.set_xticks(xticks)
x_label = [r"${%s\pi}$" % (2*w) for w in range(0, len(xticks))]
ax.set_xticklabels(x_label)
ax.set_ylim([-3,3])
plt.plot(noise+data, color = "cornflowerblue")
plt.savefig("noised sine.jpg", dpi = 600, format = "jpeg")



In [ ]: