• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import numpy
2
3
4def screen_stats(blinker_file_name, sensor_file_name):
5
6    sensor_data = numpy.loadtxt(sensor_file_name)
7    blinker_data = numpy.loadtxt(blinker_file_name)
8
9    # Convert all times to milliseconds
10    t_sensor = sensor_data[:, 0] * 1e3
11    t_vsync = blinker_data / 1e3
12
13    # Throw away any sensor timestamps earlier than the first blink
14    # this may happen if the operator attached the sensor after
15    # running the command. But this should be avoided.
16    skip_sensor = sum(t_sensor < t_vsync[0])
17    if(skip_sensor):
18        t_sensor = t_sensor[skip_sensor:]
19        print('Skipped first %d readings from the sensor' % skip_sensor)
20
21    # Get only the common size and skip the first blink, it's often weird.
22    length = min(len(t_sensor), len(t_vsync))
23    t_sensor = t_sensor[1:length]
24    t_vsync = t_vsync[1:length]
25
26    # Shift time so that first time point is 0
27    t0 = min(t_vsync)
28    t_sensor = t_sensor - t0
29    t_vsync = t_vsync - t0
30
31    dt = t_sensor - t_vsync
32
33    # Look at even and odd transitions separately - black <-> white.
34    dt_even = dt[0::2]
35    dt_odd = dt[1::2]
36
37    print('')
38    print('dt = array([' + ', '.join('%0.2f' % x for x in dt) + '])')
39    print('')
40    print('Screen response times [ms]')
41    print('Even: median %0.1f ms, stdev %0.2f ms' %
42          (numpy.median(dt_even), numpy.std(dt_even)))
43    print('Odd:  median %0.1f ms, stdev %0.2f ms' %
44          (numpy.median(dt_odd), numpy.std(dt_odd)))
45
46
47# Debug & test
48if __name__ == '__main__':
49
50    fname = '/tmp/WALT_2016_06_22__1739_21_'
51    blinker_file_name = fname + 'evtest.log'
52    sensor_file_name = fname + 'laser.log'
53
54    screen_stats(blinker_file_name, sensor_file_name)
55