mirror of
https://github.com/echemdata/galvani.git
synced 2025-12-14 01:15:34 +00:00
Merge pull request #75 from chatcannon/yuyu-step-time
Add "step time/s" column data type
This commit is contained in:
@@ -33,7 +33,7 @@ def fieldname_to_dtype(fieldname):
|
||||
return (fieldname, np.float_)
|
||||
elif fieldname in ("Q charge/discharge/mA.h", "step time/s",
|
||||
"Q charge/mA.h", "Q discharge/mA.h",
|
||||
"Efficiency/%", "Capacity/mA.h")
|
||||
"Temperature/°C", "Efficiency/%", "Capacity/mA.h")
|
||||
return (fieldname, np.float_)
|
||||
elif fieldname in ("cycle number", "I Range", "Ns", "half cycle"):
|
||||
return (fieldname, np.int_)
|
||||
@@ -41,8 +41,15 @@ def fieldname_to_dtype(fieldname):
|
||||
return ("dQ/mA.h", np.float_)
|
||||
elif fieldname in ("I/mA", "<I>/mA"):
|
||||
return ("I/mA", np.float_)
|
||||
elif fieldname in ("Ewe/V", "<Ewe>/V"):
|
||||
elif fieldname in ("Ewe/V", "<Ewe>/V", "Ecell/V"):
|
||||
return ("Ewe/V", np.float_)
|
||||
elif fieldname.endswith(("/s", "/Hz", "/deg",
|
||||
"/W", "/mW", "/W.h", "/mW.h",
|
||||
"/A", "/mA", "/A.h", "/mA.h",
|
||||
"/V", "/mV",
|
||||
"/F", "/mF", "/uF",
|
||||
"/C", "/Ohm",)):
|
||||
return (fieldname, np.float_)
|
||||
else:
|
||||
raise ValueError("Invalid column header: %s" % fieldname)
|
||||
|
||||
@@ -66,7 +73,7 @@ def MPTfile(file_or_path, encoding='ascii'):
|
||||
mpt_file = file_or_path
|
||||
|
||||
magic = next(mpt_file)
|
||||
if magic != b'EC-Lab ASCII FILE\r\n':
|
||||
if magic not in (b'EC-Lab ASCII FILE\r\n', b'BT-Lab ASCII FILE\r\n'):
|
||||
raise ValueError("Bad first line for EC-Lab file: '%s'" % magic)
|
||||
|
||||
nb_headers_match = re.match(rb'Nb header lines : (\d+)\s*$',
|
||||
@@ -213,6 +220,7 @@ VMPdata_colID_dtype_map = {
|
||||
433: ('-Im(Zwe-ce)/Ohm', '<f4'),
|
||||
434: ('(Q-Qo)/C', '<f4'),
|
||||
435: ('dQ/C', '<f4'),
|
||||
438: ('step time/s', '<f8'),
|
||||
441: ('<Ecv>/V', '<f4'),
|
||||
462: ('Temperature/°C', '<f4'),
|
||||
467: ('Q charge/discharge/mA.h', '<f8'),
|
||||
|
||||
@@ -165,7 +165,7 @@ def assert_MPR_matches_MPT(mpr, mpt, comments):
|
||||
mpt["Ewe/V"],
|
||||
decimal=6) # 32 bit float precision
|
||||
|
||||
assert_field_matches("dQ/mA.h", decimal=17) # 64 bit float precision
|
||||
assert_field_matches("dQ/mA.h", decimal=16) # 64 bit float precision
|
||||
assert_field_matches("P/W", decimal=10) # 32 bit float precision for 1.xxE-5
|
||||
assert_field_matches("I/mA", decimal=6) # 32 bit float precision
|
||||
|
||||
@@ -173,7 +173,7 @@ def assert_MPR_matches_MPT(mpr, mpt, comments):
|
||||
assert_field_matches("(Q-Qo)/C", decimal=6) # 32 bit float precision
|
||||
|
||||
try:
|
||||
assert timestamp_from_comments(comments) == mpr.timestamp
|
||||
assert timestamp_from_comments(comments) == mpr.timestamp.replace(microsecond=0)
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
@@ -186,6 +186,7 @@ def assert_MPR_matches_MPT(mpr, mpt, comments):
|
||||
# bio_logic5 and bio_logic6 are special cases
|
||||
'CV_C01',
|
||||
'121_CA_455nm_6V_30min_C01',
|
||||
'020-formation_CB5',
|
||||
])
|
||||
def test_MPR_matches_MPT(testdata_dir, basename):
|
||||
"""Check the MPR parser against the MPT parser.
|
||||
@@ -196,7 +197,7 @@ def test_MPR_matches_MPT(testdata_dir, basename):
|
||||
binpath = os.path.join(testdata_dir, basename + '.mpr')
|
||||
txtpath = os.path.join(testdata_dir, basename + '.mpt')
|
||||
mpr = MPRfile(binpath)
|
||||
mpt, comments = MPTfile(txtpath)
|
||||
mpt, comments = MPTfile(txtpath, encoding='latin1')
|
||||
assert_MPR_matches_MPT(mpr, mpt, comments)
|
||||
|
||||
|
||||
|
||||
BIN
tests/testdata/020-formation_CB5.mpr
LFS
vendored
Normal file
BIN
tests/testdata/020-formation_CB5.mpr
LFS
vendored
Normal file
Binary file not shown.
2
tests/testdata/020-formation_CB5.mpr.license
vendored
Normal file
2
tests/testdata/020-formation_CB5.mpr.license
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
SPDX-FileCopyrightText Chihyu Chen <chihyu.chen@molicel.com>
|
||||
SPDX-License-Identifier CC-BY-4.0
|
||||
BIN
tests/testdata/020-formation_CB5.mpt
LFS
vendored
Normal file
BIN
tests/testdata/020-formation_CB5.mpt
LFS
vendored
Normal file
Binary file not shown.
2
tests/testdata/020-formation_CB5.mpt.license
vendored
Normal file
2
tests/testdata/020-formation_CB5.mpt.license
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
SPDX-FileCopyrightText Chihyu Chen <chihyu.chen@molicel.com>
|
||||
SPDX-License-Identifier CC-BY-4.0
|
||||
Reference in New Issue
Block a user