Exemple #1
0
# Determine Nyquist and set generator frequency
fmax=1.0/(2*dt) # nyquist
fg = 2.0 # Hz

# Generate f0 Hz sine wave
pg = 1.0/fg #in seconds
time = np.linspace(0,npts*dt,npts) # in seconds
y = np.sin(2*PI/pg * time + PI/5)

# Hanning window
win_han = np.hanning(npts)
y_han = y * win_han

# Filter the trace
f0 = 3.0 #cut off frequency
freq, H, y_1 = filter_bc(y,dt,3.0)
freq, H, y_2 = filter_bc(y_han,dt,3.0)

# Just for plotting the frequency domain
y_f = np.fft.rfft(y)
y_f2 = np.fft.rfft(y_han)

# Remove offset
freq = freq[1:]
y_f = y_f[1:]
y_f2 = y_f2[1:]

# Print rms (root-mean-square)
print "Orig data/filtered RMS", np.sqrt(np.mean((y - y_1)**2))
print "Tapered data/filtered RMS", np.sqrt(np.mean((y_han - y_2)**2))
Exemple #2
0
# Determine Nyquist and set generator frequency
fmax = 1.0 / (2 * dt)  # nyquist
fg = 2.0  # Hz

# Generate f0 Hz sine wave
pg = 1.0 / fg  #in seconds
time = np.linspace(0, npts * dt, npts)  # in seconds
y = np.sin(2 * PI / pg * time + PI / 5)

# Hanning window
win_han = np.hanning(npts)
y_han = y * win_han

# Filter the trace
f0 = 3.0  #cut off frequency
freq, H, y_1 = filter_bc(y, dt, 3.0)
freq, H, y_2 = filter_bc(y_han, dt, 3.0)

# Just for plotting the frequency domain
y_f = np.fft.rfft(y)
y_f2 = np.fft.rfft(y_han)

# Remove offset
freq = freq[1:]
y_f = y_f[1:]
y_f2 = y_f2[1:]

# Print rms (root-mean-square)
print "Orig data/filtered RMS", np.sqrt(np.mean((y - y_1)**2))
print "Tapered data/filtered RMS", np.sqrt(np.mean((y_han - y_2)**2))
Exemple #3
0
dt = 0.05

# Determining nyquist frequency and asking for cut off frequency f0
fmax = 1.0 / (2 * dt)  # nyquist
f0 = float(raw_input('Give cut-off below Nyquist: fmax = %4.1f Hz ' % fmax))
print 'f0 =', f0

# Uncomment from random points
#y = random.rand(npts) - .5 # uniform random numbers, zero mean

# Spike at npts/2
y = np.zeros(npts, dtype='float')
y[npts / 2] = 1

# Filter with filter_bc
freq, H, y_filt = filter_bc(y, dt, f0)

# Just for the plot, frequency domain representaion of y
y_f = np.fft.rfft(y)

# Remove offset
y_f = y_f[1:]
freq = freq[1:]
H = H[1:]

# For convenience
time = np.arange(0, npts) * dt

#
# Plot the whole filtering process
#
Exemple #4
0
dt=0.05

# Determining nyquist frequency and asking for cut off frequency f0
fmax=1.0/(2*dt) # nyquist
f0 = float(raw_input('Give cut-off below Nyquist: fmax = %4.1f Hz ' % fmax))
print 'f0 =', f0

# Uncomment from random points
#y = random.rand(npts) - .5 # uniform random numbers, zero mean

# Spike at npts/2
y = np.zeros(npts,dtype='float')
y[npts/2] = 1

# Filter with filter_bc
freq, H, y_filt = filter_bc(y,dt,f0)

# Just for the plot, frequency domain representaion of y
y_f = np.fft.rfft(y)

# Remove offset
y_f = y_f[1:]
freq = freq[1:]
H = H[1:]

# For convenience
time = np.arange(0,npts)*dt



#