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
TimeSeriesTable
- Mohammadreza Rezaie
- Posts: 412
- Joined: Fri Nov 24, 2017 12:48 am
- Thomas Uchida
- Posts: 1794
- Joined: Wed May 16, 2012 11:40 am
Re: TimeSeriesTable
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.
- Mohammadreza Rezaie
- Posts: 412
- Joined: Fri Nov 24, 2017 12:48 am
Re: TimeSeriesTable
Would you please show me an example?
Cheers
Cheers
- Thomas Uchida
- Posts: 1794
- Joined: Wed May 16, 2012 11:40 am
Re: TimeSeriesTable
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]
- Mohammadreza Rezaie
- Posts: 412
- Joined: Fri Nov 24, 2017 12:48 am
Re: TimeSeriesTable
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
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
- Thomas Uchida
- Posts: 1794
- Joined: Wed May 16, 2012 11:40 am
Re: TimeSeriesTable
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.