Changeset 29501
- Timestamp:
- Oct 20, 2010, 3:38:35 PM (16 years ago)
- Location:
- tags/ipp-20100823/ippScripts/scripts
- Files:
-
- 2 edited
-
magic_destreak.pl (modified) (9 diffs, 1 prop)
-
magic_process.pl (modified) (15 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
tags/ipp-20100823/ippScripts/scripts/magic_destreak.pl
- Property svn:mergeinfo set to
r28931 r29501 42 42 # Parse the command-line arguments 43 43 my ($magic_ds_id, $camera, $streaks, $inv_streaks, $exp_id, $stage, $stage_id, $component, $uri, $path_base, $cam_path_base, $cam_reduction); 44 my ($streaks_path_base, $inv_streaks_path_base); 44 45 my ($outroot, $recoveryroot, $magicked); 45 46 my ($replace, $release); … … 49 50 'magic_ds_id=s' => \$magic_ds_id,# Magic destreak run identifier 50 51 'camera=s' => \$camera, # camera for evaluating file rules 52 'streaks_path_base=s' => \$streaks_path_base, # path_base for streaks data 53 'inv_streaks_path_base=s' => \$inv_streaks_path_base, #path_base for streaks from inverse diff 54 'inv_streaks=s' => \$inv_streaks,# file containing the list of streaks from the inverse diff 51 55 'streaks=s' => \$streaks, # file containing the list of streaks 52 56 'inv_streaks=s' => \$inv_streaks,# file containing the list of streaks from the inverse diff … … 78 82 defined $camera and 79 83 defined $streaks and 84 defined $streaks_path_base and 80 85 defined $stage and 81 86 defined $stage_id and … … 108 113 &my_die("Invalid value for stage: $stage", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 109 114 } 115 $inv_streaks_path_base = undef if defined($inv_streaks_path_base) and ($inv_streaks_path_base eq "NULL"); 110 116 $inv_streaks = undef if defined($inv_streaks) and ($inv_streaks eq "NULL"); 111 117 … … 240 246 my ($allstreaks_fh, $allstreaks_name); 241 247 248 # Set name of streaks files from their path_base. Note. ne 'NULL' test is for backward compatability 249 # with runs that don't have path_base set yet 250 if ($streaks_path_base ne 'NULL') { 251 $streaks = "$streaks_path_base.streaks"; 252 } 253 if ($inv_streaks_path_base and ($inv_streaks_path_base ne 'NULL')) { 254 $inv_streaks = "$inv_streaks_path_base.streaks"; 255 } 256 257 my $streaks_resolved = $ipprc->file_resolve($streaks) or &my_die("failed to resolve streaks file $streaks", $magic_ds_id, $component, $PS_EXIT_SYS_ERROR); 258 my $inv_streaks_resolved; 259 if ($inv_streaks) { 260 $inv_streaks_resolved = $ipprc->file_resolve($inv_streaks) or &my_die("failed to resolve inverse streaks file $inv_streaks", $magic_ds_id, $component, $PS_EXIT_SYS_ERROR); 261 } 262 263 242 264 if ($stage eq "raw") { 243 265 $image = $uri; … … 301 323 $sources = $ipprc->filename("PPSUB.OUTPUT.SOURCES", $path_base); 302 324 303 if ($inv_streaks ) {325 if ($inv_streaks_resolved) { 304 326 # create a temporary file containing the contents of the 305 327 # two streaks files … … 307 329 UNLINK => !$save_temps); 308 330 309 combine_streaks($allstreaks_fh, $streaks , $inv_streaks);331 combine_streaks($allstreaks_fh, $streaks_resolved, $inv_streaks_resolved); 310 332 311 333 # apply the combined streaks to both the forward and inverse diffs 312 $streaks = $allstreaks_name;334 $streaks_resolved = $allstreaks_name; 313 335 } 314 336 } 315 337 316 338 { 317 my $command = "$streaksremove -stage $stage -tmproot $tmproot -streaks $streaks -image $image";339 my $command = "$streaksremove -stage $stage -tmproot $tmproot -streaks $streaks_resolved -image $image"; 318 340 319 341 $command .= " -stats $statsFile"; … … 340 362 } 341 363 } 342 if (($stage eq "diff") and $inv_streaks ) {364 if (($stage eq "diff") and $inv_streaks_resolved) { 343 365 $image = $ipprc->filename("PPSUB.INVERSE", $path_base); 344 366 $mask = $ipprc->filename("PPSUB.INVERSE.MASK", $path_base); … … 349 371 my $invStatsFile = "$outroot/$exp_id.mds.$magic_ds_id.$stage_id.$component.inv.stats"; 350 372 351 my $command = "$streaksremove -stage $stage -tmproot $tmproot -streaks $streaks -image $image";373 my $command = "$streaksremove -stage $stage -tmproot $tmproot -streaks $streaks_resolved -image $image"; 352 374 $command .= " -stats $invStatsFile"; 353 375 -
tags/ipp-20100823/ippScripts/scripts/magic_process.pl
- Property svn:mergeinfo set to
r28137 r29501 17 17 use IPC::Cmd 0.36 qw( can_run run ); 18 18 use File::Temp qw( tempfile ); 19 use File::Copy; 19 20 use PS::IPP::Metadata::Config; 20 21 use PS::IPP::Metadata::List qw( parse_md_list ); … … 41 42 42 43 # Parse the command-line arguments 43 my ($magic_id, $node, $camera, $dbname, $baseroot, $save_temps, $verbose, $no_update, $no_op, $logfile );44 my ($magic_id, $node, $camera, $dbname, $baseroot, $save_temps, $verbose, $no_update, $no_op, $logfile, $final_outroot); 44 45 45 46 GetOptions( … … 49 50 'dbname=s' => \$dbname, # Database name 50 51 'baseroot=s' => \$baseroot, # Output root name 52 'final-outroot=s' => \$final_outroot, # location for final outputs 51 53 'save-temps' => \$save_temps, # Save temporary files? 52 54 'verbose' => \$verbose, # Print stuff? … … 86 88 87 89 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 90 91 # list of VerifyStreaks input and output files to copy to nebulous 92 my @verify_outputs = qw( 93 clusterPos.txt 94 duplicate.png 95 mask.png 96 original.png 97 original.fits 98 residual.png 99 residual.fits 100 clusters.list 101 ); 88 102 89 103 ### Get a list of inputs … … 311 325 } 312 326 313 314 327 ### Input result into database 315 328 { … … 334 347 335 348 if ($node eq "root") { 349 # XXXX: Since we just added the result above, all of these my_dies are going to fail 350 # with a duplicate row error. 351 # see more comments below 336 352 my $streaks_file = "$outroot.streaks"; 337 353 my $resolved = $ipprc->file_resolve($streaks_file); … … 349 365 } 350 366 351 &run_verifystreaks($baseroot);352 367 353 368 my $exp_id; # Exposure identifier … … 366 381 } 367 382 383 &run_verifystreaks($baseroot, $exp_id); 384 368 385 { 369 386 my $astrom = $ipprc->filename("PSASTRO.OUTPUT", $cam_path); # Astrometry file … … 383 400 } 384 401 402 my $output_streaks = $final_outroot . ".streaks"; 403 if ($output_streaks and ($output_streaks ne $streaks_file)) { 404 copy_to_nebulous($ipprc, $streaks_file, $output_streaks, 1); 405 foreach my $f (@verify_outputs) { 406 my $src = "$baseroot.verify/${exp_id}_$f"; 407 my $dest = "$final_outroot.${f}"; 408 copy_to_nebulous($ipprc, $src, $dest, 1); 409 } 410 } else { 411 $output_streaks = $streaks_file; 412 } 385 413 386 414 { 387 415 my $command = "$magictool -addmask"; 388 416 $command .= " -magic_id $magic_id"; 389 $command .= " -uri $ streaks_file";417 $command .= " -uri $final_outroot"; 390 418 $command .= " -streaks $num_streaks"; 391 419 $command .= " -dbname $dbname" if defined $dbname; … … 397 425 unless ($success) { 398 426 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 399 # This isn't going to work because our result was already entered. 427 # XXX: This my_die isn't going to work because the result for the root node was already 428 # added to the database up above. 429 # There is a magicMask has a fault column. Maybe we should 430 # use that and add a new revert mode that deletes the magicMask and the magicNodeResult 431 # for the root node. 400 432 &my_die("Unable to perform magictool -addmask: $error_code", $magic_id, $node, $error_code); 401 433 } … … 406 438 } 407 439 440 408 441 ### Pau. 409 442 … … 411 444 412 445 my $baseroot = shift; 446 my $exp_id = shift; 413 447 414 448 unless ($VerifyStreaks) { … … 431 465 my @files = <$baseroot.*.clusters>; 432 466 433 unless (open ($FILE, ">$outdir/clusters.list")) { 434 print "failed to create cluster file $outdir/clusters.list\n"; 467 my $clusters_list = "$outdir/${exp_id}_clusters.list"; 468 unless (open ($FILE, ">$clusters_list")) { 469 print "failed to create cluster file $clusters_list\n"; 435 470 return 1; 436 471 } … … 441 476 close ($FILE); 442 477 if ($status) { 443 print "failed to create cluster file $ outdir/clusters.list\n";478 print "failed to create cluster file $clusters_list\n"; 444 479 return 1; 445 480 } 446 481 447 my $command = "$VerifyStreaks --out $outdir --clusters $ outdir/clusters.list $baseroot.root.streakMap";482 my $command = "$VerifyStreaks --out $outdir --clusters $clusters_list $baseroot.root.streakMap"; 448 483 449 484 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 513 548 } 514 549 550 # Copy a file to nebulous and optionally replicate it 551 # We should consider making this an ipprc function. For now try it here so we can print 552 # the right error messages 553 sub copy_to_nebulous { 554 my $ipprc = shift; 555 my $src = shift; 556 my $dest = shift; 557 my $replicate = shift; 558 559 print "copying $src to $dest\n"; 560 561 $ipprc->file_exists($src) or 562 &my_die("expected output file does not exist: $src", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR); 563 564 # copy the file to it's final destination - which is presumably in nebulous 565 # we delete it so that all instances are deleted in case it has been replicated 566 if ($ipprc->file_exists($dest)) { 567 $ipprc->file_delete($dest) or 568 &my_die("failed to delete existing file: $dest", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR); 569 } 570 my $dest_resolved = $ipprc->file_resolve($dest, 'create'); 571 &my_die("failed to resolve $dest", $PS_EXIT_UNKNOWN_ERROR) if !$dest_resolved; 572 573 copy ($src, $dest_resolved) or 574 &my_die("failed to copy $src to $dest", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR); 575 576 if ($replicate and (file_scheme($dest) eq 'neb')) { 577 my $neb = $ipprc->nebulous(); 578 $neb->setxattr($dest, 'user.copies', 2, 'create') or 579 &my_die("failed to set user.copies for $dest", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR); 580 581 $neb->replicate($dest) or 582 &my_die("failed to replicate $dest", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR); 583 } 584 } 585 515 586 sub my_die 516 587 {
Note:
See TracChangeset
for help on using the changeset viewer.
