Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/source/version.6_2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ Bug fixes in ``yadg-next`` include:
- Added further ``Set I/C`` parameters. Thanks to `@Locki3 <https://github.com/Locki3>`_ for providing test files.
- Fixed ``param format`` and ``data_column`` in CV files generated with EC-Lab version 11.50 using the :mod:`yadg.extractors.eclab.mpr` module. Thank you to J.N. Hausmann from Helmholtz-Zentrum Berlin für Materialien und Energie for providing the test files.
- Fixed parsing of various kinds of Modulo Bat files in :mod:`yadg.extractors.eclab.mpr`. Thank you to `@JohannesBaller <https://github.com/JohannesBaller>`_ for providing test files.
- Columns in :mod:`yadg.extractors.eclab.mpr` files may have different meanings based on which other columns are also present in the files, see `issue 225 <https://github.com/dgbowl/yadg/issues/225>`_. Added a (hopefully extensible) way to tackle such conflicts and clarified the warnings.
47 changes: 44 additions & 3 deletions src/yadg/extractors/eclab/mpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@
settings_dtypes,
flag_columns,
data_columns,
conflict_columns,
log_dtypes,
extdev_dtypes,
)
Expand Down Expand Up @@ -314,17 +315,57 @@ def parse_columns(column_ids: list[int]) -> tuple[list, list, list, dict]:
names.append("flags")
dtypes.append("|u1")
units.append(None)
elif id in data_columns:
elif id in data_columns and id not in conflict_columns:
dtype, name, unit = data_columns[id]
if name in names:
logger.warning("Duplicate column '%s' with unit '%s'.", name, unit)
logger.error(
"Column ID %d is a duplicate of '%s' with unit '%s'. "
"This is most certainly an error, please submit a bug report.",
id,
name,
unit,
)
name = f"duplicate {name}"
names.append(name)
dtypes.append(dtype)
units.append(unit)
elif id in conflict_columns:
for cid, cvals in conflict_columns[id].items():
if cid in column_ids:
dtype, name, unit = cvals
names.append(name)
dtypes.append(dtype)
units.append(unit)
logger.warning(
"Ambiguous column ID %d assigned as '%s' with unit '%s'. "
"Please check this assignment manually.",
id,
name,
unit,
)
break
else:
dtype, name, unit = data_columns[id]
if name in names:
logger.error(
"Column ID %d is duplicate of '%s' with unit '%s'. "
"This is most certainly an error, please submit a bug report.",
id,
name,
unit,
)
name = f"duplicate {name}"
names.append(name)
dtypes.append(dtype)
units.append(unit)
else:
name = f"unknown_{len(names)}"
logger.warning("Unknown column ID %d was assigned into '%s'.", id, name)
logger.error(
"Unknown column ID %d encountered and assigned into '%s'. "
"This is an error, please submit a bug report.",
id,
name,
)
names.append(name)
dtypes.append("<f4")
units.append(None)
Expand Down
11 changes: 10 additions & 1 deletion src/yadg/extractors/eclab/mpr_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,13 @@
169: ("<f4", "Cs", "µF"),
172: ("<f4", "Cp", "µF"),
173: ("<f4", "Cp⁻²", "µF⁻²"),
174: ("<f4", "<Ewe>", "V"),
174: ("<f4", "<Ewe>", "V"), # This column may conflict with ID 77.
178: ("<f4", "(Q-Qo)", "C"),
179: ("<f4", "dQ", "C"),
182: ("<f8", "step time", "s"),
185: ("<f4", "<Ece>", "V"),
211: ("<f8", "Q charge or discharge", "C"),
215: ("<f4", "<Ece>", "V"),
217: ("<f4", "THD Ewe", "%"),
241: ("<f4", "|E1|", "V"),
242: ("<f4", "|E2|", "V"),
Expand All @@ -128,6 +129,7 @@
326: ("<f4", "P", "W"),
331: ("<f4", "Re(Z1)", "Ω"),
332: ("<f4", "Re(Z2)", "Ω"),
352: ("<f4", "|Ece|", "Ω"),
361: ("<f4", "-Im(Z1)", "Ω"),
362: ("<f4", "-Im(Z2)", "Ω"),
368: ("<f8", "Energy we", "W·h"),
Expand Down Expand Up @@ -181,6 +183,13 @@
981: ("<u4", "z cycle", None), # 981 % 512 = 469, also z cycle
}

# Conflict resolution map. If both the outer and inner column ID are present,
# the meaning of the outer column ID is set to the entry below.
conflict_columns = {
174: {
77: ("<f4", "Phase(Zwe-ce)", "deg"),
},
}

# Relates the offset in log data to the corresponding dtype and name.
# NOTE: The safety limits are maybe at 0x200?
Expand Down
2 changes: 2 additions & 0 deletions src/yadg/extractors/eclab/mpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ def process_data(
units = dict()
columns = list()
for n in names:
if n.strip() == "":
continue
c, u = column_units[n.strip()]
if c in columns:
logger.warning("Duplicate column '%s' with unit '%s'.", c, u)
Expand Down
1 change: 1 addition & 0 deletions src/yadg/extractors/eclab/mpt_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"<Ece>/V": ("<Ece>", "V"),
"<Ewe>/V": ("<Ewe>", "V"),
"<Ewe/V>": ("<Ewe>", "V"),
"<Ewe-Ece>/V": ("<Ewe-Ece>", "V"),
"<I>/mA": ("<I>", "mA"),
"|C|/nF": ("|C|", "nF"),
"|Conductivity|/mS/cm": ("|Conductivity|", "mS/cm"),
Expand Down
2 changes: 1 addition & 1 deletion src/yadg/extractors/eclab/techniques.py
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,7 @@ def dev_derived(
elif unit in {"deg"}:
# VMP-3: using accuracy: 1 degree
return 1.0
elif unit in {"Ω", "S", "W"}:
elif unit in {"Ω", "S", "W", "Ω⁻¹"}:
# [Ω] = [V]/[A];
# [S] = [A]/[V];
# [W] = [A]*[V];
Expand Down
13 changes: 8 additions & 5 deletions tests/test_x_eclab.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ def compare_params(left, right):
("ocv", "en_US"),
("ocv.issue_149", "de_DE"),
("peis", "en_US"),
("peis.issue_225.no_ece", "en_US"),
("peis.issue_225.with_ece", "en_US"),
("peis.issue_225.ewe_ece", "en_US"),
("wait", "en_US"),
("vsp_ocv_wo", "en_US"),
("vsp_ocv_with", "en_US"),
Expand All @@ -88,7 +91,7 @@ def test_eclab_consistency(froot, locale, datadir):
try:
xr.testing.assert_allclose(aret[key], bret[key])
except AssertionError as e:
e.args = (e.args[0] + f"Error happened on key: {key!r}\n",)
e.args = (e.args[0] + f"\nError happened on key: {key!r}\n",)
raise e
compare_params(aret, bret)

Expand All @@ -111,7 +114,7 @@ def test_eclab_consistency_extract_mpr_bytes(froot, locale, datadir):
try:
xr.testing.assert_equal(aret[key], bret[key])
except AssertionError as e:
e.args = (e.args[0] + f"Error happened on key: {key!r}\n",)
e.args = (e.args[0] + f"\nError happened on key: {key!r}\n",)
raise e
compare_params(aret, bret)

Expand Down Expand Up @@ -149,7 +152,7 @@ def test_eclab_consistency_partial_1(froot, locale, datadir):
try:
xr.testing.assert_allclose(aret[key], bret[key])
except AssertionError as e:
e.args = (e.args[0] + f"Error happened on key: {key!r}\n",)
e.args = (e.args[0] + f"\nError happened on key: {key!r}\n",)
raise e
compare_params(aret, bret)

Expand All @@ -176,7 +179,7 @@ def test_eclab_consistency_partial_2(froot, locale, datadir):
try:
xr.testing.assert_allclose(aret[key], bret[key])
except AssertionError as e:
e.args = (e.args[0] + f"Error happened on key: {key!r}\n",)
e.args = (e.args[0] + f"\nError happened on key: {key!r}\n",)
raise e
compare_params(aret, bret)

Expand Down Expand Up @@ -217,5 +220,5 @@ def test_eclab_mpt_old(afile, bfile, datadir):
if key in {"Efficiency", "Efficiency_std_err"}:
pass
else:
e.args = (e.args[0] + f"Error happened on key: {key!r}\n",)
e.args = (e.args[0] + f"\nError happened on key: {key!r}\n",)
raise e
Binary file added tests/test_x_eclab/peis.issue_225.ewe_ece.mpr
Binary file not shown.
Binary file not shown.
Loading
Loading