This repository has been archived by the owner on Sep 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
testrbf.py
63 lines (52 loc) · 2.58 KB
/
testrbf.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
"""
Name: r.basins.fill
Purpose: Tests r.basins.fill and its flags/options.
Author: Sunveer Singh
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 TestRasterbasin(TestCase):
celevation='elevation'
tgeology='geology'
output='basinsoutput'
input="lakes"
@classmethod
def setUpClass(cls):
seed = 500
cls.use_temp_region()
cls.runModule('g.region', raster=cls.tgeology, flags='p')
cls.runModule('r.watershed', elevation='elevation', stream=cls.celevation, threshold='50000', overwrite=True)
cls.runModule('r.geomorphon', elevation=cls.celevation, forms=cls.tgeology, overwrite=True)
cls.runModule('r.mapcalc', seed=seed, expression='rand_cell = rand(1, 200)', overwrite=True)
cls.runModule('r.thin', input=cls.input, output=cls.output)
@classmethod
def tearDownClass(cls):
cls.del_temp_region()
def tearDown(cls):
cls.runModule('g.remove', flags='f', type='raster', name=cls.output)
def test_no1(self):
lakes='lakes'
self.assertModule('r.basins.fill', cnetwork=self.celevation, tnetwork=self.tgeology, output=self.output, number='1', overwrite=True)
self.assertRasterMinMax(map=lakes, refmin=34300, refmax=43600,
msg="lakes in degrees must be between 34300 and 43600")
def test_no2(self):
soils='soils'
self.assertModule('r.basins.fill', cnetwork=self.celevation, tnetwork=self.tgeology, output=self.output, number='3')
self.assertRasterMinMax(map=soils, refmin=18683, refmax=46555,
msg="soils in degrees must be between 18683 and 46555")
def test_no3(self):
landuse='landuse'
self.assertModule('r.basins.fill', cnetwork=self.celevation, tnetwork=self.tgeology, output=self.output, number='4')
self.assertRasterMinMax(map=landuse, refmin=1, refmax=7,
msg="landuse in degrees must be between 1 and 7")
def test_no4(self):
rand_cell='rand_cell'
self.assertModule('r.basins.fill', cnetwork=self.celevation, tnetwork=self.tgeology, output=self.output, number='5')
self.assertRasterMinMax(map=rand_cell, refmin=1, refmax=199,
msg="rand_cell in degrees must be between 1 and 199")
if __name__ == '__main__':
from grass.gunittest.main import test
test()