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