Debian Codegraph @

raster3d/r3.out.ascii/test.r3.out.ascii.sh

raw
1 # Tests for r3.out.ascii and r3.in.ascii
2 # This script tests the export of voxel data using r3.out.ascii
3 # as well as the import of the generated data with r3.in.ascii
4 # using different row and depth ordering options.
5
6 # We set up a specific region in the
7 # @preprocess step of this test. We generate
8 # voxel data with r3.mapcalc. The region setting
9 # should work for UTM and LL test locations
10 g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3
11 # We create several (float, double, null value) voxel map
12 # with value = col + row + depth.
13 r3.mapcalc --o expr="volume_float = float(col() + row() + depth())"
14 r3.mapcalc --o expr="volume_double = double(col() + row() + depth())"
15 # Add null value information to test correct null value handling
16 r3.mapcalc --o expr="volume_float_null = if(row() == 1 || row() == 5, null(), volume_float)"
17 r3.mapcalc --o expr="volume_double_null = if(row() == 1 || row() == 5, null(), volume_double)"
18
19 # We export float data in the first @test using different order and precision.
20 # The created text @files are validated of correct ordering and null data handling.
21 # All reference files are located in the r3.out.ascii directory.
22 r3.out.ascii --o input=volume_float_null output=test_float_nsbt_null.txt dp=0 null=*
23 r3.out.ascii --o -r input=volume_float_null output=test_float_snbt_null.txt dp=0 null=*
24 r3.out.ascii --o -d input=volume_float_null output=test_float_nstb_null.txt dp=0 null=*
25 r3.out.ascii --o -rd input=volume_float_null output=test_float_sntb_null.txt dp=0 null=*
26 # Different precision and null values than default
27 r3.out.ascii --o input=volume_float_null output=test_float_nsbt_null_prec5.txt dp=5 null=-1000
28 r3.out.ascii --o -rd input=volume_float_null output=test_float_sntb_null_prec8.txt dp=8 null=-2000
29 # Test the no header and grass6 compatibility flags
30 r3.out.ascii --o -h input=volume_float_null output=test_float_nsbt_null_no_header.txt dp=3 null=*
31 r3.out.ascii --o -c input=volume_float_null output=test_float_nsbt_null_grass6_comp_1.txt dp=3 null=*
32 # Any row or depth order should be ignored in case grass6 compatibility is enabled
33 # The result of comp_1, _2 and _3 must be identical
34 r3.out.ascii --o -cr input=volume_float_null output=test_float_nsbt_null_grass6_comp_2.txt dp=3 null=*
35 r3.out.ascii --o -crd input=volume_float_null output=test_float_nsbt_null_grass6_comp_3.txt dp=3 null=*
36
37 # We export float data in the first @test using different order and precision.
38 # The created text @files are validated of correct ordering and null data handling.
39 # All reference files are located in the r3.out.ascii directory.
40 r3.out.ascii --o input=volume_double_null output=test_double_nsbt_null.txt dp=0 null=*
41 r3.out.ascii --o -r input=volume_double_null output=test_double_snbt_null.txt dp=0 null=*
42 r3.out.ascii --o -d input=volume_double_null output=test_double_nstb_null.txt dp=0 null=*
43 r3.out.ascii --o -rd input=volume_double_null output=test_double_sntb_null.txt dp=0 null=*
44 # Different precision and null values than default
45 r3.out.ascii --o input=volume_double_null output=test_double_nsbt_null_prec5.txt dp=5 null=-1000
46 r3.out.ascii --o -rd input=volume_double_null output=test_double_sntb_null_prec8.txt dp=8 null=-2000
47 # Test the no header and grass6 compatibility flags
48 r3.out.ascii --o -h input=volume_double_null output=test_double_nsbt_null_no_header.txt dp=3 null=*
49 r3.out.ascii --o -c input=volume_double_null output=test_double_nsbt_null_grass6_comp_1.txt dp=3 null=*
50 # Any row or depth order should be ignored in case grass6 compatibility is enabled
51 # The result of comp_1, _2 and _3 must be identical
52 r3.out.ascii --o -cr input=volume_double_null output=test_double_nsbt_null_grass6_comp_2.txt dp=3 null=*
53 r3.out.ascii --o -crd input=volume_double_null output=test_double_nsbt_null_grass6_comp_3.txt dp=3 null=*
54
55 # In the third @test we import all the generated data using r3.in.ascii.
56 # The created @raster maps should be identical to the map "volume_double_null".
57 # The export of the created g3d map should use as @precision=0 for data validation.
58 # The same raster name is used for all the imported data and so for the validation reference file.
59 r3.in.ascii --o output=test_double_nsbt_null input=test_double_nsbt_null.txt nv=*
60 r3.in.ascii --o output=test_double_nsbt_null input=test_double_snbt_null.txt nv=*
61 r3.in.ascii --o output=test_double_nsbt_null input=test_double_nstb_null.txt nv=*
62 r3.in.ascii --o output=test_double_nsbt_null input=test_double_sntb_null.txt nv=*
63 # Different precision and null values than default
64 r3.in.ascii --o output=test_double_nsbt_null input=test_double_nsbt_null_prec5.txt nv=-1000
65 r3.in.ascii --o output=test_double_nsbt_null input=test_double_sntb_null_prec8.txt nv=-2000
66 # Import grass6 legacy data
67 r3.in.ascii --o output=test_double_nsbt_null input=test_double_nsbt_null_grass6_comp_1.txt
68
69 # In this @preprocess step for the last test we create a large region and
70 # generate large input data to test the handling of large files.
71 g.region s=0 n=800 w=0 e=1200 b=0 t=50 res=10 res3=1.5 -p3
72 r3.mapcalc --o expr="volume_double_large = double(col() + row() + depth())"
73 # Add null value information
74 r3.mapcalc --o expr="volume_double_null_large = if(row() == 1 || row() == 5, null(), volume_double_large)"
75
76 # Now @test the export and import of large data without validation
77 r3.out.ascii --o input=volume_double_null_large output=test_double_nsbt_null_large.txt dp=0 null=*
78 r3.in.ascii --o output=test_double_nsbt_null_large input=test_double_nsbt_null_large.txt nv=*
79 # Just for the logs
80 r3.info test_double_nsbt_null_large
81
82 # Show differences between references and created text files
83 for i in `ls *.ref` ; do
84 diff $i "`basename $i .ref`.txt" ;
85 done
86 rm *.txt