Compare commits
5 Commits
nilmtools-
...
nilmtools-
Author | SHA1 | Date | |
---|---|---|---|
f4fda837ae | |||
5547d266d0 | |||
372e977e4a | |||
640a680704 | |||
2e74e6cd63 |
2
setup.py
2
setup.py
@@ -61,7 +61,7 @@ setup(name='nilmtools',
|
|||||||
long_description = "NILM Database Tools",
|
long_description = "NILM Database Tools",
|
||||||
license = "Proprietary",
|
license = "Proprietary",
|
||||||
author_email = 'jim@jtan.com',
|
author_email = 'jim@jtan.com',
|
||||||
install_requires = [ 'nilmdb >= 1.5.0',
|
install_requires = [ 'nilmdb >= 1.6.0',
|
||||||
'numpy',
|
'numpy',
|
||||||
'scipy',
|
'scipy',
|
||||||
'matplotlib',
|
'matplotlib',
|
||||||
|
@@ -238,12 +238,15 @@ def main(argv = None):
|
|||||||
timestamp_to_seconds(total)))
|
timestamp_to_seconds(total)))
|
||||||
continue
|
continue
|
||||||
printf(" removing data before %s\n", timestamp_to_human(remove_before))
|
printf(" removing data before %s\n", timestamp_to_human(remove_before))
|
||||||
if args.yes:
|
# Clean in reverse order. Since we only use the primary stream and not
|
||||||
client.stream_remove(path, None, remove_before)
|
# the decimated streams to figure out which data to remove, removing
|
||||||
for ap in streams[path].also_clean_paths:
|
# the primary stream last means that we might recover more nicely if
|
||||||
printf(" also removing from %s\n", ap)
|
# we are interrupted and restarted.
|
||||||
|
clean_paths = list(reversed(streams[path].also_clean_paths)) + [ path ]
|
||||||
|
for p in clean_paths:
|
||||||
|
printf(" removing from %s\n", p)
|
||||||
if args.yes:
|
if args.yes:
|
||||||
client.stream_remove(ap, None, remove_before)
|
client.stream_remove(p, None, remove_before)
|
||||||
|
|
||||||
# All done
|
# All done
|
||||||
if not args.yes:
|
if not args.yes:
|
||||||
|
@@ -275,6 +275,10 @@ class Filter(object):
|
|||||||
Return value of 'function' is the number of data rows processed.
|
Return value of 'function' is the number of data rows processed.
|
||||||
Unprocessed data will be provided again in a subsequent call
|
Unprocessed data will be provided again in a subsequent call
|
||||||
(unless 'final' is True).
|
(unless 'final' is True).
|
||||||
|
|
||||||
|
If unprocessed data remains after 'final' is True, the interval
|
||||||
|
being inserted will be ended at the timestamp of the first
|
||||||
|
unprocessed data point.
|
||||||
"""
|
"""
|
||||||
if args is None:
|
if args is None:
|
||||||
args = []
|
args = []
|
||||||
@@ -319,7 +323,13 @@ class Filter(object):
|
|||||||
|
|
||||||
# Last call for this contiguous interval
|
# Last call for this contiguous interval
|
||||||
if old_array.shape[0] != 0:
|
if old_array.shape[0] != 0:
|
||||||
function(old_array, interval, args, insert_function, True)
|
processed = function(old_array, interval, args,
|
||||||
|
insert_function, True)
|
||||||
|
if processed != old_array.shape[0]:
|
||||||
|
# Truncate the interval we're inserting at the first
|
||||||
|
# unprocessed data point. This ensures that
|
||||||
|
# we'll not miss any data when we run again later.
|
||||||
|
insert_ctx.update_end(old_array[processed][0])
|
||||||
|
|
||||||
def main(argv = None):
|
def main(argv = None):
|
||||||
# This is just a dummy function; actual filters can use the other
|
# This is just a dummy function; actual filters can use the other
|
||||||
|
13
src/prep.py
13
src/prep.py
@@ -3,6 +3,8 @@
|
|||||||
# Spectral envelope preprocessor.
|
# Spectral envelope preprocessor.
|
||||||
# Requires two streams as input: the original raw data, and sinefit data.
|
# 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 nilmtools.filter
|
||||||
import nilmdb.client
|
import nilmdb.client
|
||||||
from numpy import *
|
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
|
# Pull out sinefit data for the entire time range of this block
|
||||||
for sinefit_line in client.stream_extract(sinefit_path,
|
for sinefit_line in client.stream_extract(sinefit_path,
|
||||||
data[0, 0], data[rows-1, 0]):
|
data[0, 0], data[rows-1, 0]):
|
||||||
|
|
||||||
def prep_period(t_min, t_max, rot):
|
def prep_period(t_min, t_max, rot):
|
||||||
"""
|
"""
|
||||||
Compute prep coefficients from time t_min to t_max, which
|
Compute prep coefficients from time t_min to t_max, which
|
||||||
@@ -163,7 +164,15 @@ def process(data, interval, args, insert_function, final):
|
|||||||
break
|
break
|
||||||
processed = idx_max
|
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
|
return processed
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@@ -25,7 +25,7 @@ def main(argv = None):
|
|||||||
help='Maximum valid frequency '
|
help='Maximum valid frequency '
|
||||||
'(default: approximate frequency * 2))')
|
'(default: approximate frequency * 2))')
|
||||||
group.add_argument('-a', '--min-amp', action='store', type=float,
|
group.add_argument('-a', '--min-amp', action='store', type=float,
|
||||||
default=10.0,
|
default=20.0,
|
||||||
help='Minimum signal amplitude (default: %(default)s)')
|
help='Minimum signal amplitude (default: %(default)s)')
|
||||||
|
|
||||||
# Parse arguments
|
# Parse arguments
|
||||||
|
Reference in New Issue
Block a user