source: trunk/VerifyDuchamp.sh @ 1082

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

Adding flexibility to VerifyDuchamp?.sh to allow full comparison (all lines), versus just the header and important information. This is to try to get around issues with differences in precision.

  • Property svn:executable set to *
File size: 6.0 KB
Line 
1#!/bin/bash
2
3if [ $# -gt 1 ]; 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"Results of the Duchamp source finder:" $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            echo "  Found correct number of sources, but positions differ."
82            echo "  ERROR: Differences in positions of sources:"
83            diff -I"Results of the Duchamp source finder:" $res $Sres
84            numErrors=`expr $numErrors + 1`
85        else
86            echo "  All detections correct."
87        fi
88    else
89        echo "  ERROR. Wrong number of sources found."
90        echo "Differences in results:"
91        diff  -I"Results of the Duchamp source finder:" $res $Sres
92        numErrors=$numErrors+1
93    fi
94
95#Test the log files.
96    if [ `diff -I"flagXOutput" -I"Duchamp" -I"spectraFile" $log $Slog | wc -l` == 0 ]; then
97        echo "  Logfiles correct."
98    else
99        echo "  ERROR: Differences in the log files:"
100        diff -I"flagXOutput" -I"Duchamp" -I"spectraFile" $log $Slog
101        numErrors=`expr $numErrors + 1`
102    fi
103
104#Test the VOTable results.
105    if [ $fullComp == true ]; then
106        numdiff=`diff $vot $Svot | wc -l`
107    else
108        head -`grep -n "<TABLEDATA>" $vot | sed -e 's/://g' | cut -f 1 -d ' '` $vot > $temp1
109        head -`grep -n "<TABLEDATA>" $Svot | sed -e 's/://g' | cut -f 1 -d ' '` $vot > $temp2
110        numdiff=`diff $temp1 $temp2 | wc -l`
111    fi
112    if [ $numdiff == 0 ]; then
113        echo "  VOTables correct."
114    else
115        echo "  ERROR: Differences in the VOTables:"
116        if [ $fullComp == true ]; then
117            diff $vot $Svot
118        else
119            diff $temp1 $temp2
120        fi
121        numErrors=`expr $numErrors + 1`
122    fi
123
124#Test the Karma annotation files
125    if [ $fullComp == true ]; then
126        numdiff=`diff $karma $Skarma | wc -l`
127    else
128        grep -e "^#" $karma > $temp1
129        grep -e "^#" $Skarma > $temp2
130        numdiff=`diff $temp1 $temp2 | wc -l`
131    fi
132    if [ $numdiff == 0 ]; then
133        echo "  Karma annotation files correct."
134    else
135        echo "  ERROR: Differences in the Karma annotation files:"
136        if [ $fullComp == true ]; then
137            diff $karma $Skarma
138        else
139            diff $temp1 $temp2
140        fi
141        numErrors=`expr $numErrors + 1`
142    fi
143
144#Test the DS9 annotation files
145    if [ $fullComp == true ]; then
146        numdiff=`diff $ds9 $Sds9 | wc -l`
147    else
148        grep -e "^#" $ds9 > $temp1
149        grep -e "^#" $Sds9 > $temp2
150        numdiff=`diff $temp1 $temp2 | wc -l`
151    fi
152    if [ $numdiff == 0 ]; then
153        echo "  DS9 annotation files correct."
154    else
155        echo "  ERROR: Differences in the DS9 annotation files:"
156        if [ $fullComp == true ]; then
157            diff $ds9 $Sds9
158        else
159            diff $temp1 $temp2
160        fi
161        numErrors=`expr $numErrors + 1`
162    fi
163
164    echo ""
165    echo ""
166   
167done
168
169##################################################################
170# Summarise the results
171# Either give the OK, or give some advice about what to do.
172
173echo " "
174if [ $numErrors == 0 ]; then
175    echo "No errors! Everything is working fine."
176    echo " "
177    echo "Happy Finding! If you ever need to report a bug or request an upgrade, go to"
178    echo "  http://svn.atnf.csiro.au/trac/duchamp/newticket"
179else
180    echo "There were some differences in the results compared to the standards."
181    echo "Have a look at the diffs to see if they are trivial or not (eg. precision errors)."
182    echo "If they are more serious (e.g. wrong number of sources found), submit a bug report"
183    echo "  at http://svn.atnf.csiro.au/trac/duchamp/newticket"
184fi
Note: See TracBrowser for help on using the repository browser.