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 <arnd.koeppe@kit.edu>
  • Loading branch information
PeterKraus and arndkoeppe committed Sep 20, 2024
1 parent 65aa253 commit a16b211
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 12 deletions.
24 changes: 21 additions & 3 deletions docs/source/citing.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
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]_. We extend no warranty, neither express nor implied.
**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]_.

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
``````````````````````
If you found **yadg** useful, and would like your publication listed, let us know!

.. [#]
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
.. [#]
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 @@
"xarray": ("https://docs.xarray.dev/en/stable", None),
"datatree": ("https://xarray-datatree.readthedocs.io/en/latest/", None),
}

suppress_warnings = ["ref.footnote"]
1 change: 1 addition & 0 deletions src/yadg/parsers/electrochem/eclabcommon/techniques.py
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,7 @@ def technique_params(technique: str, settings: list[str]) -> tuple[str, list]:
0x1E: ("GEIS", _geis_params_dtype),
0x32: ("ZIR", _zir_params_dtypes),
0x6C: ("LSV", _lsv_params_dtype),
0x77: ("GCPL", _gcpl_params_dtypes),
0x7F: ("MB", _mb_params_dtypes),
}

Expand Down
23 changes: 15 additions & 8 deletions src/yadg/parsers/electrochem/eclabmpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,8 @@ def process_data(
allmeta = dict()
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 @@ -390,19 +392,20 @@ def process_data(
# Rightshift flag by that amount.
vals[name] = (flag_bits & bitmask) >> shift

if "Ns" in vals:
Erange = Eranges[vals["Ns"]]
Irstr = Iranges[vals["Ns"]]
else:
Erange = Eranges[0]
Irstr = Iranges[0]
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:
Irstr = vals["I Range"]
Irange = param_from_key("I_range", Irstr, to_str=False)
devs = {}
if "control_V_I" in vals:
icv = controls[vals["Ns"]]
name = f"control_{icv}"
icv = controls[Ns]
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"
for name, value in vals.items():
Expand All @@ -412,6 +415,10 @@ def process_data(
devs[name] = get_resolution(name, value, unit, Erange, Irange)

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 = dicts_to_dataset(allvals, allmeta, units, fulldate=False)
return ds
Expand Down
2 changes: 1 addition & 1 deletion src/yadg/parsers/electrochem/eclabmpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def process_data(
units = dict()
columns = list()
for n in names:
c, u = column_units[n]
c, u = column_units[n.strip()]
columns.append(c)
if u is not None:
units[c] = u
Expand Down

0 comments on commit a16b211

Please sign in to comment.