Disaggregate
Disaggregate Smart Meter data

AggregateData Class Reference

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>

Inheritance diagram for AggregateData:
Collaboration diagram for AggregateData:

List of all members.

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

Detailed Description

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.


Member Function Documentation

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 .

Returns:
 data[i+1].reading - data[i].reading 

Definition at line 67 of file AggregateData.cpp.

Referenced by Device::getStartTimes().

Here is the caller graph for this function:

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.

Returns:
AggregateData index where best delta match was found
Deprecated:
a relic from an abandoned attempt to disaggregate
Parameters:
candidateIndexindex into aggregateData
expectedDistancein seconds away from candidateIndex
deltathe delta we're looking for

Definition at line 86 of file AggregateData.cpp.

Referenced by Device::getStartTimes().

Here is the caller graph for this function:

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.

Parameters:
spikeStatsA statistical description of the spike to look for.
startTimeThe UNIX timecode marking the start of the search window.
endTimeThe 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().

Here is the call graph for this function:

Here is the caller graph for this function:

const size_t AggregateData::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).

This implements a kind of "poor man's" hash function and should probably be re-written as a hash-function.

Returns:
the array index at which time is located.
Parameters:
timeUNIX timestamp

Definition at line 261 of file AggregateData.cpp.

References Utils::between(), and Utils::fatalError().

Here is the call graph for this function:

const string AggregateData::getFilename ( ) const

Definition at line 46 of file AggregateData.cpp.

Referenced by PowerStateGraph::disaggregate().

Here is the caller graph for this function:

const size_t AggregateData::getSamplePeriod ( ) const

Definition at line 293 of file AggregateData.cpp.

Referenced by Device::findAlignment().

Here is the caller graph for this function:

void AggregateData::loadCurrentCostData ( const std::string &  filename)
Parameters:
filenameincluding path and suffix.

Definition at line 13 of file AggregateData.cpp.

References Utils::countDataPoints(), Utils::fatalError(), Utils::fileExists(), and Utils::openFile().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Returns:
if no sample between 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().

Here is the caller graph for this function:

const size_t AggregateData::secondsSinceFirstSample ( const size_t  i) const

Definition at line 51 of file AggregateData.cpp.

Referenced by Device::getStartTimes().

Here is the caller graph for this function:


Member Data Documentation

std::string AggregateData::aggDataFilename [private]

including path and suffix

Definition at line 120 of file AggregateData.h.

in seconds.

Definition at line 113 of file AggregateData.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Friends