1#!/bin/sh
2# This is a test to register and unregister raster maps in
3# space time raster input.
4# The raster maps will be registered in different space time raster
5# inputs
6
7# We need to set a specific region in the
8# @preprocess step of this test. We generate
9# raster with r.mapcalc and create two space time raster inputs
10# with relative
11# The region setting should work for UTM and LL test locations
12g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3
13
14# Generate data
15r.mapcalc --o expr="prec_1 = rand(0, 550)" -s
16r.mapcalc --o expr="prec_2 = rand(0, 450)" -s
17r.mapcalc --o expr="prec_3 = rand(0, 320)" -s
18r.mapcalc --o expr="prec_4 = rand(0, 510)" -s
19r.mapcalc --o expr="prec_5 = rand(0, 300)" -s
20r.mapcalc --o expr="prec_6 = rand(0, 650)" -s
21
22n1=`g.tempfile pid=1 -d` # Only map names
23n2=`g.tempfile pid=2 -d` # Map names and start time
24n3=`g.tempfile pid=3 -d` # Map names start time and increment
25
26cat > "${n1}" << EOF
27prec_1
28prec_2
29prec_3
30prec_4
31prec_5
32prec_6
33EOF
34cat "${n1}"
35
36cat > "${n2}" << EOF
37prec_1|1
38prec_2|2
39prec_3|3
40prec_4|4
41prec_5|5
42prec_6|6
43EOF
44cat "${n2}"
45
46cat > "${n3}" << EOF
47prec_1|1|4
48prec_2|4|7
49prec_3|7|10
50prec_4|10|11
51prec_5|11|14
52prec_6|14|17
53EOF
54cat "${n3}"
55
56# The first @test
57# We create the space time raster inputs and register the raster maps with absolute time interval
58t.create --o type=strds temporaltype=relative output=precip_abs8 title="A test with input files" descr="A test with input files"
59
60# Test with input files
61# File 1, and 3 without a space time raster dataset
62t.register --o -i file="${n1}" start=0 increment=7 unit=days
63t.unregister --v type=raster file="${n1}"
64t.register --o file="${n2}" unit=minutes
65t.unregister --v type=raster file="${n1}"
66t.register --o -i file="${n3}" unit=seconds
67t.unregister --v type=raster file="${n1}"
68# File 1
69t.register --o -i input=precip_abs8 file="${n1}" start=0 increment=7 unit=days
70t.info type=strds input=precip_abs8
71t.rast.list input=precip_abs8
72# File 1
73t.unregister --v type=raster file="${n1}"
74t.register --o input=precip_abs8 file="${n1}" start=20 unit=years
75t.info type=strds input=precip_abs8
76t.rast.list input=precip_abs8
77# File 2
78t.unregister --v type=raster file="${n1}"
79t.register --o input=precip_abs8 file="${n2}" unit=minutes
80t.info type=strds input=precip_abs8
81t.rast.list input=precip_abs8
82# File 2 ERROR ERROR -- Increment computation needs to be fixed
83t.unregister --v type=raster file="${n1}"
84t.register --o input=precip_abs8 file="${n2}" increment=14 unit=days
85t.info type=strds input=precip_abs8
86t.rast.list input=precip_abs8
87# File 2 ERROR ERROR -- Increment computation needs to be fixed
88t.unregister --v type=raster file="${n1}"
89t.register --o -i input=precip_abs8 file="${n2}" increment=14 unit=days
90t.info type=strds input=precip_abs8
91t.rast.list input=precip_abs8
92
93# File 3
94t.unregister --v type=raster file="${n1}"
95t.register --o -i input=precip_abs8 file="${n3}" unit=seconds
96t.info type=strds input=precip_abs8
97t.rast.list input=precip_abs8
98
99t.unregister --v type=raster file="${n1}"
100
101# @test of correct @failure handling
102t.register --o -i input=precip_abs8 maps=preac_1,prec_2 file="${n3}" # Maps and file set
103t.register --o -i input=precip_abs8 file="${n3}" # No relative unit set
104
105t.remove --v type=strds input=precip_abs8
106