Changeset 41993
- Timestamp:
- Jan 20, 2022, 6:46:50 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20211108/ippTests/ippCheck/smfcheck.pro
r41989 r41993 6 6 7 7 input tap.sh 8 9 # for a single chip, I want outputs with names like: 10 # expname.chipID.smfcmp.field.png 11 # expname.chipID.smfcmp.txt 12 13 ### example of plotting all outputs for a single chip: 14 macro go.sample 15 $SAVEPLOT = 0 16 $KAPA = kapa -noX 17 smf.compare.parse.book fields.bk psfFields 18 smf.compare.onechip o9451g0319o/o9451g0319o.XY01 o9451g0319o.1833521.cm.2467375.smf o9451g0319o.1833521.cm.2467377.smf 2 19 end 8 20 9 21 macro check.extensions … … 48 60 end 49 61 50 51 # for a single chip, I want outputs with names like:52 # expname.chipID.smfcmp.field.png53 # expname.chipID.smfcmp.txt54 55 ### example of plotting all outputs for a single chip:56 macro go.sample57 $SAVEPLOT = 158 $KAPA = kapa -noX59 smf.compare.onechip o9451g0319o/o9451g0319o.XY01 o9451g0319o.1833521.cm.2467375.smf o9451g0319o.1833521.cm.2467377.smf 260 end61 62 62 # generate plot and comparison txt file for one chip (extension) 63 63 macro smf.compare.onechip … … 76 76 mkdir $mydir 77 77 78 load.smf.fields $smf1 $extnum t0 79 load.smf.fields $smf2 $extnum t1 80 81 smf.pos.compare t0 t1 82 smf.compare.fields $output t0 t1 83 output stdout 78 # XXX TEMP: remove existing output file 79 exec rm -f $output.txt 80 81 # load in the full set of data for this extension 82 # NOTE : t0 and t1 are used to label the sets of vectors 83 load.smf.fields $smf1 $extnum t1 84 load.smf.fields $smf2 $extnum t2 85 86 # generate the matched lists (index1, index2) 87 smf.compare.positions $output t1 t2 88 89 # compare the values in the matched pairs for each field 90 smf.compare.fields $output t1 t2 84 91 end 85 92 … … 108 115 109 116 $MATCH_RADIUS = 1; # match radius in pixels 110 macro smf. pos.compare117 macro smf.compare.positions 111 118 if ($0 != 4) 112 echo "USAGE: smf. pos.compare(output) (v1) (v2)"119 echo "USAGE: smf.compare.positions (output) (v1) (v2)" 113 120 echo "generates matched position lists & stats" 114 121 break … … 120 127 $v2 = $3 121 128 122 match2d X_PSF_$v1 Y_PSF_$v1 X_PSF_$v 1 Y_PSF_$v1$MATCH_RADIUS -closest129 match2d X_PSF_$v1 Y_PSF_$v1 X_PSF_$v2 Y_PSF_$v2 $MATCH_RADIUS -closest 123 130 124 131 # initial questions to answer: … … 128 135 reindex Ym_$v1 = Y_PSF_$v1 using index2 -keep-unmatched 129 136 130 reindex Xm_$v 1 = X_PSF_$v1using index1 -keep-unmatched131 reindex Ym_$v 1 = Y_PSF_$v1using index1 -keep-unmatched137 reindex Xm_$v2 = X_PSF_$v2 using index1 -keep-unmatched 138 reindex Ym_$v2 = Y_PSF_$v2 using index1 -keep-unmatched 132 139 133 140 vstat -q Xm_$v1 … … 135 142 $N1_miss = Xm_$v1[] - $N1_keep 136 143 137 vstat -q Xm_$v 1144 vstat -q Xm_$v2 138 145 $N2_keep = $NPTS 139 $N2_miss = Xm_$v1[] - $N2_keep 140 146 $N2_miss = Xm_$v2[] - $N2_keep 141 147 148 # 149 output $output.txt 142 150 echo "$N1_keep & $N1_miss vs $N2_keep & $N2_miss" 151 output stdout 143 152 144 153 # positional consistency: 145 set dX = X_PSF_$v1 - Xm_$v 1146 set dY = Y_PSF_$v1 - Ym_$v 1154 set dX = X_PSF_$v1 - Xm_$v2 155 set dY = Y_PSF_$v1 - Ym_$v2 147 156 148 157 vstat dX … … 162 171 $v2 = $3 163 172 164 smf.fields.mag range.init173 smf.fields.magplot.init 165 174 exec rm -f $output.txt 166 175 … … 168 177 list fields -split $allfields 169 178 for i 0 $fields:n 170 $f = $fields:$i171 smf.fields.mag range.plot $output $f$v1 $v2179 smf.compare.onefield $output $fields:$i $v1 $v2 180 smf.fields.magplot.foo $output $fields:$i $v1 $v2 172 181 end 173 182 end 174 183 175 macro smf.fields.mag range.init184 macro smf.fields.magplot.init 176 185 clear -s 177 186 antialias 0.4 … … 183 192 end 184 193 185 macro smf.fields.mag range.plot194 macro smf.fields.magplot.foo 186 195 if ($0 != 5) 187 echo "USAGE: smf.fields.mag range.plot(output) {field) (v1) (v2)"196 echo "USAGE: smf.fields.magplot.foo (output) {field) (v1) (v2)" 188 197 echo " NOTE: run smf.pos.compare (or equiv) first to generate index1, index2" 189 198 break … … 196 205 $v2 = $4 197 206 198 # plot the new values vs the old values (all old values) 199 reindex tmp_$v2 = $field\_$v2 using index1 -keep-unmatched 200 set dtmp = tmp_$v2 - $field\_$v1 201 hist.range dtmp Ntmp dx 202 vstat -q dtmp 203 204 # save the summary line to be written to a file by the calling function 205 output $output.txt 206 fprintf "%24s : %12.6g %12.6g : %12.6g : %12.6g - %12.6g" $field $MEAN $SIGMA $hist:median $hist:minVal $hist:maxVal 207 output stdout 208 209 if (isnan($hist:median)) 210 continue 211 end 207 if (not(dtmp?[])) return; # this happens if the field is not listed in the fields table (or stat is NONE) 208 if (not($SAVEPLOT)) return 209 if (isnan($hist:median)) return 212 210 213 211 clear 214 212 section a 215 lim PSF_INST_MAG_$v1 $hist:min Val $hist:maxVal; box $BSTY; plot PSF_INST_MAG_$v1 dtmp -pt cir -op 0.3213 lim PSF_INST_MAG_$v1 $hist:minPlt $hist:maxPlt; box $BSTY; plot PSF_INST_MAG_$v1 dtmp -pt cir -op 0.3 216 214 section b 217 215 if (dx[] == 1) … … 221 219 end 222 220 223 if ($SAVEPLOT) 224 png -name $output.$field.png 221 png -name $output.$field.png 222 end 223 224 macro smf.compare.onefield 225 if ($0 != 5) 226 echo "USAGE: smf.fields.onefield (output) {field) (v1) (v2)" 227 echo " NOTE: run smf.compare.position (or equiv) first to generate index1, index2" 228 break 229 end 230 231 local output field v1 v2 232 $output = $1 233 $field = $2 234 $v1 = $3 235 $v2 = $4 236 237 # confirm that this field exists in the list of fields: 238 # XXX missing functions to test for book or page existence 239 240 # generate the comparison statistic 241 reindex tmp_$v2 = $field\_$v2 using index1 -keep-unmatched 242 243 # what statistic do we use to compare? 244 book getword psfFields $field STAT -var useStat 245 book getword psfFields $field SCALE -var statScale 246 book getword psfFields $field MIN_GOOD -var minGood 247 book getword psfFields $field MAX_GOOD -var maxGood 248 book getword psfFields $field MIN_MAG -var minMag 249 book getword psfFields $field MAX_MAG -var maxMag 250 echo $field $useStat 251 252 delete -q dtmp 253 if ("$useStat" == "VALUE") 254 set dtmp = $statScale*(tmp_$v2 - $field\_$v1) 255 subset dtmpS = dtmp where ((PSF_INST_MAG_$v1 > $minMag) && (PSF_INST_MAG_$v1 < $maxMag)) 256 end 257 if ("$useStat" == "IVALUE") 258 set dtmp = tmp_$v2 - $field\_$v1 259 subset dtmpS = dtmp where ((PSF_INST_MAG_$v1 > $minMag) && (PSF_INST_MAG_$v1 < $maxMag) && (tmp_$v2 != -4096) && ($field\_$v1 != -4096)) 260 end 261 if ("$useStat" == "RATIO") 262 set dtmp = $statScale(tmp_$v2 / $field\_$v1) 263 subset dtmpS = dtmp where ((PSF_INST_MAG_$v1 > $minMag) && (PSF_INST_MAG_$v1 < $maxMag)) 264 end 265 if ("$useStat" == "RVALUE") 266 set dtmp = $statScale*(tmp_$v2 - $field\_$v1) / $field\_$v1 267 subset dtmpS = dtmp where ((PSF_INST_MAG_$v1 > $minMag) && (PSF_INST_MAG_$v1 < $maxMag)) 268 end 269 if (("$useStat" == "NONE") || ("$useStat" == "NULL")) 270 output $output.txt 271 fprintf "%24s : 1 : SKIP" $field 272 output stdout 273 return 274 end 275 if (dtmp?[] == 0) 276 echo "unknown STAT value $useStat" 277 break 278 end 279 280 # measure the stats on the subset for the defined mag range 281 hist.range dtmpS Ntmp dx 282 vstat -q dtmpS 283 284 $PASS = 1 285 if ($hist:minVal < $minGood) set PASS = 0 286 if ($hist:maxVal > $maxGood) set PASS = 0 287 288 # save the summary line to be written to a file by the calling function 289 output $output.txt 290 fprintf "%24s : %2d : %12.6g %12.6g : %12.6g : %12.6g - %12.6g" $field $PASS $MEAN $SIGMA $hist:median $hist:minVal $hist:maxVal 291 output stdout 292 end 293 294 macro smf.compare.parse.book 295 if ($0 != 3) 296 echo "USAGE: smf.compare.parse.book (file) (book)" 297 break 298 end 299 300 local filename bookname pagename i j tmpline myChar 301 $filename = $1 302 $bookname = $2 303 304 # the fields table has row-by-row pages with values: 305 # LAYOUT KEY KEY KEY 306 # PAGENAME VALUE VALUE VALUE 307 308 # NOTE: this list parsing strips out extra spaces and empty lines 309 # ALSO: the code below handles quotes in the input file poorly 310 list tmplines -x "cat $filename" 311 312 book init $bookname; # creates the book if it does not exist 313 314 $myWords:n = 0 315 316 for i 0 $tmplines:n 317 $tmpline = $tmplines:$i 318 substr "$tmpline" 0 1 myChar 319 if ("$myChar" == "#") continue 320 321 list words -split $tmpline 322 if ($words:n < 2) 323 echo "ERROR: no information on line $i" 324 echo "$tmpline" 325 break 326 end 327 328 $pagename = $words:0 329 330 if ($myWords:n == 0) 331 # the first uncommented line should define the list of words 332 if ("$pagename" != "LAYOUT") 333 echo "ERROR: invalid page layout on first line" 334 echo "$tmpline" 335 break 336 end 337 338 # save these words on the list of words 339 list myWords -copy words 340 next 341 end 342 343 if ($words:n != $myWords:n) 344 echo "ERROR: missing words for page on line $i" 345 echo "$tmpline" 346 break 347 end 348 349 # the first word on the line gives the page name 350 book newpage $bookname $pagename 351 352 for j 1 $words:n 353 book setword $bookname $pagename $myWords:$j $words:$j 354 end 225 355 end 226 356 end … … 237 367 local Nm Np No value10 value50 value90 range 238 368 239 set _tmp_sort = $1 369 $hist:minPlt = NAN 370 $hist:maxPlt = NAN 371 $hist:minVal = NAN 372 $hist:maxVal = NAN 373 $hist:delVal = NAN 374 $hist:median = NAN 375 376 if (not($1?[])) 377 echo "invalid vector $1" 378 break 379 end 380 381 subset _tmp_sort = $1 where not(isnan($1)) 382 if (_tmp_sort[] < 2) return 383 240 384 sort _tmp_sort 241 385 $Nm = 0.1*_tmp_sort[] … … 248 392 $value50 = _tmp_sort[$No] 249 393 250 # set the range to be 2x the 10 - 90 percentile range 394 # save the 10 and 90 percentile values 395 $hist:minVal = $value10 396 $hist:maxVal = $value90 397 398 # set the plotting range to be 3x the 10 - 90 percentile range 251 399 $range = 3*($value90 - $value10) 252 $hist:minVal = $value50 - 0.5*$range 253 $hist:maxVal = $value50 + 0.5*$range 400 $hist:minPlt = $value50 - 0.5*$range 401 $hist:maxPlt = $value50 + 0.5*$range 402 254 403 $hist:delVal = $range / 250 255 404 $hist:median = $value50
Note:
See TracChangeset
for help on using the changeset viewer.
