nilmtools/extras/sample-cron-scripts/process.sh

33 lines
954 B
Bash
Raw Permalink Normal View History

2013-07-29 18:37:55 -04:00
#!/bin/bash
# Run all necessary processing on NilmDB data.
# Bail out on errors
set -e
# Ensure only one copy of this code runs at a time:
LOCKFILE="/tmp/nilmdb-process.lock"
exec 99>"$LOCKFILE"
if ! flock -n -x 99 ; then
echo "NilmDB processing already running, giving up..."
exit 0
fi
trap 'rm -f "$LOCKFILE"' 0
2013-08-02 23:18:32 -04:00
# redirect stdout/stderr to log, but keep it on the console too
exec > >(tee /home/nilm/data/process.log)
exec 2> >(tee -a /home/nilm/data/process.log >&2)
echo "sinefit on phase A voltage"
2013-07-29 18:37:55 -04:00
nilm-sinefit -c 5 /sharon/raw /sharon/sinefit
2013-08-02 23:18:32 -04:00
echo "prep on A, B, C with appropriate rotations"
2013-07-29 18:37:55 -04:00
nilm-prep -c 1 -r 0 /sharon/raw /sharon/sinefit /sharon/prep-a
nilm-prep -c 2 -r 120 /sharon/raw /sharon/sinefit /sharon/prep-b
nilm-prep -c 3 -r 240 /sharon/raw /sharon/sinefit /sharon/prep-c
2013-08-02 23:18:32 -04:00
echo "decimate raw and prep data"
2013-07-29 18:37:55 -04:00
nilm-decimate-auto /sharon/raw /sharon/prep*
2013-08-02 23:18:32 -04:00
echo "run cleanup"
2013-07-29 18:37:55 -04:00
nilm-cleanup --yes /home/nilm/data/cleanup.cfg