API  4.0
For C++ developers
OpenSim::TimeSeriesTable_< ETY > Class Template Reference

TimeSeriesTable_ is a DataTable_ where the independent column is time of type double. More...

+ Inheritance diagram for OpenSim::TimeSeriesTable_< ETY >:

Public Member Functions

 TimeSeriesTable_ ()=default
 
 TimeSeriesTable_ (const TimeSeriesTable_ &)=default
 
 TimeSeriesTable_ (TimeSeriesTable_ &&)=default
 
TimeSeriesTable_operator= (const TimeSeriesTable_ &)=default
 
TimeSeriesTable_operator= (TimeSeriesTable_ &&)=default
 
 ~TimeSeriesTable_ ()=default
 
 TimeSeriesTable_ (const std::vector< double > &indVec, const SimTK::Matrix_< ETY > &depData, const std::vector< std::string > &labels)
 Convenience constructor to efficiently populate a time series table from available data. More...
 
 TimeSeriesTable_ (const std::vector< double > &indVec)
 Construct a table with only the independent (time) column and 0 dependent columns. More...
 
 TimeSeriesTable_ (const DataTable_< double, ETY > &datatable)
 Construct a TimeSeriesTable_ from a DataTable_. More...
 
 TimeSeriesTable_ (const std::string &filename)
 Construct TimeSeriesTable_ from a file. More...
 
 TimeSeriesTable_ (const std::string &filename, const std::string &tablename)
 Construct TimeSeriesTable_ from a file. More...
 
size_t getNearestRowIndexForTime (const double time, const bool restrictToTimeRange=true) const
 Get index of row whose time is nearest/closest to the given value. More...
 
RowVectorView getNearestRow (const double &time, const bool restrictToTimeRange=true) const
 Get row whose time column is nearest/closest to the given value. More...
 
RowVectorView updNearestRow (const double &time, const bool restrictToTimeRange=true)
 Get writable reference to row whose time column is nearest/closest to the given value. More...
 
RowVector averageRow (const double &beginTime, const double &endTime) const
 Compute the average row in the time range (inclusive) given. More...
 
- Public Member Functions inherited from OpenSim::DataTable_< double, ETY >
 DataTable_ ()=default
 
 DataTable_ (const DataTable_ &)=default
 
 DataTable_ (DataTable_ &&)=default
 
 DataTable_ (const std::string &filename, const std::string &tablename)
 Construct DataTable_ from a file. More...
 
 DataTable_ (const DataTable_< double, ThatETY > &that, const std::vector< std::string > &suffixes)
 Construct DataTable_<double, double> from DataTable_<double, ThatETY> where ThatETY can be SimTK::Vec<X>. More...
 
 DataTable_ (const DataTable_< double, double > &that, const std::vector< std::string > &suffixes)
 Construct this DataTable from a DataTable_<double, double>. More...
 
 DataTable_ (const DataTable_< double, ThatETY > &that)
 Construct DataTable_<double, double> from DataTable_<double, ThatETY> where ThatETY can be SimTK::Vec<X>. More...
 
DataTable_operator= (const DataTable_ &)=default
 
DataTable_operator= (DataTable_ &&)=default
 
DataTable_operator= (const DataTable_< double, ThatETY > &that)
 Copy assign a DataTable_<double, double> from DataTable_<double, ThatETY> where ThatETY can be SimTK::Vec<X>. More...
 
 ~DataTable_ ()=default
 
std::shared_ptr< AbstractDataTableclone () const override
 
DataTable_< double, double > flatten () const
 Flatten the columns of this table to create a DataTable_<double, double>. More...
 
DataTable_< double, double > flatten (const std::vector< std::string > &suffixes) const
 Flatten the columns of this table to create a DataTable_<double, double>. More...
 
DataTable_< double, ThatETY > pack () const
 Pack the columns of this table to create a DataTable_<double, ThatETY>, where 'ThatETY' is the template parameter which can be SimTK::Vec3, SimTK::UnitVec3, SimTK::Quaternion, SimTK::SpatialVec and so on. More...
 
DataTable_< double, ThatETY > pack (const std::vector< std::string > &suffixes) const
 Pack the columns of this table to create a DataTable_<double, ThatETY>, where 'ThatETY' is the template parameter which can be SimTK::Vec3, SimTK::UnitVec3, SimTK::Quaternion, SimTK::SpatialVec and so on. More...
 
unsigned numComponentsPerElement () const override
 Retrieve the number of components each element (of type ETY) of the table is made of. More...
 
std::string toString (std::vector< int > rows={}, std::vector< std::string > columnLabels={}, const bool withMetaData=true, unsigned splitSize=25, unsigned maxWidth=80, unsigned precision=4) const
 Get a string representation of the table, including the key-value pairs in the table metadata. More...
 
void appendRow (const double &indRow, const Container &container)
 Append row to the DataTable_. More...
 
void appendRow (const double &indRow, const std::initializer_list< ETY > &container)
 Append row to the DataTable_. More...
 
void appendRow (const double &indRow, RowIter begin, RowIter end)
 Append row to the DataTable_. More...
 
void appendRow (const double &indRow, const RowVector &depRow)
 Append row to the DataTable_. More...
 
void appendRow (const double &indRow, const RowVectorView &depRow)
 Append row to the DataTable_. More...
 
const RowVectorView getRowAtIndex (size_t index) const
 Get row at index. More...
 
const RowVectorView getRow (const double &ind) const
 Get row corresponding to the given entry in the independent column. More...
 
RowVectorView updRowAtIndex (size_t index)
 Update row at index. More...
 
RowVectorView updRow (const double &ind)
 Update row corresponding to the given entry in the independent column. More...
 
void setRowAtIndex (size_t index, const RowVectorView &depRow)
 Set row at index. More...
 
void setRowAtIndex (size_t index, const RowVector &depRow)
 Set row at index. More...
 
void setRow (const double &ind, const RowVectorView &depRow)
 Set row corresponding to the given entry in the independent column. More...
 
void setRow (const double &ind, const RowVector &depRow)
 Set row corresponding to the given entry in the independent column. More...
 
void removeRowAtIndex (size_t index)
 Remove row at index. More...
 
void removeRow (const double &ind)
 Remove row corresponding to the given entry in the independent column. More...
 
const std::vector< double > & getIndependentColumn () const
 Get independent column. More...
 
void appendColumn (const std::string &columnLabel, const Container &container)
 Append column to the DataTable_ using a sequence container. More...
 
void appendColumn (const std::string &columnLabel, const std::initializer_list< ETY > &container)
 Append column to the DataTable_ using an initializer list. More...
 
void appendColumn (const std::string &columnLabel, ColIter begin, ColIter end)
 Append column to the DataTable_ using an iterator pair. More...
 
void appendColumn (const std::string &columnLabel, const Vector &depCol)
 Append column to the DataTable_ using a SimTK::Vector. More...
 
void appendColumn (const std::string &columnLabel, const VectorView &depCol)
 Append column to the DataTable_ using a SimTK::VectorView. More...
 
VectorView getDependentColumnAtIndex (size_t index) const
 Get dependent column at index. More...
 
VectorView getDependentColumn (const std::string &columnLabel) const
 Get dependent Column which has the given column label. More...
 
VectorView updDependentColumnAtIndex (size_t index)
 Update dependent column at index. More...
 
VectorView updDependentColumn (const std::string &columnLabel)
 Update dependent Column which has the given column label. More...
 
void setIndependentValueAtIndex (size_t rowIndex, const double &value)
 Set value of the independent column at index. More...
 
const MatrixViewgetMatrix () const
 Get a read-only view to the underlying matrix. More...
 
MatrixView getMatrixBlock (size_t rowStart, size_t columnStart, size_t numRows, size_t numColumns) const
 Get a read-only view of a block of the underlying matrix. More...
 
MatrixViewupdMatrix ()
 Get a writable view to the underlying matrix. More...
 
MatrixView updMatrixBlock (size_t rowStart, size_t columnStart, size_t numRows, size_t numColumns)
 Get a writable view of a block of the underlying matrix. More...
 
- Public Member Functions inherited from OpenSim::AbstractDataTable
 AbstractDataTable ()=default
 
 AbstractDataTable (const AbstractDataTable &)=default
 
 AbstractDataTable (AbstractDataTable &&)=default
 
AbstractDataTableoperator= (const AbstractDataTable &)=default
 
AbstractDataTableoperator= (AbstractDataTable &&)=default
 
virtual ~AbstractDataTable ()=default
 
size_t getNumRows () const
 Get number of rows. More...
 
size_t getNumColumns () const
 Get number of dependent columns. More...
 
bool hasColumn (const size_t columnIndex) const
 Check if the table has a column with the given index. More...
 
template<typename Value >
void addTableMetaData (const std::string &key, const Value &value)
 Add key-value pair to the table metadata. More...
 
bool hasTableMetaDataKey (const std::string &key) const
 Whether or not table metadata for the given key exists. More...
 
template<typename Value >
Value getTableMetaData (const std::string &key) const
 Get table metadata for a given key. More...
 
std::string getTableMetaDataAsString (const std::string &key) const
 Get table metadata for a given key as a string. More...
 
void removeTableMetaDataKey (const std::string &key)
 Remove key-value pair associated with the given key from table metadata. More...
 
std::vector< std::string > getTableMetaDataKeys () const
 Get table metadata keys. More...
 
const TableMetaDatagetTableMetaData () const
 Get metadata associated with the table. More...
 
TableMetaDataupdTableMetaData ()
 Update metadata associated with the table. More...
 
const IndependentMetaDatagetIndependentMetaData () const
 Get metadata associated with the independent column. More...
 
void setIndependentMetaData (const IndependentMetaData &independentMetaData)
 Set metadata associated with the independent column. More...
 
const DependentsMetaDatagetDependentsMetaData () const
 Get metadata associated with the dependent columns. More...
 
void setDependentsMetaData (const DependentsMetaData &dependentsMetaData)
 Set metadata associated with the dependent columns. More...
 
void removeDependentsMetaDataForKey (const std::string &key)
 Remove key-value pair associated with the given key from dependents metadata. More...
 
bool hasColumnLabels () const
 Does the table have non-zero number of column labels. More...
 
std::vector< std::string > getColumnLabels () const
 Get column labels. More...
 
const std::string & getColumnLabel (const size_t columnIndex) const
 Get column label of a given column. More...
 
template<typename InputIt >
void setColumnLabels (InputIt first, InputIt last)
 Set column labels using a pair of iterators. More...
 
template<typename Container >
void setColumnLabels (const Container &columnLabels)
 Set column labels using a sequence container. More...
 
void setColumnLabels (const std::initializer_list< std::string > &columnLabels)
 Set column labels using a std::initializer_list. More...
 
void setColumnLabel (const size_t columnIndex, const std::string &columnLabel)
 Set the label for a column. More...
 
size_t getColumnIndex (const std::string &columnLabel) const
 Get index of a column label. More...
 
bool hasColumn (const std::string &columnLabel) const
 Check if the table has a column with the given label. More...
 

Public Types

typedef SimTK::RowVector_< ETY > RowVector
 
typedef SimTK::RowVectorView_< ETY > RowVectorView
 
- Public Types inherited from OpenSim::DataTable_< double, ETY >
typedef SimTK::RowVector_< ETY > RowVector
 Type of each row of matrix holding dependent data. More...
 
typedef SimTK::RowVectorView_< ETY > RowVectorView
 (Read only view) Type of each row of matrix. More...
 
typedef SimTK::Vector_< ETY > Vector
 Type of each column of matrix holding dependent data. More...
 
typedef SimTK::VectorView_< ETY > VectorView
 Type of each column of matrix holding dependent data. More...
 
typedef SimTK::Matrix_< ETY > Matrix
 Type of the matrix holding the dependent data. More...
 
typedef SimTK::MatrixView_< ETY > MatrixView
 (Read only view) Type of the matrix holding the dependent data. More...
 
- Public Types inherited from OpenSim::AbstractDataTable
typedef ValueArrayDictionary TableMetaData
 
typedef ValueArrayDictionary DependentsMetaData
 
typedef ValueArrayDictionary IndependentMetaData
 

Protected Member Functions

void validateRow (size_t rowIndex, const double &time, const RowVector &row) const override
 Validate the given row. More...
 
- Protected Member Functions inherited from OpenSim::DataTable_< double, ETY >
 DataTable_ (const std::vector< double > &indVec, const SimTK::Matrix_< ETY > &depData, const std::vector< std::string > &labels)
 Convenience constructor to efficiently populate a DataTable from known data. More...
 
 DataTable_ (const std::vector< double > &indVec)
 Construct a table with only the independent column and 0 dependent columns. More...
 
std::string toString_impl (std::vector< int > rows={}, std::vector< int > cols={}, const bool withMetaData=true, unsigned splitSize=25, unsigned maxWidth=80, unsigned precision=4) const
 
bool isEmpty () const
 Determine whether table is empty. More...
 
bool isRowIndexOutOfRange (size_t index) const
 Check if row index is out of range. More...
 
bool isColumnIndexOutOfRange (size_t index) const
 Check if column index is out of range. More...
 
size_t implementGetNumRows () const override
 Get number of rows. More...
 
size_t implementGetNumColumns () const override
 Get number of columns. More...
 
void validateIndependentMetaData () const override
 Validate metadata for independent column. More...
 
void validateDependentsMetaData () const override
 Validate metadata for dependent columns. More...
 
- Protected Member Functions inherited from OpenSim::AbstractDataTable
void appendColumnLabel (const std::string &columnLabel)
 Append column-label. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from OpenSim::DataTable_< double, ETY >
static void splitAndAssignElement (Iter begin, Iter end, const SimTK::Vec< N > &elem)
 
static void splitAndAssignElement (Iter begin, Iter end, const SimTK::Vec< M, SimTK::Vec< N >> &elem)
 
static void splitAndAssignElement (Iter begin, Iter end,...)
 
static SimTK::RowVector_< double > splitElement (const ELT &elt)
 
static SimTK::RowVector_< double > splitElement (const double &elt)
 
static void makeElement_helper (double &elem, Iter begin, Iter end)
 
static void makeElement_helper (SimTK::Vec< N > &elem, Iter begin, Iter end)
 
static void makeElement_helper (SimTK::Vec< M, SimTK::Vec< N >> &elem, Iter begin, Iter end)
 
static ETY makeElement (Iter begin, Iter end)
 
static constexpr unsigned numComponentsPerElement_impl (double)
 
static constexpr unsigned numComponentsPerElement_impl (SimTK::Vec< M >)
 
static constexpr unsigned numComponentsPerElement_impl (SimTK::Vec< M, SimTK::Vec< N >>)
 
- Protected Attributes inherited from OpenSim::DataTable_< double, ETY >
std::vector< double > _indData
 
SimTK::Matrix_< ETY > _depData
 
- Protected Attributes inherited from OpenSim::AbstractDataTable
TableMetaData _tableMetaData
 
DependentsMetaData _dependentsMetaData
 
IndependentMetaData _independentMetaData
 

Detailed Description

template<typename ETY = SimTK::Real>
class OpenSim::TimeSeriesTable_< ETY >

TimeSeriesTable_ is a DataTable_ where the independent column is time of type double.

The time column is enforced to be strictly increasing.

Member Typedef Documentation

◆ RowVector

template<typename ETY = SimTK::Real>
typedef SimTK::RowVector_<ETY> OpenSim::TimeSeriesTable_< ETY >::RowVector

◆ RowVectorView

template<typename ETY = SimTK::Real>
typedef SimTK::RowVectorView_<ETY> OpenSim::TimeSeriesTable_< ETY >::RowVectorView

Constructor & Destructor Documentation

◆ TimeSeriesTable_() [1/8]

template<typename ETY = SimTK::Real>
OpenSim::TimeSeriesTable_< ETY >::TimeSeriesTable_ ( )
default

◆ TimeSeriesTable_() [2/8]

template<typename ETY = SimTK::Real>
OpenSim::TimeSeriesTable_< ETY >::TimeSeriesTable_ ( const TimeSeriesTable_< ETY > &  )
default

◆ TimeSeriesTable_() [3/8]

template<typename ETY = SimTK::Real>
OpenSim::TimeSeriesTable_< ETY >::TimeSeriesTable_ ( TimeSeriesTable_< ETY > &&  )
default

◆ ~TimeSeriesTable_()

template<typename ETY = SimTK::Real>
OpenSim::TimeSeriesTable_< ETY >::~TimeSeriesTable_ ( )
default

◆ TimeSeriesTable_() [4/8]

template<typename ETY = SimTK::Real>
OpenSim::TimeSeriesTable_< ETY >::TimeSeriesTable_ ( const std::vector< double > &  indVec,
const SimTK::Matrix_< ETY > &  depData,
const std::vector< std::string > &  labels 
)
inline

Convenience constructor to efficiently populate a time series table from available data.

This is primarily useful for constructing with large data read in from file without having to reallocate and copy memory.

◆ TimeSeriesTable_() [5/8]

template<typename ETY = SimTK::Real>
OpenSim::TimeSeriesTable_< ETY >::TimeSeriesTable_ ( const std::vector< double > &  indVec)
inline

Construct a table with only the independent (time) column and 0 dependent columns.

This constructor is useful if you want to populate the table by appending columns rather than by appending rows.

◆ TimeSeriesTable_() [6/8]

template<typename ETY = SimTK::Real>
OpenSim::TimeSeriesTable_< ETY >::TimeSeriesTable_ ( const DataTable_< double, ETY > &  datatable)
inline

Construct a TimeSeriesTable_ from a DataTable_.

Exceptions
InvalidTableIf the input table's independent column is not strictly increasing.

◆ TimeSeriesTable_() [7/8]

template<typename ETY = SimTK::Real>
OpenSim::TimeSeriesTable_< ETY >::TimeSeriesTable_ ( const std::string &  filename)
inline

Construct TimeSeriesTable_ from a file.

Parameters
filenameName of the file.
Exceptions
InvalidArgumentIf the input file contains more than one table.
InvalidArgumentIf the input file contains a table that is not of this TimeSeriesTable_ type.

◆ TimeSeriesTable_() [8/8]

template<typename ETY = SimTK::Real>
OpenSim::TimeSeriesTable_< ETY >::TimeSeriesTable_ ( const std::string &  filename,
const std::string &  tablename 
)
inline

Construct TimeSeriesTable_ from a file.

Parameters
filenameName of the file.
tablenameName of the table in the file to construct this TimeSeriesTable_ from. For example, a c3d file contains tables named 'markers' and 'forces'.
Exceptions
InvalidArgumentIf the input file contains more than one table and tablename was not specified.
InvalidArgumentIf the input file contains a table that is not of this TimeSeriesTable_ type.

Member Function Documentation

◆ averageRow()

template<typename ETY = SimTK::Real>
RowVector OpenSim::TimeSeriesTable_< ETY >::averageRow ( const double &  beginTime,
const double &  endTime 
) const
inline

Compute the average row in the time range (inclusive) given.

This operation does not modify the table. It just computes and returns an average row.

Exceptions
InvalidTimeRangeIf beginTime is greater than or equal to endTime.
TimeOutOfRangeIf beginTime or endTime is out of range of time column.

◆ getNearestRow()

template<typename ETY = SimTK::Real>
RowVectorView OpenSim::TimeSeriesTable_< ETY >::getNearestRow ( const double &  time,
const bool  restrictToTimeRange = true 
) const
inline

Get row whose time column is nearest/closest to the given value.

Parameters
timeValue to search for.
restrictToTimeRangeWhen true – Exception is thrown if the given value is out-of-range of the time column. When false – If the given value is less than or equal to the first value in the time column, the row returned is the first row. If the given value is greater than or equal to the last value in the time column, the row returned is the last row. This operation only returns existing rows and does not perform any interpolation. Defaults to 'true'.
Exceptions
TimeOutOfRangeIf the given value is out-of-range of time column.
EmptyTableIf the table is empty.

◆ getNearestRowIndexForTime()

template<typename ETY = SimTK::Real>
size_t OpenSim::TimeSeriesTable_< ETY >::getNearestRowIndexForTime ( const double  time,
const bool  restrictToTimeRange = true 
) const
inline

Get index of row whose time is nearest/closest to the given value.

Parameters
timeValue to search for.
restrictToTimeRangeWhen true – Exception is thrown if the given value is out-of-range of the time column. A value within SimTK::SignifcantReal of a time column bound is considered to be equal to the bound. When false – If the given value is less than or equal to the first value in the time column, the index returned is of the first row. If the given value is greater than or equal to the last value in the time column, the index of the last row is returned. Defaults to 'true'.
Exceptions
TimeOutOfRangeIf the given value is out-of-range of time column.
EmptyTableIf the table is empty.

Referenced by OpenSim::TimeSeriesTable_< ValueT >::getNearestRow(), and OpenSim::TimeSeriesTable_< ValueT >::updNearestRow().

◆ operator=() [1/2]

template<typename ETY = SimTK::Real>
TimeSeriesTable_& OpenSim::TimeSeriesTable_< ETY >::operator= ( const TimeSeriesTable_< ETY > &  )
default

◆ operator=() [2/2]

template<typename ETY = SimTK::Real>
TimeSeriesTable_& OpenSim::TimeSeriesTable_< ETY >::operator= ( TimeSeriesTable_< ETY > &&  )
default

◆ updNearestRow()

template<typename ETY = SimTK::Real>
RowVectorView OpenSim::TimeSeriesTable_< ETY >::updNearestRow ( const double &  time,
const bool  restrictToTimeRange = true 
)
inline

Get writable reference to row whose time column is nearest/closest to the given value.

Parameters
timeValue to search for.
restrictToTimeRangeWhen true – Exception is thrown if the given value is out-of-range of the time column. When false – If the given value is less than or equal to the first value in the time column, the row returned is the first row. If the given value is greater than or equal to the last value in the time column, the row returned is the last row. This operation only returns existing rows and does not perform any interpolation. Defaults to 'true'.
Exceptions
TimeOutOfRangeIf the given value is out-of-range of time column.
EmptyTableIf the table is empty.

◆ validateRow()

template<typename ETY = SimTK::Real>
void OpenSim::TimeSeriesTable_< ETY >::validateRow ( size_t  rowIndex,
const double &  time,
const RowVector row 
) const
inlineoverrideprotectedvirtual

Validate the given row.

Exceptions
InvalidRowIf the timestamp for the row breaks strictly increasing property of the independent column.

Reimplemented from OpenSim::DataTable_< double, ETY >.

Referenced by OpenSim::TimeSeriesTable_< ValueT >::TimeSeriesTable_().


The documentation for this class was generated from the following file: