-
Notifications
You must be signed in to change notification settings - Fork 2
/
select_best_functions.py
278 lines (219 loc) · 9.37 KB
/
select_best_functions.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
from pathlib import Path
import numpy as np
import pandas as pd
import Helper
def select_best_intensives(df, **kwargs):
"""
logic to select best schedule for intensive sessions
:param df: DataFrame of statistics.csv file
:return: version number of best schedule
"""
if df.shape[0] == 1:
return df.index[0]
nobs = df["n_observations"]
sky_cov = df["sky-coverage_average_37_areas_60_min"]
dut1_mfe = df["sim_mean_formal_error_dUT1_[mus]"]
dut1_rep = df["sim_repeatability_dUT1_[mus]"]
# data = pd.concat([nobs, sky_cov, dut1_mfe, dut1_rep], axis=1)
s_nobs = Helper.scale(nobs, minIsGood=False)
s_sky_cov = Helper.scale(sky_cov, minIsGood=False)
s_dut1_mfe = Helper.scale(dut1_mfe)
s_dut1_rep = Helper.scale(dut1_rep)
# scores = pd.concat([s_nobs, s_sky_cov, s_dut1_mfe, s_dut1_rep], axis=1)
score = 1 * s_nobs + .25 * s_sky_cov + .8 * s_dut1_mfe + .8 * s_dut1_rep
best = score.idxmax()
return best
def select_best_ohg(df, **kwargs):
"""
logic to select best schedule for OHG sessions
:param df: DataFrame of statistics.csv file
:return: version number of best schedule
"""
if df.shape[0] == 1:
return df.index[0]
nobs = df["n_observations"]
sky_cov = df["sky-coverage_average_25_areas_60_min"]
avg_rep = df["sim_repeatability_average_3d_station_coord._[mm]"]
avg_mfe = df["sim_mean_formal_error_average_3d_station_coord._[mm]"]
# data = pd.concat([nobs, sky_cov, avg_rep, ohg_rep, avg_mfe, ohg_mfe], axis=1)
s_nobs = Helper.scale(nobs, minIsGood=False)
s_sky_cov = Helper.scale(sky_cov, minIsGood=False)
s_rep_avg_sta = Helper.scale(avg_rep)
s_mfe_avg_sta = Helper.scale(avg_mfe)
# scores = pd.concat([s_nobs, s_sky_cov, s_rep_avg_sta, s_rep_ohg, s_mfe_avg_sta, s_mfe_ohg], axis=1)
if "sim_repeatability_OHIGGINS" in df:
ohg_rep = df["sim_repeatability_OHIGGINS"]
ohg_mfe = df["sim_mean_formal_error_OHIGGINS"]
s_rep_ohg = Helper.scale(ohg_rep)
s_mfe_ohg = Helper.scale(ohg_mfe)
score = 1 * s_nobs + .25 * s_sky_cov + 1.5 * s_rep_ohg + 1 * s_mfe_ohg + .75 * s_rep_avg_sta + .5 * s_mfe_avg_sta
else:
score = 1 * s_nobs + .25 * s_sky_cov + .75 * s_rep_avg_sta + .5 * s_mfe_avg_sta
best = score.idxmax()
return best
def select_best_24h(df, **kwargs):
"""
logic to select best schedule for OHG sessions
:param df: DataFrame of statistics.csv file
:return: version number of best schedule
"""
if df.shape[0] == 1:
return df.index[0]
mfe = 0.3
rep = 0.7
nobs = df["n_observations"]
# sky_cov = df["sky-coverage_average_25_areas_60_min"]
avg_rep = df["sim_repeatability_average_3d_station_coord._[mm]"]
avg_mfe = df["sim_mean_formal_error_average_3d_station_coord._[mm]"]
dut1_rep = df["sim_repeatability_dUT1_[mus]"]
dut1_mfe = df["sim_mean_formal_error_dUT1_[mus]"]
xpo_rep = df["sim_repeatability_x_pol_[muas]"]
xpo_mfe = df["sim_mean_formal_error_x_pol_[muas]"]
ypo_rep = df["sim_repeatability_y_pol_[muas]"]
ypo_mfe = df["sim_mean_formal_error_y_pol_[muas]"]
nutx_rep = df["sim_repeatability_x_nut_[muas]"]
nutx_mfe = df["sim_mean_formal_error_x_nut_[muas]"]
nuty_rep = df["sim_repeatability_y_pol_[muas]"]
nuty_mfe = df["sim_mean_formal_error_y_pol_[muas]"]
# data = pd.concat([nobs, sky_cov, avg_rep, ohg_rep, avg_mfe, ohg_mfe], axis=1)
s_nobs = Helper.scale(nobs, minIsGood=False)
# s_sky_cov = Helper.scale(sky_cov, minIsGood=False)
s_rep_avg_sta = Helper.scale(avg_rep)
s_mfe_avg_sta = Helper.scale(avg_mfe)
s_dut1_rep = Helper.scale(dut1_rep)
s_dut1_mfe = Helper.scale(dut1_mfe)
s_xpo_rep = Helper.scale(xpo_rep)
s_xpo_mfe = Helper.scale(xpo_mfe)
s_ypo_rep = Helper.scale(ypo_rep)
s_ypo_mfe = Helper.scale(ypo_mfe)
s_nutx_rep = Helper.scale(nutx_rep)
s_nutx_mfe = Helper.scale(nutx_mfe)
s_nuty_rep = Helper.scale(nuty_rep)
s_nuty_mfe = Helper.scale(nuty_mfe)
# scores = pd.concat([s_nobs, s_sky_cov, s_rep_avg_sta, s_rep_ohg, s_mfe_avg_sta, s_mfe_ohg], axis=1)
score = 1 * s_nobs + \
rep * 1 * s_rep_avg_sta + \
mfe * 1 * s_mfe_avg_sta + \
rep * 0.2 * s_dut1_rep + \
mfe * 0.2 * s_dut1_mfe + \
rep * 0.2 * s_xpo_rep + \
mfe * 0.2 * s_xpo_mfe + \
rep * 0.2 * s_ypo_rep + \
mfe * 0.2 * s_ypo_mfe + \
rep * 0.2 * s_nutx_rep + \
mfe * 0.2 * s_nutx_mfe + \
rep * 0.2 * s_nuty_rep + \
mfe * 0.2 * s_nuty_mfe
best = score.idxmax()
return best
def select_best_24h_focus_EOP(df, **kwargs):
"""
logic to select best schedule for OHG sessions
:param df: DataFrame of statistics.csv file
:return: version number of best schedule
"""
if df.shape[0] == 1:
return df.index[0]
mfe = 0.3
rep = 0.7
nobs = df["n_observations"]
# sky_cov = df["sky-coverage_average_25_areas_60_min"]
avg_rep = df["sim_repeatability_average_3d_station_coord._[mm]"]
avg_mfe = df["sim_mean_formal_error_average_3d_station_coord._[mm]"]
dut1_rep = df["sim_repeatability_dUT1_[mus]"]
dut1_mfe = df["sim_mean_formal_error_dUT1_[mus]"]
xpo_rep = df["sim_repeatability_x_pol_[muas]"]
xpo_mfe = df["sim_mean_formal_error_x_pol_[muas]"]
ypo_rep = df["sim_repeatability_y_pol_[muas]"]
ypo_mfe = df["sim_mean_formal_error_y_pol_[muas]"]
nutx_rep = df["sim_repeatability_x_nut_[muas]"]
nutx_mfe = df["sim_mean_formal_error_x_nut_[muas]"]
nuty_rep = df["sim_repeatability_y_pol_[muas]"]
nuty_mfe = df["sim_mean_formal_error_y_pol_[muas]"]
# data = pd.concat([nobs, sky_cov, avg_rep, ohg_rep, avg_mfe, ohg_mfe], axis=1)
s_nobs = Helper.scale(nobs, minIsGood=False)
# s_sky_cov = Helper.scale(sky_cov, minIsGood=False)
s_rep_avg_sta = Helper.scale(avg_rep)
s_mfe_avg_sta = Helper.scale(avg_mfe)
s_dut1_rep = Helper.scale(dut1_rep)
s_dut1_mfe = Helper.scale(dut1_mfe)
s_xpo_rep = Helper.scale(xpo_rep)
s_xpo_mfe = Helper.scale(xpo_mfe)
s_ypo_rep = Helper.scale(ypo_rep)
s_ypo_mfe = Helper.scale(ypo_mfe)
s_nutx_rep = Helper.scale(nutx_rep)
s_nutx_mfe = Helper.scale(nutx_mfe)
s_nuty_rep = Helper.scale(nuty_rep)
s_nuty_mfe = Helper.scale(nuty_mfe)
# scores = pd.concat([s_nobs, s_sky_cov, s_rep_avg_sta, s_rep_ohg, s_mfe_avg_sta, s_mfe_ohg], axis=1)
score = 0.75 * s_nobs + \
rep * 0.5 * s_rep_avg_sta + \
mfe * 0.5 * s_mfe_avg_sta + \
rep * 0.3 * s_dut1_rep + \
mfe * 0.3 * s_dut1_mfe + \
rep * 0.1 * s_xpo_rep + \
mfe * 0.1 * s_xpo_mfe + \
rep * 0.1 * s_ypo_rep + \
mfe * 0.1 * s_ypo_mfe + \
rep * 0.3 * s_nutx_rep + \
mfe * 0.3 * s_nutx_mfe + \
rep * 0.3 * s_nuty_rep + \
mfe * 0.3 * s_nuty_mfe
best = score.idxmax()
return best
def select_best_CRF(df, **kwargs):
if df.shape[0] == 1:
return df.index[0]
template_path = kwargs["template_path"]
target = Helper.read_sources(template_path / "source.cat.target")[0]
calib = Helper.read_sources(template_path / "source.cat.calib")[0]
df_src = df.filter(like='n_src_scans_', axis=1)
targets = [c for c in df.columns if c[12:] in target]
df_target = df_src.loc[:, df_src.columns.isin(targets)]
df_target = df_target > 4
calibs = [c for c in df.columns if c[12:] in calib]
df_calib = df_src.loc[:, df_src.columns.isin(calibs)]
df_calib = df_calib > 4
target_source_good = df_target.sum(axis=1)
calib_source_good = df_calib.sum(axis=1)
source_good = target_source_good + calib_source_good
fraction = abs(target_source_good / calib_source_good)
fraction = fraction.replace([np.inf, -np.inf], np.nan)
fraction = fraction.replace(np.nan, fraction.max())
nobs = df["n_observations"]
obs_time = df["time_average_observation"]
idle_time = df["time_average_idle"]
s_source_good = Helper.scale(source_good, minIsGood=False)
s_nobs = Helper.scale(nobs, minIsGood=False)
s_obs_time = Helper.scale(obs_time, minIsGood=False)
s_idle_time = Helper.scale(idle_time)
# scale fraction between target and calibrator scans. Target fraction is 4
s_fraction = pd.Series(data=0, index=fraction.index)
s_fraction[abs(fraction - 4) < 1.5] = 1
s_fraction[abs(fraction - 4) < .75] = 2
score = 0.5 * s_nobs + \
2 * s_source_good + \
s_fraction + \
0.2 * s_obs_time + \
0.2 * s_idle_time
best = score.idxmax()
return best
def select_best_local_tie(df, **kwargs):
"""
logic to select best schedule for local tie measurements
:param df: DataFrame of statistics.csv file
:return: version number of best schedule
"""
if df.shape[0] == 1:
return df.index[0]
nobs = df["n_observations"]
sky_cov1 = df["sky-coverage_average_25_areas_30_min"]
sky_cov2 = df["sky-coverage_average_37_areas_30_min"]
sky_cov3 = df["sky-coverage_average_37_areas_60_min"]
s_nobs = Helper.scale(nobs, minIsGood=False)
s_sky_cov1 = Helper.scale(sky_cov1, minIsGood=False)
s_sky_cov2 = Helper.scale(sky_cov2, minIsGood=False)
s_sky_cov3 = Helper.scale(sky_cov3, minIsGood=False)
score = 1 * s_nobs + .25 * s_sky_cov1 + .25 * s_sky_cov2 + .25 * s_sky_cov3
best = score.idxmax()
return best