|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.mbari.siam.utils.StaLtaEventDetector
public class StaLtaEventDetector
Detect events based on ratio of moving short-term average ("STA") to moving long-term average ("LTA") of some input data. Detector is in "triggered" state when STA/LTA exceeds specified "trigger ratio". Detector is in "de-triggered" state when STA/LTA is less than specified "de-trigger" ratio. Notify listeners when state transitions between triggered and de-triggered states. Based on seismology algorithm described in "Instrumentation in Earthquake Seismology" by Havskov and Alguacil, p 117 (available at http://www.terraip.co.jp/Seismometers.pdf)
| Nested Class Summary | |
|---|---|
static interface |
StaLtaEventDetector.Listener
Interface for event listeners |
| Field Summary | |
|---|---|
protected float |
_deTriggerRatio
|
protected java.util.Vector |
_listeners
Event listeners |
protected static org.apache.log4j.Logger |
_log4j
|
protected double |
_lta
|
protected java.util.LinkedList |
_ltaSamples
|
protected int |
_ltaSampleWidth
|
protected int |
_maxTriggeredSamples
Maximum consecutive sample accumulated in un-triggered state |
protected int |
_nConsecTriggeredSamples
|
protected long |
_nSample
|
protected java.lang.String |
_parameterName
|
protected boolean |
_ready
|
protected double |
_sta
|
protected java.util.LinkedList |
_staSamples
|
protected int |
_staSampleWidth
|
protected long |
_transitionEpochMsec
|
protected boolean |
_triggeredState
|
protected float |
_triggerRatio
|
| Constructor Summary | |
|---|---|
StaLtaEventDetector(java.lang.String parameterName,
int staSampleWidth,
int ltaSampleWidth,
float triggerRatio,
float deTriggerRatio,
int maxTriggeredSamples)
|
|
| Method Summary | |
|---|---|
void |
addListener(StaLtaEventDetector.Listener listener)
Add event listener |
void |
addSample(java.lang.Number newSample,
long epochMsecTimestamp)
Add next sample, compute moving averages and evaluate state |
protected void |
checkParameters(int staSampleWidth,
int ltaSampleWidth,
float triggerRatio,
float deTriggerRatio,
int maxTriggeredSamples)
Check that user-set parameters are valid. |
protected void |
deTrigger(long epochMsec)
Transition to detriggered state |
double |
getLTA()
|
long |
getNsamples()
|
protected double |
getRunningAverage(java.util.LinkedList samples,
java.lang.Number newSample,
int width,
double prevAverage)
Return running average |
double |
getSTA()
|
long |
getTransitionTime()
Return time of last transition, in epoch millsec |
protected void |
notifyListeners(boolean triggeredState)
Notify listeners of state transition |
void |
reset()
Reset; set averages to zero, restart accumulation |
void |
setParameters(int staSampleWidth,
int ltaSampleWidth,
float triggerRatio,
float deTriggerRatio,
int maxTriggeredSamples)
Set parameters. |
java.lang.String |
toString()
Return String representation |
protected void |
trigger(long epochMsec)
Transition to triggered state |
boolean |
triggeredState()
Return true if detector is in 'triggered' state, else return false. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static org.apache.log4j.Logger _log4j
protected java.lang.String _parameterName
protected int _staSampleWidth
protected int _ltaSampleWidth
protected long _nSample
protected int _maxTriggeredSamples
protected float _triggerRatio
protected float _deTriggerRatio
protected double _sta
protected double _lta
protected java.util.LinkedList _staSamples
protected java.util.LinkedList _ltaSamples
protected int _nConsecTriggeredSamples
protected boolean _triggeredState
protected boolean _ready
protected long _transitionEpochMsec
protected java.util.Vector _listeners
| Constructor Detail |
|---|
public StaLtaEventDetector(java.lang.String parameterName,
int staSampleWidth,
int ltaSampleWidth,
float triggerRatio,
float deTriggerRatio,
int maxTriggeredSamples)
throws java.lang.Exception
java.lang.Exception| Method Detail |
|---|
public java.lang.String toString()
toString in class java.lang.Objectpublic double getLTA()
public double getSTA()
public long getTransitionTime()
public long getNsamples()
public void reset()
public boolean triggeredState()
public void setParameters(int staSampleWidth,
int ltaSampleWidth,
float triggerRatio,
float deTriggerRatio,
int maxTriggeredSamples)
throws java.lang.Exception
java.lang.Exception
protected void checkParameters(int staSampleWidth,
int ltaSampleWidth,
float triggerRatio,
float deTriggerRatio,
int maxTriggeredSamples)
throws java.lang.Exception
java.lang.Exception
protected double getRunningAverage(java.util.LinkedList samples,
java.lang.Number newSample,
int width,
double prevAverage)
public void addSample(java.lang.Number newSample,
long epochMsecTimestamp)
throws java.lang.Exception
java.lang.Exceptionprotected void trigger(long epochMsec)
protected void deTrigger(long epochMsec)
protected void notifyListeners(boolean triggeredState)
public void addListener(StaLtaEventDetector.Listener listener)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||