Comments (4)
Hi @mrrezaie, the docs say:
Uses getRowIndexAfterTime to locate first row and getNearestRowIndexForTime method to locate last row.
so the trimming might not be inclusive to the first time point. You could try providing a time value just before your initial time to include the first time index.
I'm not sure we will change this functionality, but regardless we should expose trimToIndices
so you have more control over the start time index.
from opensim-core.
Hi @nickbianco, thanks for your response, and exposing trimToIndices
.
Uses getRowIndexAfterTime to locate first row and getNearestRowIndexForTime method to locate last row.
so the trimming might not be inclusive to the first time point. You could try providing a time value just before your initial time to include the first time index.
Not sure if trim
is functioning as documented. In this example, it is including the first time.
import opensim as osim
import numpy as np
times = np.linspace(0,1,11)
# [0. 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9, 1. ]
col = np.arange(0,11, dtype=float)
# [0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.]
table = osim.TimeSeriesTable(times)
table.appendColumn('col', osim.Vector(col))
table.trim(0.1,0.9)
print(table.getDependentColumn('col').to_numpy())
# [1. 2. 3. 4. 5. 6. 7. 8. 9.]
And if some sort of rounding error occurs, the output might be unreliable:
error = 1e-12
times = np.linspace(0,1,11) - error
...
table.trim(0.1,0.9)
# [2. 3. 4. 5. 6. 7. 8. 9.]
times = np.linspace(0,1,11) + error
...
table.trim(0.1,0.9)
# [1. 2. 3. 4. 5. 6. 7. 8.]
But getNearestRowIndexForTime
always returns the correct index. Thank you.
from opensim-core.
Not sure if
trim
is functioning as documented.
IMHO the behavior in your examples is correct: trimming based on time points will always be sensitive to numerical noise. The trim
method guarantees that all returned points are within the specified range. If what you're trying to do is find the time point closest to a specified value, then getNearestRowIndexForTime
is the right idea. As @nickbianco suggested, a trimToIndices
method would be good if there's currently no way to do this. 🐴
from opensim-core.
Thanks for your explanation. So, I'll be looking forward to trimToIndices
method. Thanks for your time.
from opensim-core.
Related Issues (20)
- Distribute an example with CMakefiles to create a plugin and to load it in a test driver program
- Importing some old models (3.3) break due to renaming of path/wrap objects and uniqueness requirements HOT 1
- `MocoOrientationTrackingGoal::setStatesReference()` should not require non-kinematic states
- Moco verbosity in Google Colab
- Very different results between Inverse Dynamics GUI vs Python code HOT 1
- Add features/utilties to support `InputController` usage in Moco
- Create toy problem based on `CasOC::Problem` for testing AD formulations
- PointToPointSpring has no available Outputs
- Force::computePotentialEnergy() should not default to return 0.0
- Ensure that all Force elements compute and output their potential energy in order to perform accurate energy accounting in OpenSim
- DLL load failed while importing _simbody
- `Bhargava2004SmoothedMuscleMetabolics` does not set muscle mass during deserialization
- Allow extra columns for Controls file
- Removing an object from a `WrapObjectSet` in MATLAB leads to a crash during `model.finalizeConnections()` HOT 2
- CMBBE 2024 OpenSim Workshop
- Support the FATROP NLP solver in Moco
- Menu is distorted at high resolution laptops
- Upgrade Python version in ci HOT 4
- `StdVectorDouble` (and other similar classes) in MATLAB store java objects
- [Moco] Support optimizing properties nested inside other properties
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opensim-core.