vetschn / eclabfiles

Processing and converting of data files from BioLogic's EC-Lab.
GNU General Public License v3.0
16 stars 2 forks source link

"Error: field '(Q-Qo)' occurs more than once" when reading .mpr file (technique=CA) #14

Closed ScottSoren closed 3 months ago

ScottSoren commented 11 months ago

Hi @vetschn ,

Great to see this package!

I am the main author of an open source project "ixdat" which also includes many python parsers for experimental data formats, including Biologic's .mpt. I'm trying to add a .mpr parser which makes use of eclabfiles for parsing the binary file.

eclabfiles works for some files but not others. For details, see this PR: https://github.com/ixdat/ixdat/pull/134

Briefly, it seems to work for LSV measurements, but not CA or CVA. It's a different error message, so I'll put CA here and CVA in a separate issue.

The error I get is "Error: field '(Q-Qo)' occurs more than once". I get this same error whether using data, meta = eclabfiles.process("05_O2dose_COox_04_CA_C01.mpr") or df = eclabfiles.to_df("05_O2dose_COox_04_CA_C01.mpr")

The file is here, along with plots of the data (made with ixdat.Measurement.read("05_O2dose_COox_04_CA_C01.mpt").plot() as demo'd in "plot_data.py"): https://www.dropbox.com/scl/fo/cl0cnovmik7pjgcls2l9h/h?rlkey=v93snkrt2rq3uf95au26qdi0o&dl=0

Happy for any help or suggestions!

vetschn commented 11 months ago

Hi @ScottSoren!

First off, thank you for your interest in this package! As you have probably seen from the README, I can unfortunately no longer really maintain this package in a meaningful way, as I have no access to the equipment.

That being said, I highly encourage you to have a look at yadg / the dgbowl suite of tools for parsing and processing a variety of experimental data. The electrochem parser built into yadg is the most comprehensive parser for files from ECLab and is being kept up-to-date.

At a short glance, it also seems like there is a non-negligible overlap between your very nice ixdat project and yadg's capabilities. You should get in touch with @PeterKraus and perhaps even find a way to join ventures towards more standardized experimental data ;)


Now, concerning the actual problem at hand: It looks like both column ID 0x000D https://github.com/vetschn/eclabfiles/blob/025aefd9887751809f98816ebc5a1f9c1f73f794/src/eclabfiles/mpr.py#L257 and ID 0x01B2 https://github.com/vetschn/eclabfiles/blob/025aefd9887751809f98816ebc5a1f9c1f73f794/src/eclabfiles/mpr.py#L315 are present in the file, i. e. the charge both in Coulombs and in mA·h. This causes a collision when constructing the data_dtype. https://github.com/vetschn/eclabfiles/blob/025aefd9887751809f98816ebc5a1f9c1f73f794/src/eclabfiles/mpr.py#L596 The hacky, easy fix would be to rename the columns to avoid the collision. Properly taking care of this might require a little more work.

Actually, it looks like yadg will have the same problem with your file. Could you maybe open the same issue over there so I can try to address it in the up-to-date and maintained parser?

Thanks and apologies for the inconvenience!

PeterKraus commented 3 months ago

Should be fixed by https://github.com/dgbowl/yadg/pull/161, available in yadg-5.1.