Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eclab: Support for files generated in EC-Lab 11.50. #171

Merged
merged 11 commits into from
Jun 30, 2024
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
2 changes: 2 additions & 0 deletions docs/source/version.5_1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ New features since ``yadg-5.0`` are:

- Support for the ``CVA`` (Cyclic Voltammetry Advanced) technique in the :mod:`yadg.extractors.eclab` extractors. Test files were provided by S. B. Scott from University of Copenhagen.

- Support for files generated with EC-Lab 11.50 using the :mod:`yadg.extractors.eclab` module. Test files were provided by ``@fg-personal`` and ``@tk-4767`` on `GitHub <https://github.com/dgbowl/yadg/pull/171>`_, and E. Svaluto-Ferro from Empa.

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

- The storage of original metadata present in the extracted files as well as **yadg**-related metadata has been standardised in all extractors.
Expand Down
12 changes: 7 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ classifiers = [
]
requires-python = ">= 3.9"
dependencies = [
"numpy >= 1.20; python_version > '3.9'",
"pint >= 0.24; python_version > '3.9'",
"numpy >= 1.20, < 2.0; python_version == '3.9'",
"pint >= 0.22; python_version == '3.9'",
"numpy >= 1.20",
"pint >= 0.24.1",
"pyyaml",
"uncertainties",
"striprtf",
Expand Down Expand Up @@ -65,4 +63,8 @@ enabled = true
dev_template = "{tag}.dev{ccount}"
dirty_template = "{tag}.dev{ccount}"

[tool.ruff]
[tool.ruff]

[tool.pytest.ini_options]
log_cli = false
log_cli_level = "DEBUG"
9 changes: 4 additions & 5 deletions src/yadg/dgutils/dateutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,10 @@ def complete_uts(
ds = ds.expand_dims("uts")
if len(ds.uts.coords) == 0:
ds["uts"] = np.zeros(ds.uts.size)
ds.attrs["fulldate"] = False
if not ds.attrs.get("fulldate", True) or externaldate is not None:
ds.attrs["fulldate"] = 0

# fulldate should be an int, as it's converted int yadg.extract.extract_from_path()
if ds.attrs.get("fulldate", 1) == 0 or externaldate is not None:
ts, fulldate = complete_timestamps(
timesteps=ds.uts.values,
fn=filename,
Expand All @@ -448,7 +450,4 @@ def complete_uts(
ds["uts"] = ts
if fulldate:
ds.attrs.pop("fulldate", None)
else:
# cannot store booleans in NetCDF files
ds.attrs["fulldate"] = int(fulldate)
return ds
2 changes: 2 additions & 0 deletions src/yadg/extractors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def jsonize_orig_meta(obj: DataTree):
jsonize_orig_meta(obj[k])
if "original_metadata" in obj.attrs:
obj.attrs["original_metadata"] = json.dumps(obj.attrs["original_metadata"])
if "fulldate" in obj.attrs:
obj.attrs["fulldate"] = int(obj.attrs["fulldate"])


__all__ = ["extract"]
249 changes: 135 additions & 114 deletions src/yadg/extractors/eclab/common/mpr_columns.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
import numpy as np

# Module header starting after each MODULE keyword.
module_header_dtype = np.dtype(
[
("short_name", "|S10"),
("long_name", "|S25"),
("length", "<u4"),
("version", "<u4"),
("date", "|S8"),
]
module_header_dtypes = (
np.dtype(
[
("short_name", "|S10"),
("long_name", "|S25"),
("length", "<u4"),
("version", "<u4"),
("date", "|S8"),
]
),
np.dtype(
[
("short_name", "|S10"),
("long_name", "|S25"),
("max_length", "<u4"),
("length", "<u4"),
("version", "<u4"),
("unknown", "<u4"),
("date", "|S8"),
]
),
)


Expand Down Expand Up @@ -39,120 +52,128 @@

# Maps the flag column ID bytes to the corresponding bitmask and name.
flag_columns = {
0x0001: (0b00000011, "mode"),
0x0002: (0b00000100, "ox or red"),
0x0003: (0b00001000, "error"),
0x0015: (0b00010000, "control changes"),
0x001F: (0b00100000, "Ns changes"),
1: (0b00000011, "mode"),
2: (0b00000100, "ox or red"),
3: (0b00001000, "error"),
21: (0b00010000, "control changes"),
31: (0b00100000, "Ns changes"),
# NOTE: I think the missing bitmask (0b01000000) is a stop bit. It
# sometimes appears in the flag byte of the very last data point.
0x0041: (0b10000000, "counter inc."),
65: (0b10000000, "counter inc."),
}


# Maps the data column ID bytes to the corresponding dtype, name and
# unit.
data_columns = {
0x0004: ("<f8", "time", "s"),
0x0005: ("<f4", "control_V_I", "V/mA"),
0x0006: ("<f4", "Ewe", "V"),
0x0007: ("<f8", "dq", "mA·h"),
0x0008: ("<f4", "I", "mA"),
0x0009: ("<f4", "Ece", "V"),
0x000B: ("<f8", "<I>", "mA"),
0x000D: ("<f8", "(Q-Qo)", "mA·h"),
0x0010: ("<f4", "Analog IN 1", "V"),
0x0011: ("<f4", "Analog IN 2", "V"),
0x0013: ("<f4", "control_V", "V"),
0x0014: ("<f4", "control_I", "mA"),
0x0017: ("<f8", "dQ", "mA·h"),
0x0018: ("<f8", "cycle number", None),
0x0020: ("<f4", "freq", "Hz"),
0x0021: ("<f4", "|Ewe|", "V"),
0x0022: ("<f4", "|I|", "A"),
0x0023: ("<f4", "Phase(Z)", "deg"),
0x0024: ("<f4", "|Z|", "Ω"),
0x0025: ("<f4", "Re(Z)", "Ω"),
0x0026: ("<f4", "-Im(Z)", "Ω"),
0x0027: ("<u2", "I Range", None),
0x0046: ("<f4", "P", "W"),
0x004A: ("<f8", "|Energy|", "W·h"),
0x004B: ("<f4", "Analog OUT", "V"),
0x004C: ("<f4", "<I>", "mA"),
0x004D: ("<f4", "<Ewe>", "V"),
0x004E: ("<f4", "Cs⁻²", "µF⁻²"),
0x0060: ("<f4", "|Ece|", "V"),
0x0062: ("<f4", "Phase(Zce)", "deg"),
0x0063: ("<f4", "|Zce|", "Ω"),
0x0064: ("<f4", "Re(Zce)", "Ω"),
0x0065: ("<f4", "-Im(Zce)", "Ω"),
0x007B: ("<f8", "Energy charge", "W·h"),
0x007C: ("<f8", "Energy discharge", "W·h"),
0x007D: ("<f8", "Capacitance charge", "µF"),
0x007E: ("<f8", "Capacitance discharge", "µF"),
0x0083: ("<u2", "Ns", None),
0x00A3: ("<f4", "|Estack|", "V"),
0x00A8: ("<f4", "Rcmp", "Ω"),
0x00A9: ("<f4", "Cs", "µF"),
0x00AC: ("<f4", "Cp", "µF"),
0x00AD: ("<f4", "Cp⁻²", "µF⁻²"),
0x00AE: ("<f4", "<Ewe>", "V"),
0x00F1: ("<f4", "|E1|", "V"),
0x00F2: ("<f4", "|E2|", "V"),
0x010F: ("<f4", "Phase(Z1)", "deg"),
0x0110: ("<f4", "Phase(Z2)", "deg"),
0x012D: ("<f4", "|Z1|", "Ω"),
0x012E: ("<f4", "|Z2|", "Ω"),
0x014B: ("<f4", "Re(Z1)", "Ω"),
0x014C: ("<f4", "Re(Z2)", "Ω"),
0x0169: ("<f4", "-Im(Z1)", "Ω"),
0x016A: ("<f4", "-Im(Z2)", "Ω"),
0x0187: ("<f4", "<E1>", "V"),
0x0188: ("<f4", "<E2>", "V"),
0x01A6: ("<f4", "Phase(Zstack)", "deg"),
0x01A7: ("<f4", "|Zstack|", "Ω"),
0x01A8: ("<f4", "Re(Zstack)", "Ω"),
0x01A9: ("<f4", "-Im(Zstack)", "Ω"),
0x01AA: ("<f4", "<Estack>", "V"),
0x01AE: ("<f4", "Phase(Zwe-ce)", "deg"),
0x01AF: ("<f4", "|Zwe-ce|", "Ω"),
0x01B0: ("<f4", "Re(Zwe-ce)", "Ω"),
0x01B1: ("<f4", "-Im(Zwe-ce)", "Ω"),
0x01B2: ("<f4", "(Q-Qo)", "C"),
0x01B3: ("<f4", "dQ", "C"),
0x01B9: ("<f4", "<Ece>", "V"),
0x01CE: ("<f4", "Temperature", "°C"),
0x01D3: ("<f8", "Q charge or discharge", "mA·h"),
0x01D4: ("<u4", "half cycle", None),
0x01D5: ("<u4", "z cycle", None),
0x01D7: ("<f4", "<Ece>", "V"),
0x01D9: ("<f4", "THD Ewe", "%"),
0x01DA: ("<f4", "THD I", "%"),
0x01DB: ("<f4", "THD Ece", "%"),
0x01DC: ("<f4", "NSD Ewe", "%"),
0x01DD: ("<f4", "NSD I", "%"),
0x01DE: ("<f4", "NSD Ece", "%"),
0x01DF: ("<f4", "NSR Ewe", "%"),
0x01E0: ("<f4", "NSR I", "%"),
0x01E1: ("<f4", "NSR Ece", "%"),
0x01E6: ("<f4", "|Ewe h2|", "V"),
0x01E7: ("<f4", "|Ewe h3|", "V"),
0x01E8: ("<f4", "|Ewe h4|", "V"),
0x01E9: ("<f4", "|Ewe h5|", "V"),
0x01EA: ("<f4", "|Ewe h6|", "V"),
0x01EB: ("<f4", "|Ewe h7|", "V"),
0x01EC: ("<f4", "|I h2|", "A"),
0x01ED: ("<f4", "|I h3|", "A"),
0x01EE: ("<f4", "|I h4|", "A"),
0x01EF: ("<f4", "|I h5|", "A"),
0x01F0: ("<f4", "|I h6|", "A"),
0x01F1: ("<f4", "|I h7|", "A"),
0x01F2: ("<f4", "|Ece h2|", "V"),
0x01F3: ("<f4", "|Ece h3|", "V"),
0x01F4: ("<f4", "|Ece h4|", "V"),
0x01F5: ("<f4", "|Ece h5|", "V"),
0x01F6: ("<f4", "|Ece h6|", "V"),
0x01F7: ("<f4", "|Ece h7|", "V"),
4: ("<f8", "time", "s"),
5: ("<f4", "control_V_I", "V/mA"),
6: ("<f4", "Ewe", "V"),
7: ("<f8", "dq", "mA·h"),
8: ("<f4", "I", "mA"),
9: ("<f4", "Ece", "V"),
11: ("<f8", "<I>", "mA"),
13: ("<f8", "(Q-Qo)", "mA·h"),
16: ("<f4", "Analog IN 1", "V"),
17: ("<f4", "Analog IN 2", "V"),
19: ("<f4", "control_V", "V"),
20: ("<f4", "control_I", "mA"),
23: ("<f8", "dQ", "mA·h"),
24: ("<f8", "cycle number", None),
32: ("<f4", "freq", "Hz"),
33: ("<f4", "|Ewe|", "V"),
34: ("<f4", "|I|", "A"),
35: ("<f4", "Phase(Z)", "deg"),
36: ("<f4", "|Z|", "Ω"),
37: ("<f4", "Re(Z)", "Ω"),
38: ("<f4", "-Im(Z)", "Ω"),
39: ("<u2", "I Range", None),
69: ("<f4", "R", "Ω"),
70: ("<f4", "P", "W"),
74: ("<f8", "|Energy|", "W·h"),
75: ("<f4", "Analog OUT", "V"),
76: ("<f4", "<I>", "mA"),
77: ("<f4", "<Ewe>", "V"),
78: ("<f4", "Cs⁻²", "µF⁻²"),
96: ("<f4", "|Ece|", "V"),
98: ("<f4", "Phase(Zce)", "deg"),
99: ("<f4", "|Zce|", "Ω"),
100: ("<f4", "Re(Zce)", "Ω"),
101: ("<f4", "-Im(Zce)", "Ω"),
123: ("<f8", "Energy charge", "W·h"),
124: ("<f8", "Energy discharge", "W·h"),
125: ("<f8", "Capacitance charge", "µF"),
126: ("<f8", "Capacitance discharge", "µF"),
131: ("<u2", "Ns", None),
163: ("<f4", "|Estack|", "V"),
168: ("<f4", "Rcmp", "Ω"),
169: ("<f4", "Cs", "µF"),
172: ("<f4", "Cp", "µF"),
173: ("<f4", "Cp⁻²", "µF⁻²"),
174: ("<f4", "<Ewe>", "V"),
178: ("<f4", "(Q-Qo)", "C"),
179: ("<f4", "dQ", "C"),
182: ("<f8", "step time", "s"),
211: ("<f8", "Q charge or discharge", "C"),
217: ("<f4", "THD Ewe", "%"),
241: ("<f4", "|E1|", "V"),
242: ("<f4", "|E2|", "V"),
271: ("<f4", "Phase(Z1)", "deg"),
272: ("<f4", "Phase(Z2)", "deg"),
295: ("<u2", "I Range", None),
301: ("<f4", "|Z1|", "Ω"),
302: ("<f4", "|Z2|", "Ω"),
326: ("<f4", "P", "W"),
331: ("<f4", "Re(Z1)", "Ω"),
332: ("<f4", "Re(Z2)", "Ω"),
361: ("<f4", "-Im(Z1)", "Ω"),
362: ("<f4", "-Im(Z2)", "Ω"),
391: ("<f4", "<E1>", "V"),
392: ("<f4", "<E2>", "V"),
422: ("<f4", "Phase(Zstack)", "deg"),
423: ("<f4", "|Zstack|", "Ω"),
424: ("<f4", "Re(Zstack)", "Ω"),
425: ("<f4", "-Im(Zstack)", "Ω"),
426: ("<f4", "<Estack>", "V"),
430: ("<f4", "Phase(Zwe-ce)", "deg"),
431: ("<f4", "|Zwe-ce|", "Ω"),
432: ("<f4", "Re(Zwe-ce)", "Ω"),
433: ("<f4", "-Im(Zwe-ce)", "Ω"),
434: ("<f4", "(Q-Qo)", "C"),
435: ("<f4", "dQ", "C"),
441: ("<f4", "<Ece>", "V"),
462: ("<f4", "Temperature", "°C"),
467: ("<f8", "Q charge or discharge", "mA·h"),
468: ("<u4", "half cycle", None),
469: ("<u4", "z cycle", None),
471: ("<f4", "<Ece>", "V"),
473: ("<f4", "THD Ewe", "%"),
474: ("<f4", "THD I", "%"),
475: ("<f4", "THD Ece", "%"),
476: ("<f4", "NSD Ewe", "%"),
477: ("<f4", "NSD I", "%"),
478: ("<f4", "NSD Ece", "%"),
479: ("<f4", "NSR Ewe", "%"),
480: ("<f4", "NSR I", "%"),
481: ("<f4", "NSR Ece", "%"),
486: ("<f4", "|Ewe h2|", "V"),
487: ("<f4", "|Ewe h3|", "V"),
488: ("<f4", "|Ewe h4|", "V"),
489: ("<f4", "|Ewe h5|", "V"),
490: ("<f4", "|Ewe h6|", "V"),
491: ("<f4", "|Ewe h7|", "V"),
492: ("<f4", "|I h2|", "A"),
493: ("<f4", "|I h3|", "A"),
494: ("<f4", "|I h4|", "A"),
495: ("<f4", "|I h5|", "A"),
496: ("<f4", "|I h6|", "A"),
497: ("<f4", "|I h7|", "A"),
498: ("<f4", "|Ece h2|", "V"),
499: ("<f4", "|Ece h3|", "V"),
500: ("<f4", "|Ece h4|", "V"),
501: ("<f4", "|Ece h5|", "V"),
502: ("<f4", "|Ece h6|", "V"),
503: ("<f4", "|Ece h7|", "V"),
}


Expand Down
13 changes: 13 additions & 0 deletions src/yadg/extractors/eclab/common/mpt_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,26 @@
"(Q-Qo)/mA.h": ("(Q-Qo)", "mA·h"),
"<Ece>/V": ("<Ece>", "V"),
"<Ewe>/V": ("<Ewe>", "V"),
"<Ewe/V>": ("<Ewe>", "V"),
"<I>/mA": ("<I>", "mA"),
"|C|/nF": ("|C|", "nF"),
"|Conductivity|/mS/cm": ("|Conductivity|", "mS/cm"),
"|Ece|/V": ("|Ece|", "V"),
"|Energy|/W.h": ("|Energy|", "W·h"),
"|Ewe|/V": ("|Ewe|", "V"),
"|Ewe h2|/V": ("|Ewe h2|", "V"),
"|Ewe h3|/V": ("|Ewe h3|", "V"),
"|Ewe h4|/V": ("|Ewe h4|", "V"),
"|Ewe h5|/V": ("|Ewe h5|", "V"),
"|Ewe h6|/V": ("|Ewe h6|", "V"),
"|Ewe h7|/V": ("|Ewe h7|", "V"),
"|I|/A": ("|I|", "A"),
"|I h2|/A": ("|I h2|", "A"),
"|I h3|/A": ("|I h3|", "A"),
"|I h4|/A": ("|I h4|", "A"),
"|I h5|/A": ("|I h5|", "A"),
"|I h6|/A": ("|I h6|", "A"),
"|I h7|/A": ("|I h7|", "A"),
"|M|": ("|M|", ""),
"|Permittivity|": ("|Permittivity|", ""),
"|Resistivity|/Ohm.cm": ("|Resistivity|", "Ω·cm"),
Expand Down
Loading
Loading