Disaggregate
Disaggregate Smart Meter data
|
This class is responsible for storing and searching aggregated data, such as the data produced by the Current Cost home energy monitor. More...
#include <AggregateData.h>
Classes | |
struct | FoundSpike |
A simple struct for representing delta spikes found by findSpike() More... | |
Public Member Functions | |
const int | aggDelta (const size_t i) const |
Calculate the change between data[ i+1 ].reading and data[ i ].reading. | |
General functions used by all disaggregation algorithms | |
void | loadCurrentCostData (const std::string &filename) |
const size_t | secondsSinceFirstSample (const size_t i) const |
const size_t | getSamplePeriod () const |
const std::string | getFilename () const |
Functions used by the 'graphs and spikes' algorithms. | |
std::list < AggregateData::FoundSpike > | findSpike (const Statistic< Sample_t > &spikeStats, size_t startTime=0, size_t endTime=0, const bool verbose=false) const |
Find all spikes in aggregate data which fit spikeStats . | |
const size_t | findTime (const size_t time) const |
a simple way to find the array index at which a timestamp occurs. If precise time cannot be found, returns the index to the sample immediately prior. Terminates program if time is out of range (as this is always fatal). | |
const bool | readingGoesBelowPowerState (const size_t startTime, const size_t endTime, const Statistic< Sample_t > &powerState) const |
Run through the raw aggregate data from startTime to endTime to make sure that no agg data sample has a lower value than powerState.min . | |
Functions used by the 'histogram' algorithms. | |
const size_t | findNear (const size_t candidateIndex, const size_t expectedDistance, const size_t delta) const |
Find 'delta'. Start searching 'expectedDistance' away from 'candidateIndex'. DOESN'T WORK YET. | |
Private Member Functions | |
const size_t | checkStartAndEndTimes (size_t *startTime, size_t *endTime) const |
Make sure start and end times are sane. | |
Private Attributes | |
size_t | samplePeriod |
in seconds. | |
std::string | aggDataFilename |
including path and suffix |
This class is responsible for storing and searching aggregated data, such as the data produced by the Current Cost home energy monitor.
Definition at line 36 of file AggregateData.h.
const int AggregateData::aggDelta | ( | const size_t | i | ) | const |
Calculate the change between data[ i+1
].reading and data[ i
].reading.
Would've been nice to overload Array::getDelta(size_t)
but that returns an object of type T
and the compiler won't let me overload with a function which returns a size_t
.
Definition at line 67 of file AggregateData.cpp.
Referenced by Device::getStartTimes().
const size_t AggregateData::checkStartAndEndTimes | ( | size_t * | startTime, |
size_t * | endTime | ||
) | const [private] |
Make sure start and end times are sane.
Definition at line 98 of file AggregateData.cpp.
const size_t AggregateData::findNear | ( | const size_t | candidateIndex, |
const size_t | expectedDistance, | ||
const size_t | delta | ||
) | const |
Find 'delta'. Start searching 'expectedDistance' away from 'candidateIndex'. DOESN'T WORK YET.
candidateIndex | index into aggregateData |
expectedDistance | in seconds away from candidateIndex |
delta | the delta we're looking for |
Definition at line 86 of file AggregateData.cpp.
Referenced by Device::getStartTimes().
list< AggregateData::FoundSpike > AggregateData::findSpike | ( | const Statistic< Sample_t > & | spikeStats, |
size_t | startTime = 0 , |
||
size_t | endTime = 0 , |
||
const bool | verbose = false |
||
) | const |
Find all spikes in aggregate data which fit spikeStats
.
spikeStats | A statistical description of the spike to look for. |
startTime | The UNIX timecode marking the start of the search window. |
endTime | The UNIX timecode marking the end of the search window. |
Definition at line 164 of file AggregateData.cpp.
References Utils::between(), Statistic< T >::max, Statistic< T >::mean, Statistic< T >::min, Statistic< T >::nonZeroStdev(), Statistic< T >::normalisedLikelihood(), Utils::sameSign(), and Statistic< T >::stdev.
Referenced by PowerStateGraph::disaggregate(), and PowerStateGraph::traceToEnd().
a simple way to find the array index at which a timestamp occurs. If precise time cannot be found, returns the index to the sample immediately prior. Terminates program if time is out of range (as this is always fatal).
This implements a kind of "poor man's" hash function and should probably be re-written as a hash-function.
time
is located. time | UNIX timestamp |
Definition at line 261 of file AggregateData.cpp.
References Utils::between(), and Utils::fatalError().
const string AggregateData::getFilename | ( | ) | const |
Definition at line 46 of file AggregateData.cpp.
Referenced by PowerStateGraph::disaggregate().
const size_t AggregateData::getSamplePeriod | ( | ) | const |
Definition at line 293 of file AggregateData.cpp.
Referenced by Device::findAlignment().
void AggregateData::loadCurrentCostData | ( | const std::string & | filename | ) |
filename | including path and suffix. |
Definition at line 13 of file AggregateData.cpp.
References Utils::countDataPoints(), Utils::fatalError(), Utils::fileExists(), and Utils::openFile().
Referenced by main().
const bool AggregateData::readingGoesBelowPowerState | ( | const size_t | startTime, |
const size_t | endTime, | ||
const Statistic< Sample_t > & | powerState | ||
) | const |
Run through the raw aggregate data from startTime
to endTime
to make sure that no agg data sample has a lower value than powerState.min
.
startTime
and endTime
is lower than powerState.min
then return false else return true. Definition at line 139 of file AggregateData.cpp.
References Statistic< T >::min.
Referenced by PowerStateGraph::traceToEnd().
Definition at line 51 of file AggregateData.cpp.
Referenced by Device::getStartTimes().
std::string AggregateData::aggDataFilename [private] |
including path and suffix
Definition at line 120 of file AggregateData.h.
size_t AggregateData::samplePeriod [private] |
in seconds.
Definition at line 113 of file AggregateData.h.