source: trunk/VerifyDuchamp.sh @ 1077

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

Enabling the output of DS9 region files in addition to the Karma annotation files. Also adding this to the verification script. Still to do documentation.

  • Property svn:executable set to *
File size: 4.6 KB
Line 
1#!/bin/bash
2
3version=`grep VERSION src/config.h | sed '/\"/s///' | sed '/\"/s///' | awk '{print $3}'`
4
5progname=./Duchamp-$version
6dir=./verification
7
8numErrors=0
9
10ndet=(5 5 5 5 1 1 5 5 5)
11number=("first" "second" "third" "fourth" "fifth" "sixth" "seventh" "eighth" "ninth")
12explanation=("This is a simple sigma-clipping search"
13"This uses the FDR method"
14"This spatially smoothes the cube, then searches with simple sigma-clipping"
15"This reconstructs the cube, then searches with simple sigma-clipping"
16"This just uses a small subsection of the full cube, with simple searching"
17"This reconstructs the subsection, then searches with simple sigma-clipping"
18"This does the same as the first, and grows detections"
19"This does the same as the first, but with regular statistics instead of robust"
20"This does the same as the first, but changing the spectral type, units, and rest frequency")
21explanation2=("-" "-" "It should take a bit longer than the first two." "It should take a bit longer again" "-" "-" "-" "-" "-")
22
23##################################################################
24# Run the tests.
25# First, test the results file, just looking at the number of sources
26#  and their pixel positions.
27# This is to avoid precision problems with the WCS positions.
28# Second, test the entire log files.
29
30for (( i=0; i<${#number[@]}; i++ )); do
31   
32    N=`expr $i + 1`
33    in=${dir}/input${N}
34    res=${dir}/results${N}.txt
35    Sres=${dir}/stdResults${N}.txt
36    log=${dir}/log${N}.txt
37    Slog=${dir}/stdLog${N}.txt
38    vot=${dir}/results${N}.xml
39    Svot=${dir}/stdResults${N}.xml
40    karma=${dir}/results${N}.ann
41    Skarma=${dir}/stdResults${N}.ann
42    ds9=${dir}/results${N}.reg
43    Sds9=${dir}/stdResults${N}.reg
44
45    echo "Running the ${number[i]} Duchamp test:"
46    echo "  [${explanation[i]}]"
47    if  (( ( $i == "2" ) || ( $i == "3" ) )); then
48        echo "  [${explanation2[i]}]"
49    fi
50    rm -f /tmp/duchampRes /tmp/duchampComp /tmp/duchamptest
51    $progname -p $in > /tmp/duchamptest
52    echo "Done. Comparison to standard result:"
53    numDet=`grep "Total number" $res | cut -f 6 -d " "`
54    if [ $numDet == ${ndet[i]} ]; then
55        tail -${numDet} $res | awk '{print $1,$3,$4,$5}' > /tmp/duchampRes
56        tail -${numDet} $Sres | awk '{print $1,$3,$4,$5}' > /tmp/duchampComp
57        if [ `diff /tmp/duchampRes /tmp/duchampComp | wc -l` != 0 ]; then
58            echo "  Found correct number of sources, but positions differ."
59            echo "  ERROR: Differences in positions of sources:"
60            diff -I"Results of the Duchamp source finder:" $res $Sres
61            numErrors=`expr $numErrors + 1`
62        else
63            echo "  All detections correct."
64        fi
65    else
66        echo "  ERROR. Wrong number of sources found."
67        echo "Differences in results:"
68        diff  -I"Results of the Duchamp source finder:" $res $Sres
69        numErrors=$numErrors+1
70    fi
71
72#Test the log files.
73    if [ `diff -I"flagXOutput" -I"Duchamp" -I"spectraFile" $log $Slog | wc -l` == 0 ]; then
74        echo "  Logfiles correct."
75    else
76        echo "  ERROR: Differences in the log files:"
77        diff -I"flagXOutput" -I"Duchamp" -I"spectraFile" $log $Slog
78        numErrors=`expr $numErrors + 1`
79    fi
80
81#Test the VOTable results.
82    if [ `diff $vot $Svot | wc -l` == 0 ]; then
83        echo "  VOTables correct."
84    else
85        echo "  ERROR: Differences in the VOTables:"
86        diff $vot $Svot
87        numErrors=`expr $numErrors + 1`
88    fi
89
90#Test the Karma annotation files
91    if [ `diff $karma $Skarma | wc -l` == 0 ]; then
92        echo "  Karma annotation files correct."
93    else
94        echo "  ERROR: Differences in the Karma annotation files:"
95        diff $karma $Skarma
96        numErrors=`expr $numErrors + 1`
97    fi
98
99#Test the DS9 annotation files
100    if [ `diff $ds9 $Sds9 | wc -l` == 0 ]; then
101        echo "  DS9 annotation files correct."
102    else
103        echo "  ERROR: Differences in the Ds9 annotation files:"
104        diff $ds9 $Sds9
105        numErrors=`expr $numErrors + 1`
106    fi
107
108    echo ""
109    echo ""
110   
111done
112
113##################################################################
114# Summarise the results
115# Either give the OK, or give some advice about what to do.
116
117echo " "
118if [ $numErrors == 0 ]; then
119    echo "No errors! Everything is working fine."
120    echo " "
121    echo "Happy Finding! If you ever need to report a bug or request an upgrade, go to"
122    echo "  http://svn.atnf.csiro.au/trac/duchamp/newticket"
123else
124    echo "There were some differences in the results compared to the standards."
125    echo "Have a look at the diffs to see if they are trivial or not (eg. precision errors)."
126    echo "If they are more serious (e.g. wrong number of sources found), submit a bug report"
127    echo "  at http://svn.atnf.csiro.au/trac/duchamp/newticket"
128fi
Note: See TracBrowser for help on using the repository browser.