You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to only load the .mat file partially?
When only wanting to extract a few variables it seems that still the whole .mat file is loaded. This results in a buffer overload error when the .mat file gets to big (e.g. when also the protected variables were stored for debugging purposes) which might be avoided when only the necessary data is loaded.
I checked indeed and it doesn't i'm afraid. DyMat uses the scipy.io.loadmat I mentioned but doesn't use the 'variables _names' option so I think it always loads the whole file.
@Walshest, I haven't.
DyMat (and later BuildingsPy) should be updated so that the optional argument 'variables_names' of scipy.io.loadmat could be used.
@thorade, indeed, exporting a smaller .MAT file is what I ended up doing. Well, I first simulated and stored all variables (might need them for later analysis or used to check the internal workings of the model/controls) then I plotted the once I needed and exported a .MAT file with only those variables.
This wasn't convient though and is a lot of manual work for bath simulations. It would be nice to be able to load only a subset of the original .MAT file directly in Python. I haven't actually tried this, but as scipy.io.loadmat can do it, probably the fix is not that far away. Although I don't think there is any active developement for DyMat.
However there is still a limitation when we run much longer & complex Modelica simulation e.g. for months/ year of seasonal operation.
It would be defiantly beneficial if the BuildingsPy was updated to support these larger files. e.g. only loading variables of interest or resampling of the variables.
Activity
mwetter commentedon Nov 16, 2021
Did you check if DyMat supports this? Reading the
.matfiles is done through theDyMatlibrary.kldjonge commentedon Nov 16, 2021
I checked indeed and it doesn't i'm afraid. DyMat uses the scipy.io.loadmat I mentioned but doesn't use the 'variables _names' option so I think it always loads the whole file.
Walshest commentedon Mar 2, 2022
Hi @kldjonge ,
Did you find a solution to the buffer error? I have the same issue with larger files: #474
kldjonge commentedon Mar 2, 2022
@Walshest, I haven't.
DyMat (and later BuildingsPy) should be updated so that the optional argument 'variables_names' of scipy.io.loadmat could be used.
thorade commentedon Mar 2, 2022
https://stackoverflow.com/questions/70513151/opening-big-result-mat-file-raises-buffer-is-too-small-for-requested-array
jraedler/DyMat#4
kldjonge commentedon Mar 3, 2022
@thorade, indeed, exporting a smaller .MAT file is what I ended up doing. Well, I first simulated and stored all variables (might need them for later analysis or used to check the internal workings of the model/controls) then I plotted the once I needed and exported a .MAT file with only those variables.
This wasn't convient though and is a lot of manual work for bath simulations. It would be nice to be able to load only a subset of the original .MAT file directly in Python. I haven't actually tried this, but as scipy.io.loadmat can do it, probably the fix is not that far away. Although I don't think there is any active developement for DyMat.
Walshest commentedon Mar 7, 2022
Hi @thorade and @kldjonge ,
Thanks for all of the feedback and suggestions.
I can confirm that Variable selections as outlined here: https://stackoverflow.com/questions/70513151/opening-big-result-mat-file-raises-buffer-is-too-small-for-requested-array reduced the size of the simulation file a lot.
However there is still a limitation when we run much longer & complex Modelica simulation e.g. for months/ year of seasonal operation.
bravache commentedon Mar 7, 2022
Thanks @Walshest , I agree that it would probably be better to allow BuildingsPy to handle larger results. I will take a look at it.