-
-
Notifications
You must be signed in to change notification settings - Fork 339
/
Copy pathtest_vi.py
166 lines (149 loc) · 4.57 KB
/
test_vi.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
"""
Name: i.vi test
Purpose: Tests i.vi and its flags/options.
Author: Sunveer Singh, Google Code-in 2017
Copyright: (C) 2017 by Sunveer Singh and the GRASS Development Team
Licence: This program is free software under the GNU General Public
License (>=v2). Read the file COPYING that comes with GRASS
for details.
"""
from grass.gunittest.case import TestCase
class TestReport(TestCase):
blue = "lsat5_1987_10@landsat"
green = "lsat5_1987_20@landsat"
red = "lsat5_1987_30@landsat"
nir = "lsat5_1987_40@landsat"
@classmethod
def setUpClass(cls):
"""Use temporary region settings"""
cls.runModule("g.region", raster="lsat5_1987_30@landsat")
cls.use_temp_region()
@classmethod
def tearDownClass(cls):
cls.runModule(
"g.remove",
flags="f",
type="raster",
name="ipvi,ndwi,dvi,sr,evi,evi2,gari,gemi",
)
cls.del_temp_region()
def test_vinameipvi(self):
"""Testing viname ipvi"""
map_output = "ipvi"
self.assertModule(
"i.vi", red=self.red, nir=self.nir, output=map_output, viname="ipvi"
)
self.assertRasterMinMax(
map=map_output,
refmin=0.0454545454545,
refmax=0.9066667,
msg="ipvi in degrees must be between 0.0454545 and 0.9066667",
)
def test_vinamendwi(self):
"""Testing viname ndwi"""
map_output = "ndwi"
self.assertModule(
"i.vi",
red=self.red,
green=self.green,
nir=self.nir,
viname="ndwi",
output=map_output,
)
self.assertRasterMinMax(
map=map_output,
refmin=-0.71,
refmax=0.93,
msg="ndwi in percent must be between -0.71 and 0.93",
)
def test_vinamedvi(self):
"""Testing viname dvi"""
map_output = "dvi"
self.assertModule(
"i.vi", red=self.red, nir=self.nir, viname="dvi", output=map_output
)
self.assertRasterMinMax(
map=map_output,
refmin=-0.33,
refmax=0.56,
msg="dvi in percent must be between -0.32 and 0.52",
)
def test_vinamesr(self):
"""Testing viname sr"""
map_output = "sr"
self.assertModule(
"i.vi",
red=self.red,
nir=self.nir,
blue=self.blue,
output=map_output,
viname="sr",
)
self.assertRasterMinMax(
map=map_output,
refmin=0.04,
refmax=9.73,
msg="sr in percent must be between 0.04 and 9.72",
)
def test_vinameevi(self):
"""Testing viname evi"""
map_output = "evi"
self.assertModule(
"i.vi",
red=self.red,
nir=self.nir,
blue=self.blue,
output=map_output,
viname="evi",
)
self.assertRasterMinMax(
map=map_output,
refmin=-8.12414050428e16,
refmax=4.45061610234e17,
msg="evi in degrees must be between -8.12 and 4.45061610234e+17",
)
def test_vinameevi2(self):
"""Testing viname evi2"""
map_output = "evi2"
self.assertModule(
"i.vi", red=self.red, nir=self.nir, output=map_output, viname="evi2"
)
self.assertRasterMinMax(
map=map_output,
refmin=-0.33,
refmax=0.74,
msg="evi2 in degrees must be between -0.33 and 0.74",
)
def test_vinamegari(self):
"""Testing viname gari"""
map_output = "gari"
self.assertModule(
"i.vi",
red=self.red,
nir=self.nir,
blue=self.blue,
green=self.green,
output=map_output,
viname="gari",
)
self.assertRasterMinMax(
map=map_output,
refmin=-1.58244128083e17,
refmax=float("inf"),
msg="gari in degrees must be between -1.58",
)
def test_vinamegemi(self):
"""Testing viname gemi"""
map_output = "gemi"
self.assertModule(
"i.vi", red=self.red, nir=self.nir, output=map_output, viname="gemi"
)
self.assertRasterMinMax(
map=map_output,
refmin=-221.69,
refmax=0.97,
msg="gemi in degrees must be between -221.69 and 0.97",
)
if __name__ == "__main__":
from grass.gunittest.main import test
test()