- Timestamp:
- Mar 5, 2012, 5:19:48 PM (14 years ago)
- Location:
- branches/meh_branches/ppstack_test
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippScripts/scripts/magic_destreak.pl (modified) (10 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
branches/meh_branches/ppstack_test
- Property svn:mergeinfo changed
-
branches/meh_branches/ppstack_test/ippScripts/scripts/magic_destreak.pl
- Property svn:mergeinfo set to
r31435 r33415 35 35 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); 36 36 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 37 my $dvoImageOverlaps = can_run('dvoImageOverlaps') or (warn "Can't find dvoImageOverlaps" and $missing_tools = 1); 37 38 if ($missing_tools) { 38 39 warn("Can't find required tools."); … … 45 46 my ($outroot, $recoveryroot, $magicked); 46 47 my ($replace, $release); 48 my ($diff_tess_id, $mismatched_tess); 47 49 my ($dbname, $save_temps, $verbose, $no_update, $no_op, $logfile); 48 50 … … 60 62 'stage_id=s' => \$stage_id, # exp_id, chip_id, warp_id, or diff_id 61 63 'component=s' => \$component, # the class_id or skycell_id 64 'mismatched_tess'=> \$mismatched_tess, # true if tess_id of input does not match tess_id of the diff used for magic 65 'diff_tess_id=s' => \$diff_tess_id, # tess_id of diffRun used to compute the streaks 62 66 'uri=s' => \$uri, # uri of the input image 63 67 'path_base=s' => \$path_base, # path_base of the input … … 95 99 96 100 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 97 $ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_ds_id, $component, $PS_EXIT_SYS_ERROR ) if $logfile; 101 102 if ($logfile) { 103 $ipprc->redirect_to_logfile($logfile) or my_die( "Unable to redirect output", $magic_ds_id, $component, $PS_EXIT_SYS_ERROR ); 104 print "\n\n"; 105 print "Continuing script $0 on $host at $date\n\n"; 106 } 98 107 99 108 $cam_reduction = 'DEFAULT' if !$cam_reduction or ($cam_reduction eq 'NULL'); … … 106 115 if (($stage eq "raw") or ($stage eq "chip") or $stage eq "chip_bg") { 107 116 $class_id = $component; 108 $skycell_args = " -class_id $component";117 $skycell_args = " -class_id"; 109 118 } elsif ($stage eq "warp" or $stage eq "warp_bg") { 110 119 $skycell_id = $component; 111 $skycell_args = " -skycell_id $component";120 $skycell_args = " -skycell_id"; 112 121 } elsif ($stage eq "diff") { 113 122 $skycell_id = $component; … … 176 185 } 177 186 178 my $statsFile = "$outroot/$exp_id.mds.$magic_ds_id.$stage_id.$component.stats"; 187 # XXX: create a DESTREAK file rule. For now just steal one that will work 188 my $error; 189 my $statsFile = $ipprc->prepare_output("PSASTRO.STATS", "$outroot/$exp_id.mds.$magic_ds_id.$stage_id.$component", undef, 1, \$error) or &my_die("failed to prepare output for stats", $magic_ds_id, $component, $error); 179 190 180 191 my $backup_path_base; … … 215 226 my ($sfh, $skycell_list); 216 227 if ($skycell_args) { 217 my $command = "$magicdstool -magic_ds_id $magic_ds_id -getskycells $skycell_args"; 218 $command .= " -dbname $dbname" if defined $dbname; 219 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 220 run(command => $command, verbose => $verbose); 221 unless ($success) { 222 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 223 &my_die("Unable to perform magicdstool -diffskyfile $skycell_args: $error_code", $magic_ds_id, $component, $error_code); 224 } 225 226 my $getskycells_output = join "", @$stdout_buf; 227 if ($getskycells_output) { 228 my $metadata = $mdcParser->parse($getskycells_output) or 229 &my_die("Unable to parse metadata config doc", $magic_ds_id, $component, $PS_EXIT_PROG_ERROR); 230 231 my $skycells = parse_md_list($metadata) or 232 &my_die("Unable to parse metadata list", $magic_ds_id, $component, $PS_EXIT_PROG_ERROR); 233 234 ($sfh, $skycell_list) = tempfile( "/tmp/skycell_list.XXXX", UNLINK => !$save_temps); 235 236 foreach my $skycell (@$skycells) { 237 my $skycell_uri; 238 if ($skycell->{data_state} eq "full" and $skycell->{quality} = 0) { 239 $skycell_uri = $ipprc->filename("PPSUB.OUTPUT", $skycell->{path_base}); 240 } else { 241 # diff run must have been cleaned up, need to create this skycell file on the fly 242 if (!defined $temp_dir ) { 243 $temp_dir = tempdir( CLEANUP => !$save_temps); 228 my $command = "$magicdstool -magic_ds_id $magic_ds_id -getskycells"; 229 $command .= " $skycell_args"; 230 $command .= " -dbname $dbname" if $dbname; 231 my @diff_components; 232 if ($mismatched_tess) { 233 # tessellation for this skycell does not match the tessellation used for the magic analysis 234 # used to calculate the streaks file 235 @diff_components = get_overlaps($path_base, $component, $diff_tess_id); 236 } else { 237 @diff_components = ($component); 238 } 239 240 # hash of uris by skycell. 241 my %diff_skycells; 242 foreach my $component (@diff_components) { 243 my $this_command = "$command $component"; 244 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 245 run(command => $this_command, verbose => $verbose); 246 unless ($success) { 247 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 248 &my_die("Unable to perform magicdstool -diffskyfile $skycell_args: $error_code", $magic_ds_id, $component, $error_code); 249 } 250 251 my $getskycells_output = join "", @$stdout_buf; 252 if ($getskycells_output) { 253 my $metadata = $mdcParser->parse($getskycells_output) or 254 &my_die("Unable to parse metadata config doc", $magic_ds_id, $component, $PS_EXIT_PROG_ERROR); 255 256 my $skycells = parse_md_list($metadata) or 257 &my_die("Unable to parse metadata list", $magic_ds_id, $component, $PS_EXIT_PROG_ERROR); 258 259 foreach my $skycell (@$skycells) { 260 my $skycell_uri; 261 $skycell->{quality} = undef; 262 # XXXXXXXX remake all skycells to avoid dead instances (ipp064) 263 if (0 and $skycell->{data_state} eq "full" and $skycell->{quality} == 0) { 264 $skycell_uri = $ipprc->filename("PPSUB.OUTPUT", $skycell->{path_base}); 265 my $skycell_id = $skycell->{skycell_id}; 266 $diff_skycells{$skycell_id} = $skycell_uri; 267 } else { 268 # diff run must have been cleaned up, need to create this skycell file on the fly 269 if (!defined $temp_dir ) { 270 $temp_dir = tempdir( CLEANUP => !$save_temps); 271 } 272 my $skycell_id = $skycell->{skycell_id}; 273 if (!$diff_skycells{$skycell_id}) { 274 $skycell_uri = "$temp_dir/$skycell_id"; 275 $ipprc->skycell_file($skycell->{tess_id}, $skycell_id, $skycell_uri, $verbose) or 276 &my_die("failed to create skycell file for $skycell_id", $magic_ds_id, $component, $PS_EXIT_PROG_ERROR); 277 } 278 $diff_skycells{$skycell_id} = $skycell_uri; 244 279 } 245 my $skycell_id = $skycell->{skycell_id};246 $skycell_uri = "$temp_dir/$skycell_id";247 $ipprc->skycell_file($skycell->{tess_id}, $skycell_id, $skycell_uri, $verbose) or248 &my_die("failed to create skycell file for $skycell_id", $magic_ds_id, $component, $PS_EXIT_PROG_ERROR);249 280 } 250 print $sfh "$skycell_uri\n"; 251 } 252 close $sfh 253 } 281 } 282 } 283 # write the skycell list file 284 ($sfh, $skycell_list) = tempfile( "/tmp/skycell_list.XXXX", UNLINK => !$save_temps); 285 foreach my $skycell_id (keys %diff_skycells) { 286 print $sfh $diff_skycells{$skycell_id} . "\n"; 287 } 288 close $sfh 254 289 } 255 290 … … 360 395 $command .= " -chip_mask $ch_mask" if defined $ch_mask; 361 396 $command .= " -weight $weight" if defined $weight; 362 if ((defined($sources))&&($ipprc->file_exists($sources))) { 363 $command .= " -sources $sources" if defined $sources; 364 } 365 else { 366 print "Did not add sources because they do not appear to exist. This may be an error.\n"; 367 } 397 $command .= " -sources $sources" if defined $sources; 368 398 $command .= " -skycelllist $skycell_list" if defined $skycell_list; 369 399 $command .= " -replace" if $replace; … … 475 505 476 506 my $statsFlags; 477 if ( $stage ne "camera") {507 if (!$no_op and $stage ne "camera") { 478 508 file_check($statsFile); 479 509 { … … 595 625 } 596 626 627 # @diff_components = get_overlaps($path_base, $component, $tess_id, $diff_tess_id); 628 sub get_overlaps { 629 my $path_base = shift; 630 my $component = shift; 631 my $diff_tess_id = shift; 632 633 my $tess_dir = $ipprc->tessellation_catdir( $diff_tess_id ); 634 my $catdir = $ipprc->convert_filename_absolute($tess_dir); 635 636 my $cmf = $ipprc->file_resolve("$path_base.cmf"); 637 &my_die("Unable to resolve $path_base.$cmf", $magic_ds_id, $component, $PS_EXIT_SYS_ERROR) unless $cmf; 638 639 my $command = "$dvoImageOverlaps -D CATDIR $catdir -accept-astrom $cmf"; 640 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 641 run(command => $command, verbose => $verbose); 642 unless ($success) { 643 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 644 &my_die("Unable to perform dvoImageOverlaps $error_code", $magic_ds_id, $component, 645 $error_code); 646 } 647 my @list; 648 my $output = join "\n", @$stdout_buf; 649 if ($output) { 650 foreach my $line (split "\n", $output) { 651 my (undef, undef, $skycell_id) = split " ", $line; 652 push @list, $skycell_id; 653 } 654 } 655 return @list 656 } 657 597 658 598 659 sub my_die
Note:
See TracChangeset
for help on using the changeset viewer.
