test.r3.stats.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # Tests for r3.stats
  2. # We set up a specific region in the
  3. # @preprocess step of this test. We generate
  4. # voxel data with r3.mapcalc. The region setting
  5. # 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. # We create several (float, double, null value) voxel map
  8. # with value = col + row + depth.
  9. r3.mapcalc --o expr="volume_float = float(col() + row() + depth())"
  10. r3.mapcalc --o expr="volume_double = double(col() + row() + depth())"
  11. # Add null value information to test correct null value handling
  12. r3.mapcalc --o expr="volume_float_null = if(row() == 1 || row() == 5, null(), volume_float)"
  13. r3.mapcalc --o expr="volume_double_null = if(row() == 2 || row() == 6, null(), volume_double)"
  14. # @test r3.stats with float maps and @file validation.
  15. # The module output on stdout is piped into text files
  16. r3.stats input=volume_float_null nsteps=1 > test_volume_float_stats_1.txt
  17. r3.stats input=volume_float_null nsteps=2 > test_volume_float_stats_2.txt
  18. r3.stats input=volume_float_null nsteps=7 > test_volume_float_stats_7.txt
  19. r3.stats input=volume_float_null nsteps=14 > test_volume_float_stats_14.txt
  20. r3.stats input=volume_float_null nsteps=21 > test_volume_float_stats_21.txt
  21. r3.stats -e input=volume_float_null > test_volume_float_stats_e.txt
  22. # Test double maps
  23. r3.stats input=volume_double_null nsteps=1 > test_volume_double_stats_1.txt
  24. r3.stats input=volume_double_null nsteps=3 > test_volume_double_stats_3.txt
  25. r3.stats input=volume_double_null nsteps=9 > test_volume_double_stats_9.txt
  26. r3.stats input=volume_double_null nsteps=18 > test_volume_double_stats_18.txt
  27. r3.stats input=volume_double_null nsteps=22 > test_volume_double_stats_22.txt
  28. r3.stats -e input=volume_double_null > test_volume_double_stats_e.txt
  29. # Comparison of references and text files
  30. for i in `ls *.ref` ; do
  31. diff $i "`basename $i .ref`.txt" ;
  32. done
  33. rm *.txt