Browse Source

Fix divide by zero in sinefit

tags/nilmtools-1.5.0^0
Jim Paris 7 years ago
parent
commit
0cf2db6c5e
1 changed files with 5 additions and 2 deletions
  1. +5
    -2
      nilmtools/sinefit.py

+ 5
- 2
nilmtools/sinefit.py View File

@@ -96,8 +96,11 @@ def process(data, interval, args, insert_function, final):
rows = data.shape[0]

# Estimate sampling frequency from timestamps
fs = (rows-1) / (timestamp_to_seconds(data[-1][0]) -
timestamp_to_seconds(data[0][0]))
ts_min = timestamp_to_seconds(data[0][0])
ts_max = timestamp_to_seconds(data[-1][0])
if ts_min >= ts_max:
return 0
fs = (rows-1) / (ts_max - ts_min)

# Pull out about 3.5 periods of data at once;
# we'll expect to match 3 zero crossings in each window


Loading…
Cancel
Save