Ejemplo n.º 1
0
"""

from signalUtility import functionGenerator
from signalUtility import oscilloscope
from signalUtility import sampler
from signalUtility import reconstructor
from scipy import signal as scipySignal
from copy import copy
import sys
import numpy as np
import scipy.fftpack as scipyFFT
from signalUtility import signalType


# Create three different types waveform 
f1 = functionGenerator()
s1= copy(f1.sinWaveformGenerate(frequency = 100, noOfCycle=20, phase = 0))
# Add gaussian noise to signal 1
s2 = copy(f1.addNoise(s1,noiseType='gaussian', parameter1=0,parameter2=0.1))
# sample noisy signal, sampling frequency is 10 times of original signal about original signal
# this is s2 signal which we will be getting in real scenario, we assume that we have some idea
# (like it's frequency, if we don't have any previous information we can visualise the signal and try to extract some info) so we will be able to design filter.
adc = sampler()
Fs=10000
s3 =  copy(adc.sampleSignal(s2,samplingFrequency=Fs))

o1=oscilloscope(title='Signal Visualisation')
o1.addWaveform(s1,plotColor='C0', plotLabel='Original Signal')
o1.addWaveform(s2,plotColor='C1', plotLabel='Noisy signal')
o1.addWaveform(s3,plotType='discrete',plotColor='C2', plotLabel='sampled discrete signal')
Ejemplo n.º 2
0
from signalUtility import reconstructor
from signalUtility import signalType
from scipy import signal as scipySignal
from copy import copy
import sys
import numpy as np
import scipy.fftpack as scipyFFT


# create analog signals.
"""
time duration of each signal = 1 sec
to maintain same data length for each signal in 1 sec time duration dataPerCycle has been changed, 
because for addition each should have same length
"""
f_10 = functionGenerator(dataPerCycle=1000)
f_100= functionGenerator(dataPerCycle=100)
f_1000= functionGenerator(dataPerCycle=10)

s_10 = copy(f_10.sinWaveformGenerate(frequency=10,noOfCycle=3))
s_100 =  copy(f_100.sinWaveformGenerate(frequency=100,noOfCycle=30))
s_1000 =  copy(f_1000.sinWaveformGenerate(frequency=1000,noOfCycle=300))

s_add = signalType()
s_add.time = copy(s_10.time)
s_add.value = copy(s_10.value + s_100.value +s_1000.value)

s = copy(f_10.addNoise(s_add,noiseType='gaussian',parameter1=0, parameter2=0.3))

Fs = 10000
adc = sampler()