| 1 | #!/bin/sh
|
|---|
| 2 | # Tests the temporal topology module of space time datasets
|
|---|
| 3 |
|
|---|
| 4 | # We need to set a specific region in the
|
|---|
| 5 | # @preprocess step of this test.
|
|---|
| 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 | # Generate data
|
|---|
| 10 | r.mapcalc --o expr="prec_1 = rand(0, 550)" -s
|
|---|
| 11 | r.mapcalc --o expr="prec_2 = rand(0, 450)" -s
|
|---|
| 12 | r.mapcalc --o expr="prec_3 = rand(0, 320)" -s
|
|---|
| 13 | r.mapcalc --o expr="prec_4 = rand(0, 510)" -s
|
|---|
| 14 | r.mapcalc --o expr="prec_5 = rand(0, 300)" -s
|
|---|
| 15 | r.mapcalc --o expr="prec_6 = rand(0, 650)" -s
|
|---|
| 16 |
|
|---|
| 17 | n1=`g.tempfile pid=1 -d`
|
|---|
| 18 | n2=`g.tempfile pid=2 -d`
|
|---|
| 19 | n3=`g.tempfile pid=3 -d`
|
|---|
| 20 | n4=`g.tempfile pid=4 -d`
|
|---|
| 21 | n5=`g.tempfile pid=5 -d`
|
|---|
| 22 |
|
|---|
| 23 | cat > "${n1}" << EOF
|
|---|
| 24 | prec_1
|
|---|
| 25 | prec_2
|
|---|
| 26 | prec_3
|
|---|
| 27 | prec_4
|
|---|
| 28 | prec_5
|
|---|
| 29 | prec_6
|
|---|
| 30 | EOF
|
|---|
| 31 |
|
|---|
| 32 | cat > "${n2}" << EOF
|
|---|
| 33 | prec_1|1
|
|---|
| 34 | prec_2|2
|
|---|
| 35 | prec_3|3
|
|---|
| 36 | prec_4|4
|
|---|
| 37 | prec_5|5
|
|---|
| 38 | prec_6|6
|
|---|
| 39 | EOF
|
|---|
| 40 |
|
|---|
| 41 | cat > "${n3}" << EOF
|
|---|
| 42 | prec_1|1|4
|
|---|
| 43 | prec_2|5|7
|
|---|
| 44 | prec_3|8|10
|
|---|
| 45 | prec_4|11|12
|
|---|
| 46 | prec_5|13|14
|
|---|
| 47 | prec_6|15|25
|
|---|
| 48 | EOF
|
|---|
| 49 |
|
|---|
| 50 | cat > "${n4}" << EOF
|
|---|
| 51 | prec_1|2001|2007
|
|---|
| 52 | prec_2|2002|2004
|
|---|
| 53 | prec_3|2003|2004
|
|---|
| 54 | prec_4|2004|2006
|
|---|
| 55 | prec_5|2005|2006
|
|---|
| 56 | prec_6|2006|2007
|
|---|
| 57 | EOF
|
|---|
| 58 |
|
|---|
| 59 | cat > "${n5}" << EOF
|
|---|
| 60 | prec_1|2001|2003
|
|---|
| 61 | prec_2|2002|2004
|
|---|
| 62 | prec_3|2003|2006
|
|---|
| 63 | prec_4|2004|2004
|
|---|
| 64 | prec_5|2005|2005
|
|---|
| 65 | prec_6|2006|2007
|
|---|
| 66 | EOF
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 | # The first @test
|
|---|
| 70 | # We create the space time raster inputs and register the raster maps with relolute time interval
|
|---|
| 71 | t.create --o type=strds temporaltype=relative output=precip_rel_d title="A test with input files of unti days" descr="A test with input files"
|
|---|
| 72 | t.create --o type=strds temporaltype=relative output=precip_rel_y title="A test with input files of unit years" descr="A test with input files"
|
|---|
| 73 |
|
|---|
| 74 | t.register --o type=raster -i --v input=precip_rel_d file="${n1}" start=0 increment=1 unit=days
|
|---|
| 75 | cat "${n1}"
|
|---|
| 76 | t.topology input=precip_rel_d
|
|---|
| 77 | t.topology -m input=precip_rel_d
|
|---|
| 78 |
|
|---|
| 79 | t.register --o type=raster -i input=precip_rel_d file="${n2}" unit=days
|
|---|
| 80 | cat "${n2}"
|
|---|
| 81 | t.topology input=precip_rel_d
|
|---|
| 82 | t.topology -m input=precip_rel_d
|
|---|
| 83 |
|
|---|
| 84 | t.register --o type=raster -i input=precip_rel_d file="${n3}" unit=days
|
|---|
| 85 | cat "${n3}"
|
|---|
| 86 | t.topology input=precip_rel_d
|
|---|
| 87 | t.topology -m input=precip_rel_d
|
|---|
| 88 |
|
|---|
| 89 | t.register --o type=raster -i input=precip_rel_y file="${n4}" unit=years
|
|---|
| 90 | cat "${n4}"
|
|---|
| 91 | t.topology input=precip_rel_y
|
|---|
| 92 | t.topology -m input=precip_rel_y
|
|---|
| 93 |
|
|---|
| 94 | t.register --o type=raster -i input=precip_rel_y file="${n5}" unit=years
|
|---|
| 95 | cat "${n5}"
|
|---|
| 96 | t.topology input=precip_rel_y
|
|---|
| 97 | t.topology -m input=precip_rel_y
|
|---|
| 98 |
|
|---|
| 99 | t.remove type=strds input=precip_rel_d
|
|---|
| 100 | t.remove type=strds input=precip_rel_y
|
|---|
| 101 | t.unregister type=raster file="${n1}"
|
|---|