Closed merung1203 closed 3 months ago
Hi! Regarding your first question: The mpr
files are made up of a number of modules, each of which starts with a module header that is structured like this:
offset | field name | description |
---|---|---|
0x0000 |
short_name |
Short name, e.g. VMP Set. |
0x000A |
long_name |
Longer name, e.g. VMP settings. |
0x0023 |
length |
Number of bytes in module data. |
0x0027 |
version |
Module version. |
0x002B |
date |
Acquisition date in ASCII, e.g. 08/10/21. |
With the module_header_dtype
you can read all of these values in one go from the binary.
Concerning the second part of your question: Could you provide a file, where you encounter this problem? The parser should parse all data columns stored in the file, not just the first 21.
Hello! Thank you for your kind reply.
This file is an ec-lab default sample, not an actual analysis file. In fact, in my file, when the mpr file is output as data, the required columns are 'Re(Z)' and '-Im(Z)', but they are not there.
However, when I run the sample file, an error message appears as shown below, so I converted it to data using ec-lab software. I would like to know the code that causes the 'Re(Z)' and '-Im(Z)' columns to appear.
Thank you.
ValueError Traceback (most recent call last)
3 frames /usr/local/lib/python3.10/dist-packages/eclabfiles/mpr.py in _read_value(data, offset, dtype, encoding) 445 # Allow the use of 'pascal' in all of the dtype maps. 446 return _read_pascal_string(data[offset:]) --> 447 value = np.frombuffer(data, offset=offset, dtype=dtype, count=1) 448 item = value.item() 449 if value.dtype.names:
ValueError: offset must be non-negative and no greater than buffer length (1859)
To me it looks like this default sample was created with an older version of EC-Lab (v9.54
). I assume the problem is that there is a different offset for the number of parameters in this file version (see here).
This project is only tested on files created with v11.33
. In the PEIS mpr
files I tested, the Re(Z)
and -Im(Z)
columns are present and parsed correctly.
If you are using a different version of the software it's pretty much impossible for me to fix, as I don't have access to the equipment. Unfortunately, the people at BioLogic like to randomly change things and do not provide a spec for their binary files.
Yeah, it also fails to parse with the current git of yadg. I'll have a look at it in due course. The mpr format has recently changed again, files from EC-Lab versions newer than (and including) v11.50
also don't work.
@vetschn is there any persistent file version number in the mpr files, or not really?
I suffer from the same issue after upgrading the software to v11.50. Any fix would be very welcome! Regards
Yeah, it also fails to parse with the current git of yadg. I'll have a look at it in due course. The mpr format has recently changed again, files from EC-Lab versions newer than (and including)
v11.50
also don't work.
Yep, users over at echemdata/galvani#87 seem to have had problems for a while now as well.
@vetschn is there any persistent file version number in the mpr files, or not really?
The LOG module contains the EC-Lab version (at least for v11.33
). However, I don't remember whether the LOG module was present in all the files.
In any case, the most one could do for now would be to raise an exception/warning for unprocessable/untested versions.
I have a question about processing mpr files.
def process: module_header_dtype = np.dtype([("short_name", "|S10"), ("long_name", "|S25"), ("length", "<u4"), ("version" , "<u4"), ("date", "|S8")]) in this function, could you explain the purpose of this line?
def _process_data: n_datapoints = _read_value(data, 0x0000, "<u4") n_columns = _read_value(data, 0x0004, "|u1") column_ids = _read_values(data, 0x0005, "<u2", n_columns) when I run this code, only the first 21 columns are converted. How can I convert all of the flag_columns and data_columns?
thank you