Search code examples
pythonmatopenmodelica

How read .mat openmodelica result file in python correctly?


I tried to read modelica resul file (.mat) in python and used code like this:

data = scipy.io.loadmat('TPPSim.Boilers.Tests.EMA_028_HRSG_Test_res.mat')
print data.keys()
['Aclass', 'dataInfo', 'name', 'data_2', 'data_1', 'description']

names = [''.join(s).rstrip() for s in zip(*data['name'])]
len(names)    
899

But it's not all variables that i can see in 'OMEdit plotting'. I think that's only variables that have derivatives in simulation.

And data['data_1'] have more than 899 sets of data:

data['data_2'][0]
4192L

How I can get all results in Python?

Sorry for my bad English.

Artyom.


Solution

  • You could use a Python library that handles the format, such as DyMat

    d = DyMat.DyMatFile('TPPSim.Boilers.Tests.EMA_028_HRSG_Test_res.mat')
    print(d.names())