Changeset 13618
- Timestamp:
- Jun 4, 2007, 2:25:37 PM (19 years ago)
- Location:
- trunk/ippScripts/scripts
- Files:
-
- 2 edited
-
detrend_reject_imfile.pl (modified) (9 diffs)
-
detrend_resid.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_reject_imfile.pl
r13590 r13618 120 120 my @means; # Array of means 121 121 my @variances; # Array of variances 122 my @binVariances; # Array of binned variances 122 123 my @meanStdevs; # Array of mean stdevs 123 124 my @names; # Array of names (class_id) … … 129 130 ## calculate the root-mean-square of the bd_stdevs 130 131 push @variances, $file->{bg_stdev}*$file->{bg_stdev}; 132 push @binVariances, $file->{bin_stdev}*$file->{bin_stdev}; 131 133 push @names, $file->{class_id}; 132 134 } … … 180 182 my $reject_imfile_meanstdev = rejection_limit( 'IMFILE.MEANSTDEV', $det_type, $filter ); 181 183 my $reject_imfile_sn = rejection_limit( 'IMFILE.SN', $det_type, $filter ); 184 my $reject_imfile_bin_sn = rejection_limit( 'IMFILE.BIN.SN', $det_type, $filter ); 182 185 my $reject_exp_mean = rejection_limit( 'EXP.MEAN', $det_type, $filter ); 183 186 my $reject_exp_stdev = rejection_limit( 'EXP.STDEV', $det_type, $filter ); 184 187 my $reject_exp_meanstdev = rejection_limit( 'EXP.MEANSTDEV', $det_type, $filter ); 185 188 my $reject_exp_sn = rejection_limit( 'EXP.SN', $det_type, $filter ); 189 my $reject_exp_bin_sn = rejection_limit( 'EXP.BIN.SN', $det_type, $filter ); 186 190 187 191 my $logName = caturi( $workdir, "$exp_tag.detreject.$det_id.$iter.log" ); # Name for log … … 199 203 $mean -= $expected; 200 204 my $stdev = sqrt($variances[$i]); # Stdev for this imfile 205 my $binStdev = sqrt($binVariances[$i]); # Stdev for this imfile 201 206 my $name = $names[$i]; 202 207 … … 247 252 } else { 248 253 print $logFile "No rejection on imfile S/N for $name\n"; 254 } 255 if ($reject_imfile_bin_sn) { 256 if ($mean < $binStdev * $reject_imfile_bin_sn) { 257 print $logFile "Rejecting exposure based on bad imfile binned S/N for $name: "; 258 $reject = 1; 259 } else { 260 print $logFile "Imfile binned S/N for $name meets requirements: "; 261 } 262 print $logFile "mean: $mean vs binStdev*SNlimit: " . $binStdev * $reject_imfile_bin_sn . "\n"; 263 } else { 264 print $logFile "No rejection on imfile binned S/N for $name\n"; 249 265 } 250 266 } … … 255 271 my $varianceStats = Statistics::Descriptive::Sparse->new(); # Statistics calculator for variances 256 272 $varianceStats->add_data(@variances); 273 my $binVarianceStats = Statistics::Descriptive::Sparse->new(); # Statistics calculator for variances 274 $binVarianceStats->add_data(@binVariances); 257 275 258 276 my $mean = $meanStats->mean(); # Mean of the imfile means … … 263 281 } 264 282 my $stdev = sqrt($varianceStats->mean()); # Root-Mean-Square of the imfile stdevs (root mean of variances) 283 my $binStdev = sqrt($binVarianceStats->mean()); # Root-Mean-Square of the imfile stdevs (root mean of variances) 265 284 my $exp_sn = 0.0; 266 285 if ($stdev > 0) { $exp_sn = $mean / $stdev; } … … 318 337 print $logFile "No rejection for exp S/N\n"; 319 338 } 339 # reject if the signal-to-noise is insufficient 340 if ($reject_exp_bin_sn) { 341 if (abs($mean) < abs($binStdev * $reject_exp_bin_sn)) { 342 print $logFile "Rejecting exposure based on poor binned S/N: \n"; 343 $reject = 1; 344 } else { 345 print $logFile "Exposure binned S/N meets requirements: \n"; 346 } 347 print $logFile "signal: $mean vs noise: $binStdev (s/n limit is: $reject_exp_bin_sn)\n"; 348 } else { 349 print $logFile "No rejection for exp binned S/N\n"; 350 } 320 351 321 352 close $logFile; … … 326 357 my $bg_stdev = $stdev; 327 358 my $bg_mean_stdev = $meanStdev; 359 my $bin_stdev = $binStdev; 328 360 329 361 unless ($no_update) { 330 362 my $command = "$dettool -addresidexp -det_id $det_id -iteration $iter -exp_tag $exp_tag"; 331 363 $command .= " -recip $recipe1,$recipe2 -path_base $outputRoot "; 332 $command .= " -bg $bg -bg_stdev $bg_stdev -bg_mean_stdev $bg_mean_stdev ";364 $command .= " -bg $bg -bg_stdev $bg_stdev -bg_mean_stdev $bg_mean_stdev -bin_stdev $bin_stdev"; 333 365 $command .= ' -reject' if $reject; 334 366 $command .= " -dbname $dbname" if defined $dbname; -
trunk/ippScripts/scripts/detrend_resid.pl
r13552 r13618 105 105 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 106 106 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 107 my $ppStats = can_run('ppStats') or (warn "Can't find ppStats" and $missing_tools = 1); 107 108 if ($missing_tools) { 108 109 warn("Can't find required tools."); … … 123 124 my $bin2Name = $ipprc->filename("PPIMAGE.BIN2", $outputRoot, $class_id); 124 125 my $outputStats = $outputRoot . '.' . $class_id . '.stats'; 126 my $outputBinnedStats = $outputRoot . '.' . $class_id . '.bin.stats'; 125 127 126 128 # Run ppImage 127 129 my $stats = PS::IPP::Metadata::Stats->new(); # Stats parser 130 my $binnedStats = PS::IPP::Metadata::Stats->new(); # Stats parser 128 131 unless ($no_op) { 129 132 my $command = "$ppImage -file $input_uri $outputRoot -recipe PPIMAGE $recipe" . … … 154 157 close $statsFile; 155 158 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 156 my $metadata = $mdcParser->parse(join "", @contents) or 157 &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 158 $stats = PS::IPP::Metadata::Stats->new(); # Stats parser 159 my $metadata = $mdcParser->parse(join "", @contents) or &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 160 # $stats = PS::IPP::Metadata::Stats->new(); # Stats parser 159 161 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 162 163 # run ppStats on the binned image 164 $command = "$ppStats $bin2Name $outputBinnedStats"; 165 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 166 run(command => $command, verbose => 1); 167 168 unless ($success) { 169 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 170 &my_die("Unable to perform ppStats: $error_code", $det_id, $iter, $exp_tag, $class_id, $error_code); 171 } 172 173 &my_die("Couldn't find expected output file: $outputBinnedStats", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBinnedStats); 174 175 open $statsFile, $ipprc->file_resolve($outputBinnedStats) or &my_die("Can't open statistics file $outputBinnedStats: $!", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR); 176 @contents = <$statsFile>; # Contents of file 177 close $statsFile; 178 my $binnedMetadata = $mdcParser->parse(join "", @contents) or &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 179 # $binnedStats = PS::IPP::Metadata::Stats->new(); # Stats parser 180 $binnedStats->parse($binnedMetadata) or &my_die("Unable to find all values in statistics output.", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 160 181 } 161 182 … … 164 185 my $bg_stdev = ($stats->bg_stdev() or 'NAN'); 165 186 my $bg_mean_stdev = ($stats->bg_mean_stdev() or 'NAN'); 187 my $bin_stdev = ($binnedStats->bg_stdev() or 'NAN'); 166 188 167 189 unless ($no_update) { 168 my $command = "$dettool -addresidimfile -det_id $det_id -iteration $iter -exp_tag $exp_tag " . 169 "-class_id $class_id -recip $recipe -uri $outputName -path_base $outputRoot"; # Command to run dettool 190 my $command = "$dettool -addresidimfile -det_id $det_id -iteration $iter"; 191 $command .= " -exp_tag $exp_tag -class_id $class_id"; 192 $command .= " -recip $recipe -uri $outputName -path_base $outputRoot"; 170 193 $command .= " -bg $bg -bg_stdev $bg_stdev -bg_mean_stdev $bg_mean_stdev"; 194 $command .= " -bin_stdev $bin_stdev"; 171 195 $command .= " -dbname $dbname" if defined $dbname; 172 196 … … 179 203 } 180 204 } 181 182 183 205 184 206 sub my_die
Note:
See TracChangeset
for help on using the changeset viewer.
