API 4.4.1-2022-10-19-2c4045e59
For MATLAB, Python, Java, and C++ users
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...
 
size_t getRowIndexAfterTime (const double &time) const
 Get index of row whose time is first to be higher than the given value. More...
 
size_t getRowIndexBeforeTime (const double &time) const
 Get index of row whose time is the largest time less than 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...
 
void trim (const double &newStartTime, const double &newFinalTime)
 Trim TimeSeriesTable to rows that have times that lies between newStartTime, newFinalTime. More...
 
void trimFrom (const double &newStartTime)
 trim TimeSeriesTable, keeping rows at newStartTime to the end. More...
 
void trimTo (const double &newFinalTime)
 trim TimeSeriesTable, keeping rows up to newFinalTime More...
 
- Public Member Functions inherited from OpenSim::DataTable_< double, SimTK::Real >
 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< SimTK::Real > &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< SimTK::Real > &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...
 
void removeColumnAtIndex (size_t index)
 Remove column corresponding to the given column index. More...
 
void removeColumn (const std::string &columnLabel)
 Remove column corresponding to the given dependent column label. 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...
 

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.

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.

References OpenSim::DataTable_< double, SimTK::Real >::_depData, OpenSim::DataTable_< double, SimTK::Real >::_indData, OpenSim::AbstractDataTable::removeDependentsMetaDataForKey(), OpenSim::DataTable_< double, SimTK::Real >::validateDependentsMetaData(), and OpenSim::TimeSeriesTable_< ETY >::validateRow().

◆ 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.

References OpenSim::DataTable_< double, SimTK::Real >::_depData, OpenSim::DataTable_< double, SimTK::Real >::_indData, OpenSim::AbstractDataTable::removeDependentsMetaDataForKey(), OpenSim::DataTable_< double, SimTK::Real >::validateDependentsMetaData(), and OpenSim::TimeSeriesTable_< ETY >::validateRow().

◆ 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.

References OpenSim::FileAdapter::createAdapterFromExtension().

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

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.

References OpenSim::TimeSeriesTable_< ETY >::getNearestRowIndexForTime().

◆ 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_< ETY >::getNearestRow(), OpenSim::TimeSeriesTable_< ETY >::getRowIndexAfterTime(), OpenSim::TimeSeriesTable_< ETY >::getRowIndexBeforeTime(), and OpenSim::TimeSeriesTable_< ETY >::updNearestRow().

◆ getRowIndexAfterTime()

template<typename ETY = SimTK::Real>
size_t OpenSim::TimeSeriesTable_< ETY >::getRowIndexAfterTime ( const double &  time) const
inline

Get index of row whose time is first to be higher than the given value.

Parameters
timeValue to search for.

References OpenSim::TimeSeriesTable_< ETY >::getNearestRowIndexForTime().

Referenced by OpenSim::TimeSeriesTable_< ETY >::trim().

◆ getRowIndexBeforeTime()

template<typename ETY = SimTK::Real>
size_t OpenSim::TimeSeriesTable_< ETY >::getRowIndexBeforeTime ( const double &  time) const
inline

Get index of row whose time is the largest time less than the given value.

Parameters
timeValue to search for.

References OpenSim::TimeSeriesTable_< ETY >::getNearestRowIndexForTime().

Referenced by OpenSim::TimeSeriesTable_< ETY >::trim().

◆ 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

◆ trim()

template<typename ETY = SimTK::Real>
void OpenSim::TimeSeriesTable_< ETY >::trim ( const double &  newStartTime,
const double &  newFinalTime 
)
inline

Trim TimeSeriesTable to rows that have times that lies between newStartTime, newFinalTime.

The trimming is done in place, no copy is made. Uses getRowIndexAfterTime to locate first row and getNearestRowIndexForTime method to locate last row.

References OpenSim::DataTable_< double, SimTK::Real >::getIndependentColumn(), OpenSim::AbstractDataTable::getNumRows(), OpenSim::TimeSeriesTable_< ETY >::getRowIndexAfterTime(), OpenSim::TimeSeriesTable_< ETY >::getRowIndexBeforeTime(), and OpenSim::TimeSeriesTable_< ETY >::trimToIndices().

Referenced by OpenSim::TimeSeriesTable_< ETY >::trimFrom(), and OpenSim::TimeSeriesTable_< ETY >::trimTo().

◆ trimFrom()

template<typename ETY = SimTK::Real>
void OpenSim::TimeSeriesTable_< ETY >::trimFrom ( const double &  newStartTime)
inline

trim TimeSeriesTable, keeping rows at newStartTime to the end.

References OpenSim::DataTable_< double, SimTK::Real >::getIndependentColumn(), and OpenSim::TimeSeriesTable_< ETY >::trim().

◆ trimTo()

template<typename ETY = SimTK::Real>
void OpenSim::TimeSeriesTable_< ETY >::trimTo ( const double &  newFinalTime)
inline

trim TimeSeriesTable, keeping rows up to newFinalTime

References OpenSim::DataTable_< double, SimTK::Real >::getIndependentColumn(), and OpenSim::TimeSeriesTable_< ETY >::trim().

◆ trimToIndices()

template<typename ETY = SimTK::Real>
void OpenSim::TimeSeriesTable_< ETY >::trimToIndices ( const size_t &  start_index,
const size_t &  last_index 
)
inlineprotected

◆ 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.

References OpenSim::TimeSeriesTable_< ETY >::getNearestRowIndexForTime().

◆ validateRow()

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

Validate the given row.

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

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


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