IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19680


Ignore:
Timestamp:
Sep 23, 2008, 10:01:25 AM (18 years ago)
Author:
bills
Message:

update processing for stack

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/stack_skycell.pl

    r19674 r19680  
    5555
    5656my $logDest = "$outroot.log";
     57
     58my $do_stats;
     59if ($run_state eq 'new') {
     60    $do_stats = 1;
     61} else {
     62    $logDest .= ".update";
     63}
    5764$ipprc->redirect_output($logDest) if $redirect;
    5865
     
    192199my $outputStats = $ipprc->filename("SKYCELL.STATS", $outroot);
    193200my $traceDest = $ipprc->filename("TRACE.EXP", $outroot);
     201$traceDest .= ".update" if $run_state eq 'update';
    194202my $configuration = $ipprc->filename("PPSTACK.CONFIG", $outroot);
     203
     204# for update we need to resolve the config filename here because the code that reads it
     205# doesn't know how to resolve paths. (The information is stored in the configuration file)
     206$configuration = $ipprc->file_resolve($configuration) if ($run_state eq 'update');
    195207
    196208# Perform stacking
    197209unless ($no_op) {
    198210    my $command = "$ppStack $listName $outroot";
    199     $command .= " -stats $outputStats";
     211    $command .= " -stats $outputStats" if $do_stats;;
    200212    $command .= " -recipe PPSUB STACK";
    201     $command .= " -recipe PPSTATS WARPSTATS";
     213    $command .= " -recipe PPSTATS WARPSTATS" if $do_stats;;
    202214    $command .= " -F PSPHOT.PSF.SAVE PSPHOT.PSF.SKY.SAVE";
    203215    $command .= " -F PSPHOT.OUTPUT PSPHOT.OUT.CMF.MEF";
     
    207219    $command .= " -debug-stack" if defined $debug;
    208220    $command .= " -tracedest $traceDest -log $logDest";
    209     $command .= " -dumpconfig $configuration";
    210221    $command .= " -dbname $dbname" if defined $dbname;
     222    if ($run_state eq 'new') {
     223        $command .= " -dumpconfig $configuration";
     224    } else {
     225        $command .= " -ipprc $configuration";
     226    }
     227       
    211228
    212229    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    222239#   &my_die("Couldn't find expected output file: $bin1Name",    $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin1Name);
    223240#   &my_die("Couldn't find expected output file: $bin2Name",    $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin2Name);
    224     &my_die("Couldn't find expected output file: $outputStats", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputStats);
    225 
    226     # Get the statistics on the stacked image
    227     my $statsFile;              # File handle
    228     open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $stack_id, $PS_EXIT_SYS_ERROR);
    229     my @contents = <$statsFile>; # Contents of file
    230     close $statsFile;
    231     my $metadata = $mdcParser->parse(join "", @contents) or
    232         &my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR);
    233     $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $stack_id, $PS_EXIT_PROG_ERROR);
     241    &my_die("Couldn't find expected output file: $outputStats", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputStats) or !$do_stats;
     242
     243    if ($do_stats) {
     244        # Get the statistics on the stacked image
     245        my $statsFile;              # File handle
     246        open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $stack_id, $PS_EXIT_SYS_ERROR);
     247        my @contents = <$statsFile>; # Contents of file
     248        close $statsFile;
     249        my $metadata = $mdcParser->parse(join "", @contents) or
     250            &my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR);
     251        $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $stack_id, $PS_EXIT_PROG_ERROR);
     252    }
    234253}
    235254
     
    238257    # Add the stack result
    239258    {
    240         my $command = "$stacktool -addsumskyfile -stack_id $stack_id -uri $outputName -path_base $outroot";
    241         $command .= $stats->cmdflags();
    242         $command .= " -hostname $host" if defined $host;
     259        my $command = "$stacktool";
     260        my $mode;
     261        if ($run_state eq 'new') {
     262            $mode = "-addsumskyfile";
     263            $command .= " -uri $outputName -path_base $outroot";
     264            $command .= " -hostname $host" if defined $host;
     265        } else {
     266            $mode = "-updaterun -state full";
     267        }
     268        $command .= " $mode -stack_id $stack_id";
     269        $command .= $stats->cmdflags() if $do_stats;
    243270        $command .= " -dbname $dbname" if defined $dbname;
    244271
     
    247274        unless ($success) {
    248275            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    249             &my_die("Unable to perform stacktool -addsumskyfile: $error_code", $stack_id, $error_code);
     276            &my_die("Unable to perform stacktool $mode $error_code", $stack_id, $error_code);
    250277        }
    251278    }
    252279
    253     # Register the run as completed
    254     # XXX why is this needed?  the stackRun is set to 'full' by the stacktool -addsumskyfile command...
    255     if (0) {
    256         my $command = "$stacktool -updaterun -stack_id $stack_id -state full"; # Command to run stacktool
    257         $command .= " -dbname $dbname" if defined $dbname;
    258 
    259         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    260             run(command => $command, verbose => $verbose);
    261         unless ($success) {
    262             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    263             warn("Unable to perform stacktool -updaterun: $error_code\n");
    264             exit($error_code);
    265         }
    266     }
    267280}
    268281
     
    276289    carp($msg);
    277290    if (defined $stack_id and not $no_update) {
    278         my $command = "$stacktool -addsumskyfile -stack_id $stack_id -code $exit_code";
    279         $command .= " -hostname $host" if defined $host;
     291        my $command = "$stacktool -stack_id $stack_id -code $exit_code";
     292        if ($run_state eq 'new') {
     293            $command .= " -addsumskyfile";
     294            $command .= " -hostname $host" if defined $host;
     295        } else {
     296            $command .= " -updatesumskyfile";
     297        }
    280298        $command .= " -dbname $dbname" if defined $dbname;
    281299        system ($command);
Note: See TracChangeset for help on using the changeset viewer.