-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcompute_atten.py
More file actions
executable file
·38 lines (29 loc) · 1.41 KB
/
compute_atten.py
File metadata and controls
executable file
·38 lines (29 loc) · 1.41 KB
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
38
#!/usr/bin/env python
import sys
import numpy as np
from matplotlib import pyplot as plt
import pickle
fp = open(sys.argv[1], 'rb')
cal_raw = pickle.load(fp)
#for att_idx in xrange(len(raw['atten_vals'])):
# plt.plot(raw['raw'][:, att_idx], label=f+' '+str(raw['atten_vals'][att_idx]))
fp.close()
for f in sys.argv[2:]:
fp = open(f, 'rb')
raw_test = pickle.load(fp)
for att_idx in range(len(raw_test['atten_vals'])):
vals = []
#plt.plot(raw['raw'][:, att_idx], label=f+' '+str(raw['atten_vals'][att_idx]))
for x in range(raw_test['raw'][:, att_idx].shape[0]):
for cal_att_idx in range(len(cal_raw['atten_vals'])-1):
if raw_test['raw'][:, att_idx][x] < cal_raw['raw'][:, cal_att_idx][x] and (
raw_test['raw'][:, att_idx][x] > cal_raw['raw'][:, cal_att_idx+1][x]):
dv = (raw_test['raw'][:, att_idx][x] - cal_raw['raw'][:, cal_att_idx+1][x])
da = (cal_raw['atten_vals'][cal_att_idx+1] - cal_raw['atten_vals'][cal_att_idx])
dr = (cal_raw['raw'][:, cal_att_idx][x] - cal_raw['raw'][:, cal_att_idx+1][x])
vals.append(cal_raw['atten_vals'][cal_att_idx+1] - dv * da / dr)
#print cal_raw['raw'][:, cal_att_idx][x],cal_raw['atten_vals'][cal_att_idx],raw_test['raw'][:, att_idx][x], cal_raw['raw'][:, cal_att_idx+1][x],cal_raw['atten_vals'][cal_att_idx+1], vals[-1], dv, da, dr
plt.plot(vals, label = f+ ' ' + format(np.mean(vals), '.2f'))
fp.close()
plt.legend()
plt.show()