-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenerate_eventfiles.py
More file actions
35 lines (26 loc) · 892 Bytes
/
generate_eventfiles.py
File metadata and controls
35 lines (26 loc) · 892 Bytes
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
""" Generates some fake event files for testing. """
import datetime
import numpy as np
import eventfile
import fakedata
def main():
eventcount = 10000
thresholds = [0.0099, 0.0095, 0.0090]
for i, threshold in enumerate(thresholds):
runnumber = 10000+i
recorded = datetime.datetime.now().isoformat()+'Z'
header = {
'runnumber': runnumber,
'eventcount': eventcount,
'threshold': threshold,
'recorded': recorded
}
with open('run%d.run' % runnumber, 'wb') as f:
eventfile.write_header(f, header)
for evtno in range(eventcount):
eventdata = fakedata.create_binary_map(threshold)
bits = np.packbits(eventdata)
thebytes = bits.tobytes()
f.write(thebytes)
if __name__ == '__main__':
main()