- Timestamp:
- May 26, 2009, 1:59:32 PM (17 years ago)
- Location:
- branches/cnb_branches/cnb_branch_20090301
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippScripts/scripts/magic_process.pl (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branches/cnb_branch_20090301
- Property svn:mergeinfo changed
-
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/magic_process.pl
r23352 r24244 30 30 my $missing_tools; 31 31 my $magictool = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1); 32 my $ removestreaks = can_run('RemoveStreaks') or (warn "Can't find RemoveStreaks" and $missing_tools = 1);32 my $detectstreaks = can_run('DetectStreaks') or (warn "Can't find DetectStreaks" and $missing_tools = 1); 33 33 if ($missing_tools) { 34 34 warn("Can't find required tools."); … … 63 63 $ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_id, $node, $PS_EXIT_SYS_ERROR ) if $logfile; 64 64 65 # RemoveStreaks doesn't know about nebulous. It expects to be able to append strings to outroot65 # DetectStreaks doesn't know about nebulous. It expects to be able to append strings to outroot 66 66 # to form valid file names. 67 # So forbid nebulous path in outroot. We could relax this by change RemoveStreaks to take all68 # of the file names as arguments 67 # So forbid nebulous path in outroot. We could relax this by change DetectStreaks to take all 68 # of the file names as arguments or by teaching it about Nebulous 69 69 if ($outroot =~ 'neb:/') { 70 &my_die(" RemoveStreaks does not support nebulous paths in outroot", $magic_id, $node, $PS_EXIT_CONFIG_ERROR);70 &my_die("DetectStreaks does not support nebulous paths in outroot", $magic_id, $node, $PS_EXIT_CONFIG_ERROR); 71 71 } 72 72 … … 100 100 { 101 101 my $command; # Command to execute 102 $command = "$ removestreaks --outroot $outroot";102 $command = "$detectstreaks --outroot $outroot"; 103 103 $command .= " --verbose" if $verbose; 104 104 105 # added per Paul Sydney's Jan 6, 2009 106 $command .= " -D 3"; 105 # added per Paul Sydney's request Jan 6, 2009 106 # removed per Paul Sydney March 30, 2009 107 # $command .= " -D 3"; 107 108 108 109 … … 118 119 if (scalar @$inputs == 1 and $node ne "root") { 119 120 # 120 # RemoveStreak--detect --image filename --mask maskname --weight weightname --outroot path_base121 # DetectStreaks --detect --image filename --mask maskname --weight weightname --outroot path_base 121 122 # 122 123 # Leaf node: 'detect' stage … … 131 132 } 132 133 my ($image, $mask, $weight) = resolve_inputs($innode); 133 134 $command .= " --detect --image $image --mask $mask --weight $weight"; 134 if (!defined($image) or !defined($mask) or !defined($weight)) { 135 &my_die("failed to resolve inputs", $magic_id, $node, $PS_EXIT_DATA_ERROR); 136 } 137 138 my $template = resolve_template($innode); 139 &my_die("failed to resolve template", $magic_id, $node, $PS_EXIT_DATA_ERROR) 140 unless defined $template; 141 142 $command .= " --detect --image $image --mask $mask --weight $weight -k $template"; 135 143 136 144 # set threshold to 4 sigma 137 145 $command .= ' -t 4'; 146 147 # add -S 148 $command .= ' -S'; 138 149 139 150 # create the list of inputs used at this stage. At higher levels the … … 156 167 } else { 157 168 # 158 # RemoveStreak--merge --inputs input.list --images image0_1.list \169 # DetectStreaks --merge --inputs input.list --images image0_1.list \ 159 170 # --masks mask0_1.list --weight weights0_1.list 160 171 # --outroot outroot … … 176 187 foreach my $innode (@$inputs) { 177 188 # root for inputs from previous stage 178 my $in_ uri = $innode->{uri};179 print $sfh "$in_ uri\n";180 181 cat_list_to_list($in_fh, $in_ uri, "input.list");189 my $in_path_base = $innode->{magic_path_base}; 190 print $sfh "$in_path_base\n"; 191 192 cat_list_to_list($in_fh, $in_path_base, "input.list"); 182 193 # build input lists by combining the lists from 183 194 # previous stages 184 cat_list_to_list($ifh, $in_ uri, "image.list");185 cat_list_to_list($mfh, $in_ uri, "mask.list");186 cat_list_to_list($wfh, $in_ uri, "weight.list");195 cat_list_to_list($ifh, $in_path_base, "image.list"); 196 cat_list_to_list($mfh, $in_path_base, "mask.list"); 197 cat_list_to_list($wfh, $in_path_base, "weight.list"); 187 198 } 188 199 close $in_fh; … … 195 206 $command .= " --images $image_list --masks $mask_list --weights $weight_list" ; 196 207 $command .= " --inputstreaks $streaks_list"; 208 # new option to "merge duplicate streaks into unique streaks" 209 $command .= " --duplicates"; 197 210 }; 198 211 if ($@) { … … 202 215 203 216 unless ($no_op) { 204 # RemoveStreaks fails if an output file already exists217 # DetectStreaks fails if an output file already exists 205 218 foreach my $output (@outputs) { 206 219 unlink($output) if -e $output; … … 211 224 unless ($success) { 212 225 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 213 &my_die("Unable to perform RemoveStreaks: $error_code", $magic_id, $node, $error_code);226 &my_die("Unable to perform DetectStreaks: $error_code", $magic_id, $node, $error_code); 214 227 } 215 228 … … 228 241 $command .= " -magic_id $magic_id"; 229 242 $command .= " -node $node"; 230 $command .= " - uri$outroot";243 $command .= " -path_base $outroot"; 231 244 $command .= " -dbname $dbname" if defined $dbname; 232 245 … … 247 260 my $resolved = $ipprc->file_resolve($streaks_file); 248 261 249 my $fh; 250 open $fh, "<$resolved" or 251 &my_die("failed to open streaks file $streaks_file", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR); 252 # the first line in the streaks file contains the number of streaks found 253 my $num_streaks = <$fh>; 254 chomp $num_streaks; 255 close $fh; 256 print "$num_streaks streaks found on magicRun $magic_id\n" if $verbose; 262 my $num_streaks = -1; 263 unless ($no_op) { 264 my $fh; 265 open $fh, "<$resolved" or 266 &my_die("failed to open streaks file $streaks_file", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR); 267 # the first line in the streaks file contains the number of streaks found 268 $num_streaks = <$fh>; 269 chomp $num_streaks; 270 close $fh; 271 print "$num_streaks streaks found on magicRun $magic_id\n" if $verbose; 272 } 257 273 258 274 my $command = "$magictool -addmask"; … … 294 310 sub cat_list_to_list { 295 311 my $out = shift; # output file handle 296 my $ uri = shift; # urito append ...312 my $path_base = shift; # path_base to append ... 297 313 my $extension = shift; # ... the extension to 298 314 299 my $filename = "$ uri.$extension";315 my $filename = "$path_base.$extension"; 300 316 301 317 my $in; … … 306 322 } 307 323 308 sub resolve_inputs {309 324 sub resolve_inputs 325 { 310 326 my $node = shift; 311 my $input_base = $node->{path_base}; 312 313 my $image = $ipprc->file_resolve($ipprc->filename("PPSUB.OUTPUT", $input_base)); 314 my $mask = $ipprc->file_resolve($ipprc->filename("PPSUB.OUTPUT.MASK", $input_base)); 315 my $weight= $ipprc->file_resolve($ipprc->filename("PPSUB.OUTPUT.VARIANCE", $input_base)); 316 317 return ($image, $mask, $weight); 327 my $input_base = $node->{diff_path_base}; 328 329 my ($image, $mask, $variance); # Names to return 330 if ($node->{inverse}) { 331 $image = "PPSUB.INVERSE"; 332 $mask = "PPSUB.INVERSE.MASK"; 333 $variance = "PPSUB.INVERSE.VARIANCE"; 334 } else { 335 $image = "PPSUB.OUTPUT"; 336 $mask = "PPSUB.OUTPUT.MASK"; 337 $variance = "PPSUB.OUTPUT.VARIANCE"; 338 } 339 340 $image = $ipprc->file_resolve($ipprc->filename($image, $input_base)); 341 $mask = $ipprc->file_resolve($ipprc->filename($mask, $input_base)); 342 $variance= $ipprc->file_resolve($ipprc->filename($variance, $input_base)); 343 344 return ($image, $mask, $variance); 345 } 346 347 sub resolve_template 348 { 349 my $node = shift; 350 351 my $image; # Name of template to return 352 my $path_base; # Base name for name 353 if (defined $node->{warp_path_base} and $node->{warp_path_base} ne "NULL") { 354 $path_base = $node->{warp_path_base}; 355 $image = "PSWARP.OUTPUT"; 356 } elsif (defined $node->{stack_path_base} and $node->{stack_path_base} ne "NULL") { 357 $path_base = $node->{stack_path_base}; 358 $image = "PPSTACK.OUTPUT"; 359 } else { 360 return undef; 361 } 362 363 $image = $ipprc->file_resolve($ipprc->filename($image, $path_base)); 364 365 return $image 318 366 } 319 367 … … 339 387 $command .= " -magic_id $magic_id"; 340 388 $command .= " -node $node"; 341 $command .= " - code$exit_code";389 $command .= " -fault $exit_code"; 342 390 $command .= " -dbname $dbname" if defined $dbname; 343 391 system($command);
Note:
See TracChangeset
for help on using the changeset viewer.
