Skip to content

Data conversion inconsistent #204

@max3-2

Description

@max3-2

Python version

'3.10.9 (tags/v3.10.9:1dd9be6, Dec 6 2022, 20:01:21) [MSC v.1934 64 bit (AMD64)]'

Platform information

'Windows-10-10.0.19044-SP0'

Numpy version

'1.24.1'

mdfreader version

'4.1'

Description

Loading a can file and converting channels fails if conversion is not specified as 1 in the main group but in a sub(?)-group. MDF is a CAN file with version 4.1. Other software tools read and convert the data correctly (but are closed source, e.g. MATLAB)

Example data is as follows:

File info

file_info['ID']

{'id_file': b'MDF     ',
 'id_vers': b'4.10    ',
 'id_prog': b'MDF4Lib\x00',
 'id_ver': 410,
 'id_unfi_flags': 0,
 'id_custom_unfi_flags': 0}

Loading the data with no conversion (just for having data in between the steps, the final result is the same if I apply conversion on load or subsequently). Some info is shown as xxx by me to blank out some information. So the data yields for a working signal called ACC

file_data['ACC']

{'unit': 'm/s²',
 'description': '',
 'master': 't_274_274',
 'masterType': 0,
 'data': array([32507, ..., 32342], dtype=uint16),
 'conversion': {'type': 1, 'parameters': {'cc_val': (-65.0, 0.002)}},
 'axis': [],
 'id': ((274, 0, 64),
  ('xxx', 'xxx', 'xxx'),
  ('xxx', 'xxx', 'xxx'))}

then converting ACC, the result is correct

{'unit': 'm/s²',
 'description': '',
 'master': 't_274_274',
 'masterType': 0,
 'data': array([ 0.014, ..., -0.316]),
 'axis': [],
 'id': ((274, 0, 64),
  ('xxx', 'xxx', 'xxx'),
  ('xxx', 'xxx', 'xxx'))}

for a not working signal called temp

file_data['temp']

{'unit': '°C',
 'description': '',
 'master': 't_222_222',
 'masterType': 0,
 'data': array([820, ..., 960], dtype=uint16),
 'conversion': {'type': 7,
  'parameters': {'cc_val': (16381.0, 16382.0, 16383.0),
   'cc_ref': ['Reserviert_nicht_verfuegbar',
    'Reserviert_Fehler',
    'Signal_unbefuellt',
    {'pointer': 579024,
     'id': b'##CC',
     'length': 96,
     'link_count': 4,
     'cc_tx_name': 0,
     'cc_md_unit': 578992,
     'cc_md_comment': 0,
     'cc_cc_inverse': 0,
     'cc_type': 1,
     'cc_precision': 0,
     'cc_flags': 0,
     'cc_ref_count': 0,
     'cc_val_count': 2,
     'cc_phy_range_min': 0.0,
     'cc_phy_range_max': 0.0,
     'cc_val': (-100.0, 0.1),
     'unit': {'id': b'##TX',
      'length': 32,
      'link_count': 0,
      'Comment': '°C'}}]}},
 'axis': [],
 'id': ((222, 0, 368),
  ('xxx', 'xxx', 'xxx'),
  ('xxx', 'xxx', 'xxx'))}

and then conversion for a not working signal called temp - the conversion is consumed but the data is the same. The conversion global type seems 7 but the true correct conversion that other software reads is 1 and the parameters are specified in a sub-group

{'unit': '°C',
 'description': '',
 'master': 't_222_222',
 'masterType': 0,
 'data': array([820, ..., 960], dtype=uint16),
 'axis': [],
 'id': ((222, 0, 368),
  ('xxx', 'xxx', 'xxx'),
  ('xxx', 'xxx', 'xxx'))}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions