Browse Source

work in progress

tags/nilmtools-0.2
Jim Paris 11 years ago
parent
commit
9d38d6c21b
2 changed files with 27 additions and 1 deletions
  1. +4
    -1
      nilmtools/decimate.py
  2. +23
    -0
      nilmtools/filter.py

+ 4
- 1
nilmtools/decimate.py View File

@@ -53,7 +53,10 @@ def main():
"decimate_factor": args.factor })

# Process it
f.process(maxlen = 600, function = decimate, args = (factor,))

def decimate(data, start, end, factor):
pass

if __name__ == "__main__":
main()

+ 23
- 0
nilmtools/filter.py View File

@@ -95,13 +95,36 @@ class Filter(object):

# Misc helpers
def stream_info_string(self, info):
"""Print stream info as a string"""
return sprintf("%s (%s), %.2fM rows, %.2f hours",
info[0], info[1], info[4] / 1e6, info[5] / 3600)

def interval_string(self, interval):
"""Print interval as a string"""
return sprintf("[ %s -> %s ]", format_time(interval[0]),
format_time(interval[1]))

# Main processing helper
def process(self, function, maxlen, args):
"""Process data in chunks.

function: function to process the data
maxlen: maximum length of data to pass to function, in seconds
args: tuple containing extra arguments to pass to function

'function' should be defined like:
function(data, start, end, *args)
It will be passed a block of data from the source stream,
the start and end times of that block, and any arguments
that were passed to process in 'args'. The total
length of the interval will be at most 'maxlen' seconds.

'function' should transform the data as desired, and return
a new list of data, which will be inserted into the
destination stream."""
for (start, end) in self.intervals():
if (end - start)
return

def main():
# This is just a dummy function; actual filters can use the other


Loading…
Cancel
Save