source: tags/release-1.2.1/VerifyDuchamp.sh @ 1441

Last change on this file since 1441 was 1086, checked in by MatthewWhiting, 12 years ago

A few more edits to get the comparisons correct.

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