IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 5, 2008, 12:39:33 PM (18 years ago)
Author:
bills
Message:

cleanup and update processing for chip stage

File:
1 edited

Legend:

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

    r19333 r19397  
    5959
    6060my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
     61$logDest .= "_update" if $run_state eq "update";
    6162
    6263$ipprc->redirect_output($logDest) if $redirect;
     
    134135my $outputStats   = $ipprc->filename("PPIMAGE.STATS",       $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
    135136my $traceDest     = $ipprc->filename("TRACE.IMFILE",        $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
     137my $configuration = $ipprc->filename("PPIMAGE.CONFIG",      $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
    136138
    137139# Run ppImage
     
    140142    ## XXX also stats: output should be implied by $outroot
    141143    my $command;
     144    my $do_stats = 1;
    142145
    143146    if ($run_state eq "new") {
    144147        $command  = "$ppImage -file $uri $outroot";
    145148        $command .= " -recipe PPIMAGE $recipe";
     149        $command .= " -threads $threads" if defined $threads;
     150        $command .= " -dbname $dbname" if defined $dbname;
     151        $command .= " -dumpconfig $configuration";
     152        $command .= " -tracedest $traceDest -log $logDest";
     153    } else {
     154
     155        $do_stats = 0; # XXX write stats to an alternate file and compare?
     156
     157        $command  = "$ppImage -file $uri $outroot";
     158        $command .= " -ipprc $configuration";
     159        $command .= " -threads $threads" if defined $threads;
     160        $command .= " -dbname $dbname" if defined $dbname;
     161        $command .= " -tracedest ${traceDest}_update -log $logDest";
     162        $command .= " -Db PPIMAGE:PHOTOM FALSE";
     163    }
     164    if ($do_stats) {
    146165        $command .= " -recipe PPSTATS CHIPSTATS";
    147166        $command .= " -stats $outputStats";
    148         $command .= " -threads $threads" if defined $threads;
    149         $command .= " -dbname $dbname" if defined $dbname;
    150         $command .= " -tracedest $traceDest -log $logDest";
    151     } else {
    152         ## for the UPDATE processing, we need to determine the config file
    153         my $configuration = $ipprc->filename("PPIMAGE.CONFIG", $outroot, $class_id) or
    154             &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
    155 
    156         $command  = "$ppImage -file $uri $outroot";
    157         $command .= " -ipprc $configuration";
    158         # $command .= " -stats $outputStats"; XXX write stats to an alternate file and compare?
    159         $command .= " -threads $threads" if defined $threads;
    160         $command .= " -dbname $dbname" if defined $dbname;
    161         # $command .= " -tracedest $traceDest -log $logDest"; XXX use an alternate trace and log file?
    162         $command .= "-Db PPIMAGE:PHOTOM FALSE";
    163167    }
    164168
     
    199203    &my_die("Couldn't find expected output file: $outputBin1\n",   $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputBin1);
    200204    &my_die("Couldn't find expected output file: $outputBin2\n",   $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputBin2);
    201     &my_die("Couldn't find expected output file: $outputStats\n",  $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputStats);
    202 
    203     # Get the statistics on the processed image
    204     my $statsFile;              # File handle
    205     open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    206     my @contents = <$statsFile>; # Contents of file
    207     close $statsFile;
    208 
    209     # parse the statistics MDC file
    210     my $mdcParser = PS::IPP::Metadata::Config->new();   # Parser for metadata config files
    211     my $metadata = $mdcParser->parse(join "", @contents);
    212     unless ($metadata) {
    213         &my_die("Unable to parse metadata config doc", $exp_id, $chip_id, $class_id, $PS_EXIT_PROG_ERROR);
    214     }
    215 
    216     # extract the stats from the metadata
    217     unless ($stats->parse($metadata)) {
    218         &my_die("Failure extracting metadata from the statistics output file.\n", $exp_id, $chip_id, $class_id, $PS_EXIT_PROG_ERROR);
    219     }
    220 }
    221 
    222 # command to update database
    223 my $command = "$chiptool -addprocessedimfile";
    224 $command .= " -exp_id $exp_id";
    225 $command .= " -chip_id $chip_id";
    226 $command .= " -class_id $class_id";
    227 $command .= " -uri $outputImage";
    228 $command .= " -path_base $outroot";
    229 $command .= " -hostname $host" if defined $host;
    230 $command .= " -dbname $dbname" if defined $dbname;
    231 $command .= $stats->cmdflags();
     205
     206    if ($do_stats) {
     207        &my_die("Couldn't find expected output file: $outputStats\n",  $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputStats);
     208
     209        # Get the statistics on the processed image
     210        my $statsFile;              # File handle
     211        open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     212        my @contents = <$statsFile>; # Contents of file
     213        close $statsFile;
     214
     215        # parse the statistics MDC file
     216        my $mdcParser = PS::IPP::Metadata::Config->new();   # Parser for metadata config files
     217        my $metadata = $mdcParser->parse(join "", @contents);
     218        unless ($metadata) {
     219            &my_die("Unable to parse metadata config doc", $exp_id, $chip_id, $class_id, $PS_EXIT_PROG_ERROR);
     220        }
     221
     222        # extract the stats from the metadata
     223        unless ($stats->parse($metadata)) {
     224            &my_die("Failure extracting metadata from the statistics output file.\n", $exp_id, $chip_id, $class_id, $PS_EXIT_PROG_ERROR);
     225        }
     226    }
     227}
     228
     229my $command;
     230if ($run_state eq 'new') {
     231    # command to update database
     232    $command = "$chiptool -addprocessedimfile";
     233    $command .= " -exp_id $exp_id";
     234    $command .= " -chip_id $chip_id";
     235    $command .= " -class_id $class_id";
     236    $command .= " -uri $outputImage";
     237    $command .= " -path_base $outroot";
     238    $command .= " -hostname $host" if defined $host;
     239    $command .= " -dbname $dbname" if defined $dbname;
     240    $command .= $stats->cmdflags();
     241} else {
     242    $command = "$chiptool -tofullimfile";
     243    $command .= " -chip_id $chip_id";
     244    $command .= " -class_id $class_id";
     245    $command .= " -dbname $dbname" if defined $dbname;
     246}
    232247
    233248# Add the processed file to the database
     
    251266    my $class_id = shift; # Class identifier
    252267    my $exit_code = shift; # Exit code to add
    253     # outputImage and outroot are globals
     268    # run_state, outputImage, and outroot are globals
    254269
    255270    carp($msg);
    256271    if (defined $chip_id and defined $class_id and not $no_update) {
    257         my $command = "$chiptool -addprocessedimfile";
    258         $command .= " -exp_id $exp_id";
     272        my $command;
     273        if ($run_state eq 'new') {
     274            $command = "$chiptool -addprocessedimfile";
     275            $command .= " -exp_id $exp_id";
     276            $command .= " -uri $outputImage";
     277            $command .= " -path_base $outroot";
     278            $command .= " -hostname $host" if defined $host;
     279        } else {
     280            $command .= "$chiptool -updateprocessedimfile";
     281        }
    259282        $command .= " -chip_id $chip_id";
    260283        $command .= " -class_id $class_id";
    261284        $command .= " -code $exit_code";
    262         $command .= " -uri $outputImage";
    263         $command .= " -path_base $outroot";
    264         $command .= " -hostname $host" if defined $host;
    265285        $command .= " -dbname $dbname" if defined $dbname;
    266286        system ($command);
Note: See TracChangeset for help on using the changeset viewer.