forked from SensorsINI/ddd20-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_stats.py
37 lines (29 loc) · 812 Bytes
/
get_stats.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/python
from __future__ import print_function
import sys
import h5py
import numpy as np
import scipy.interpolate as ip
tstep = 1
if __name__ == '__main__':
k = sys.argv[1]
fnames = sys.argv[2:]
vout = []
for fname in fnames:
try:
f = h5py.File(fname, 'r')
except:
print('could not open', fname)
continue
print('processing', fname)
nnz = f[k]['timestamp'][:] > 0
if not any(nnz):
print('no data...')
continue
data = f[k]['data'][nnz, :]
t, v = data[:, 0] * 1e-6, data[:, 1]
curve = ip.interp1d(t, v)
tnew = np.linspace(t[0], t[-1], (t[-1] - t[0]) / tstep)
vout.append(curve(tnew))
out = np.hstack(vout)
np.savetxt(k + '.dat', out)