-
Notifications
You must be signed in to change notification settings - Fork 1
/
data_extraction.py
95 lines (62 loc) · 1.86 KB
/
data_extraction.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Extraction and plotting of the data taken from the REM 500 Neutron Survey Meter
# Authors: Leo Borrel, Sophie Middleton
# Date: 2022-05-20
import matplotlib.pyplot as plt
import csv
time = []
counts = []
#file_pre = "data/1002_60kV_1_10min/"
#file_pre = "data/1108_80kV_2_10min/"
file_pre = "data/2022-11-03/1028_80kV_1.71gas_0-10min/"
with open(file_pre + "count_data.txt") as data_file:
for line in data_file:
if len(line) == 16:
value = int(line[0:6],16)
date = line[7:15]
time.append(int(date[6:8]) + 60*int(date[3:5]) + 3600*int(date[0:2]))
counts.append(value)
# Export data to csv
csv_file = open(file_pre + "count_data.csv", 'w')
header = ['time', 'counts']
rows = zip(time, counts)
with open(file_pre + "count_data.csv", 'w') as csv_file:
writer = csv.writer(csv_file)
writer.writerow(header)
for row in rows:
writer.writerow(row)
# plots
plt.figure()
plt.plot(time, counts)
plt.xlabel('time [s]')
plt.ylabel('Counts')
# Plot of the data from each channel
channel = []
with open(file_pre + "channel_data.txt") as channel_file:
for line in channel_file:
channel.append(int(line[0:5]))
QF = []
with open('data/QF.txt') as QF_file:
for line in QF_file:
QF.append(float(line[0:-1]))
rad = 0
for i in range(5,255):
rad += 100 * i * channel[i] / 20
rem = 0
for i in range(5,255):
rem += 100 * i * channel[i] * QF[i] / 20
# divide by runtime (in seconds) because the formula works for 1 sec integration
rad = rad / time[-1]
rem = rem / time[-1]
print('rad: ', rad, ' urad/h')
print('rem: ', rem, ' urem/h')
# multiply by runtime (in hour)
rad = rad * (time[-1] / 3600)
rem = rem * (time[-1] / 3600)
print('rad: ', rad, ' urad')
print('rem: ', rem, ' urem')
# plot
plt.figure()
plt.bar(range(256),channel)
plt.xlabel('channel #')
plt.ylabel('count')
plt.show()