test.r3.in.bin.sh 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #!/bin/sh
  2. g.region w=0 e=180 s=0 n=90 b=0 t=100 res3=10
  3. r3.mapcalc --o expr="test_out_bin_float = float(if(row() == 2, null(), row()))"
  4. r3.mapcalc --o expr="test_out_bin_double = double(if(row() == 2, null(), row()))"
  5. r3.out.ascii --o dp=0 input=test_out_bin_float output=test_out_bin_float.ref;
  6. r3.out.ascii --o dp=0 input=test_out_bin_double output=test_out_bin_double.ref;
  7. # @test
  8. r3.out.bin --o input=test_out_bin_float byte=4 null=-9999 \
  9. output=test_out_bin_float_native_b4.bin order=native
  10. r3.out.bin --o input=test_out_bin_float byte=8 null=-9999 \
  11. output=test_out_bin_float_native_b8.bin order=native
  12. r3.out.bin --o -r input=test_out_bin_float byte=4 null=-9999 \
  13. output=test_out_bin_float_native_r_b4.bin order=native
  14. r3.out.bin --o -d input=test_out_bin_float byte=4 null=-9999 \
  15. output=test_out_bin_float_native_d_b4.bin order=native
  16. r3.out.bin --o -rd input=test_out_bin_float byte=4 null=-9999 \
  17. output=test_out_bin_float_native_rd_b4.bin order=native
  18. # Test little and big endian
  19. r3.out.bin --o input=test_out_bin_float byte=4 null=-9999 \
  20. output=test_out_bin_float_little_b4.bin order=little
  21. #r3.out.bin --o input=test_out_bin_float byte=4 null=-9999 \
  22. # output=test_out_bin_float_big_b4.bin order=big
  23. r3.out.bin --o input=test_out_bin_float byte=4 null=-9999 \
  24. output=test_out_bin_float_swap_b4.bin order=swap
  25. # Write float map as integer array
  26. r3.out.bin --o -i input=test_out_bin_float byte=1 null=0 \
  27. output=test_out_bin_float_native_b1_as_integer.bin order=native
  28. r3.out.bin --o -i input=test_out_bin_float byte=2 null=0 \
  29. output=test_out_bin_float_native_b2_as_integer.bin order=native
  30. r3.out.bin --o -i input=test_out_bin_float byte=4 null=0 \
  31. output=test_out_bin_float_native_b4_as_integer.bin order=native
  32. r3.out.bin --o -i input=test_out_bin_float byte=8 null=0 \
  33. output=test_out_bin_float_native_b8_as_integer.bin order=native
  34. # Double precision
  35. r3.out.bin --o input=test_out_bin_double byte=4 null=-9999 \
  36. output=test_out_bin_double_native_b4.bin order=native
  37. r3.out.bin --o input=test_out_bin_double byte=8 null=-9999 \
  38. output=test_out_bin_double_native_b8.bin order=native
  39. # Import test floating point
  40. r3.in.bin --o output=test_in_bin_float_1 byte=4 null=-9999 \
  41. input=test_out_bin_float_native_b4.bin order=native \
  42. bottom=0 top=100 west=0 east=180 south=0 north=90 \
  43. cols=18 rows=9 depths=10
  44. r3.in.bin --o output=test_in_bin_float_2 byte=8 null=-9999 \
  45. input=test_out_bin_float_native_b8.bin order=native \
  46. bottom=0 top=100 west=0 east=180 south=0 north=90 \
  47. cols=18 rows=9 depths=10
  48. r3.in.bin --o output=test_in_bin_float_4 byte=4 null=-9999 \
  49. input=test_out_bin_float_native_d_b4.bin order=native \
  50. bottom=0 top=100 west=0 east=180 south=0 north=90 \
  51. cols=18 rows=9 depths=10 -d
  52. r3.in.bin --o output=test_in_bin_float_5 byte=4 null=-9999 \
  53. input=test_out_bin_float_native_r_b4.bin order=native \
  54. bottom=0 top=100 west=0 east=180 south=0 north=90 \
  55. cols=18 rows=9 depths=10 -r
  56. r3.in.bin --o output=test_in_bin_float_6 byte=4 null=-9999 \
  57. input=test_out_bin_float_native_rd_b4.bin order=native \
  58. bottom=0 top=100 west=0 east=180 south=0 north=90 \
  59. cols=18 rows=9 depths=10 -rd
  60. # Integer binary file import
  61. r3.in.bin --o output=test_in_bin_float_7 byte=1 null=0 \
  62. input=test_out_bin_float_native_b1_as_integer.bin order=native \
  63. bottom=0 top=100 west=0 east=180 south=0 north=90 \
  64. cols=18 rows=9 depths=10 -i
  65. r3.in.bin --o output=test_in_bin_float_8 byte=2 null=0 \
  66. input=test_out_bin_float_native_b2_as_integer.bin order=native \
  67. bottom=0 top=100 west=0 east=180 south=0 north=90 \
  68. cols=18 rows=9 depths=10 -i
  69. r3.in.bin --o output=test_in_bin_float_9 byte=4 null=0 \
  70. input=test_out_bin_float_native_b4_as_integer.bin order=native \
  71. bottom=0 top=100 west=0 east=180 south=0 north=90 \
  72. cols=18 rows=9 depths=10 -i
  73. r3.in.bin --o output=test_in_bin_float_10 byte=8 null=0 \
  74. input=test_out_bin_float_native_b8_as_integer.bin order=native \
  75. bottom=0 top=100 west=0 east=180 south=0 north=90 \
  76. cols=18 rows=9 depths=10 -i
  77. # Test little and big endian
  78. r3.in.bin --o output=test_in_bin_float_11 byte=4 null=-9999 \
  79. input=test_out_bin_float_little_b4.bin order=little \
  80. bottom=0 top=100 west=0 east=180 south=0 north=90 \
  81. cols=18 rows=9 depths=10
  82. #r3.in.bin --o output=test_in_bin_float_12 byte=4 null=-9999 \
  83. # input=test_out_bin_float_big_b4.bin order=big \
  84. # bottom=0 top=100 west=0 east=180 south=0 north=90 \
  85. # cols=18 rows=9 depths=10
  86. r3.in.bin --o output=test_in_bin_float_13 byte=4 null=-9999 \
  87. input=test_out_bin_float_swap_b4.bin order=swap \
  88. bottom=0 top=100 west=0 east=180 south=0 north=90 \
  89. cols=18 rows=9 depths=10
  90. for map in `g.list type=raster3d pattern=test_in_bin_float*` ; do
  91. r3.out.ascii input=${map} output=${map}.txt dp=0
  92. done
  93. for i in `ls test_in_bin_float_*.txt` ; do
  94. diff $i test_out_bin_float.ref
  95. done
  96. g.remove -f type=raster3d pattern=test_in*
  97. g.remove -f type=raster3d pattern=test_out*
  98. rm test_in_*.txt
  99. rm test_out_*.bin