Compare commits

...

2 Commits

Author SHA1 Message Date
8ab31eafc2 Allow shorthand method for creating an option-less parser.
This is mostly just intended to make a simple filter example shorter.
2013-04-21 16:53:28 -04:00
979ab13bff Force fs to be a float in sfit4 2013-04-17 17:58:15 -04:00
2 changed files with 6 additions and 3 deletions

View File

@@ -67,7 +67,7 @@ def get_stream_info(client, path):
class Filter(object): class Filter(object):
def __init__(self): def __init__(self, parser_description = None):
self._parser = None self._parser = None
self._client_src = None self._client_src = None
self._client_dest = None self._client_dest = None
@@ -78,6 +78,9 @@ class Filter(object):
self.end = None self.end = None
self.interhost = False self.interhost = False
self.force_metadata = False self.force_metadata = False
if parser_description is not None:
self.setup_parser(parser_description)
self.parse_args()
@property @property
def client_src(self): def client_src(self):

View File

@@ -157,7 +157,7 @@ def sfit4(data, fs):
(Verified to match sfit4.m) (Verified to match sfit4.m)
""" """
N = len(data) N = len(data)
t = linspace(0, (N-1) / fs, N) t = linspace(0, (N-1) / float(fs), N)
## Estimate frequency using FFT (step b) ## Estimate frequency using FFT (step b)
Fc = fft(data) Fc = fft(data)
@@ -182,7 +182,7 @@ def sfit4(data, fs):
i = arccos((Z2*cos(ni2) - Z1*cos(ni1)) / (Z2-Z1)) / n i = arccos((Z2*cos(ni2) - Z1*cos(ni1)) / (Z2-Z1)) / n
# Convert to Hz # Convert to Hz
f0 = i * fs / N f0 = i * float(fs) / N
# Fit it. We'll catch exceptions here and just returns zeros # Fit it. We'll catch exceptions here and just returns zeros
# if something fails with the least squares fit, etc. # if something fails with the least squares fit, etc.