timeSeries< T > Class Template Reference
[timeSeries objects]
a scalar sequence of data samples spaced evenly in time
More...
#include <timeSeries.h>
Inherits tsBase< T >.
List of all members.
Public Member Functions |
| timeSeries (std::string varnam, dataFile &df) |
| timeSeries (dataDef &dd, dataFile &df) |
| timeSeries (const char *vn, const char *sn, double t) |
tsVal< T > | operator[] (int k) const |
const T | operator() (double t) |
timeSeries< T > | range (int j, int k) |
timeSeries< T > | range (double t0, double tf) |
timeSeries< T > | range (state &s) |
timeSeries< T > | duplicate () const |
timeSeries< T > | integrate () |
timeSeries< T > | differentiate () |
timeSeries< T > | sqrt () const |
| element-by-element square root
|
int | min () const |
| returns index of the minimum value
|
int | max () const |
| returns index of the maximum value
|
tsResult | stddev () |
| returns standard deviation
|
template<class U > |
timeSeries< T > & | operator+= (const timeSeries< U > &ts) |
timeSeries< T > & | operator+= (const T &v) |
template<class U > |
timeSeries< T > & | operator-= (const timeSeries< U > &ts) |
timeSeries< T > & | operator-= (const T &v) |
template<class U > |
timeSeries< T > & | operator*= (const timeSeries< U > &ts) |
timeSeries< T > & | operator*= (const T &v) |
template<class U > |
timeSeries< T > & | operator/= (const timeSeries< U > &ts) |
timeSeries< T > & | operator/= (const T &v) |
template<class U > |
boolResult | operator> (const timeSeries< U > &ts) const |
boolResult | operator> (const T &v) const |
template<class U > |
boolResult | operator< (const timeSeries< U > &ts) const |
boolResult | operator< (const T &v) const |
template<class U > |
boolResult | operator== (const timeSeries< U > &ts) const |
boolResult | operator== (const T &v) const |
template<class U > |
boolResult | operator!= (const timeSeries< U > &ts) const |
boolResult | operator!= (const T &v) const |
template<class U > |
boolResult | operator>= (const timeSeries< U > &ts) const |
boolResult | operator>= (const T &v) const |
template<class U > |
boolResult | operator<= (const timeSeries< U > &ts) const |
boolResult | operator<= (const T &v) const |
timeSeries< T > | operator>> (const unsigned int n) const |
timeSeries< T > | operator<< (const unsigned int n) const |
template<class U > |
| operator timeSeries< U > () const |
Friends |
class | timeSeriesArray |
class | timeSeries |
Related Functions |
(Note that these are not member functions.)
|
template<class T , class U > |
const timeSeries< T > | operator+ (const timeSeries< T > &lhs, const U &rhs) |
template<class T , class U > |
const timeSeries< T > | operator- (const timeSeries< T > &lhs, const U &rhs) |
template<class T , class U > |
const timeSeries< T > | operator* (const timeSeries< T > &lhs, const U &rhs) |
template<class T , class U > |
const timeSeries< T > | operator/ (const timeSeries< T > &lhs, const U &rhs) |
template<class T > |
std::ostream & | operator<< (std::ostream &os, timeSeries< T > ts) |
Detailed Description
template<class T>
class timeSeries< T >
a scalar sequence of data samples spaced evenly in time
T is the base type of the timeSeries object. T must be one of char
, short
, int
, float
or double
.
- Overview
- The timeSeries class encapsulates data recorded at uniform time intervals. A timeSeries object is typically constructed from a previously instantiated dataFile object. Once constructed, a timeSeries object can be indexed like a normal C++ array (in the examples below,
tsvar
is a timeSeries<float> object): where i
is an integer index that denotes the particular data sample to be retrieved.
- You can also reference a timeSeries object by time instead of sample number:
- Assigning a value to a timeSeries object is also permitted:
- However, such an assignment modifies only the timeSeries. The dataFile object retains the original data.
- Note that an expression like
tsvar
[53] does not return an ordinay float. It returns a tsVal object, which is also defined here. When used as a r-value, a tsVal object is silently converted to the appropriate type. When used as an l-value, the tsVal class implements an automatic copy-on-write scheme. However, for all purposes, a tsVal object can and should be treated as an ordinary data type.
- timeSeries objects may be assigned using = as in:
- Assignment operations are both space and time efficient -- no data is copied.
- Performance
- The timeSeries class is designed to operate efficiently on very large datasets. To minimize memory usage a timeSeries object constructed from a dataFile does not automatically make a new copy of the underlying data. Instead, the timeSeries object references the data already contained in the dataFile object.
- When a timeSeries is modified, the timeSeries class implements a copy-on-write mechanism that makes a duplicate of the underlying data the first time it is modified. No user intervention is required and the copy-on-write operation is transparent to the user. However, depending on the size of the data set, there may be a substantial performance penalty for the first write access to a timeSeries object.
- Examples:
-
camp_utilities.h, campAnalysis.cpp, campVIRTTEXAnalysis.cpp, hmi04.cpp, hmi04.h, hmi04_utilities.cpp, and hmi04_utilities.h.
Constructor & Destructor Documentation
timeSeries constructor
- Parameters:
-
| df | a dataFile object that contains the data on which the timeSeries will be based |
| varnam | a string that selects the field contained in the dataFile that will be used to construct the timeSeries object |
- Exceptions:
-
timeSeries constructor
- Parameters:
-
| vn | a variable name to be associated with the timeSeries |
| sn | a "short" variable name associated with the timeSeries. This field is not currently used by any of the timeSeries member functions |
| t | the sample time associated with the timeSeries object |
Member Function Documentation
numerical differntiation
- Returns:
- a timeSeries object
performs differentiation by central differences and returns a new timeSeries containing the result. The original timeSeries object is not modified.
- Returns:
- a new timeSeries object containing a copy of the original data
numerical integration
- Returns:
- a timeSeries object
performs trapezoidal integration and returns a new timeSeries containing the result. The original timeSeries object is not modified.
template<class T>
template<class U >
not equals
- Parameters:
-
- Returns:
- returns a boolResult object with each element in the boolResult calculated from an element-by-element comparsion of the timeSeries with the scalar
template<class T>
template<class U >
not equals
- Parameters:
-
- Exceptions:
-
- Returns:
- returns a boolResult object with each element in the boolResult calculated from an element-by-element comparsion
template<class T >
template const double timeSeries< T >::operator() |
( |
double |
t |
) |
[inline] |
index by time
- Parameters:
-
- Returns:
- returns a tsVal< T > data object representing the value of the timeSeries at time t. The tsVal object will be silenty converted to type T when used in an expression.
() performs automatic range-checking but unlike [] it returns a value at the end of the range if t is out of bounds. No exception is thrown. If the t does not correspond to a data sample, a linear interpolation between samples is returned.
assign-product operator
- Parameters:
-
- Returns:
- returns an element-by-element product of the object and the scalar v
template<class T>
template<class U >
assign-product operator
- Parameters:
-
- Returns:
- returns an element-by-element product of the object and ts
- Exceptions:
-
assign-sum operator
- Parameters:
-
- Returns:
- returns an element-by-element sum of the object and the scalar v
template<class T>
template<class U >
assign-sum operator
- Parameters:
-
- Returns:
- returns an element-by-element sum of the object and ts
- Exceptions:
-
assign-difference operator
- Parameters:
-
- Returns:
- returns an element-by-element difference of the object and the scalar v
template<class T>
template<class U >
assign-difference operator
- Parameters:
-
- Returns:
- returns an element-by-element difference of the object and ts
- Exceptions:
-
assign-quotient operator
- Parameters:
-
- Returns:
- returns an element-by-element quotient of the object and the scalar v
template<class T>
template<class U >
assign-quotient operator
- Parameters:
-
- Returns:
- returns an element-by-element quotient of the object and ts
- Exceptions:
-
less than
- Parameters:
-
- Returns:
- returns a boolResult
template<class T>
template<class U >
less than
- Parameters:
-
- Returns:
- returns a boolResult
- Exceptions:
-
shift
Shift a timeSeries left by n samples. When new values are shifted in, they are set to zero.
Currently, the entire timeSeries shifted, even if a subrange is the target.
- Parameters:
-
| n | the number of samples to shift the time series |
- Returns:
- a timeSeries shifted by n samples
less than or equal
- Parameters:
-
- Returns:
- returns a boolResult
template<class T>
template<class U >
less than or equal
- Parameters:
-
- Returns:
- returns a boolResult
- Exceptions:
-
equals
- Parameters:
-
- Returns:
- returns a boolResult object with each element in the boolResult calculated from an element-by-element comparsion of the timeSeries with the scalar
template<class T>
template<class U >
equals
- Parameters:
-
- Exceptions:
-
- Returns:
- returns a boolResult object with each element in the boolResult calculated from an element-by-element comparsion
greater than
- Parameters:
-
- Returns:
- returns a boolResult
template<class T>
template<class U >
greater than
- Parameters:
-
- Returns:
- returns a boolResult
- Exceptions:
-
greater than or equal
- Parameters:
-
- Returns:
- returns a boolResult
template<class T>
template<class U >
greater than or equal
- Parameters:
-
- Returns:
- returns a boolResult
- Exceptions:
-
shift
Shift a timeSeries right by n samples. When new values are shifted in, they are set to zero.
Currently, the entire timeSeries shifted, even if a subrange is the target.
- Parameters:
-
| n | the number of samples to shift the time series |
- Returns:
- a timeSeries shifted by n samples
index operator
- Parameters:
-
- Returns:
- returns a tsVal< T > data object representing the value of the timeSeries at sample k. The tsVal object will be silenty converted to type T when used in an expression.
- Exceptions:
-
| OutOfRange | [] performs automatic range-checking and will throw an exception if the index value is out of range. |
- Parameters:
-
- Returns:
- a timeSeries object formed from the subrange defined by the state s
States are simply pairs of indices that define a region. They usually arise from searches on stateFlag objects. Subranges are created by reference. No data is copied or moved.
Reimplemented in stateFlag.
- Parameters:
-
| t0 | begining time |
| tf | ending time |
- Returns:
- a timeSeries object corresponding approximately to the range [t0,tf]. If t0 or tf do not correspond exactly to a sample time, the nearest sample is used.
Subranges are created by reference. No data is copied or moved.
Reimplemented in stateFlag.
- Parameters:
-
| j | begining sample |
| k | ending sample |
- Returns:
- a timeSeries object corresponding to the range [j,k]
Subranges are created by reference. No data is copied or moved.
Reimplemented in stateFlag.