![]() ![]() If isinstance(elem, 5_params.mat_struct): If isinstance(dict, 5_params.mat_struct):Ī recursive function which constructs from matobjects nested dictionaries Todict is called to change them to nested dictionaries It calls the function check keys to cure all entriesĭata = spio.loadmat(filename, struct_as_record=False, squeeze_me=True)Ĭhecks if entries in dictionary are mat-objects. This function should be called instead of direct spio.loadmatĪs it cures the problem of not properly recovering python dictionariesįrom mat files. Here are the functions, which reconstructs the dictionaries just use this loadmat instead of scipy.io's loadmat: import scipy.io as spio Now it was possible to access it by > v.c.d However, by using the option struct_as_record=False the field could be accessed: v=spio.loadmat('xy.mat',squeeze_me=True,struct_as_record=False) ValueError Traceback (most recent call last) If I now want to access the fields I get: > vigĪrray(((array(3),),), dtype=)Īrray(array((3,), dtype=), dtype=object) I tried the following: vig=spio.loadmat('xy.mat',squeeze_me=True) ![]() Now I want to read the mat-File back into python. To present the problem I run into in more detail, I give the following toy example: load scipy.io as spio mat files with scipy), I could not access deeper nested structures to recover them into dictionaries Oid = h5o.open(self.id, self._e(name), lapl=self._lapl)įile "C:\Program Files\Python37\lib\site-packages\h5py\_hl\base.py", line 137, in _eĪttributeError: 'numpy.Using the given routines (how to load Matlab. I have also tried this: > for element in tfr:įile "C:\Program Files\JetBrains\P圜harm Community Edition 2018.3.2\helpers\pydev\_pydevd_bundle\pydevd_exec2.py", line 3, in Execįile "C:\Program Files\Python37\lib\site-packages\h5py\_hl\group.py", line 262, in _getitem_ Does anyone know how I can use this to actually address the timeseries data? Or even find my signals? "Use dataset instead.", H5pyDeprecationWarning)Ĭlearly tfr is an object reference but I can't seem to do anything with it. ValueError: Field names only allowed for compound typesĬ:\Program Files\Python37\lib\site-packages\h5py\_hl\dataset.py:313: H5pyDeprecationWarning: dataset.value has been deprecated. Raise ValueError("Field names only allowed for compound types") New_dtype = readtime_dtype(self.id.dtype, names)įile "C:\Program Files\Python37\lib\site-packages\h5py\_hl\dataset.py", line 48, in readtime_dtype f = h5.File(mat_dir + file_name, 'r')įile "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapperįile "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapperįile "C:\Program Files\Python37\lib\site-packages\h5py\_hl\dataset.py", line 506, in _getitem_ mat_dir = r'C:\Users\Perry\Desktop\testing\Matlab' I've got a sample down to a simple file that should have 3 signals as shown above and I'm trying to extract the data: Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) on win32 ![]() I can't seem to address the data or even find the signals. I've spent the day reviewing various tips and tricks here and here but seem to be stuck. I need to be able to access the time series data that is stored to put it into a numpy array. The data from matlab is in the attached Screenshot: Timeseries Matalab Screenshot I'm using python 3.7 and h5py in order to convert the data into comtrade format. I am trying to read a matlab file created by a colleague. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |