def test_normalize_time_arguments(self): fh = self._create_file(0, 2) r = DataReader().open(fh) self.assertEqual(r.normalize_time_arguments(0, 1), (0, 1)) self.assertEqual(r.normalize_time_arguments(0.0, 0.01, 'seconds'), (0, 10)) self.assertEqual(r.normalize_time_arguments(-10, -1), (242, 251)) self.assertEqual(r.normalize_time_arguments(-0.01, -0.005, 'seconds'), (0, 252))
def test_statistics_get(self): #fh = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data_recording_01.jls') fh = self.create_sinusoid_file(2000000, 400000) r = DataReader().open(fh) t_start, t_stop = 0.066780, 0.069004 k_start, k_stop = r.normalize_time_arguments(t_start, t_stop, units='seconds') ranges = [ (0, 1000), # trivial, direct (0, 20000), # trivial, single reduction (100000, 101000), # offset, direct (100000, 120000), # offset, ex (99000, 120000), (100000, 121000), (99000, 121000), (k_start, k_stop), ] for k_start, k_stop in ranges: # print(f'range {k_start}:{k_stop}') s1 = r.statistics_get(k_start, k_stop, units='samples') k = r.samples_get(k_start, k_stop, units='samples', fields=['current']) i_mean = np.mean(k['signals']['current']['value']) np.testing.assert_allclose(s1['signals']['current']['µ']['value'], i_mean, rtol=0.0005) r.close()