Skip to content

Commit

Permalink
eclab: Support for another GCPL 11.40 format (#179)
Browse files Browse the repository at this point in the history
* Add trial support

* Different handling of versions.

* Add test.

* Version info.

* Fix pages.

* Fixed pages properly.
  • Loading branch information
PeterKraus committed Aug 23, 2024
1 parent ce3f2a1 commit 7c2f0a1
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 19 deletions.
6 changes: 1 addition & 5 deletions docs/source/version.5_1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
.. image:: https://img.shields.io/static/v1?label=release%20date&message=2024-XX-YY&color=red&logo=pypi


Developed in the |concat_lab|_ at Technische Universität Berlin (Berlin, DE).
Developed in the `ConCat Lab <https://tu.berlin/en/concat>`_ at Technische Universität Berlin (Berlin, DE).

New features since ``yadg-5.0`` are:

Expand Down Expand Up @@ -48,7 +48,3 @@ Bug fixes in ``yadg-5.1`` include:
- Fixed incorrect column name (``Energy`` to ``|Energy|``) in :mod:`yadg.extractors.eclab.mpr`.
- Removed column renaming for ``Analog IN 1`` and ``Analog IN 2`` to maintain consistency within :mod:`yadg.extractors.eclab`.
- Reworked parsing of ``.mpt`` file headers in :mod:`yadg.extractors.eclab.mpt`. The parser is now more stable, and the original labels are used without renaming.

.. _concat_lab: https://tu.berlin/en/concat

.. |concat_lab| replace:: ConCat Lab
23 changes: 23 additions & 0 deletions docs/source/version.5_2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**yadg** version 5.2
``````````````````````
.. warning::

This version of yadg is not yet released.

.. image:: https://img.shields.io/static/v1?label=yadg&message=v5.2&color=blue&logo=github
:target: https://github.com/PeterKraus/yadg/tree/5.2
.. image:: https://img.shields.io/static/v1?label=yadg&message=v5.2&color=blue&logo=pypi
:target: https://pypi.org/project/yadg/5.2/
.. image:: https://img.shields.io/static/v1?label=release%20date&message=YYYY-MM-DD&color=red&logo=pypi


Developed in the `ConCat Lab <https://tu.berlin/en/concat>`_ at Technische Universität Berlin (Berlin, DE).

New features in ``yadg-5.2`` are:

Other changes in ``yadg-5.2`` are:

Bug fixes in ``yadg-5.2`` include:

- Increased supported I-range values in :mod:`~yadg.extractors.eclab` up to 193.
- Implemented support for a 33-parameter GCPL file in :mod:`~yadg.extractors.eclab.mpr`.
2 changes: 2 additions & 0 deletions docs/source/version.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
**yadg** version history
------------------------

.. include:: version.5_2.rst

.. include:: version.5_1.rst

.. include:: version.5_0.rst
Expand Down
9 changes: 5 additions & 4 deletions src/yadg/extractors/eclab/common/mpr_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
[
("short_name", "|S10"),
("long_name", "|S25"),
("max_length", "<u4"),
("length", "<u4"),
("version", "<u4"),
("oldver", "<u4"),
("newver", "<u4"),
("date", "|S8"),
]
),
np.dtype(
[
("short_name", "|S10"),
("long_name", "|S25"),
("max_length", "<u4"),
("length", "<u4"),
("version", "<u4"),
("unknown", "<u4"),
("oldver", "<u4"),
("date", "|S8"),
]
),
Expand Down Expand Up @@ -128,6 +128,7 @@
332: ("<f4", "Re(Z2)", "Ω"),
361: ("<f4", "-Im(Z1)", "Ω"),
362: ("<f4", "-Im(Z2)", "Ω"),
379: ("<f8", "Energy charge", "W·h"),
391: ("<f4", "<E1>", "V"),
392: ("<f4", "<E2>", "V"),
422: ("<f4", "Phase(Zstack)", "deg"),
Expand Down
40 changes: 40 additions & 0 deletions src/yadg/extractors/eclab/common/techniques.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,46 @@
),
{"10.40"},
),
(
np.dtype(
[
("set_I/C", "|u1"),
("Is", "<f4"),
("Is_unit", "|u1"),
("Is_vs", "|u1"),
("N", "f4"),
("I_sign", "|u1"),
("t1", "<f4"),
("I_range", "|u1"),
("bandwidth", "|u1"),
("dE1", "<f4"),
("dt1", "<f4"),
("EM", "<f4"),
("tM", "<f4"),
("Im", "<f4"),
("Im_unit", "|u1"),
("dI/dt", "<f4"),
("dI/dt_unit", "|u1"),
("E_range_min", "<f4"),
("E_range_max", "<f4"),
("dq", "<f4"),
("dq_unit", "|u1"),
("dtq", "<f4"),
("dQM", "<f4"),
("dQM_unit", "|u1"),
("dxM", "<f4"),
("delta SoC", "<f4"),
("tR", "<f4"),
("dER/dt", "<f4"),
("dER", "<f4"),
("dtR", "<f4"),
("EL", "<f4"),
("goto_Ns", "<u4"),
("nc_cycles", "<u4"),
]
),
{"10.40"},
),
(
np.dtype(
[
Expand Down
24 changes: 14 additions & 10 deletions src/yadg/extractors/eclab/mpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ def process_settings(data: bytes, minver: str) -> tuple[dict, list]:
settings = {}
# First parse the settings right at the top of the data block.
technique, params_dtypes = technique_params_dtypes[data[0x0000]]
logger.debug("Found technique '%s'.", technique)
settings["technique"] = technique
for offset, (dtype, name) in settings_dtypes.items():
settings[name] = dgutils.read_value(data, offset, dtype)
Expand All @@ -271,7 +272,6 @@ def process_settings(data: bytes, minver: str) -> tuple[dict, list]:
0x1846,
0x1847,
)
logger.debug("Looking for %d params.", len(dtype))
for offset in offsets:
n_params = dgutils.read_value(data, offset + 0x0002, "<u2")
logger.debug("Trying to find %d technique params at 0x%x.", n_params, offset)
Expand Down Expand Up @@ -387,7 +387,7 @@ def process_data(
"""
n_datapoints = dgutils.read_value(data, 0x0000, "<u4")
n_columns = dgutils.read_value(data, 0x0004, "|u1")
if version == 0:
if version in {10, 11}:
column_ids = np.frombuffer(data, offset=0x005, dtype=">u2", count=n_columns)
elif version in {2, 3}:
column_ids = np.frombuffer(data, offset=0x005, dtype="<u2", count=n_columns)
Expand All @@ -397,7 +397,7 @@ def process_data(
units = {k: v for k, v in zip(namelist, unitlist) if v is not None}
data_dtype = np.dtype(list(zip(namelist, dtypelist)))
# Depending on module version, datapoints start at different offsets.
if version == 0:
if version in {10, 11}:
offset = 0x3EF
elif version == 2:
offset = 0x195
Expand Down Expand Up @@ -537,23 +537,27 @@ def process_modules(contents: bytes) -> tuple[dict, list, list, dict, dict]:
for mhd in module_header_dtypes:
header = dgutils.read_value(module, 0x0000, mhd)
if len(module) == mhd.itemsize + header["length"]:
version = header.get("newver", 0) + header["oldver"]
logger.debug(
"Parsed module header with length %d, version %s",
header["length"],
version,
)
break
else:
raise RuntimeError("Unknown module header.")
name = header["short_name"].strip()
# We need to determine file version from the header to be able to select correct
# dtypes. Unfortunately, the header["version"] of the "VMP Set" module is always
# dtypes. Unfortunately, the header["oldver"] of the "VMP Set" module is always
# set to 0. However, the newer versions of this module include the "max_length"
# entry as well as an "unknown" key set to 10.
if "max_length" in header and header.get("unknown", None) is not None:
# entry as well as an "newver" key set to 10.
if version >= 10:
minver = "11.50"
# The oldest version we have in test files is 10.40.
else:
minver = "10.40"

logger.debug(
"Read '%s' with version '%d' ('%s')", name, header["version"], minver
)
logger.debug("Read '%s' with version '%s' ('%s')", name, version, minver)
module_data = module[mhd.itemsize :]
if name == "VMP Set":
settings, params = process_settings(module_data, minver)
Expand All @@ -572,7 +576,7 @@ def process_modules(contents: bytes) -> tuple[dict, list, list, dict, dict]:
else:
ctrls.append(None)
elif name == "VMP data":
ds = process_data(module_data, header["version"], Eranges, Iranges, ctrls)
ds = process_data(module_data, version, Eranges, Iranges, ctrls)
elif name == "VMP LOG":
log = process_log(module_data)
elif name == "VMP loop":
Expand Down
1 change: 1 addition & 0 deletions tests/test_x_eclab_mpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"cva.issue_135.mpr",
"gcpl.mpr",
"gcpl.issue_149.mpr",
"gcpl.issue_175.mpr",
"geis.mpr",
"geis.issue_149.mpr",
"lsv.mpr",
Expand Down
Binary file added tests/test_x_eclab_mpr/gcpl.issue_175.mpr
Binary file not shown.
Binary file added tests/test_x_eclab_mpr/gcpl.issue_175.mpr.pkl
Binary file not shown.

0 comments on commit 7c2f0a1

Please sign in to comment.