Page 1 of 1
TimeSeriesTable
Posted: Fri Feb 14, 2020 7:28 am
by kernalnet
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
Re: TimeSeriesTable
Posted: Fri Feb 14, 2020 9:06 am
by tkuchida
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.
Re: TimeSeriesTable
Posted: Sat Feb 15, 2020 1:43 am
by kernalnet
Would you please show me an example?
Cheers
Re: TimeSeriesTable
Posted: Sat Feb 15, 2020 7:18 am
by tkuchida
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]
Re: TimeSeriesTable
Posted: Sat Feb 15, 2020 4:42 pm
by kernalnet
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
Re: TimeSeriesTable
Posted: Sat Feb 15, 2020 7:56 pm
by tkuchida
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.