Package: eclabfiles
eclabfilesThis is a package to process and convert files from BioLogic's EC-Lab.
The parsers build onChris Kerr'sgalvanipackageand on the work of a previous civilian service member at Empa Lab 501,
Jonas Krieger.InstallationUsepipto install eclabfiles.>pipinstalleclabfilesExample Usageprocess: Processing Into DictionariesProcess the data as it is stored in the corresponding file. The method
automatically determines filetype and tries to apply the respective
parser.For.mpssettings files you can specify the keywordload_datato
also load the data files from the same folder.importeclabfilesasecfdata,meta=ecf.process("./mpt_files/test_01_OCV.mpt")The returned data structure may look a bit different depending on which
filetype you read in.SeeFiletypes and Processed Data Structure.to_df: Processing Into DataframeProcesses the file and converts it into aPandasDataFrame.
Thepd.DataFrame.attrswill contain all the processed metadata.importeclabfilesasecfdf=ecf.to_df("./mpr_files/test_02_CP.mpr")If the given file is an.mps, all data files from the same folder will
be read into apd.DataFramewith ahierarchical index. The top-level index is the technique
number. Thepd.DataFrame.attrswill contain.mpsmetadata, as well
as all techniques and their loaded metadata.to_csv: Converting to CSVProcess the file and write the data part into a.csvfile at the
specified location.>>>importeclabfilesasecf>>>ecf.to_csv("./mpt_files/test_03_PEIS.mpt",csv_fn="./csv_files/test_PEIS.csv")Thecsv_fnparameter is optional. If left away, the method writes a.csvfile into the same folder as the input file.to_excel: Converting to ExcelProcess the file and write the data part into an Excel.xlsxfile at
the specified location.>>>importeclabfilesasecf>>>ecf.to_excel("./experiment/test.mps")Theexcel_fnparameter is optional. If left away, the method writes
a.xlsxfile at the location of the input file.Filetypes and Processed Data Structure.The file types that are implemented are:FiletypeDescription.mprRaw data binary file, which also contains the current parameter settings.mptText format file generated when the user exports the raw.mprfile in text format..mpsSettings file, which contains all the parameters of the experiment.Processed.mprFilesdata,meta=ecf.process("./test_01_OCV.mpr")Anydatareturned by theprocessfunction for.mprfiles is
structured into record dictionaries:[{column->value},...,{column->value}]Themetaprocessed from.mprfiles looks like this:{"settings":{# (optional) Settings if present."technique":str,# Technique name."comments":str,# Cell characteristics."active_material_mass":float,"at_x":float,"molecular_weight":float,"atomic_weight":float,"acquisition_start":float,"e_transferred":int,"electrode_material":str,"electrolyte":str,"electrode_area":float,"reference_electrode":str,"characteristic_mass":float,"battery_capacity":float,"battery_capacity_unit":int},"params":[# (optional) Technique parameter sequences.{"param1":float,"param2":str,...},...,{"param1":float,"param2":str,...},],"units":{# Units of the data columns."time":"s","mode":None,...,},"log":{# (optional) Log if present."channel_number":int,"channel_sn":int,"Ewe_ctrl_min":float,"Ewe_ctrl_max":float,"ole_timestamp":float,"filename":str,"host":str,"address":str,"ec_lab_version":str,"server_version":str,"interpreter_version":str,"device_sn":str,"averaging_points":int,"posix_timestamp":float,},}Processed.mptFilesdata,meta=ecf.process("./test_01_OCV.mpt")Anydatareturned by theprocessfunction for.mprfiles is
structured into record dictionaries:[{column->value},...,{column->value}]The.mptfiles generally contain a few moredatacolumns than the
corresponding binary.mprfiles from what I have seen.Themetaprocessed from.mptfiles looks like this:{"raw":str,# (optional) The raw file header if present."settings":{# (optional) Settings if the file has a header."posix_timestamp":float,# POSIX timestamp if present."technique":str,# Technique name.},"params":[# (optional) Technique parameter sequences.{"param1":float,"param2":str,...},{"param1":float,"param2":str,...},...,],"units":{# Units of the data columns."time":"s","mode":None,...,},"loops":{# (optional) Loops if present."n_indexes":int,"indexes":list[int],}}Processed.mpsFilestechniques,meta=ecf.process("./test.mps").mpsfiles simply relate differenttechniquestogether and store no
data, while the other files contain the measurements.For.mpssettings files theprocessfunction returns the following
the linkedtechniquesinstead of the data (each technique can contain
data depending onload_data):{"1":{"technique":str,# Technique name."params":[# (optional) Technique parameter sequences.{"param1":float,"param2":str,...},...,{"param1":float,"param2":str,...},],"data":list[dict]# (optional) Data processed from data files."meta":dict# (optional) Metadata processed from data files.},...}Themetaprocessed from.mpronly contains the raw file header.{"raw":str}TechniquesDetecting and processing the technique parameter sequences is not
implemented for all techniques as this is pretty tedious to do.
Currently, the following techniques are implemented:Short NameFull NameCAChronoamperometry / ChronocoulometryCPChronopotentiometryCVCyclic VoltammetryGCPLGalvanostatic Cycling with Potential LimitationGEISGalvano Electrochemical Impedance SpectroscopyLOOPLoopLSVLinear Sweep VoltammetryMBModulo BatOCVOpen Circuit VoltagePEISPotentio Electrochemical Impedance SpectroscopyWAITWaitZIRIR compensation (PEIS)Implementing further techniquesIn the best case you should have an.mps,.mprand.mptfiles
ready that contain the technique you would like to implement.For the parsing of EC-Lab ASCII files (.mpt/.mps) you add a function
with alistof parameter names intechniques.pyin the order they
appear in the text files. See_wait_params()to get an idea.If the technique has a changing number of parameters in these ASCII
files, e.g. it contains a modifiable number of 'Limits' or 'Records',
you have to write a slightly more complicated function. Compare_peis_params().Finally, add a case for the parsing function intotechnique_params().If you want to implement the technique in the.mprfile parser, you
will need to define a corresponding Numpynp.dtypein thetechniques.pymodule. I would recommend getting a solid hex editor
(e.g. Hexinator, Hex Editor Neo) to find the actual binary data type of
each parameter.From the.mprfiles I have seen, you will usually find the parameter
sequences at an offset of0x1845from the start of the data section in
theVMP settingsmodule or somewhere around there. Compare the
parameter values in the binary data to the values in the corresponding
ASCII files.As a rule of thumb, floats are usually 32bit little-endian (<f4),
integers are often 8bit (|u1) or 16bit (<u2) wide and units are
stored in 8bit integers. I have not gotten around to linking the integer
value with the corresponding unit yet.If the technique has a changing number of parameters, make a list of
Numpydtypes. Compare_mb_params_dtypesto see how this looks.Finally, add yournp.dtypeorlist[np.dtype]to thetechnique_params_dtypesdictionary indexed by the technique ID. This
ID is the first byte value after theVMP settingsmodule's header.Good luck!