473,385 Members | 1,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

high-pass filter implementation in python

Hi
I want to subtract all the behaviour that have length scale bigger than data-length/10 from each vector. Here is the function I wrote:

Expand|Select|Wrap|Line Numbers
  1. def hpass(vec):
  2.     cutoff_hz = len(vec)/10.
  3.     sample_rate=len(vec)
  4.     nyq_rate = sample_rate / 2.
  5.     numtaps = 10
  6.     warmup = numtaps - 1
  7.     fir_coeff = firwin(numtaps, cutoff_hz/nyq_rate)
  8.     delay = (warmup) #/ sample_rate
  9.     t=np.arange(len(vec))
  10.     t-=delay
  11.     ln=len(t)-delay
  12.     t=t[:ln]
  13.     fl= lfilter(fir_coeff,1.0,vec)
  14.     tmp=vec[:ln]-fl[t]
  15.     filtered=(tmp)
  16.         return filtered
but apparently this does not work probably since the delay part is not calculated right, can anybody help me with this?

Cheers
Apr 10 '13 #1
1 2314
YarrOfDoom
1,247 Expert 1GB
It's been a while since I've done anything frequency related so could you explain what the value for delay should be?
Right now it is equal to warmup, since half of line 8 is commented out.

If you're using Python 2.x rather than 3.x the problem might be integer division related since warmup and sample_rate are both integer values (assuming you're using the full line 8 without anything commented out). Python 3.x integer division results in a float (so 3/2=1.5), but 2.x versions still have classic integer division where the results are rounded down (3/2=1).
Apr 17 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Wiebke Pätzold | last post by:
Hi all! I have to work with MetaKit. My job is it to filter. For example: If I search for the initial letter "P", the programm should all results print with this characteristic. Couls somebody...
9
by: Robin Cull | last post by:
Imagine I have a dict looking something like this: myDict = {"key 1": , "key 2": , "key 3": , "key 4": } That is, a set of keys which have a variable length list of associated values after...
5
by: Mailer | last post by:
Hello, all, Well, I need to write a mail filter in Python. The filter will be used in shared web hosting environment, so the control over MTA configuration etc is limited. The basic premise,...
1
by: Woojtos | last post by:
Hi, I have a problem. I don't know how to create lowpass, highpass and bandpass filter. I capture the sound using CaptureBuffer from DirectX library. Then I create memory buffor as follow: ...
21
by: Dmitry Anikin | last post by:
I mean, it's very convenient when default parameters can be in any position, like def a_func(x = 2, y = 1, z): ... (that defaults must go last is really a C++ quirk which is needed for overload...
1
by: korndevil666 | last post by:
hi, has anyone written / programmed a spam filter in python? i am quite new to python and wanted to write my own script but wanted a working example to work off? thanks for any help
0
by: Chris Curvey | last post by:
Hi all, I'm trying to write an ISAPI filter in Python, using the examples that come in the "isapi" directory of the win32com package. The installation program itself runs fine, but when I...
3
by: azrael | last post by:
Hy guys. I'd like to ask you for a favour. I tried several times to implement the otsu threshold filter in python. but I failed every time. I found the soucre code i n Java from the ImageJ...
6
by: kellygreer1 | last post by:
What is the best way to filter a Python list to its unique members? I tried some method using Set but got some "unhashable" error. lstone = # how do i reduce this to lsttwo = Is there a...
2
by: Mathieu Prevot | last post by:
Hi, I use in a bourne shell script the following filter: sed '/watch?v=/! d;s/.*v=//;s/\(.\{11\}\).*/\1/' \ | sort | uniq | awk 'ORS=" "{print $1}' that give me all sets of 11 characters...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.