TimeSeriesTable

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Mohammadreza Rezaie
Posts: 408
Joined: Fri Nov 24, 2017 12:48 am

TimeSeriesTable

Post by Mohammadreza Rezaie » Fri Feb 14, 2020 7:28 am

Dear Experts,

I want to read the ".sto" data in python (Spyder).
And this is the beginings:

dir = os.path.abspath('..\desktop')
series= opensim.TimeSeriesTable
data = series(os.path.join(dir, 'JRF.sto'))

But the result is an unsupported data type (TimeSeriesTable object of OpenSim.common module).

Are there any extra functions I have to use for reading the data values?

Your response would be greatly appreciated.

Cheers

Tags:

User avatar
Thomas Uchida
Posts: 1793
Joined: Wed May 16, 2012 11:40 am

Re: TimeSeriesTable

Post by Thomas Uchida » Fri Feb 14, 2020 9:06 am

Here are some Python test cases that use the TimeSeriesTable: https://github.com/opensim-org/opensim- ... eriestable. Methods for reading from a TimeSeriesTable can be found in the doxygen documentation: https://simtk.org/api_docs/opensim/api_ ... ble__.html.

User avatar
Mohammadreza Rezaie
Posts: 408
Joined: Fri Nov 24, 2017 12:48 am

Re: TimeSeriesTable

Post by Mohammadreza Rezaie » Sat Feb 15, 2020 1:43 am

Would you please show me an example?

Cheers

User avatar
Thomas Uchida
Posts: 1793
Joined: Wed May 16, 2012 11:40 am

Re: TimeSeriesTable

Post by Thomas Uchida » Sat Feb 15, 2020 7:18 am

Code: Select all

import opensim as osim
table = osim.TimeSeriesTable('test.sto')
print table.getNumColumns()
print table.getNumRows()
print table.getColumnLabels()
timeVector = table.getIndependentColumn()
print timeVector[0]
print timeVector[1]
firstColumn = table.getDependentColumnAtIndex(0)
print firstColumn[0]
print firstColumn[1]

User avatar
Mohammadreza Rezaie
Posts: 408
Joined: Fri Nov 24, 2017 12:48 am

Re: TimeSeriesTable

Post by Mohammadreza Rezaie » Sat Feb 15, 2020 4:42 pm

Hi Thomas,

Many thanks for those examples,
But I need to read data in arrays (like converting OpenSim table to struct or double in MATLAB).
"firstColumn = table.getDependentColumnAtIndex(0)" is still classified as an unsupported data type.
I've tried using "for loop" to generate an array for total columns but I didn't succeed.
Any help would be greatly appreciated.

Regards

User avatar
Thomas Uchida
Posts: 1793
Joined: Wed May 16, 2012 11:40 am

Re: TimeSeriesTable

Post by Thomas Uchida » Sat Feb 15, 2020 7:56 pm

You could populate a data structure in Python by iterating through each row and column of the table, but the best coding strategy depends on what you're trying to do. It may be more efficient to just access the values directly from the OpenSim table.

POST REPLY