Class PeakFinderLocalMaximum
- java.lang.Object
-
- ca.uqac.lif.cep.Processor
-
- ca.uqac.lif.cep.SynchronousProcessor
-
- ca.uqac.lif.cep.signal.WindowProcessor
-
- ca.uqac.lif.cep.signal.PeakFinderLocalMaximum
-
- All Implemented Interfaces:
ca.uqac.lif.azrael.Printable,ca.uqac.lif.azrael.Readable,ca.uqac.lif.cep.Contextualizable,ca.uqac.lif.cep.Duplicable,ca.uqac.lif.cep.DuplicableProcessor
public class PeakFinderLocalMaximum extends WindowProcessor
Finds a peak in a data stream using the local maximum algorithm.The local maximum method is a brute force searching algorithm which finds the local maximum in a moving window. The window size is determined by a predefined a number of local points.
Initially, an n-point window is placed at the start point of data stream. The maximum in this window, as well as its index, is recorded. Then the window is moved one step further. If the new maximun is greater than the saved maximum, update both the maximum value and index value and then move forward. If the maximum moves out of the window, i.e. all points in the window are less than the maximum, a peak is found an the whole window configuration is reconstructed for the next peak.
For each input event, the processor outputs the height of the peak, or the value 0 if this event is not a peak. Since an event needs to be out of the window to determine that it is a peak, the emission of output events is delayed with respect to the consumption of input events.
By default, the window is of width 5.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanm_invertWhether to invert the values before computing.protected intm_numSincePeakThe number of events that went out of the window since the last peak was seen.protected intm_peakPositionThe position in the window where the highest value is-
Fields inherited from class ca.uqac.lif.cep.signal.WindowProcessor
m_maxValue, m_minValue, m_values, m_windowWidth, s_precision
-
Fields inherited from class ca.uqac.lif.cep.SynchronousProcessor
m_inputPushables, m_outputPullables, m_tempQueue
-
Fields inherited from class ca.uqac.lif.cep.Processor
m_context, m_eventTracker, m_hasBeenNotifiedOfEndOfTrace, m_inputArity, m_inputCount, m_inputPullables, m_inputQueues, m_notifiedEndOfTraceDownstream, m_outputArity, m_outputCount, m_outputPushables, m_outputQueues, MAX_PULL_RETRIES, s_versionString
-
-
Constructor Summary
Constructors Constructor Description PeakFinderLocalMaximum()PeakFinderLocalMaximum(int width)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancompute(java.lang.Object[] inputs, java.util.Queue<java.lang.Object[]> outputs)java.lang.FloatcomputeOutputValue()PeakFinderLocalMaximumduplicate(boolean with_state)PeakFinderLocalMaximumfindDrops(boolean b)Sets whether the peak finder detects drops or peaks.intgetPeakPosition()voidreset()-
Methods inherited from class ca.uqac.lif.cep.signal.WindowProcessor
doubleEquals, getMaxValue, getMinValue
-
Methods inherited from class ca.uqac.lif.cep.SynchronousProcessor
getPullableOutput, getPushableInput, setEventTracker
-
Methods inherited from class ca.uqac.lif.cep.Processor
allNotifiedEndOfTrace, allNull, associateTo, associateToInput, associateToOutput, copyInputQueue, copyOutputQueue, duplicate, duplicateInto, equals, getAt, getContext, getContext, getEmptyQueue, getEventTracker, getId, getInputArity, getInputCount, getInputQueue, getInputType, getInputTypesFor, getLeaves, getLeaves, getOutputArity, getOutputCount, getOutputQueue, getOutputType, getPullableInput, getPullableOutput, getPushableInput, getPushableOutput, hashCode, leftShift, newContext, onEndOfTrace, or, or, print, printState, read, readState, rightShift, setContext, setContext, setPullableInput, setPushableOutput, start, startAll, stop, stopAll
-
-
-
-
Field Detail
-
m_peakPosition
protected int m_peakPosition
The position in the window where the highest value is
-
m_numSincePeak
protected int m_numSincePeak
The number of events that went out of the window since the last peak was seen.
-
m_invert
protected boolean m_invert
Whether to invert the values before computing. Setting this to true will make the processor detect drops (sudden decreases) instead of peaks.
-
-
Method Detail
-
findDrops
public PeakFinderLocalMaximum findDrops(boolean b)
Sets whether the peak finder detects drops or peaks.- Parameters:
b- Set totrueto detect drops- Returns:
- This processor
-
reset
public void reset()
- Overrides:
resetin classWindowProcessor
-
compute
protected boolean compute(java.lang.Object[] inputs, java.util.Queue<java.lang.Object[]> outputs)- Specified by:
computein classca.uqac.lif.cep.SynchronousProcessor
-
getPeakPosition
public int getPeakPosition()
-
duplicate
public PeakFinderLocalMaximum duplicate(boolean with_state)
- Specified by:
duplicatein interfaceca.uqac.lif.cep.Duplicable- Specified by:
duplicatein classca.uqac.lif.cep.Processor
-
computeOutputValue
public java.lang.Float computeOutputValue()
- Specified by:
computeOutputValuein classWindowProcessor
-
-