source: trunk/VerifyDuchamp.sh @ 1085

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

Minor edit.

  • Property svn:executable set to *
File size: 6.1 KB
RevLine 
[754]1#!/bin/bash
[148]2
[1083]3if [ $# -gt 0 ]; then
[1082]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
[389]18version=`grep VERSION src/config.h | sed '/\"/s///' | sed '/\"/s///' | awk '{print $3}'`
[325]19
[361]20progname=./Duchamp-$version
[754]21dir=./verification
[338]22
[361]23numErrors=0
[325]24
[952]25ndet=(5 5 5 5 1 1 5 5 5)
26number=("first" "second" "third" "fourth" "fifth" "sixth" "seventh" "eighth" "ninth")
[754]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"
[890]33"This does the same as the first, and grows detections"
[952]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" "-" "-" "-" "-" "-")
[754]37
[325]38##################################################################
[754]39# Run the tests.
[325]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
[754]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
[1062]53    vot=${dir}/results${N}.xml
[1073]54    Svot=${dir}/stdResults${N}.xml
55    karma=${dir}/results${N}.ann
56    Skarma=${dir}/stdResults${N}.ann
[1077]57    ds9=${dir}/results${N}.reg
58    Sds9=${dir}/stdResults${N}.reg
[148]59
[1082]60    temp1=/tmp/duchampRes
61    temp2=/tmp/duchampComp
62
[754]63    echo "Running the ${number[i]} Duchamp test:"
64    echo "  [${explanation[i]}]"
65    if  (( ( $i == "2" ) || ( $i == "3" ) )); then
66        echo "  [${explanation2[i]}]"
[361]67    fi
[754]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
[1082]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
[1083]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
[1085]88            diff -I"Duchamp:" $res $Sres
[754]89            numErrors=`expr $numErrors + 1`
90        else
91            echo "  All detections correct."
92        fi
[325]93    else
[754]94        echo "  ERROR. Wrong number of sources found."
95        echo "Differences in results:"
96        diff  -I"Results of the Duchamp source finder:" $res $Sres
[361]97        numErrors=$numErrors+1
98    fi
[1062]99
[325]100#Test the log files.
[1057]101    if [ `diff -I"flagXOutput" -I"Duchamp" -I"spectraFile" $log $Slog | wc -l` == 0 ]; then
[754]102        echo "  Logfiles correct."
[604]103    else
[754]104        echo "  ERROR: Differences in the log files:"
[1057]105        diff -I"flagXOutput" -I"Duchamp" -I"spectraFile" $log $Slog
[754]106        numErrors=`expr $numErrors + 1`
[604]107    fi
108
[1062]109#Test the VOTable results.
[1082]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
[1062]118        echo "  VOTables correct."
119    else
120        echo "  ERROR: Differences in the VOTables:"
[1082]121        if [ $fullComp == true ]; then
122            diff $vot $Svot
123        else
124            diff $temp1 $temp2
125        fi
[1062]126        numErrors=`expr $numErrors + 1`
127    fi
128
[1073]129#Test the Karma annotation files
[1082]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
[1076]138        echo "  Karma annotation files correct."
[1073]139    else
140        echo "  ERROR: Differences in the Karma annotation files:"
[1082]141        if [ $fullComp == true ]; then
142            diff $karma $Skarma
143        else
144            diff $temp1 $temp2
145        fi
[1073]146        numErrors=`expr $numErrors + 1`
147    fi
148
[1077]149#Test the DS9 annotation files
[1082]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
[1077]158        echo "  DS9 annotation files correct."
159    else
[1082]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
[1077]166        numErrors=`expr $numErrors + 1`
167    fi
168
[754]169    echo ""
170    echo ""
171   
172done
[604]173
[632]174##################################################################
[325]175# Summarise the results
176# Either give the OK, or give some advice about what to do.
177
[278]178echo " "
[361]179if [ $numErrors == 0 ]; then
[325]180    echo "No errors! Everything is working fine."
[354]181    echo " "
182    echo "Happy Finding! If you ever need to report a bug or request an upgrade, go to"
[327]183    echo "  http://svn.atnf.csiro.au/trac/duchamp/newticket"
[325]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)."
[486]187    echo "If they are more serious (e.g. wrong number of sources found), submit a bug report"
[327]188    echo "  at http://svn.atnf.csiro.au/trac/duchamp/newticket"
[361]189fi
Note: See TracBrowser for help on using the repository browser.