def apply_refraction(self, us_time):
"""Implements a refractory period for each pixel.
Does not modify instance data
In other words, if an event occurs within 'us_time' microseconds of
a previous event at the same pixel, then the second event is removed
us_time: time in microseconds
"""
t0 = np.ones((self.width, self.height)) - us_time - 1
valid_indices = np.ones(len(self.data), np.bool_)
#with timer.Timer() as ref_timer:
i = 0
for datum in np.nditer(self.data):
datum_ts = datum['ts'].item(0)
datum_x = datum['x'].item(0)
datum_y = datum['y'].item(0)
if datum_ts - t0[datum_x, datum_y] < us_time:
valid_indices[i] = 0
else:
t0[datum_x, datum_y] = datum_ts
i += 1
#print 'Refraction took %s seconds' % ref_timer.secs
return self.data[valid_indices.astype('bool')]
评论列表
文章目录