farm-ng-core
|
TimeSeries is a container of StampedValue that are sorted by their timestamp. More...
#include <time_series.h>
Classes | |
struct | Bounds |
Public Types | |
using | ValueWithStamp = TValueWithStamp |
using | Container = std::deque< ValueWithStamp > |
using | ConstIterator = typename Container::const_iterator |
Public Member Functions | |
bool | empty () const |
Returns true if there are no Values in series. More... | |
void | insert (ValueWithStamp const &value) |
Adds ValueWithStamp to series. More... | |
size_t | size () const |
Number of values in series. More... | |
ValueWithStamp const & | operator[] (size_t idx) const |
access ValueWithStamp by index More... | |
Expected< ValueWithStamp > | findNearest (double query_stamp) const |
Find nearest value given stamp . More... | |
Expected< Bounds > | findBounds (double query_stamp) const |
Expected< ValueWithStamp > | findNearestWithin (double stamp, double threshold) const |
Find nearest value given stamp within search radius threshold . More... | |
bool | testIsSortedInvariant () const |
Just for unit testing. More... | |
std::enable_if_t< time_series::InterpolativeValue< TValueWithStamp >, Expected< TValueWithStamp > > | interpolatedValue (double query_stamp, time_series::MaxGap maximal_time_gap=time_series::MaxGap(1.0), time_series::NearnessThreshold nearness_threshold=time_series::NearnessThreshold(1e-5)) const |
Returns interpolated value from time series at query_stamp. More... | |
ValueWithStamp const & | front () const |
ValueWithStamp const & | back () const |
void | clear () |
void | pop_front () |
void | pop_back () |
ConstIterator | begin () const |
ConstIterator | cbegin () const |
ConstIterator | end () const |
ConstIterator | cend () const |
TimeSeries is a container of StampedValue that are sorted by their timestamp.
Invariant: time_ordered_series_ is sorted by time_series::getStamp.
Consequence: The invariant implies that we have a strict weak ordering relation on the time stamps. Hence, it is not allowed to add NAN timestamps to the time series.
TODO: Add std::ranges support to the API once we fully move to c++20.
using farm_ng::TimeSeries< TValueWithStamp >::ConstIterator = typename Container::const_iterator |
using farm_ng::TimeSeries< TValueWithStamp >::Container = std::deque<ValueWithStamp> |
using farm_ng::TimeSeries< TValueWithStamp >::ValueWithStamp = TValueWithStamp |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Returns true if there are no Values in series.
|
inline |
|
inline |
|
inline |
Find nearest value given stamp
.
Precondition: stamp is not NAN.
Returns error if times series is empty.
|
inline |
Find nearest value given stamp
within search radius threshold
.
Precondition: stamp is not NAN.
Returns error if |value.stamp - stamp| > threshold.
|
inline |
|
inline |
Adds ValueWithStamp to series.
Precondition: stamp is not NAN.
|
inline |
Returns interpolated value from time series at query_stamp.
Note: Only available if TValueWithStamp meets time_series::InterpolativeValue concept.
The following strategy is used:
nearness_threshold
, that exiting value is return directly.|upper.t - lower.t| <= maximal_time_gap
.|upper.t - lower.t| > maximal_time_gap
and error is return.
|
inline |
access ValueWithStamp by index
Precondition: idx < size()
|
inline |
|
inline |
|
inline |
Number of values in series.
|
inline |
Just for unit testing.
Must return always true.