Skip to content

Commit

Permalink
eclab.mpr: Further fixes (#182)
Browse files Browse the repository at this point in the history
* mpr file fixes

* revert warning -> valueerror

* Fix appended/merged files.

* Add reference to paper.

* ruff

---------

Co-authored-by: Arnd Koeppe <[email protected]>
  • Loading branch information
PeterKraus and arndkoeppe committed Sep 20, 2024
1 parent 322b773 commit ef12f7e
Show file tree
Hide file tree
Showing 10 changed files with 5,565 additions and 9 deletions.
23 changes: 16 additions & 7 deletions docs/source/citing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,27 @@ Citing **yadg**
---------------
**yadg** is currently being developed at the `ConCat Lab <https://tu.berlin/en/concat>`_ at Technische Universität Berlin, Berlin, Germany. It has been previously developed at `Materials for Energy Conversion lab <https://www.empa.ch/web/s501>`_ at Empa, Dübendorf, Switzerland. If you find **yadg** useful, please cite our recent paper [Kraus2022b]_, or our previous work where **yadg** was first introduced [Kraus2022a]_.

Other works where **yadg** has been used include [Bernasconi2023a]_, [Kraus2024a]_ and [Senocrate2024a]_. If you found **yadg** useful, and would like your publication listed, let us know!

We extend no warranty, neither express nor implied.

.. [Kraus2022b]
Kraus, P.; Vetsch, N.; Battaglia, C. *yadg: yet another datagram*, Journal of Open Source Software **2022**, *7*, 4166, DOI: https://doi.org/10.21105/joss.04166
.. [Kraus2022a]
Kraus, P.; Wolf, E.H.; Prinz, C.; Bellini, G.; Trunschke, A.; Schlögl, R. *Towards automation of operando experiments: a case study in contactless conductivity measurements*, Digital Discovery **2022**, *1*, 241, DOI: https://doi.org/10.1039/D1DD00029B
Papers related to yadg
``````````````````````
.. [Senocrate2024a] Senocrate, A.; Bernasconi, F.; Kraus, P.; Plainpan, N.; Trafkowski, J.; Tolle, F.; Weber, T.; Sauter, U.; Battaglia, C.; *Parallel experiments in electrochemical CO2 reduction enabled by standardized analytics*, Nature Catalysis **2024**, *7*, 742, DOI: https://doi.org/10.1038/s41929-024-01172-x
If you found **yadg** useful, and would like your publication listed, let us know!

.. [Kraus2024a] Kraus, P.; Bainglass, E.; Ramirez, F. F.; Svaluto-Ferro, E.; Ercole, L.; Kunz, B.; Huber, S. P.; Plainpan, N.; Marzari, N.; Battaglia, C.; Pizzi, G. *A bridge between trust and control: computational workflows meet automated battery cycling*, Journal of Materials Chemistry A **2024**, *12*, 10773, DOI: https://doi.org/10.1039/D3TA06889G
.. [#]
Stüble, P.; Müller, C.; Bohn, N.; Müller, M.; Hofmann, A.; Akçay, T.; Klemens, J.; Koeppe, A.; Kolli, S.; Rajagopal, D.; Geßwein, H.; Schabel, W.; Scharfer, P.; Selzer, M.; Binder, J. R.; Smith, A.; *From Powder to Pouch Cell: Setting up a Sodium-Ion Battery Reference System Based on Na3V2(PO4)3/C and Hard Carbon*, Batteries & Supercaps **2024**, e202400406, DOI: https://doi.org/10.1002/batt.202400406
.. [Bernasconi2023a] Bernasconi, F.; Senocrate, A.; Kraus, P.; Battaglia, C.; *Enhancing C≥2 product selectivity in electrochemical CO2 reduction by controlling the microstructure of gas diffusion electrodes*, EES Catalysis **2023**, *1*, 1009, DOI: https://doi.org/10.1039/D3EY00140G
.. [#]
Senocrate, A.; Bernasconi, F.; Kraus, P.; Plainpan, N.; Trafkowski, J.; Tolle, F.; Weber, T.; Sauter, U.; Battaglia, C.; *Parallel experiments in electrochemical CO2 reduction enabled by standardized analytics*, Nature Catalysis **2024**, *7*, 742, DOI: https://doi.org/10.1038/s41929-024-01172-x
.. [Kraus2022b] Kraus, P.; Vetsch, N.; Battaglia, C. *yadg: yet another datagram*, Journal of Open Source Software **2022**, *7*, 4166, DOI: https://doi.org/10.21105/joss.04166
.. [#]
Kraus, P.; Bainglass, E.; Ramirez, F. F.; Svaluto-Ferro, E.; Ercole, L.; Kunz, B.; Huber, S. P.; Plainpan, N.; Marzari, N.; Battaglia, C.; Pizzi, G. *A bridge between trust and control: computational workflows meet automated battery cycling*, Journal of Materials Chemistry A **2024**, *12*, 10773, DOI: https://doi.org/10.1039/D3TA06889G
.. [Kraus2022a] Kraus, P.; Wolf, E.H.; Prinz, C.; Bellini, G.; Trunschke, A.; Schlögl, R. *Towards automation of operando experiments: a case study in contactless conductivity measurements*, Digital Discovery **2022**, *1*, 241, DOI: https://doi.org/10.1039/D1DD00029B
.. [#]
Bernasconi, F.; Senocrate, A.; Kraus, P.; Battaglia, C.; *Enhancing C≥2 product selectivity in electrochemical CO2 reduction by controlling the microstructure of gas diffusion electrodes*, EES Catalysis **2023**, *1*, 1009, DOI: https://doi.org/10.1039/D3EY00140G
2 changes: 2 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,5 @@
"datatree": ("https://xarray-datatree.readthedocs.io/en/latest/", None),
"babel": ("https://babel.pocoo.org/en/latest/", None),
}

suppress_warnings = ["ref.footnote"]
1 change: 1 addition & 0 deletions src/yadg/extractors/eclab/common/techniques.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,7 @@
0x32: ("ZIR", _zir_params_dtypes),
0x33: ("CVA", _cva_params_dtypes),
0x6C: ("LSV", _lsv_params_dtype),
0x77: ("GCPL", _gcpl_params_dtypes),
0x7F: ("MB", _mb_params_dtypes),
}

Expand Down
9 changes: 8 additions & 1 deletion src/yadg/extractors/eclab/mpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ def process_data(
values = np.frombuffer(data, offset=offset, dtype=data_dtype, count=n_datapoints)
values = [dict(zip(value.dtype.names, value.item())) for value in values]
warn_I_range = False
warn_Ns = False
for vi, vals in enumerate(values):
# Lets split this into two loops: get the indices first, then the data
for (name, value), unit in list(zip(vals.items(), unitlist)):
Expand All @@ -431,6 +432,10 @@ def process_data(
vals[name] = (flag_bits & bitmask) >> shift

Ns = vals.get("Ns", 0)
# Manually merged/appended mpr files have a mysteriously larger Ns
if Ns >= len(Eranges):
warn_Ns = True
Ns = len(Eranges) - 1
Erange = Eranges[Ns]
Irstr = Iranges[Ns]
if "I Range" in vals:
Expand All @@ -444,13 +449,15 @@ def process_data(

if "control_V_I" in vals:
icv = controls[Ns]
name = f"control_{icv}"
name = "control_I" if icv in {"I", "C"} else "control_V" # f"control_{icv}"
vals[name] = vals.pop("control_V_I")
units[name] = "mA" if icv in {"I", "C"} else "V"
devs = get_devs(vals=vals, units=units, Erange=Erange, Irange=Irange)
dgutils.append_dicts(vals, devs, allvals, allmeta, li=vi)
if warn_I_range:
logger.warning("I Range could not be understood, defaulting to 1 A.")
if warn_Ns:
logger.warning("Ns found in data exceeds Ns in header, using last defined Ns.")

ds = dgutils.dicts_to_dataset(allvals, allmeta, units, fulldate=False)
return ds
Expand Down
2 changes: 1 addition & 1 deletion src/yadg/extractors/eclab/mpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def process_data(
units = dict()
columns = list()
for n in names:
c, u = column_units[n]
c, u = column_units[n.strip()]
if c in columns:
logger.warning("Duplicate column '%s' with unit '%s'.", c, u)
c = f"duplicate {c}"
Expand Down
27 changes: 27 additions & 0 deletions tests/test_x_eclab.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,30 @@ def test_eclab_consistency_partial(afile, bfile, locale, _datadir):
except AssertionError as e:
e.args = (e.args[0] + f"Error happened on key: {key!r}\n",)
raise e


@pytest.mark.parametrize(
"afile, bfile, locale",
[
("gcpl.pr_182.1.mpr", "gcpl.pr_182.1.mpt", "en_US"),
("gcpl.pr_182.2.mpr", "gcpl.pr_182.2.mpt", "en_US"),
],
)
def test_eclab_consistency_partial_2(afile, bfile, locale, _datadir):
os.chdir(_datadir)
aret = extract_mpr(fn=afile, timezone="Europe/Berlin")
bret = extract_mpt(
fn=bfile, timezone="Europe/Berlin", encoding="windows-1252", locale=locale
)
print(f"{aret.data_vars=}")
print(f"{bret.data_vars=}")
for key in aret.variables:
if key.endswith("std_err"):
continue
elif key in {"control_I"}:
continue
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",)
raise e
Binary file added tests/test_x_eclab_mpr/gcpl.pr_182.1.mpr
Binary file not shown.
Binary file added tests/test_x_eclab_mpr/gcpl.pr_182.2.mpr
Binary file not shown.
Loading

0 comments on commit ef12f7e

Please sign in to comment.