test.t.topology.reltime.sh 2.4 KB

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