Stefanowitschko
Stefanowitschko

Reputation: 41

Loading previously saved JModelica result-file

I got the following question:

I am loading a JModelica model and simulate it easily by doing:

from pymodelica import compile_fmu
from pyfmi import load_fmu

model = load_fmu(SOME_FMU);
res=model.simulate();

Everything works fine and it even saves a resulting .txt - file. Now, with this .txt the problem is that I did not find any funtionality so far within the jmodelica-python packages to actually load such an .txt result file again later on into a result-object ( like the one being returned by simulate() ) to easily extract the previous saved data.

Implementing that by hand is of course possible but I find it quiet nasty and just wanted to ask if anyone knows of method that does the job to load that JModlica-format result-file into an result object for me.

Thanks!!!!

Upvotes: 0

Views: 179

Answers (1)

Christian Winther
Christian Winther

Reputation: 1123

The functionality that you need is located in the io module:

    from pyfmi.common.io import ResultDymolaTextual
    res = ResultDymolaTextual("MyResult.txt")

    var = res.get_variable_data("MyVariable")

    var.x #Trajectory
    var.t #Corresponding time vector

Upvotes: 1

Related Questions