Semantic dependent variable retrieval: SimulationVariableDict and result2dict #115
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TL;DR
This pull requests implements semantic dependent variable retrieval using dependent variable settings objects, that is, to obtain time histories (
epoch
:value
maps) of dependent variables with ease, where thevalue
of the dependent variable at each epoch will be either numeric, vectorial, a matrix, etc.:Subject to approval and review
result2dict
functionTable of contents
Usage
This pull request implements the pure Python
SimulationVariableDict
dictionary-like class andresult2dict
function, which takes anumerical_simulation.SingleArcSimulator
and returns aSimulationVariableDict
.Both live in the
tudatpy.utils
module. Importingresult2dict
is done as follows:The goal of
result2dict
and theSimulationVariableDict
class is to make dependent variable time history retrieval semantic and straight-forward:See the complete example below. As you can see, we can use as keys either the
Original dependent variable settings object (
dependent_variables_to_save[0]
),Or a newly created dependent variable settings object (
propagation_setup.dependent_variable.total_acceleration("Delfi-C3")
)In-depth explanation
result2dict
result2dict
is a function that takes anumerical_simulation.SingleArcSimulator
object, obtains from it theSimulationVariableDict
which associates the dependent variable's ID string to its correct-shape time historySimulationVariableDict
SimulationVariableDict
is a dictionary-like class designed to store and retrieve dependent variable time histories using dependent variable settings objects (instances ofVariableSettings
-derived classes, check the Tudat API docs for more information about this class).How are time histories saved in a
SimulationVariableDict
?A
SimulationVariableDict
maps which maps dependent variables, identified by either theircorresponding dependent variable settings object (an instance of a
VariableSettings
-derivedclass) or its string ID, to their time histories.
The time history of each dependent variable is a Python
dict
which maps epochs (float
) toNumPy arrays (
np.ndarray
) of shape(A, B)
:Practical examples:
[1, 1]
(a number, most likely afloat
) for a scalar dependent variable[3, 1]
for a vectorial dependent variable[3, 3]
for a matrix dependent variable, etc.