Borehole NMR processing
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

notch.py 900B

12345678910111213141516171819202122232425262728293031323334353637
  1. from numpy import pi, cos, zeros
  2. def notch(x, R, fn, dt, scale=True):
  3. '''Simple Pole and Zero Notch Filter. Note that this filter
  4. is not zero phase, if you need a zero phase filter use
  5. zpnotch.
  6. x # Input Sequence
  7. fn # Frequency to Filter
  8. R # Pole and Zero locations
  9. dt # Sampling rate
  10. '''
  11. wn = 2. * pi * fn * dt
  12. b0 = 1.
  13. b1 = -2.*cos(wn)
  14. b2 = 1.
  15. a1 = -R*2.*cos(wn)
  16. a2 = R*R
  17. if scale == True:
  18. sc = (1. + a1 + a2)/(b0 + b1 + b2)
  19. b0 *= sc
  20. b1 *= sc
  21. b2 *= sc
  22. xnm1 = 0.
  23. xnm2 = 0.
  24. ynm1 = 0.
  25. ynm2 = 0.
  26. y = zeros(len(x))
  27. for i in range(len(x)):
  28. y[i] = b0*x[i]+b1*xnm1+b2*xnm2-a1*ynm1-a2*ynm2
  29. xnm2 = xnm1
  30. xnm1 = x[i]
  31. ynm2 = ynm1
  32. ynm1 = y[i]
  33. return y