Compare commits
5 Commits
nilmtools-
...
nilmtools-
Author | SHA1 | Date | |
---|---|---|---|
0cf2db6c5e | |||
f530edd8a0 | |||
4d946bee79 | |||
13ceb91999 | |||
dab9625296 |
10
Makefile
10
Makefile
@@ -5,7 +5,7 @@ all: test
|
||||
|
||||
test:
|
||||
ifeq ($(INSIDE_EMACS), t)
|
||||
@make test_trainola3
|
||||
@make test_sinefit
|
||||
else
|
||||
@echo 'No test suite for nilmtools. Try "make install"'
|
||||
endif
|
||||
@@ -58,6 +58,14 @@ test_prep: /tmp/raw.dat
|
||||
nilmtools/prep.py -c 2 /test/raw /test/sinefit /test/prep
|
||||
nilmtool extract -s min -e max /test/prep | head -20
|
||||
|
||||
test_sinefit:
|
||||
make install >/dev/null 2>&1
|
||||
-nilmtool destroy -R /test/sinefit
|
||||
nilmtool create /test/sinefit float32_3
|
||||
nilmtools/sinefit.py -c 5 -s '2013/03/25 09:11:00' \
|
||||
-e '2013/03/25 10:11:00' /sharon/raw /test/sinefit
|
||||
nilmtool extract -s min -e max /test/sinefit | head -20
|
||||
|
||||
test_decimate:
|
||||
-@nilmtool destroy /lees-compressor/no-leak/raw/4 || true
|
||||
-@nilmtool destroy /lees-compressor/no-leak/raw/16 || true
|
||||
|
@@ -1,5 +1,8 @@
|
||||
# Install this by running "crontab crontab" (will replace existing crontab)
|
||||
|
||||
SHELL=/bin/bash
|
||||
PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
|
||||
|
||||
# m h dom mon dow cmd
|
||||
|
||||
# Run NilmDB processing every 5 minutes
|
||||
@@ -7,3 +10,6 @@
|
||||
|
||||
# Try frequently restarting the capture process in case it died
|
||||
*/5 * * * * chronic /home/nilm/data/capture.sh
|
||||
|
||||
# Run fsck at startup
|
||||
@reboot chronic nilmdb-fsck --fix --no-data /home/nilm/data/db/
|
||||
|
@@ -37,17 +37,21 @@ def sfit4(data, fs):
|
||||
i = argmax(F[0:int(N/2)] + F[1:int(N/2+1)])
|
||||
|
||||
# Interpolate FFT to get a better result (from Markus [B37])
|
||||
U1 = real(Fc[i])
|
||||
U2 = real(Fc[i+1])
|
||||
V1 = imag(Fc[i])
|
||||
V2 = imag(Fc[i+1])
|
||||
n = 2 * pi / N
|
||||
ni1 = n * i
|
||||
ni2 = n * (i+1)
|
||||
K = ((V2-V1)*sin(ni1) + (U2-U1)*cos(ni1)) / (U2-U1)
|
||||
Z1 = V1 * (K - cos(ni1)) / sin(ni1) + U1
|
||||
Z2 = V2 * (K - cos(ni2)) / sin(ni2) + U2
|
||||
i = arccos((Z2*cos(ni2) - Z1*cos(ni1)) / (Z2-Z1)) / n
|
||||
try:
|
||||
U1 = real(Fc[i])
|
||||
U2 = real(Fc[i+1])
|
||||
V1 = imag(Fc[i])
|
||||
V2 = imag(Fc[i+1])
|
||||
n = 2 * pi / N
|
||||
ni1 = n * i
|
||||
ni2 = n * (i+1)
|
||||
K = ((V2-V1)*sin(ni1) + (U2-U1)*cos(ni1)) / (U2-U1)
|
||||
Z1 = V1 * (K - cos(ni1)) / sin(ni1) + U1
|
||||
Z2 = V2 * (K - cos(ni2)) / sin(ni2) + U2
|
||||
i = arccos((Z2*cos(ni2) - Z1*cos(ni1)) / (Z2-Z1)) / n
|
||||
except Exception:
|
||||
# Just go with the biggest FFT peak
|
||||
i = argmax(F[0:int(N/2)])
|
||||
|
||||
# Convert to Hz
|
||||
f0 = i * float(fs) / N
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user