From 4239d2c1bc144c6b5b2adb6f48318f34455de8ef Mon Sep 17 00:00:00 2001 From: Peter Kraus Date: Fri, 16 Dec 2022 08:01:35 +0100 Subject: [PATCH] `electrochem`: Modulo-bat new format. (#97) * Remove mgr file * silence logging flag values. * Patch parsing of 67-parameter MB files. Parameter is between E_range_max and I_range. Meaning unknown. * Rework _technique_dtype -> _technique_dtypes. * Identified unknown parameter as current/potential using mps file. * Add test. --- src/yadg/parsers/electrochem/eclabmpr.py | 18 +- .../parsers/electrochem/eclabtechniques.py | 673 ++++++++++-------- tests/test_electrochem.py | 17 + tests/test_electrochem/ca.mgr | 281 -------- tests/test_electrochem/mb_67.mpr | Bin 0 -> 19108 bytes 5 files changed, 406 insertions(+), 583 deletions(-) delete mode 100644 tests/test_electrochem/ca.mgr create mode 100644 tests/test_electrochem/mb_67.mpr diff --git a/src/yadg/parsers/electrochem/eclabmpr.py b/src/yadg/parsers/electrochem/eclabmpr.py index fd33e616..32c06db8 100644 --- a/src/yadg/parsers/electrochem/eclabmpr.py +++ b/src/yadg/parsers/electrochem/eclabmpr.py @@ -514,7 +514,7 @@ def _process_settings(data: bytes) -> tuple[dict, list]: """ settings = {} # First parse the settings right at the top of the data block. - technique, params_dtype = technique_params_dtypes[data[0x0000]] + technique, params_dtypes = technique_params_dtypes[data[0x0000]] settings["technique"] = technique for offset, (dtype, name) in settings_dtypes.items(): settings[name] = _read_value(data, offset, dtype) @@ -525,14 +525,12 @@ def _process_settings(data: bytes) -> tuple[dict, list]: for offset in (0x0572, 0x1845, 0x1846): logger.debug("Trying to find the technique parameters at 0x%x.", offset) n_params = _read_value(data, offset + 0x0002, " list[str]: return _prepend_ns(settings, params) -_ca_params_dtype = np.dtype( - [ - ("Ei", " list[str]: return _prepend_ns(settings, params) -_cp_params_dtype = np.dtype( - [ - ("Is", " list[str]: @@ -191,31 +195,33 @@ def _cv_params(settings: list[str]) -> list[str]: return params -_cv_params_dtype = np.dtype( - [ - ("Ei", " list[str]: @@ -257,42 +263,44 @@ def _gcpl_params(settings: list[str]) -> list[str]: return _prepend_ns(settings, params) -_gcpl_params_dtype = np.dtype( - [ - ("set_I/C", "|u1"), - ("Is", " list[str]: @@ -347,65 +355,67 @@ def _geis_params(settings: list[str]) -> list[str]: return params -_geis_params_dtype = np.dtype( - [ - ("sine_mode", "|u1"), - ("Is", " list[str]: @@ -446,33 +456,35 @@ def _lsv_params(settings: list[str]) -> list[str]: ####################### Linear Sweep Voltammetry ####################### -_lsv_params_dtype = np.dtype( - [ - ("tR", " list[str]: ("bandwidth", "|u1"), ] ), + np.dtype( + [ + ("ctrl_type", "|u1"), + ("apply_I/C", "|u1"), + ("current/potential", "|u1"), + ("ctrl1_val", " list[str]: return params -_peis_params_dtype = np.dtype( - [ - ("sine_mode", "|u1"), - ("E", " list[str]: return params -_wait_params_dtype = np.dtype( - [ - ("select", "|u1"), - ("td", " list[str]: return params -_zir_params_dtype = np.dtype( - [ - ("E", " tuple[str, list]: @@ -956,15 +1045,15 @@ def technique_params(technique: str, settings: list[str]) -> tuple[str, list]: # Maps the technique byte to its corresponding dtype. technique_params_dtypes = { - 0x04: ("GCPL", _gcpl_params_dtype), - 0x06: ("CV", _cv_params_dtype), + 0x04: ("GCPL", _gcpl_params_dtypes), + 0x06: ("CV", _cv_params_dtypes), 0x0B: ("OCV", _ocv_params_dtypes), - 0x18: ("CA", _ca_params_dtype), - 0x19: ("CP", _cp_params_dtype), - 0x1C: ("WAIT", _wait_params_dtype), - 0x1D: ("PEIS", _peis_params_dtype), + 0x18: ("CA", _ca_params_dtypes), + 0x19: ("CP", _cp_params_dtypes), + 0x1C: ("WAIT", _wait_params_dtypes), + 0x1D: ("PEIS", _peis_params_dtypes), 0x1E: ("GEIS", _geis_params_dtype), - 0x32: ("ZIR", _zir_params_dtype), + 0x32: ("ZIR", _zir_params_dtypes), 0x6C: ("LSV", _lsv_params_dtype), 0x7F: ("MB", _mb_params_dtypes), } diff --git a/tests/test_electrochem.py b/tests/test_electrochem.py index d9ff6590..a2036276 100644 --- a/tests/test_electrochem.py +++ b/tests/test_electrochem.py @@ -370,6 +370,23 @@ "pars": {"uts": {"value": 1522109455.9886506}}, }, ), + ( # ts20 - mb_67.mpr + { + "case": "mb_67.mpr", + "encoding": "windows-1252", + "parameters": {"filetype": "eclab.mpr"}, + }, + { + "nsteps": 1, + "step": 0, + "nrows": 33, + "point": 0, + "pars": { + "uts": {"value": 1670510213.355}, + "Ewe": {"value": 2.3278546, "unit": "V", "sigma": 7.5e-05}, + }, + }, + ), ], ) def test_datagram_from_eclab(input, ts, datadir): diff --git a/tests/test_electrochem/ca.mgr b/tests/test_electrochem/ca.mgr deleted file mode 100644 index 6c2b1aff..00000000 --- a/tests/test_electrochem/ca.mgr +++ /dev/null @@ -1,281 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/test_electrochem/mb_67.mpr b/tests/test_electrochem/mb_67.mpr new file mode 100644 index 0000000000000000000000000000000000000000..97ba54e3c72af95ae5d2b28ff92e18d4f357d24d GIT binary patch literal 19108 zcmeI23sh4_8pkI*62L`0nsiTt#i&I=G$uUcCCp6#X#_Q*xT|JOQEAJu6-sb>Dp>`w zx?Mfh#a%^lDcZ9SwC%cj#7Aw>)RwfOVk^h3t=QdyRq7UmQbDYD=ex-Tt^^k}EP9wZ z$K3h8JM+8W{AcFk%pI+6_T;453A$Lt%-L}%Nt$HEbX`)sT+vfPBylC<=g-tD=B8zn zf{-(%WoM_ac-|zaXYzsK2&sdnsKTcN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