1 | #!/bin/bash |
---|
2 | |
---|
3 | fullComp=false |
---|
4 | |
---|
5 | if [ $# -gt 0 ]; then |
---|
6 | |
---|
7 | if [ $1 == "-f" ]; then |
---|
8 | fullComp=true |
---|
9 | else |
---|
10 | echo "VerifyDuchamp.sh: A script to run multiple Duchamp runs, testing different algorithms." |
---|
11 | echo " Options: -f - Full comparison. This may throw up differences arising merely from precision" |
---|
12 | echo " The default is a basic comparison that won't be affected by precision changes" |
---|
13 | echo " -h - This help text." |
---|
14 | exit 0 |
---|
15 | fi |
---|
16 | |
---|
17 | fi |
---|
18 | |
---|
19 | version=`grep VERSION src/config.h | sed '/\"/s///' | sed '/\"/s///' | awk '{print $3}'` |
---|
20 | |
---|
21 | progname=./Duchamp-$version |
---|
22 | dir=./verification |
---|
23 | |
---|
24 | numErrors=0 |
---|
25 | |
---|
26 | ndet=(5 5 5 5 1 1 5 5 5) |
---|
27 | number=("first" "second" "third" "fourth" "fifth" "sixth" "seventh" "eighth" "ninth") |
---|
28 | explanation=("This is a simple sigma-clipping search" |
---|
29 | "This uses the FDR method" |
---|
30 | "This spatially smoothes the cube, then searches with simple sigma-clipping" |
---|
31 | "This reconstructs the cube, then searches with simple sigma-clipping" |
---|
32 | "This just uses a small subsection of the full cube, with simple searching" |
---|
33 | "This reconstructs the subsection, then searches with simple sigma-clipping" |
---|
34 | "This does the same as the first, and grows detections" |
---|
35 | "This does the same as the first, but with regular statistics instead of robust" |
---|
36 | "This does the same as the first, but changing the spectral type, units, and rest frequency") |
---|
37 | explanation2=("-" "-" "It should take a bit longer than the first two." "It should take a bit longer again" "-" "-" "-" "-" "-") |
---|
38 | |
---|
39 | ################################################################## |
---|
40 | # Run the tests. |
---|
41 | # First, test the results file, just looking at the number of sources |
---|
42 | # and their pixel positions. |
---|
43 | # This is to avoid precision problems with the WCS positions. |
---|
44 | # Second, test the entire log files. |
---|
45 | |
---|
46 | for (( i=0; i<${#number[@]}; i++ )); do |
---|
47 | |
---|
48 | N=`expr $i + 1` |
---|
49 | in=${dir}/input${N} |
---|
50 | res=${dir}/results${N}.txt |
---|
51 | Sres=${dir}/stdResults${N}.txt |
---|
52 | log=${dir}/log${N}.txt |
---|
53 | Slog=${dir}/stdLog${N}.txt |
---|
54 | vot=${dir}/results${N}.xml |
---|
55 | Svot=${dir}/stdResults${N}.xml |
---|
56 | karma=${dir}/results${N}.ann |
---|
57 | Skarma=${dir}/stdResults${N}.ann |
---|
58 | ds9=${dir}/results${N}.reg |
---|
59 | Sds9=${dir}/stdResults${N}.reg |
---|
60 | |
---|
61 | temp1=/tmp/duchampRes |
---|
62 | temp2=/tmp/duchampComp |
---|
63 | |
---|
64 | echo "Running the ${number[i]} Duchamp test:" |
---|
65 | echo " [${explanation[i]}]" |
---|
66 | if (( ( $i == "2" ) || ( $i == "3" ) )); then |
---|
67 | echo " [${explanation2[i]}]" |
---|
68 | fi |
---|
69 | rm -f /tmp/duchampRes /tmp/duchampComp /tmp/duchamptest |
---|
70 | $progname -p $in > /tmp/duchamptest |
---|
71 | echo "Done. Comparison to standard result:" |
---|
72 | numDet=`grep "Total number" $res | cut -f 7 -d " "` |
---|
73 | if [ $numDet == ${ndet[i]} ]; then |
---|
74 | if [ $fullComp == true ]; then |
---|
75 | numdiff=`diff -I"Duchamp" $res $Sres | wc -l` |
---|
76 | else |
---|
77 | tail -${numDet} $res | awk '{print $1,$3,$4,$5}' > $temp1 |
---|
78 | tail -${numDet} $Sres | awk '{print $1,$3,$4,$5}' > $temp2 |
---|
79 | numdiff=`diff $temp1 $temp2 | wc -l` |
---|
80 | fi |
---|
81 | if [ $numdiff != 0 ]; then |
---|
82 | if [ $fullComp == true ]; then |
---|
83 | echo " Found correct number of sources, but differences exist in the results table." |
---|
84 | echo " ERROR: Differences in results:" |
---|
85 | else |
---|
86 | echo " Found correct number of sources, but positions differ." |
---|
87 | echo " ERROR: Differences in positions of sources:" |
---|
88 | fi |
---|
89 | diff -I"Duchamp" $res $Sres |
---|
90 | numErrors=`expr $numErrors + 1` |
---|
91 | else |
---|
92 | echo " All detections correct." |
---|
93 | fi |
---|
94 | else |
---|
95 | echo " ERROR. Wrong number of sources found." |
---|
96 | echo "Differences in results:" |
---|
97 | diff -I"Duchamp" $res $Sres |
---|
98 | numErrors=$numErrors+1 |
---|
99 | fi |
---|
100 | |
---|
101 | #Test the log files. |
---|
102 | if [ `diff -I"flagXOutput" -I"Duchamp" -I"spectraFile" $log $Slog | wc -l` == 0 ]; then |
---|
103 | echo " Logfiles correct." |
---|
104 | else |
---|
105 | echo " ERROR: Differences in the log files:" |
---|
106 | diff -I"flagXOutput" -I"Duchamp" -I"spectraFile" $log $Slog |
---|
107 | numErrors=`expr $numErrors + 1` |
---|
108 | fi |
---|
109 | |
---|
110 | #Test the VOTable results. |
---|
111 | if [ $fullComp == true ]; then |
---|
112 | numdiff=`diff $vot $Svot | wc -l` |
---|
113 | else |
---|
114 | head -`grep -n "<TABLEDATA>" $vot | sed -e 's/://g' | cut -f 1 -d ' '` $vot > $temp1 |
---|
115 | head -`grep -n "<TABLEDATA>" $Svot | sed -e 's/://g' | cut -f 1 -d ' '` $Svot > $temp2 |
---|
116 | numdiff=`diff $temp1 $temp2 | wc -l` |
---|
117 | fi |
---|
118 | if [ $numdiff == 0 ]; then |
---|
119 | echo " VOTables correct." |
---|
120 | else |
---|
121 | echo " ERROR: Differences in the VOTables:" |
---|
122 | if [ $fullComp == true ]; then |
---|
123 | diff $vot $Svot |
---|
124 | else |
---|
125 | diff $temp1 $temp2 |
---|
126 | fi |
---|
127 | numErrors=`expr $numErrors + 1` |
---|
128 | fi |
---|
129 | |
---|
130 | #Test the Karma annotation files |
---|
131 | if [ $fullComp == true ]; then |
---|
132 | numdiff=`diff -I"Duchamp" $karma $Skarma | wc -l` |
---|
133 | else |
---|
134 | grep -v -e "^#" $karma > $temp1 |
---|
135 | grep -v -e "^#" $Skarma > $temp2 |
---|
136 | numdiff=`diff $temp1 $temp2 | wc -l` |
---|
137 | fi |
---|
138 | if [ $numdiff == 0 ]; then |
---|
139 | echo " Karma annotation files correct." |
---|
140 | else |
---|
141 | echo " ERROR: Differences in the Karma annotation files:" |
---|
142 | if [ $fullComp == true ]; then |
---|
143 | diff $karma $Skarma |
---|
144 | else |
---|
145 | diff $temp1 $temp2 |
---|
146 | fi |
---|
147 | numErrors=`expr $numErrors + 1` |
---|
148 | fi |
---|
149 | |
---|
150 | #Test the DS9 annotation files |
---|
151 | if [ $fullComp == true ]; then |
---|
152 | numdiff=`diff -I"Duchamp" $ds9 $Sds9 | wc -l` |
---|
153 | else |
---|
154 | grep -v -e "^#" $ds9 > $temp1 |
---|
155 | grep -v -e "^#" $Sds9 > $temp2 |
---|
156 | numdiff=`diff $temp1 $temp2 | wc -l` |
---|
157 | fi |
---|
158 | if [ $numdiff == 0 ]; then |
---|
159 | echo " DS9 annotation files correct." |
---|
160 | else |
---|
161 | echo " ERROR: Differences in the DS9 annotation files:" |
---|
162 | if [ $fullComp == true ]; then |
---|
163 | diff $ds9 $Sds9 |
---|
164 | else |
---|
165 | diff $temp1 $temp2 |
---|
166 | fi |
---|
167 | numErrors=`expr $numErrors + 1` |
---|
168 | fi |
---|
169 | |
---|
170 | echo "" |
---|
171 | echo "" |
---|
172 | |
---|
173 | done |
---|
174 | |
---|
175 | ################################################################## |
---|
176 | # Summarise the results |
---|
177 | # Either give the OK, or give some advice about what to do. |
---|
178 | |
---|
179 | echo " " |
---|
180 | if [ $numErrors == 0 ]; then |
---|
181 | echo "No errors! Everything is working fine." |
---|
182 | echo " " |
---|
183 | echo "Happy Finding! If you ever need to report a bug or request an upgrade, go to" |
---|
184 | echo " http://svn.atnf.csiro.au/trac/duchamp/newticket" |
---|
185 | else |
---|
186 | echo "There were some differences in the results compared to the standards." |
---|
187 | echo "Have a look at the diffs to see if they are trivial or not (eg. precision errors)." |
---|
188 | echo "If they are more serious (e.g. wrong number of sources found), submit a bug report" |
---|
189 | echo " at http://svn.atnf.csiro.au/trac/duchamp/newticket" |
---|
190 | fi |
---|