示例#1
0
def create_fake_data(N):
    ''' Given number of signal components N, return signal object containing N components with random frquencies, amplitudes and phases.
    '''

    signal = seismo.signal()

    print("Fake numbers")
    for i in range(N):
        amplitude = 0.1*np.random.rand()
        frequency = np.random.rand()*300
        phase = np.random.rand()*np.pi

        component = seismo.sinewave(amplitude, frequency, phase, 0)
        # add component to signal
        signal.add_component(component)

        print("{}, {}, {}".format(amplitude, frequency, phase))

    return signal
示例#2
0
def create_fake_data(N):
    ''' Given number of signal components N, return signal object containing N components with random frquencies, amplitudes and phases.
    '''

    signal = seismo.signal()

    print("Fake numbers")
    for i in range(N):
        amplitude = 0.1 * np.random.rand()
        frequency = np.random.rand() * 300
        phase = np.random.rand() * np.pi

        component = seismo.sinewave(amplitude, frequency, phase, 0)
        # add component to signal
        signal.add_component(component)

        print("{}, {}, {}".format(amplitude, frequency, phase))

    return signal
示例#3
0
import matplotlib
from matplotlib.pyplot import subplot, plot, show
from numpy import linspace, sin, pi, random
import seismo

matplotlib.style.use('ggplot')

x = linspace(0, 0.05, 500)
y = 0.6*sin(2*pi*240*x) + 0.2*random.randn(x.size)

f, a = seismo.deeming(x, y)
fmax, amax = seismo.find_peak(f, a)

signal = seismo.signal()
comp1 = seismo.sinewave(amax, fmax, 0)

signal.add_component(comp1)

signal.fit(x, y)

plot(x, y, '.')
plot(x, signal.evaluate(x), lw=2)
show()
示例#4
0
if __name__ == "__main__":
    # create some fake data
    t = np.linspace(0, 20, 10000)

    # let's add some random sine waves
    N_signals = 5

    signal = seismo.signal()

    for i in range(N_signals):
        amplitude = 0.01*np.random.rand()
        frequency = np.random.rand()*200
        phase = np.random.rand()*np.pi

        component = seismo.sinewave(amplitude, frequency, phase, 0)
        # add component to signal
        signal.add_component(component)

    # evaluate signal at times
    s = signal.evaluate(t) + 0.025*np.random.randn(t.size)

    # now calculate the DFT
    # Need to know Nyquist (more or less)
    nyuquist = 0.5/((t[1] - t[0]))

    # need to know freq resolution and oversample
    fres = 1.0/(t[-1] - t[0])
    freqs = np.linspace(0, nyuquist, 5*int(nyuquist/fres))
    freqs, amps = seismo.deeming(t, s, freqs)
示例#5
0
if __name__ == "__main__":
    # create some fake data
    t = np.linspace(0, 20, 10000)

    # let's add some random sine waves
    N_signals = 5

    signal = seismo.signal()

    for i in range(N_signals):
        amplitude = 0.01 * np.random.rand()
        frequency = np.random.rand() * 200
        phase = np.random.rand() * np.pi

        component = seismo.sinewave(amplitude, frequency, phase, 0)
        # add component to signal
        signal.add_component(component)

    # evaluate signal at times
    s = signal.evaluate(t) + 0.025 * np.random.randn(t.size)

    # now calculate the DFT
    # Need to know Nyquist (more or less)
    nyuquist = 0.5 / ((t[1] - t[0]))

    # need to know freq resolution and oversample
    fres = 1.0 / (t[-1] - t[0])
    freqs = np.linspace(0, nyuquist, 5 * int(nyuquist / fres))
    freqs, amps = seismo.deeming(t, s, freqs)