Reading matlab timeseries in python not working

54 Views Asked by At

I cannot read timeseries values of .mat files in python.

The only workaround I have found is to split the time series into two one for data and one for time so that I can be able to store them in a python array:

   import scipy.io
   import numpy as np

   def load_model_parameters(file_path):
        return scipy.io.loadmat(file_path)
    
    
    mat_data0 = load_model_parameters('assets/normal_data.mat')
    mat_data1 = load_model_parameters('assets/timeseries_data.mat')
    
    print(mat_data0)
    print(mat_data1)

First mat_data0 gives the following: (Which is expected, values are correct and can be retrieved easily)

{'__header__': b'MATLAB 5.0 MAT-file, Platform: PCWIN64, Created on: Fri Feb  9 13:02:38 2024', '__version__': '1.0', '__globals__': [], 'data': array([[0.00000000e+00],
       [0.00000000e+00],
       [3.46944695e-18],
       [3.46944695e-18],
       [3.46944695e-18],
       [1.41937759e-05],
       [8.52688617e-03],
       [2.23877453e-03],
       [7.83785726e-05]])}

Second mat_data1 gives the following: (I can't find my timeseries values)

{'__header__': b'MATLAB 5.0 MAT-file, Platform: PCWIN64, Created on: Fri Feb  9 12:32:59 2024', '__version__': '1.0', '__globals__': [], 'None': MatlabOpaque([(b'test2', b'MCOS', b'timeseries', array([[3707764736],
                     [         2],
                     [         1],
                     [         1],
                     [         1],
                     [         5]], dtype=uint32))                   ],
             dtype=[('s0', 'O'), ('s1', 'O'), ('s2', 'O'), ('arr', 'O')]), '__function_workspace__': array([[ 0,  1, 73, ...,  0,  0,  0]], dtype=uint8)}

I'm not sure how to dereference the timeseries data of mat_data1. Is there a solution for it ?

0

There are 0 best solutions below