1

I have been having some issues trying to open a simulation result output file (.mat) in Python. Upon loading the file I am faced with the following error:

ValueError: Not enough bytes to read matrix 'description'; is this a badly-formed file? Consider listing matrices with whosmat and loading named matrices with variable_names kwarg to loadmat

Has anyone been successful in rectifying this error? I have heard there is a script DyMat which can manage mat files in Python but haven't had any luck with it so far.

Any suggestions would be greatly appreciated.

AlG
  • 14,697
  • 4
  • 41
  • 54
  • What library are you using to open the file? That isn't a standard Python error message but seems to be thrown from some library. The error message itself seems to suggest a solution -- have you tried it? In any event, unless you post a [mcve] there isn't much for anyone to go on. – John Coleman Dec 06 '16 at 14:53
  • Hi John, So I see now that DyMat is in fact the library being used to load the result file. I am unsure what is meant by the term whosmat though and where I can access it. – Keith O'Donovan Dec 06 '16 at 15:31

1 Answers1

1

You can reduce the size of the simulation result file by using variable selections in Dymola. That will restrict the output to states, parameters, and the variables that match your selection criteria.

The new Dymola 2017 FD01 has a user interface for defining variable selections.

Dag B
  • 621
  • 3
  • 8
  • Another solution might be to convert the result file to SDF (a.k.a. HDF5) format, see Simulation>Setup in Dymola. There are Python functions in the Dymola distribution to read the SDF files. – Dag B Dec 17 '16 at 09:22