Added I/mA column type = 8

Also there seems to be a duplicate of colID=23 is the same as 7 (dq/mAh)
This commit is contained in:
Chris Kerr
2013-12-11 12:50:45 +00:00
parent ce554aab2c
commit 00e6670b4a
2 changed files with 25 additions and 6 deletions

View File

@@ -9,6 +9,7 @@ from os import SEEK_SET, SEEK_CUR
import time import time
from datetime import date from datetime import date
from collections import OrderedDict from collections import OrderedDict
from warnings import warn
import numpy as np import numpy as np
@@ -74,8 +75,7 @@ def MPTfile(file_or_path):
"counter inc.", "time/s", "control/V", "Ewe/V", "<I>/mA", "counter inc.", "time/s", "control/V", "Ewe/V", "<I>/mA",
"dQ/mA.h", "P/W"]) "dQ/mA.h", "P/W"])
if fieldnames not in expected_fieldnames: if fieldnames not in expected_fieldnames:
raise ValueError("Unrecognised headers for MPT file format %s" % warn("Unrecognised headers for MPT file format %s" % fieldnames)
fieldnames)
record_type = np.dtype(list(map(fieldname_to_dtype, fieldnames))) record_type = np.dtype(list(map(fieldname_to_dtype, fieldnames)))
@@ -150,8 +150,11 @@ def VMPdata_dtype_from_colIDs(colIDs):
dtype_dict['control/V/mA'] = '<f4' dtype_dict['control/V/mA'] = '<f4'
elif colID == 6: elif colID == 6:
dtype_dict['Ewe/V'] = '<f4' dtype_dict['Ewe/V'] = '<f4'
elif colID == 7: ## Not sure of the difference between 7 and 23 - they seem to be the same
elif colID == 7 or colID == 23:
dtype_dict['dQ/mA.h'] = '<f8' dtype_dict['dQ/mA.h'] = '<f8'
elif colID == 8:
dtype_dict['I/mA'] = '<f4'
elif colID == 19: elif colID == 19:
dtype_dict['control/V'] = '<f4' dtype_dict['control/V'] = '<f4'
elif colID == 70: elif colID == 70:

View File

@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os.path import os.path
import re
from datetime import date from datetime import date
import numpy as np import numpy as np
@@ -69,6 +70,13 @@ def test_open_MPR4():
eq_(mpr.enddate, date(2011, 11, 2)) eq_(mpr.enddate, date(2011, 11, 2))
def test_open_MPR5():
mpr = MPRfile(os.path.join(testdata_dir, 'bio-logic5.mpr'))
## Check the dates as a basic test that it has been read properly
eq_(mpr.startdate, date(2013, 1, 28))
eq_(mpr.enddate, date(2013, 1, 28))
@raises(ValueError) @raises(ValueError)
def test_open_MPR_fails_for_bad_file(): def test_open_MPR_fails_for_bad_file():
mpr1 = MPRfile(os.path.join(testdata_dir, 'arbin1.res')) mpr1 = MPRfile(os.path.join(testdata_dir, 'arbin1.res'))
@@ -77,7 +85,7 @@ def test_open_MPR_fails_for_bad_file():
def assert_MPR_matches_MPT(mpr, mpt): def assert_MPR_matches_MPT(mpr, mpt):
def assert_field_matches(fieldname, decimal): def assert_field_matches(fieldname, decimal):
if fieldname in mpt.dtype.fields: if fieldname in mpr.dtype.fields:
assert_array_almost_equal(mpr.data[fieldname], assert_array_almost_equal(mpr.data[fieldname],
mpt[fieldname], mpt[fieldname],
decimal=decimal) decimal=decimal)
@@ -97,7 +105,7 @@ def assert_MPR_matches_MPT(mpr, mpt):
assert_array_almost_equal(mpr.data["time/s"], assert_array_almost_equal(mpr.data["time/s"],
mpt["time/s"], mpt["time/s"],
decimal=5) # 5 digits in CSV decimal=4) # 5 digits in CSV
assert_field_matches("control/V/mA", decimal=6) assert_field_matches("control/V/mA", decimal=6)
assert_field_matches("control/V", decimal=6) assert_field_matches("control/V", decimal=6)
@@ -111,6 +119,7 @@ def assert_MPR_matches_MPT(mpr, mpt):
decimal=17) # 64 bit float precision decimal=17) # 64 bit float precision
assert_field_matches("P/W", decimal=10) # 32 bit float precision for 1.xxE-5 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
def test_MPR1_matches_MPT1(): def test_MPR1_matches_MPT1():
@@ -132,4 +141,11 @@ def test_MPR4_matches_MPT4():
mpr4 = MPRfile(os.path.join(testdata_dir, 'bio-logic4.mpr')) mpr4 = MPRfile(os.path.join(testdata_dir, 'bio-logic4.mpr'))
mpt4, comments = MPTfile(os.path.join(testdata_dir, 'bio-logic4.mpt')) mpt4, comments = MPTfile(os.path.join(testdata_dir, 'bio-logic4.mpt'))
assert_MPR_matches_MPT(mpr4, mpt4) assert_MPR_matches_MPT(mpr4, mpt4)
def test_MPR5_matches_MPT5():
mpr = MPRfile(os.path.join(testdata_dir, 'bio-logic5.mpr'))
mpt, comments = MPTfile((re.sub(b'\tXXX\t', b'\t0\t', line) for line in
open(os.path.join(testdata_dir, 'bio-logic5.mpt'),
mode='rb')))
assert_MPR_matches_MPT(mpr, mpt)