-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_test_data.py
More file actions
executable file
·46 lines (36 loc) · 1015 Bytes
/
make_test_data.py
File metadata and controls
executable file
·46 lines (36 loc) · 1015 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
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
"""
Create a .csv file to feed to the gmdSimIoc caproto IOC. Reads 100
un-damaged events from the specified detector and puts the data into the
specified file.
Arguments
---------
experiment : str
The experiment to pull (X)GMD data from, e.g. tmox43218
run : int
Run number to pull data from.
detector : str
The detector name to pull (X)GMD data from, e.g. xgmdstr0 (XGMD electron
stream 1).
file_name : str
The filename to write the .csv data to.
"""
from psana import DataSource
import sys
import csv
args = sys.argv
ds = DataSource(exp=args[1], run=int(args[2]))
run = next(ds.runs())
det = run.Detector(args[3])
raw_streams = []
ngood = 0
for evt in run.events():
stream = det.raw.value(evt)
if stream is not None:
raw_streams.append(stream)
ngood += 1
if ngood >= 100: break
with open(args[4], 'w', newline='') as csvfile:
writer = csv.writer(csvfile, delimiter=',')
for raw in raw_streams:
writer.writerow(raw)