-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreporter.py
executable file
·52 lines (48 loc) · 1.65 KB
/
reporter.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
# -*- coding: utf-8 -*-
#
# # Dobroslav P. Egorov
# # Kotel'nikov Institute of Radio-engineering and Electronics of RAS
# # 2019
#
from session import *
class Reports:
@staticmethod
def makeTable(session: Session,
f_path: str, append: bool = False,
apply_to_timestamp=lambda t: t) -> None:
print('Making report...')
session.box()
timestamps = session.get_timestamps_averaged()
mode = 'w'
if append:
mode = 'a'
with open(f_path, mode) as file:
s = "time "
for key in session.keys:
s += str(key) + " "
file.write(s + '\n')
for t in timestamps:
s = str(apply_to_timestamp(t)) + " "
for series in session.series:
s += '{:.3f}'.format(series.get(t).val) + " "
file.write(s + '\n')
@staticmethod
def makeTableTransposed(session: Session,
f_path: str, append: bool = False,
apply_to_timestamp=lambda t: t) -> None:
print('Making report...')
session = session.transpose()
mode = 'w'
if append:
mode = 'a'
with open(f_path, mode) as file:
s = "freqs "
for t in session.keys:
s += str(apply_to_timestamp(t)) + " "
file.write(s + '\n')
freqs = session.get_timestamps(session.series[0].key)
for f in freqs:
s = str(f) + " "
for series in session.series:
s += '{:.3f}'.format(series.get(f).val) + " "
file.write(s + '\n')