s = fakesignal.evaluate(t) + 0.05*np.random.randn(t.size) # subtract average, random numbers may not average to 0 s -= np.average(s) s_original = np.zeros_like(s) s_original[:] = s[:] # cosine bell hann = np.hanning(s.size) # Need to know Nyquist (more or less) nyuquist = 0.5/((t[1] - t[0])) fittedsignal = seismo.fitting.signal() freqs0, amps0 = seismo.deeming(t, s) noise = 4*np.median(amps0) # Find and subtract signal, until no signals above 4*median amplitude in # DFT is found while True: # calculate the DFT # apply hanning / cosine bell first freqs, amps = seismo.deeming(t, s) # find peak and fit it fmax, amax = seismo.timeseries.find_peak(freqs, amps) if amax < noise: break fittedsignal.add_component(seismo.fitting.sinewave(amax, fmax, 3.14, 0))
s = fakesignal.evaluate(t) + 0.05 * np.random.randn(t.size) # subtract average, random numbers may not average to 0 s -= np.average(s) s_original = np.zeros_like(s) s_original[:] = s[:] # cosine bell hann = np.hanning(s.size) # Need to know Nyquist (more or less) nyuquist = 0.5 / ((t[1] - t[0])) fittedsignal = seismo.fitting.signal() freqs0, amps0 = seismo.deeming(t, s) noise = 4 * np.median(amps0) # Find and subtract signal, until no signals above 4*median amplitude in # DFT is found while True: # calculate the DFT # apply hanning / cosine bell first freqs, amps = seismo.deeming(t, s) # find peak and fit it fmax, amax = seismo.timeseries.find_peak(freqs, amps) if amax < noise: break fittedsignal.add_component(seismo.fitting.sinewave(
import matplotlib from matplotlib.pyplot import subplot, plot, show from numpy import linspace, sin, pi import seismo matplotlib.style.use('ggplot') x = linspace(0, 0.05, 500) y = 0.6*sin(2*pi*240*x)\ + 0.15*sin(2*pi*1303*x + 0.4)\ + 0.1*sin(2*pi*3000*x) f, a = seismo.deeming(x, y) subplot(211) plot(x, y, '.') subplot(212) plot(f, a) show()
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) fig = plt.figure() # make some plots plt.subplot(211) plt.plot(t, s, '.') plt.xlabel("Time (days)") plt.ylabel("Magnitude") ymin, ymax = plt.ylim() plt.ylim(2*ymax, 2*ymin) plt.subplot(212) plt.plot(freqs, amps) plt.xlabel(r"Frequency (day$^{-1}$)") plt.ylabel("Amplitude (mag)")
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) fig = plt.figure() # make some plots plt.subplot(211) plt.plot(t, s, '.') plt.xlabel("Time (days)") plt.ylabel("Magnitude") ymin, ymax = plt.ylim() plt.ylim(2 * ymax, 2 * ymin) plt.subplot(212) plt.plot(freqs, amps) plt.xlabel(r"Frequency (day$^{-1}$)") plt.ylabel("Amplitude (mag)")