test.t.shift.absolue.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/sh
  2. # Space time raster dataset temporal shifting
  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. # Generate data
  8. r.mapcalc --o expr="prec_1 = rand(0, 550)"
  9. r.mapcalc --o expr="prec_2 = rand(0, 450)"
  10. r.mapcalc --o expr="prec_3 = rand(0, 320)"
  11. r.mapcalc --o expr="prec_4 = rand(0, 510)"
  12. r.mapcalc --o expr="prec_5 = rand(0, 300)"
  13. r.mapcalc --o expr="prec_6 = rand(0, 650)"
  14. t.create --o type=strds temporaltype=absolute output=precip_abs title="A test" descr="A test"
  15. t.register -i --o type=rast input=precip_abs maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 \
  16. start="2001-01-01 12:00:00" increment="14 days"
  17. t.rast.list input=precip_abs
  18. # The first @test
  19. t.shift --o input=precip_abs granularity="3 years"
  20. t.info type=strds input=precip_abs
  21. t.rast.list input=precip_abs
  22. t.shift --o input=precip_abs granularity="12 months"
  23. t.info type=strds input=precip_abs
  24. t.rast.list input=precip_abs
  25. t.shift --o input=precip_abs granularity="2 days"
  26. t.info type=strds input=precip_abs
  27. t.rast.list input=precip_abs
  28. t.shift --o input=precip_abs granularity="3 hours"
  29. t.info type=strds input=precip_abs
  30. t.rast.list input=precip_abs
  31. t.shift --o input=precip_abs granularity="30 minutes"
  32. t.info type=strds input=precip_abs
  33. t.rast.list input=precip_abs
  34. t.shift --o input=precip_abs granularity="5 seconds"
  35. t.info type=strds input=precip_abs
  36. t.rast.list input=precip_abs
  37. # This should give an error because of the monthly increment
  38. # that will result in wrong number of days in the next month
  39. t.shift --o input=precip_abs granularity="1 month"
  40. t.unregister type=rast maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6
  41. t.remove type=strds input=precip_abs