test.t.rast.accdetect.sh 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/sh -e
  2. # Space time raster dataset neighborhood operations
  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 -p
  7. export GRASS_OVERWRITE=1
  8. # Generate data
  9. r.mapcalc expr="temp_1 = 5"
  10. r.mapcalc expr="temp_2 = 10"
  11. r.mapcalc expr="temp_3 = 15"
  12. r.mapcalc expr="temp_4 = 20"
  13. r.mapcalc expr="temp_5 = 25"
  14. r.mapcalc expr="temp_6 = 30"
  15. t.create type=strds temporaltype=absolute output=temp_abs1 title="A test" descr="A test"
  16. t.register -i type=rast input=temp_abs1 maps=temp_1,temp_2,temp_3,temp_4,temp_5,temp_6 \
  17. start="2001-01-01" increment="2 months"
  18. # The first @test
  19. t.rast.accumulate input=temp_abs1 output=temp_accumulation base=temp_acc \
  20. limits=10,25 start="2001-01-01" gran="2 months" cycle="12 months"
  21. t.rast.accdetect input=temp_accumulation occurrence=temp_occ base=temp_occ \
  22. range=20,80 start="2001-01-01" cycle="12 months"
  23. # Check the registered maps metadata
  24. t.rast.list temp_accumulation col=name,start_time,min,max > test_1_temp_accumulation.txt
  25. t.rast.list temp_occ col=name,start_time,min,max > test_1_temp_occ_a.txt
  26. # Leets test the minimum and maximum STRDS implementation
  27. r.mapcalc expr="minimum = 18"
  28. r.mapcalc expr="maximum = 78"
  29. # We use different
  30. t.create type=strds temporaltype=absolute output=minimum title="minimum limit" descr="minimum limit"
  31. t.register -i type=rast input=minimum maps=minimum start="2001-01-01" increment="8 months"
  32. t.create type=strds temporaltype=absolute output=maximum title="maximum limit" descr="maximum limit"
  33. t.register -i type=rast input=maximum maps=maximum start="2001-01-01" increment="10 months"
  34. t.rast.accdetect input=temp_accumulation occurrence=temp_occ base=temp_occ \
  35. range=20,80 start="2001-01-01" cycle="12 months" min=minimum \
  36. max=maximum staend=1,2,3 indi=temp_indi
  37. # Check the registered maps metadata
  38. t.rast.list temp_occ col=name,start_time,min,max > test_1_temp_occ_b.txt
  39. t.rast.list temp_indi col=name,start_time,min,max > test_1_temp_indi.txt
  40. t.remove -rf type=strds input=temp_abs1,temp_accumulation,temp_indi,minimum,maximum
  41. for i in `ls test_1_*.txt` ; do
  42. diff $i "`basename $i .txt`.ref" >> out.diff
  43. done
  44. CHAR_NUM=`cat out.diff | wc -c`
  45. # Return as exit status 0 in case no diffs are found
  46. exit $CHAR_NUM