|
|
@@ -3,6 +3,8 @@ |
|
|
|
# Spectral envelope preprocessor. |
|
|
|
# Requires two streams as input: the original raw data, and sinefit data. |
|
|
|
|
|
|
|
from nilmdb.utils.printf import * |
|
|
|
from nilmdb.utils.time import timestamp_to_human |
|
|
|
import nilmtools.filter |
|
|
|
import nilmdb.client |
|
|
|
from numpy import * |
|
|
@@ -106,7 +108,6 @@ def process(data, interval, args, insert_function, final): |
|
|
|
# Pull out sinefit data for the entire time range of this block |
|
|
|
for sinefit_line in client.stream_extract(sinefit_path, |
|
|
|
data[0, 0], data[rows-1, 0]): |
|
|
|
|
|
|
|
def prep_period(t_min, t_max, rot): |
|
|
|
""" |
|
|
|
Compute prep coefficients from time t_min to t_max, which |
|
|
@@ -163,7 +164,15 @@ def process(data, interval, args, insert_function, final): |
|
|
|
break |
|
|
|
processed = idx_max |
|
|
|
|
|
|
|
print "Processed", processed, "of", rows, "rows" |
|
|
|
# If we processed no data but there's lots in here, pretend we |
|
|
|
# processed half of it. |
|
|
|
if processed == 0 and rows > 10000: |
|
|
|
processed = rows / 2 |
|
|
|
printf("%s: warning: no periods found; skipping %d rows\n", |
|
|
|
timestamp_to_human(data[0][0]), processed) |
|
|
|
else: |
|
|
|
printf("%s: processed %d of %d rows\n", |
|
|
|
timestamp_to_human(data[0][0]), processed, rows) |
|
|
|
return processed |
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|