[754] | 1 | #!/bin/bash |
---|
[148] | 2 | |
---|
[1082] | 3 | if [ $# -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 | |
---|
| 14 | else |
---|
| 15 | fullComp=false |
---|
| 16 | fi |
---|
| 17 | |
---|
[389] | 18 | version=`grep VERSION src/config.h | sed '/\"/s///' | sed '/\"/s///' | awk '{print $3}'` |
---|
[325] | 19 | |
---|
[361] | 20 | progname=./Duchamp-$version |
---|
[754] | 21 | dir=./verification |
---|
[338] | 22 | |
---|
[361] | 23 | numErrors=0 |
---|
[325] | 24 | |
---|
[952] | 25 | ndet=(5 5 5 5 1 1 5 5 5) |
---|
| 26 | number=("first" "second" "third" "fourth" "fifth" "sixth" "seventh" "eighth" "ninth") |
---|
[754] | 27 | explanation=("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") |
---|
| 36 | explanation2=("-" "-" "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] | 45 | for (( 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 |
---|
[754] | 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 |
---|
[325] | 88 | else |
---|
[754] | 89 | echo " ERROR. Wrong number of sources found." |
---|
| 90 | echo "Differences in results:" |
---|
| 91 | diff -I"Results of the Duchamp source finder:" $res $Sres |
---|
[361] | 92 | numErrors=$numErrors+1 |
---|
| 93 | fi |
---|
[1062] | 94 | |
---|
[325] | 95 | #Test the log files. |
---|
[1057] | 96 | if [ `diff -I"flagXOutput" -I"Duchamp" -I"spectraFile" $log $Slog | wc -l` == 0 ]; then |
---|
[754] | 97 | echo " Logfiles correct." |
---|
[604] | 98 | else |
---|
[754] | 99 | echo " ERROR: Differences in the log files:" |
---|
[1057] | 100 | diff -I"flagXOutput" -I"Duchamp" -I"spectraFile" $log $Slog |
---|
[754] | 101 | numErrors=`expr $numErrors + 1` |
---|
[604] | 102 | fi |
---|
| 103 | |
---|
[1062] | 104 | #Test the VOTable results. |
---|
[1082] | 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 |
---|
[1062] | 113 | echo " VOTables correct." |
---|
| 114 | else |
---|
| 115 | echo " ERROR: Differences in the VOTables:" |
---|
[1082] | 116 | if [ $fullComp == true ]; then |
---|
| 117 | diff $vot $Svot |
---|
| 118 | else |
---|
| 119 | diff $temp1 $temp2 |
---|
| 120 | fi |
---|
[1062] | 121 | numErrors=`expr $numErrors + 1` |
---|
| 122 | fi |
---|
| 123 | |
---|
[1073] | 124 | #Test the Karma annotation files |
---|
[1082] | 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 |
---|
[1076] | 133 | echo " Karma annotation files correct." |
---|
[1073] | 134 | else |
---|
| 135 | echo " ERROR: Differences in the Karma annotation files:" |
---|
[1082] | 136 | if [ $fullComp == true ]; then |
---|
| 137 | diff $karma $Skarma |
---|
| 138 | else |
---|
| 139 | diff $temp1 $temp2 |
---|
| 140 | fi |
---|
[1073] | 141 | numErrors=`expr $numErrors + 1` |
---|
| 142 | fi |
---|
| 143 | |
---|
[1077] | 144 | #Test the DS9 annotation files |
---|
[1082] | 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 |
---|
[1077] | 153 | echo " DS9 annotation files correct." |
---|
| 154 | else |
---|
[1082] | 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 |
---|
[1077] | 161 | numErrors=`expr $numErrors + 1` |
---|
| 162 | fi |
---|
| 163 | |
---|
[754] | 164 | echo "" |
---|
| 165 | echo "" |
---|
| 166 | |
---|
| 167 | done |
---|
[604] | 168 | |
---|
[632] | 169 | ################################################################## |
---|
[325] | 170 | # Summarise the results |
---|
| 171 | # Either give the OK, or give some advice about what to do. |
---|
| 172 | |
---|
[278] | 173 | echo " " |
---|
[361] | 174 | if [ $numErrors == 0 ]; then |
---|
[325] | 175 | echo "No errors! Everything is working fine." |
---|
[354] | 176 | echo " " |
---|
| 177 | echo "Happy Finding! If you ever need to report a bug or request an upgrade, go to" |
---|
[327] | 178 | echo " http://svn.atnf.csiro.au/trac/duchamp/newticket" |
---|
[325] | 179 | else |
---|
| 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)." |
---|
[486] | 182 | echo "If they are more serious (e.g. wrong number of sources found), submit a bug report" |
---|
[327] | 183 | echo " at http://svn.atnf.csiro.au/trac/duchamp/newticket" |
---|
[361] | 184 | fi |
---|