Debian Codegraph @

raster/r.series.accumulate/test_suite/test.r.series.accumulate.sh

raw
1 #!/bin/sh -e
2 # Test r.series.accumulate
3 # We need to set a specific region in the
4 # @preprocess step of this test. We generate
5 # raster maps with r.mapcalc
6 # The region setting should work for UTM and LL test locations
7 g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3
8
9 export GRASS_OVERWRITE=1
10
11 r.mapcalc expr="basemap = if(row() == 3, null(), 10)"
12 r.mapcalc expr="lower = 5"
13 r.mapcalc expr="upper = 10"
14
15 r.mapcalc expr="map_a = rand(0, 15)" -s
16 r.mapcalc expr="map_b = rand(1, 14)" -s
17 r.mapcalc expr="map_c = rand(2, 13)" -s
18
19 # BEDD with lower limit map and upper limit value
20 r.series.accumulate basemap=basemap input=map_a lower=lower limits=5,10 \
21 output=test_accu_0 method=bedd -f --verbose
22 # GDD with lower limit map
23 r.series.accumulate basemap=basemap input=map_a lower=lower \
24 output=test_accu_1 method=gdd -f --verbose
25 # Winkler with lower limit map
26 r.series.accumulate basemap=basemap input=map_a lower=lower \
27 output=test_accu_2 method=gdd -f --verbose
28 # Mean
29 r.series.accumulate basemap=basemap input=map_a \
30 output=test_accu_3 method=mean --verbose
31 # Average
32 r.series.accumulate basemap=basemap input=map_a \
33 output=test_accu_3 method=mean --verbose
34 # GDD with lower limit value
35 r.series.accumulate basemap=basemap input=map_a,map_b,map_c limits=5,10 \
36 output=test_accu_4 method=gdd -f --verbose
37 # Winkler with multiple maps, lower limit value
38 r.series.accumulate basemap=basemap input=map_a,map_b,map_c limits=5,10 \
39 output=test_accu_5 method=bedd -f --verbose
40 # BEDD with multiple maps, lower limit map and upper limit value
41 r.series.accumulate basemap=basemap input=map_a,map_b,map_c lower=lower limits=5,10 \
42 output=test_accu_6 method=bedd -f --verbose
43 # BEDD with multiple maps, lower limit map and upper limit map
44 r.series.accumulate basemap=basemap input=map_a,map_b,map_c lower=lower upper=upper \
45 output=test_accu_7 method=bedd -f --verbose
46 # Mean with range multiple maps
47 r.series.accumulate basemap=basemap input=map_a,map_b,map_c \
48 output=test_accu_8 range=6,9 method=mean --verbose
49 # Mean with range
50 r.series.accumulate basemap=basemap input=map_a, \
51 output=test_accu_9 range=6,9 method=mean --verbose
52
53 # Test for correct results
54 for map in `g.list type=raster pattern=test_accu_*` ; do
55 r.out.ascii input=${map} output=${map}.ref precision=2
56 done
57
58 for i in `ls test_accu_*.ref` ; do
59 diff $i "`basename $i`" >> out.diff
60 done
61 rm -f test_accu_*.ref
62
63 CHAR_NUM=`cat out.diff | wc -c`
64
65 # Return as exit status 0 in case no diffs are found
66 exit $CHAR_NUM