|
|
@@ -24,6 +24,9 @@ def main(argv = None): |
|
|
|
group.add_argument('-M', '--max-freq', action='store', type=float, |
|
|
|
help='Maximum valid frequency ' |
|
|
|
'(default: approximate frequency * 2))') |
|
|
|
group.add_argument('-a', '--min-amp', action='store', type=float, |
|
|
|
default=10.0, |
|
|
|
help='Minimum signal amplitude (default: %(default)s)') |
|
|
|
|
|
|
|
# Parse arguments |
|
|
|
try: |
|
|
@@ -48,14 +51,16 @@ def main(argv = None): |
|
|
|
args.min_freq > args.frequency or |
|
|
|
args.max_freq < args.frequency): |
|
|
|
parser.error("invalid min or max frequency") |
|
|
|
if args.min_amp < 0: |
|
|
|
parser.error("min amplitude must be >= 0") |
|
|
|
|
|
|
|
f.check_dest_metadata({ "sinefit_source": f.src.path, |
|
|
|
"sinefit_column": args.column }) |
|
|
|
f.process_numpy(process, args = (args.column, args.frequency, |
|
|
|
f.process_numpy(process, args = (args.column, args.frequency, args.min_amp, |
|
|
|
args.min_freq, args.max_freq)) |
|
|
|
|
|
|
|
def process(data, interval, args, insert_function, final): |
|
|
|
(column, f_expected, f_min, f_max) = args |
|
|
|
(column, f_expected, a_min, f_min, f_max) = args |
|
|
|
rows = data.shape[0] |
|
|
|
|
|
|
|
# Estimate sampling frequency from timestamps |
|
|
@@ -86,6 +91,12 @@ def process(data, interval, args, insert_function, final): |
|
|
|
start += N |
|
|
|
continue |
|
|
|
|
|
|
|
# If amplitude is too low, results are probably just noise |
|
|
|
if A < a_min: |
|
|
|
print "amplitude", A, "below minimum threshold", a_min |
|
|
|
start += N |
|
|
|
continue |
|
|
|
|
|
|
|
#p.plot(arange(N), this) |
|
|
|
#p.plot(arange(N), A * cos(f0/fs * 2 * pi * arange(N) + phi) + C, 'g') |
|
|
|
|
|
|
|