Search the web
Sign In
New User? Sign Up
PhillyPug · Python Users Group
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
How to use Classes and Definitions?   Message List  
Reply | Forward Message #269 of 364 |
Dear Python users,

I am trying to use a piece of coding for FFT filtering, but I haven't
figure out how to implement the definitions. The Python tutorials
mention something about it, but it is not working for me. The piece
of code that I want to use is posted below. Now, I am interested in
using the function defined as filter (def filter). It seemed to me,
that something like this should work (but it does not):

myFilter = Filter() # This is to call the class.
y_filtered = myFilter.filter(y_raw) # To filter the raw signal.

Thank you all for your kind attention.
Best Regards, Peter

###############################################
class Filter:
def set_cutoff(self,cutoff):
self.cutoff = cutoff

def set_band(self,f1, f2):
self.f1 = f1
self.f2 = f2

def filter(self,x,y):
self.delta = x[1] - x[0]
self.f_Nyquist = 1.0 / 2.0 / self.delta
self.N = len(x)

self.fft = fft(y)

self.freqs = array(range(len(self.fft))) / self.delta / len
(self.fft)
N = len(self.freqs)
for i in range(N/2):
self.freqs[N/2+i] = - self.freqs[N/2-i]

self.calculate_condition()
for i in range(len(self.freqs)):
print '%10d %10f %2d' % ( i, self.freqs[i], self.cond[i] )
self.filtered_fft = self.cond * self.fft
self.filtered_y = inverse_fft(self.filtered_fft)

return self.filtered_y

def calculate_condition(self):
pass
################################################






Mon Mar 24, 2008 5:23 pm

plpd00
Offline Offline
Send Email Send Email

Forward
Message #269 of 364 |
Expand Messages Author Sort by Date

Dear Python users, I am trying to use a piece of coding for FFT filtering, but I haven't figure out how to implement the definitions. The Python tutorials ...
Peter Perez
plpd00
Offline Send Email
Mar 24, 2008
5:23 pm

... You've defined the filter() function to take two arguments yet you only pass one. That would cause a problem. If that's not what you mean by "not...
Kevin Hill
khill3210
Offline Send Email
Mar 24, 2008
5:30 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help