[英]Python post-processing
i have to analyse/visualize results of simulations(Simulink, EES) in Python.我必须在 Python 中分析/可视化模拟(Simulink、EES)的结果。
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):平均我必须从结果文件中导入 40-100 个变量(每个变量是一个带有多个 thausend 行的向量):每个变量在 result.data("path to varaible") 中有一个适当的路径我的工作流程如下(不是真的高效的):
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.最后,我有一个大约 100 行的代码——每一行几乎都一样。 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()
) (假设 Python 3,否则使用
paths.iteritems()
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.