Skip to content

Commit

Permalink
eclab: Rename params for consistency between mpr and mpt (#193)
Browse files Browse the repository at this point in the history
* Harmonize names between mpt and mpr.

* fix mp params

* typos etc.

* Fix CV for 11.50

* Fix consistency tests.

* ruff.

* Add params to map.
  • Loading branch information
PeterKraus authored Oct 19, 2024
1 parent 02f1531 commit 1f77294
Show file tree
Hide file tree
Showing 38 changed files with 566 additions and 479 deletions.
37 changes: 19 additions & 18 deletions src/yadg/extractors/eclab/mpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,18 @@ def process_settings(data: bytes, minver: str) -> tuple[dict, list]:
params = []
for pardict in pardicts:
for k, v in pardict.items():
# MPR quirk: I_range off by one
if k == "I_range":
# MPR quirk: I Range off by one
if k == "I Range":
v += 1
pardict[k] = param_from_key(k, v, to_str=True)
# Handle NaNs and +/-Inf in params here
if np.isnan(v) or np.isinf(v):
pardict[k] = str(v)
params.append(pardict)
if len(params) > 0:
params = {k: [d[k] for d in params] for k in params[0]}
else:
params = {}
return settings, params


Expand Down Expand Up @@ -420,7 +424,7 @@ def process_data(
elif unit is None:
intv = int(value)
if name == "I Range":
vals[name] = param_from_key("I_range", intv)
vals[name] = param_from_key("I Range", intv)
else:
vals[name] = intv
if flaglist:
Expand All @@ -441,7 +445,7 @@ def process_data(
Irstr = Iranges[Ns]
if "I Range" in vals:
Irstr = vals["I Range"]
Irange = param_from_key("I_range", Irstr, to_str=False)
Irange = param_from_key("I Range", Irstr, to_str=False)

# I Range can be None if it's set to "Auto", "PAC" or other such string.
if Irange is None:
Expand Down Expand Up @@ -569,20 +573,17 @@ def process_modules(contents: bytes) -> tuple[dict, list, list, dict, dict]:
module_data = module[mhd.itemsize :]
if name == "VMP Set":
settings, params = process_settings(module_data, minver)
Eranges = []
Iranges = []
ctrls = []
for el in params:
E_range_max = el.get("E_range_max", float("inf"))
E_range_min = el.get("E_range_min", float("-inf"))
Eranges.append(E_range_max - E_range_min)
Iranges.append(el.get("I_range", "Auto"))
if "set_I/C" in el:
ctrls.append(el["set_I/C"])
elif "apply_I/C" in el:
ctrls.append(el["apply_I/C"])
else:
ctrls.append(None)

E_range_max = params.get("E range max (V)", [float("inf")])
E_range_min = params.get("E range min (V)", [float("-inf")])
Eranges = [a - b for a, b in zip(E_range_max, E_range_min)]
Iranges = params.get("I Range", ["Auto"])
if "Set I/C" in params:
ctrls = params.get("Set I/C")
elif "Apply I/C" in params:
ctrls = params.get("Apply I/C")
else:
ctrls = [None] * len(Iranges)
elif name == "VMP data":
ds = process_data(module_data, version, Eranges, Iranges, ctrls)
elif name == "VMP LOG":
Expand Down
4 changes: 2 additions & 2 deletions src/yadg/extractors/eclab/mpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def process_data(
if units.get(name) is None:
ival = int(parse_decimal(value, locale=locale))
if name == "I Range":
vals[name] = param_from_key("I_range", ival)
vals[name] = param_from_key("I Range", ival)
else:
vals[name] = ival
else:
Expand All @@ -280,7 +280,7 @@ def process_data(
Irstr = Iranges[Ns] if isinstance(Iranges, list) else Iranges
if "I Range" in vals:
Irstr = vals["I Range"]
Irange = param_from_key("I_range", Irstr, to_str=False)
Irange = param_from_key("I Range", Irstr, to_str=False)

# I Range can be None if it's set to "Auto", "PAC" or other such string.
if Irange is None:
Expand Down
Loading

0 comments on commit 1f77294

Please sign in to comment.