Changeset 27596 for trunk/ippScripts/scripts/magic_process.pl
- Timestamp:
- Apr 5, 2010, 10:16:10 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippScripts/scripts/magic_process.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to
/branches/pap_delete merged eligible
-
Property svn:mergeinfo
set to
-
trunk/ippScripts/scripts/magic_process.pl
r27240 r27596 30 30 my $missing_tools; 31 31 my $magictool = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1); 32 my $difftool = can_run('difftool') or (warn "Can't find difftool" and $missing_tools = 1); 33 my $ppSubConvolve = can_run('ppSubConvolve') or (warn "Can't find ppSubConvolve" and $missing_tools = 1); 32 34 my $detectstreaks = can_run('DetectStreaks') or (warn "Can't find DetectStreaks" and $missing_tools = 1); 33 35 my $VerifyStreaks = can_run('VerifyStreaks') or (warn "Can't find VerifyStreaks, will not produce png images"); … … 80 82 $baseroot = $ipprc->file_resolve($baseroot); 81 83 my $outroot = "$baseroot.$node"; 84 $ipprc->outroot_prepare($outroot); 82 85 83 86 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 116 119 $command .= " --threshold 2.35"; 117 120 121 my @deletions; # Files to delete 118 122 if (scalar @$inputs == 1 and $node ne "root") { 119 123 # … … 135 139 } 136 140 137 my $template = resolve_template($innode); 138 &my_die("failed to resolve template", $magic_id, $node, $PS_EXIT_DATA_ERROR) 139 unless defined $template; 141 my $diff_base = $innode->{diff_path_base}; # Base name for diff 142 my $tempName = $innode->{inverse} ? "PPSUB.INPUT.CONV" : "PPSUB.REF.CONV"; # File rule of interest 143 my $template = $ipprc->file_resolve($ipprc->filename($tempName, $diff_base)); 144 &my_die("failed to resolve template", $magic_id, $node, $PS_EXIT_DATA_ERROR) unless defined $template; 145 146 # Delete the convolved products when done (we can recreate them as we need) 147 push @deletions, $template; 148 push @deletions, $ipprc->filename($tempName . ".MASK", $diff_base); 149 push @deletions, $ipprc->filename($tempName . ".VARIANCE", $diff_base); 150 151 unless ($ipprc->file_exists($template)) { 152 # Template doesn't exist (or can't be found); try to recreate it 153 my $tempPath = "/tmp/magic.$magic_id.$node.template"; 154 155 my $kernel = $ipprc->filename("PPSUB.OUTPUT.KERNELS", $diff_base); # Name of kernel file 156 &my_die("Unable to find kernel file", $magic_id, $node, $PS_EXIT_DATA_ERROR) unless $ipprc->file_exists($kernel); 157 158 my ($image, $mask); # Image and mask 159 { 160 my $command = "$difftool -inputskyfile -diff_id $diff_id -skycell_id $node"; # Command to run 161 $command .= " -dbname $dbname" if defined $dbname; 162 if ($innode->{inverse}) { 163 # Want the input because we're magicking the reference 164 $command .= " -input"; 165 } else { 166 # Want the reference because we're magicking the input 167 $command .= " -template"; 168 } 169 170 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 171 run(command => $command, verbose => $verbose); 172 unless ($success) { 173 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 174 &my_die("Unable to determine convolution inputs: $error_code", $magic_id, $node, $error_code); 175 } 176 177 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 178 &my_die("Unable to parse metadata config doc", $magic_id, $node, $PS_EXIT_PROG_ERROR); 179 180 my $inputs = parse_md_list($metadata) or 181 &my_die("Unable to parse metadata list", $magic_id, $node, $PS_EXIT_PROG_ERROR); 182 &my_die("Unexpected number of outputs", $magic_id, $node, $PS_EXIT_PROG_ERROR) unless scalar @$inputs == 1; 183 my $input = $$inputs[0]; 184 my $path = $input->{path_base}; # Path of interest 185 if (defined $input->{warp_id} and $input->{warp_id} > 0) { 186 $image = $ipprc->filename("PSWARP.OUTPUT", $path); 187 $mask = $ipprc->filename("PSWARP.OUTPUT.MASK", $path); 188 } elsif (defined $input->{stack_id} and $input->{stack_id} > 0) { 189 $image = $ipprc->filename("PPSTACK.UNCONV", $path); 190 $mask = $ipprc->filename("PPSTACK.UNCONV.MASK", $path); 191 } 192 &my_die("Unable to determine image and mask name", $magic_id, $node, $PS_EXIT_PROG_ERROR) unless defined $image and defined $mask; 193 } 194 195 { 196 &my_die("Unable to find image and mask", $magic_id, $node, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($image) and $ipprc->file_exists($mask); 197 198 my $command = "$ppSubConvolve $tempPath -image $image -mask $mask -kernel $kernel"; 199 $command .= " -reference" unless $innode->{inverse}; 200 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 201 run(command => $command, verbose => $verbose); 202 unless ($success) { 203 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 204 &my_die("Unable to create template image: $error_code", $magic_id, $node, $error_code); 205 } 206 207 $template = $ipprc->filename("PPSUB.INPUT.CONV", $tempPath) or &my_die("Unable to determine filename for created template", $magic_id, $node, $PS_EXIT_PROG_ERROR); 208 $template = $ipprc->file_resolve($template) or &my_die("Unable to resolve filename for created template", $magic_id, $node, $PS_EXIT_PROG_ERROR); 209 &my_die("Unable to find created template", $magic_id, $node, $PS_EXIT_PROG_ERROR) unless $ipprc->file_exists($template); 210 push @deletions, $template; 211 } 212 } 140 213 141 214 $command .= " --detect --image $image --mask $mask --weight $weight -k $template"; … … 223 296 file_check( $output ); 224 297 } 298 299 foreach my $file (@deletions) { 300 print "Deleting $file...\n"; 301 $ipprc->file_delete($file); 302 } 303 225 304 } else { 226 305 print "Skipping command: $command\n"; 227 306 } 307 228 308 } 229 309 … … 387 467 } 388 468 389 sub resolve_template390 {391 my $node = shift;392 393 my $path_base = $node->{diff_path_base}; # Base name for name394 my $image = $node->{inverse} ? "PPSUB.INPUT.CONV" : "PPSUB.REF.CONV"; # File rule of interest395 396 $image = $ipprc->file_resolve($ipprc->filename($image, $path_base));397 398 return $image399 }400 401 469 sub file_check 402 470 {
Note:
See TracChangeset
for help on using the changeset viewer.
