i have to analyse/visualize results of simulations(Simulink, EES) in Python.
Averaged I have to import 40-100 variables (each variable is a vector with several thausend rows) from a result file: Each Variable has a appropriate path in result.data("path to varaible") My workflow is the following (not really efficient):
Result = {}
Result["VariableA"] = result.data("moment1.p3.Temperatur")
Result["VariableB"] = result.data("moment2.p1.pressure")
..
..
At the end I have a code with around 100 lines - and every line is almost the same. So I assume that there is maybe a better way to do that.
I would be very grateful for suggestions
You should define a dictionary with all the variable/path definitions like
paths = {"VariableA": "moment1.p3.Temperatur",
"VariableB": "moment2.p1.pressure",
...
}
Then you can do
Result = {key: result.data(paths[key]) for key in paths}
or (possibly faster)
Result = {key: result.data(value) for key, value in paths.items()}
(assuming Python 3, otherwise use paths.iteritems()
)