mdfreader
mdfreader copied to clipboard
Parsing error
Python version
Please write here the output of printing sys.version
3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 00:42:30) [MSC v.1916 64 bit (AMD64)]
Platform information
Please write here the output of printing platform.platform()
Windows-10-10.0.17763-SP0
Numpy version
Please write here the output of printing numpy.__version__
1.18.1
mdfreader version
Please write here the output of printing mdfreader.__version__
4.0
Description
Hi, I am trying to convert .mf4 (version 4.10) to mat file. The code I made using mdfreader gives me the converted file with multiple identical warnings: ...\Python\Python37\site-packages\mdfreader\mdfinfo4.py:597: UserWarning: Could not parse CG block names tag warn('Could not parse CG block names tag'). Comparing to a converted file using CANape, double-typed data stay as uint16 in my converted file. Could you please help me to correct the problem? The mf4 file is version 4.10 and does not have any error/warning message when imported to MDFValidator.
For the warning, it says mdfreader has difficulties to read the CG block xml metadata, not to worry too much. Regarding your data uint16 in CANape, it is normal it remains uint16 because its representation exists along with its conversion model. If for this channel your conversion from raw to physical need to multiply the uint16 to a float, the physical value can only be a float. If you use the parameter convert_after_read, you will probably see your channel is still uint16. However for the conversion to Matlab, you cannot realistically transfer the conversion model (doe not exist equivalent in Matlab), no choice than writing a float into your mat file. Can you confirm ?
Thank you for the reply! But think I didn't explain the problem well enough in the first place.
So, the problem is, the mat file converted by mdfreader has wrong values for some items. Compared to the correct values they are supposed to be, it seems they are not parsed (raw values, not converted to actual physical value). For example, for temperature data, I need to get [39 39 38.5 ...] but [158 158 157 ...] in the file. The items with wrong values are integer, either uint8 or uint16, in the mdfreader mat file, while the mat file converted by CANape have them in double and the values are correct. I realise that those whose data type is the same to their correspondent on the CANape converted file have correct value.
Hi, What parameters do you use to read your file ? Do you use convert_after_read = False ? If yes, can you try to put at the beginning of export_to_matlab() in mdfreader.py, 'self.convert_all_channels()'