def test_is_loaded(self):
     gp = parser.CyclicVoltammetry()
     # should raise exception if file not loaded
     self.assertRaises(AssertionError, gp.get_curve_count)
     self.assertRaises(AssertionError, gp.get_curve_data, 2)
     self.assertRaises(AssertionError, gp.get_curves)
     self.assertRaises(AssertionError, gp.get_scan_rate)
     self.assertRaises(AssertionError, gp.get_experiment_type)
    def test_getters(self):
        gp = parser.CyclicVoltammetry(filename='tests/cv_data.dta')
        gp.load()
        vrange = gp.get_v_range()
        self.assertEqual(vrange[0], 0.1)
        self.assertEqual(vrange[1], 0.9)

        scanrate = gp.get_scan_rate()
        self.assertEqual(scanrate, 1.23456)
        curve = gp.get_curve_data(1)
        self.assertTrue((curve.columns == ['Vf', 'Im']).all())
Пример #3
0
import gamry_parser as parser
import random

file = 'tests/cv_data.dta'
gp = parser.GamryParser()
gp.load(filename=file)
print('GamryParser() usage:')
print("experiment type: {}".format(gp.get_experiment_type()))
print("loaded curves: {}".format(gp.get_curve_count()))

curve_index = random.randint(1, gp.get_curve_count())
print("showing curve #{}".format(curve_index))
print(gp.get_curve_data(curve_index))

cv = parser.CyclicVoltammetry(filename=file)
cv.load()
vrange = cv.get_v_range()
print('\nCyclic Voltammetry class')
print('Programmed Scan Rate: {} mV/s'.format(cv.get_scan_rate()))
print('Programmed V range: [{}, {}] V'.format(vrange[0], vrange[1]))
print(
    '\tnote: range will not match with below; the raw file has been modified for faster test execution'
)

curve = cv.get_curve_data(curve_index)
print("showing curve #{}".format(curve_index))
print('Acheived V range: [{}, {}]'.format(min(curve['Vf']), max(curve['Vf'])))
print(curve)