-
Notifications
You must be signed in to change notification settings - Fork 0
/
dump_runlist.py
executable file
·69 lines (48 loc) · 2.05 KB
/
dump_runlist.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
#!/usr/bin/env python3
# NOTE: run_data.py: ``e_field`` run list file units are V/cm.
# Run log spreadsheet: kV/cm
# And just for extra confusion, RunData.yaml uses kV/mm
from collections import defaultdict
from functools import lru_cache
from pathlib import Path
import sys
from RunLog import RunLog, RunInfo
HEADER = 'e_field charge_filename light_filename charge_thresholds light_samples'
DEFAULT_LIGHT_SAMPLES = 1024
BASEDIR = Path('/global/cfs/cdirs/dune/www/data/Module3/run3')
@lru_cache
def read_lightdict() -> dict[str, Path]:
result = defaultdict(lambda: '-')
lightbase = BASEDIR.joinpath('LRS')
for path in lightbase.rglob('*.data'):
result[path.name] = path
return result
def format_line(info: RunInfo) -> str:
# e_field = '%.3f' % (info.drift_field * 1000) if info.drift_field else '-'
e_field = '%.3f' % (info.drift_field * 1000)
charge_filename = info.charge_fname
# light_filename = ','.join(info.light_fnames) if info.light_fnames else '-'
charge_thresholds = 'medm'
light_samples = str(DEFAULT_LIGHT_SAMPLES)
# packet_path = BASEDIR.joinpath('packet', 'ramp_up',
# info.charge_fname.replace('-binary-', '-packet-'))
packet_path = BASEDIR.joinpath('packet', 'tpc12',
info.charge_fname.replace('-binary-', '-packet-'))
if not packet_path.exists():
print('WTF', packet_path, file=sys.stderr)
return ''
light_paths = ','.join(str(read_lightdict()[fname]) for fname in info.light_fnames)
return f'{e_field} {packet_path} {light_paths} {charge_thresholds} {light_samples}\n'
def is_good(info: RunInfo) -> bool:
return True
return info.drift_field and len(info.light_fnames) >= 1 \
and all(fname.endswith('.data') for fname in info.light_fnames) \
and info.charge_fname.endswith('.h5')
def main():
runlog = RunLog()
print(HEADER)
for info in RunLog().dict().values():
if is_good(info):
print(format_line(info), end='')
if __name__ == '__main__':
main()