-
Notifications
You must be signed in to change notification settings - Fork 0
/
evaluation_static_tests.py
111 lines (99 loc) · 3.68 KB
/
evaluation_static_tests.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
from numpy import zeros_like
from static_tests import dawn_day_test, gross_cloud_test, thin_cirrus_test
from static_tests import (
typical_static_classifier,
epsilon_transparent_cloud_test,
thick_cloud_test,
)
from utils import visualize_map_time, typical_bbox
def corr2test(test_1, test_2):
# expect list
# test_1 = test_1.flatten()
# test_2 = test_2.flatten()
assert len(test_1) == len(test_2), "the two lists have different sizes"
score = float(sum(test_2)) / sum(test_1)
# score = (1.*sum(test_1 == test_2)) / len(test_1)
return score
def compute_common_scores(*args):
# expect list
n = len(args)
common = args[0]
for k in range(1, n):
common = args[k] | common
score = []
for l in range(n):
score.append(corr2test(common, args[l]))
return score
def compute_unique_scores(*args):
# expect list
n = len(args)
common = args[0]
for k in range(1, n):
common = args[k] | common
scores = []
for k in range(n):
unique = args[k]
for l in range(n):
if k != l:
unique = unique & ~args[l]
scores.append(corr2test(common, unique))
return scores
def visualize_regular_cloud_tests(quick_test=False):
"""
Show the clouds detected by regular test above lands (does not include the visible cloud test
and the unstable snowy test), and print the "individual score" of each test (=the ratio of clouds
which have been detected only by this test)
:param quick_test: if True, does not compute texture test
:return: two lists: the list
"""
(
zen,
lands,
cli_mu,
cli_var,
cli_epsilon,
vis,
lir,
fir,
lir_forecast,
fir_forecast,
) = typical_static_classifier(bypass=True)
# visualize_map_time(cli_mu, typical_bbox(), vmin=0, vmax=50, color='gray')
# visualize_map_time(cli_epsilon*2, typical_bbox(), vmin=0, vmax=1, color='gray')
common_condition = lands & dawn_day_test(zen)
opaque_condition = thick_cloud_test(lands, lir, cli_mu, cli_epsilon, quick_test)
epsilon_condition = epsilon_transparent_cloud_test(cli_epsilon)
gross_condition = gross_cloud_test(lir, lir_forecast)
transparent_condition = thin_cirrus_test(
lands, lir, fir, lir_forecast, fir_forecast
)
print("CONDITIONS: GROSS, EPSILON, OPAQUE")
print("COMMON SCORES FOR LAND DAWN-DAY PRIMARY CLOUD CLASSIFICATION")
common_scores = compute_common_scores(
gross_condition[common_condition],
epsilon_condition[common_condition],
# transparent_condition[common_condition],
opaque_condition[common_condition],
)
print(common_scores)
print("INDIVIDUAL SCORES FOR LAND DAWN-DAY PRIMARY CLOUD CLASSIFICATION")
unique_scores = compute_unique_scores(
gross_condition[common_condition],
epsilon_condition[common_condition],
# transparent_condition[common_condition],
opaque_condition[common_condition],
)
print(unique_scores)
to_return = zeros_like(gross_condition)
to_return[opaque_condition] = 1
to_return[gross_condition] = 2
to_return[epsilon_condition] = 3
to_return[transparent_condition] = 4
visualize_map_time(to_return, typical_bbox(), vmin=0, vmax=5)
visualize_map_time(gross_condition, typical_bbox(), vmin=0, vmax=1)
visualize_map_time(opaque_condition, typical_bbox(), vmin=0, vmax=1)
visualize_map_time(epsilon_condition, typical_bbox(), vmin=0, vmax=1)
visualize_map_time(transparent_condition, typical_bbox(), vmin=0, vmax=1)
return common_scores, unique_scores
if __name__ == "__main__":
visualize_regular_cloud_tests(quick_test=False)