ratal / mdfreader

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

Cannot read mf4 file #170

Closed DougRzz closed 4 years ago

DougRzz commented 4 years ago

Python version

'3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)]'

Platform information

'Windows-10-10.0.17763-SP0'

Numpy version

'1.16.4'

mdfreader version

'3.3'

Description

Version of md4 = 4.10

import mdfreader
info = mdfreader.MdfInfo()
info.list_channels(MDFfilePath) # returns only the list of channels

The above snippet works as expected

Snippet

yop=mdfreader.Mdf(MDFfilePath)

The snippet above gives the following traceback

Traceback


NameError Traceback (most recent call last)

in ----> 1 yop=mdfreader.Mdf(MDFfilePath) ~\AppData\Local\Continuum\miniconda3_37_2\lib\site-packages\mdfreader\mdf.py in __init__(self, file_name, channel_list, convert_after_read, filter_channel_names, no_data_loading, compression, convert_tables, metadata) 158 no_data_loading=no_data_loading, 159 compression=compression, --> 160 metadata=metadata) 161 162 def add_channel(self, channel_name, data, master_channel, master_type=1, unit='', description='', conversion=None, ~\AppData\Local\Continuum\miniconda3_37_2\lib\site-packages\mdfreader\mdfreader.py in read(self, file_name, multi_processed, channel_list, convert_after_read, filter_channel_names, no_data_loading, compression, metadata) 411 if not no_data_loading: 412 self.read4(self.fileName, None, multi_processed, channel_list, --> 413 convert_after_read, compression, metadata) 414 else: # populate minimum mdf structure 415 self._noDataLoading = True ~\AppData\Local\Continuum\miniconda3_37_2\lib\site-packages\mdfreader\mdf4reader.py in read4(self, file_name, info, multi_processed, channel_list, convert_after_read, compression, metadata) 1441 if convert_after_read and not compression: 1442 self._noDataLoading = False -> 1443 self._convert_all_channel4() 1444 # print( 'Finished in ' + str( time.clock() - inttime ) , file=stderr) 1445 ~\AppData\Local\Continuum\miniconda3_37_2\lib\site-packages\mdfreader\mdf4reader.py in _convert_all_channel4(self) 1561 else: 1562 if self.multiProc is False: -> 1563 [self._convert_channel4(channelName) for channelName in self] 1564 else: # multiprocessing 1565 proc = [] ~\AppData\Local\Continuum\miniconda3_37_2\lib\site-packages\mdfreader\mdf4reader.py in (.0) 1561 else: 1562 if self.multiProc is False: -> 1563 [self._convert_channel4(channelName) for channelName in self] 1564 else: # multiprocessing 1565 proc = [] ~\AppData\Local\Continuum\miniconda3_37_2\lib\site-packages\mdfreader\mdf4reader.py in _convert_channel4(self, channel_name) 1549 Name of channel 1550 """ -> 1551 self.set_channel_data(channel_name, self._get_channel_data4(channel_name)) 1552 self.remove_channel_conversion(channel_name) 1553 ~\AppData\Local\Continuum\miniconda3_37_2\lib\site-packages\mdfreader\mdf4reader.py in _get_channel_data4(self, channel_name, raw_data) 1471 if not raw_data: 1472 return self._convert_channel_data4(self.get_channel(channel_name), channel_name, -> 1473 self.convertTables)[channel_name] 1474 else: 1475 return self.get_channel(channel_name)[dataField] ~\AppData\Local\Continuum\miniconda3_37_2\lib\site-packages\mdfreader\mdf4reader.py in _convert_channel_data4(channel, channel_name, convert_tables, multi_processed, q) 1516 vector = _rational_conversion(vector, conversion_parameter['cc_val']) 1517 elif conversion_type == 3 and not text_type: -> 1518 vector = _formula_conversion(vector, conversion_parameter['cc_ref']['Comment']) 1519 elif conversion_type == 4 and not text_type: 1520 vector = _value_to_value_table_with_interpolation_conversion(vector, conversion_parameter['cc_val']) ~\AppData\Local\Continuum\miniconda3_37_2\lib\site-packages\mdfreader\mdf4reader.py in _formula_conversion(vector, formula) 1950 X = symbols('X') 1951 expr = lambdify(X, formula, modules='numpy', dummify=False) -> 1952 return expr(vector) 1953 1954 in _lambdifygenerated(X) 1 def _lambdifygenerated(X): ----> 2 return (x) NameError: name 'x' is not defined ### Other Unfortunately, it will be difficult to send you an example mf4 file to debug. Please can you offer me any advice on how I should investigate this issue further? Thanks very much.
DougRzz commented 4 years ago

The formula has a lower case x. Should be upper case 'X'. I guess the formulas recorded in the MF4 are not in within the MF4 specification. I will add my own patch to this code and hopefully I can get it working.

ratal commented 4 years ago

Yes, sorry, I cannot help if the file is not complying to the standard. I guess you could make it, if not, repoen this issue. Please do as you proposed to have specific snippet to cope with your use case.