-
Notifications
You must be signed in to change notification settings - Fork 2
/
new_summary.py
60 lines (47 loc) · 1.45 KB
/
new_summary.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
import argparse
import shutil
from pathlib import Path
import pandas as pd
def start(path_main):
shutil.copy(path_main / "summary.txt", path_main / "summary.txt.old_format_5")
ls = []
names = []
for p in path_main.iterdir():
p = p / "selected"
if not p.is_dir():
continue
if not (p / "email.txt").is_file():
continue
if not (p / "merged_statistics.csv").is_file():
continue
with open(p / "email.txt") as f:
for l in f:
if l.startswith("best version: "):
tmp = l.split(" ")[-1]
v = int(tmp[1:])
break
df = pd.read_csv(p / "merged_statistics.csv")
l = df.loc[df["version"] == v, :].copy()
# number of observations per baseline
tlcs = set()
filter_col = [col for col in l if col.startswith('n_bl_obs_')]
for col in filter_col:
name = col.split("_")[-1]
tlc1 = name[0:2]
tlc2 = name[3:5]
tlcs.add(tlc1)
tlcs.add(tlc2)
tlcs = "".join(tlcs)
l["stations"] = tlcs
ls.append(l)
names.append(p.parent.stem)
d = pd.concat(ls)
d.index = names
d.to_csv(path_main / "summary.txt")
pass
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-p")
args = parser.parse_args()
path = Path(args.p)
start(path)