-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils_analysis_per_orbit.py
46 lines (30 loc) · 1.37 KB
/
utils_analysis_per_orbit.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
import pandas as pd
import numpy as np
import csv
from os.path import splitext, join
import os
import argparse
parser = argparse.ArgumentParser(description='')
parser.add_argument('subfolder', type=str, help='Subfolder')
args = parser.parse_args()
csv_path = 'output_csv'
path = join(csv_path, args.subfolder)
for filename in os.listdir(path):
if (splitext(filename)[1] != '.csv' or filename.startswith('analysis_')):
continue
df = pd.read_csv(join(path, filename), skiprows=[1]) #, header=0, names=['Date'] + cols + ['Total', 'Total IOU', 'Orbit', 'Direction'])
cols = []
for key in df:
if (key.isnumeric()):
cols.append(key)
orbits = np.unique(df['Orbit'])
with open(join(path, 'analysis_' + filename), 'w') as f:
w = csv.writer(f, lineterminator="\n")
w.writerow(['Direction', 'Orbit'] + cols + ['Total'])
for orbit in orbits:
sel_df = df[df['Orbit'] == orbit]
row = [sel_df.iloc[0]['Direction'], orbit]
for col in cols:
row.append(str(int(round(np.mean(sel_df[col]) * 100))) + ' -+ ' + str(int(round(np.std(sel_df[col]) * 100))))
row.append(str(int(round(np.mean(sel_df['Total']) * 100))) + ' -+ ' + str(int(round(np.std(sel_df['Total']) * 100))))
w.writerow(row)