ratal / mdfreader

Read Measurement Data Format (MDF) versions 3.x and 4.x file formats in python
Other
169 stars 73 forks source link

Error when using method get_channel_data(... , raw_data=True) #168

Closed bbto89 closed 4 years ago

bbto89 commented 4 years ago

Python version

'3.6.9'

Platform information

' Windows 10 Enterprise Version 1809 - Build 17763.678'

Numpy version

'1.16.4'

mdfreader version

'3.2'

Description

After updating to mdfreader version 3.2, I have encountered the following issue: In my script I am loading a .mf4 file with the option no_data_loading=True. Later, I read every channel explicitly by calling get_channel_data with the option raw_data=True. This results in the following error:

File "D:...\converter\format\mdf\converter.py", line 90, in _export     raw = mdf.get_channel_data(signal.name, raw_data=True) File "C:...\lib\site-packages\mdfreader\mdfreader.py", line 474, in get_channel_data     vector = self._get_channel_data4(channel_name, raw_data) File "C:...\lib\site-packages\mdfreader\mdf4reader.py", line 1457, in _get_channel_data4     self.read4(file_name=None, info=None, channel_list=[channel_name], convert_after_read=False) File "C:...\lib\site-packages\mdfreader\mdf4reader.py", line 1277, in read4     if not info['DG'][dataGroup]['dg_data'] == 0 and \ KeyError: (0, 0, 1)

Some further things I noticed: The code worked properly with an older version of the mdfreader (2.7.6) Also, the code works if I set the option raw_data=False when calling the get_channel_data method.

ratal commented 4 years ago

Hi, I do not understand the keyerror for this condition check. Can you debug there and tell what are the values several elements in the condition statement ? Some snapshot from MDFvalidator of the related datagroup and channel group woudl probably also to understand special corner case that is missed in the code.

bbto89 commented 4 years ago
import mdfreader

mdf = mdfreader.Mdf('ASAP2_Demo_V171.mf4', no_data_loading=True)
info = mdfreader.MdfInfo('ASAP2_Demo_V171.mf4')
channels = info.list_channels()

for channel in channels:
    values = mdf.get_channel_data(channel)
    raw = mdf.get_channel_data(channel, raw_data=True)

Hi, the error above happens with the code in this comment using the mf4 example from ASAM. Link to the mf4 file: https://www.asam.net/standards/detail/mdf/wiki/#Downloads If no_data_loading is set to False, the code works flawlessly. Thanks!

ratal commented 4 years ago

I pushed modifications that should solve this bug, you can check in dev branch. Thanks for reporting it.

bbto89 commented 4 years ago

Hi,

just tested the fix with several files. Works perfectly, thank you!

bbto89 commented 4 years ago

Hi,

would you be so kind to release the fix on your master branch? This would be greatly appreciated. Thanks!