Changeset 14048 for trunk/ippScripts/scripts/detrend_reject_exp.pl
- Timestamp:
- Jul 6, 2007, 3:44:38 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_reject_exp.pl (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_reject_exp.pl
r14009 r14048 16 16 use IPC::Cmd 0.36 qw( can_run run ); 17 17 use PS::IPP::Metadata::Config; 18 use PS::IPP::Metadata::Stats; 19 18 20 use PS::IPP::Metadata::List qw( parse_md_list ); 19 21 use Statistics::Descriptive; … … 86 88 87 89 # Get list of component files 88 my $exposures; # Array of exposures90 my ($exposures, $command, $success, $error_code, $full_buf, $stdout_buf, $stderr_buf); 89 91 { 90 92 # dettool command to select exp data for this det_run 91 my$command = "$dettool -residexp";93 $command = "$dettool -residexp"; 92 94 $command .= " -det_id $det_id"; 93 95 $command .= " -iteration $iter"; 94 96 $command .= " -dbname $dbname" if defined $dbname; 95 my( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =97 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 96 98 run(command => $command, verbose => 1); 97 99 unless ($success) { … … 118 120 } 119 121 120 my @expTags; # Array of exposure IDs 121 my @accept; # Array of accept flags 122 my @include; # Array of include flags 123 foreach my $exposure (@$exposures) { 124 &my_die("Unable to find exposure id.\n", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless defined $exposure->{exp_tag}; 125 &my_die("Unable to find accept.\n", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless defined $exposure->{accept}; 126 &my_die("Unable to find include.\n", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless defined $exposure->{include}; 127 } 128 122 # we use the statistics of the ensemble to accept/reject exposurs 129 123 my $ensMeanMean = &STATS_value_for_flag ($REJSTATS, "ensMeanMean"); 130 124 my $ensMeanStdev = &STATS_value_for_flag ($REJSTATS, "ensMeanStdev"); … … 147 141 unless ($no_op) { 148 142 $logFile = $ipprc->file_create_append( $logName ); 149 print $logFile "Ensemble mean $ meanEnsemble +/- $stdevEnsemble, stdev $meanStdevEnsemble\n\n";143 print $logFile "Ensemble mean $ensMeanMean +/- $ensMeanStdevMean, stdev $ensStdevMean\n\n"; 150 144 } 151 145 … … 153 147 my $numChanges = 0; # Number of exposures with changed status 154 148 my $numReject = 0; # Number of exposures rejected 155 156 for (my $i = 0; $i < scalar @$exposures; $i++) { 157 my $file = $files[$i]; 158 my $mean = $file->{bg}; # Mean for this exposure 159 my $stdev = $file->{bg_stdev}; # Stdev for this exposure 160 my $meanStdev = $file->{bg_mean_stdev}; # Stdev of Means for this exposure 161 162 my $expTag = $exposure->{exp_tag}; 163 my $accept = $exposure->{accept}; 164 my $include = $exposure->{include}; 149 my $firstElement = 1; 150 151 foreach my $exposure (@$exposures) { 152 my $mean = $exposure->{bg}; # Mean for this exposure 153 my $stdev = $exposure->{bg_stdev}; # Stdev for this exposure 154 my $meanStdev = $exposure->{bg_mean_stdev}; # Stdev of Means for this exposure 155 my $expID = $exposure->{exp_id}; 156 my $accept = $exposure->{accept}; 157 my $include = $exposure->{include}; 158 159 &my_die("Unable to find exposure id.\n", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless defined $expID; 160 &my_die("Unable to find accept.\n", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless defined $accept; 161 &my_die("Unable to find include.\n", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless defined $include; 165 162 166 163 my $reject = 0; # Reject this exposure? 167 164 168 my $command= "$dettool -updateresidexp";165 $command = "$dettool -updateresidexp"; 169 166 $command .= " -det_id $det_id"; 170 167 $command .= " -iteration $iter"; 171 $command .= " -exp_ tag $expTag";168 $command .= " -exp_id $expID"; 172 169 $command .= " -dbname $dbname" if defined $dbname; 173 170 … … 175 172 # Rejected this at an earlier stage 176 173 unless ($no_op) { 177 print $logFile "Rejecting $exp Tagbased on earlier determination.\n";174 print $logFile "Rejecting $expID based on earlier determination.\n"; 178 175 } 179 176 $reject = 1; … … 185 182 # Make sure something gets rejected (just once!), just so that 186 183 # we can trace the full range of the workflow 187 if ($ i == 0and $iter == 0) {184 if ($firstElement and $iter == 0) { 188 185 $reject = 1; 189 186 } … … 194 191 my $delta = abs($mean - $ensMeanMean); 195 192 if ($delta > ($reject_mean * $ensMeanStdev)) { 196 print $logFile "Rejecting $exp Tagbased on ensemble mean value: ";193 print $logFile "Rejecting $expID based on ensemble mean value: "; 197 194 $reject = 1; 198 195 #goto UPDATE; 199 196 } else { 200 print $logFile "$exp TagOK against ensemble mean: ";197 print $logFile "$expID OK against ensemble mean: "; 201 198 } 202 199 print $logFile "$mean --> $delta vs " . $reject_mean * $ensMeanStdev . "\n"; 203 200 } else { 204 print $logFile "No rejection of $exp Tagfor ensemble mean\n";201 print $logFile "No rejection of $expID for ensemble mean\n"; 205 202 } 206 203 … … 208 205 my $delta = abs($stdev - $ensStdevMean); 209 206 if ($delta > ($reject_stdev * $ensStdevStdev)) { 210 print $logFile "Rejecting $exp Tagbased on ensemble stdev: ";207 print $logFile "Rejecting $expID based on ensemble stdev: "; 211 208 $reject = 1; 212 209 #goto UPDATE; 213 210 } else { 214 print $logFile "$exp TagOK against ensemble stdev: ";211 print $logFile "$expID OK against ensemble stdev: "; 215 212 } 216 213 print $logFile "$stdev --> $delta sigma vs " . $reject_stdev * $ensStdevStdev . "\n"; 217 214 } else { 218 print $logFile "No rejection of $exp Tagfor ensemble stdev\n";215 print $logFile "No rejection of $expID for ensemble stdev\n"; 219 216 } 220 217 … … 222 219 my $delta = abs($meanStdev - $ensMeanStdevMean); 223 220 if ($delta > ($reject_meanstdev * $ensMeanStdevStdev)) { 224 print $logFile "Rejecting $exp Tagbased on ensemble mean stdev: ";221 print $logFile "Rejecting $expID based on ensemble mean stdev: "; 225 222 $reject = 1; 226 223 #goto UPDATE; 227 224 } else { 228 print $logFile "$exp TagOK against ensemble mean stdev: ";225 print $logFile "$expID OK against ensemble mean stdev: "; 229 226 } 230 227 print $logFile "$meanStdev --> $delta sigma vs " . $reject_meanstdev * $ensMeanStdevStdev. "\n"; 231 228 } else { 232 print $logFile "No rejection of $exp Tagfor ensemble mean stdev\n";229 print $logFile "No rejection of $expID for ensemble mean stdev\n"; 233 230 } 234 231 … … 242 239 if ((not $include and not $reject) or ($include and $reject)) { 243 240 unless ($no_op) { 244 print $logFile "Status of $exp Taghas changed.\n";241 print $logFile "Status of $expID has changed.\n"; 245 242 } 246 243 $numChanges++; … … 249 246 unless ($no_update) { 250 247 # Update 251 my( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =248 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 252 249 run(command => $command, verbose => 1); 253 250 unless ($success) { … … 268 265 269 266 # Rejecting everything --- stop before something bad happens! 270 if ($numReject == scalar @ means) {267 if ($numReject == scalar @$exposures) { 271 268 $master = 0; 272 269 $stop = 1; … … 279 276 } 280 277 281 my$command = "$dettool -adddetrunsummary";278 $command = "$dettool -adddetrunsummary"; 282 279 $command .= " -det_id $det_id"; 283 280 $command .= " -iteration $iter"; … … 294 291 # Put results into the database 295 292 unless ($no_update) { 296 my( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =293 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 297 294 run(command => $command, verbose => 1); 298 295 unless ($success) { … … 310 307 $command .= " -dbname $dbname" if defined $dbname; 311 308 312 my( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =309 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 313 310 run(command => $command, verbose => 1); 314 311 unless ($success) {
Note:
See TracChangeset
for help on using the changeset viewer.
