IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 15, 2008, 2:24:27 PM (18 years ago)
Author:
bills
Message:

update processing for camera stage

File:
1 edited

Legend:

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

    r19466 r19561  
    2727
    2828my ( $exp_tag, $cam_id, $camera, $outroot, $recipe, $dbname, $reduction, $dvodb, $verbose, $no_update,
    29      $no_op, $redirect, $save_temps );
     29     $no_op, $redirect, $save_temps, $run_state);
    3030GetOptions(
    3131    'exp_tag=s'          => \$exp_tag, # Exposure identifier
     
    3737    'reduction=s'       => \$reduction, # Reduction class
    3838    'dvodb|w=s'         => \$dvodb,  # output DVO database
     39    'run-state=s'       => \$run_state, # 'new' or 'update'
    3940    'verbose'           => \$verbose,   # Print to stdout
    4041    'no-update'         => \$no_update, # Update the database?
     
    5758
    5859my $logDest = $ipprc->filename("LOG.EXP", $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR);
     60if ($run_state eq 'update') {
     61    $logDest .= '.update';
     62}
    5963
    6064$ipprc->redirect_output($logDest) if $redirect;
     
    196200my $fpaStats   = $ipprc->filename("PSASTRO.STATS",      $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR);
    197201my $traceDest  = $ipprc->filename("TRACE.EXP",          $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR);
     202my $configuration = $ipprc->filename("PSASTRO.CONFIG",  $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR);
     203
     204if ($run_state eq 'update') {
     205    $traceDest .= '.update';
     206    $fpaStats .= '.update';
     207}
    198208
    199209# convert supplied DVO database name to UNIX filename
     
    210220
    211221    # Make the jpeg for binning 1
    212     {
     222    if ($run_state eq 'new') {
    213223        my $command = "$ppImage -list $list1Name $outroot -recipe PPIMAGE $recipe1"; # Command to run
    214224        $command .= " -dbname $dbname" if defined $dbname;
     
    224234
    225235    # Make the jpeg for binning 2
    226     {
     236    if ($run_state eq 'new') {
    227237        my $command = "$ppImage -list $list2Name $outroot -recipe PPIMAGE $recipe2"; # Command to run
    228238        $command .= " -dbname $dbname" if defined $dbname;
     
    244254        $command  = "$psastro -list $list3Name $outroot";
    245255        $command .= " -tracedest $traceDest -log $logDest";
    246         $command .= " -stats $fpaStats -recipe PPSTATS CHIPSTATS";
    247256        $command .= " -dbname $dbname" if defined $dbname;
     257
     258        my $do_stats;
     259        if ($run_state eq 'new') {
     260            $command .= " -stats $fpaStats -recipe PPSTATS CHIPSTATS";
     261            $command .= " -dumpconfig $configuration";
     262            $do_stats = 1;
     263        } elsif ($run_state eq 'update') {
     264            $command .= " -ipprc $configuration";
     265        } else {
     266            &my_die("invalid value for run-state: $run_state", $cam_id, $PS_EXIT_CONFIG_ERROR);
     267        }
    248268
    249269        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    255275        # XXX do we want to give an error if astrometry fails here?
    256276        &my_die("Unable to find expected output file: $fpaObjects", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($fpaObjects);
    257         &my_die("Unable to find expected output file: $fpaStats",   $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($fpaObjects);
    258 
    259         # Get the statistics on the processed image
    260         my $statsFile;              # File handle
    261         open $statsFile, $ipprc->file_resolve($fpaStats) or &my_die("Can't open statistics file $fpaStats: $!", $cam_id, $PS_EXIT_SYS_ERROR);
    262         my @contents = <$statsFile>; # Contents of file
    263         close $statsFile;
    264 
    265         # parse the statistics MDC file
    266         my $mdcParser = PS::IPP::Metadata::Config->new();   # Parser for metadata config files
    267         my $metadata = $mdcParser->parse(join "", @contents);
    268         unless ($metadata) {
    269             &my_die("Unable to parse metadata config doc", $cam_id, $PS_EXIT_PROG_ERROR);
    270         }
    271 
    272         # extract the stats from the metadata
    273         unless ($camStats->parse($metadata)) {
    274             &my_die("Failure extracting metadata from the statistics output file.\n", $cam_id, $PS_EXIT_PROG_ERROR);
     277
     278        if ($do_stats) {
     279            &my_die("Unable to find expected output file: $fpaStats",   $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($fpaObjects);
     280
     281            # Get the statistics on the processed image
     282            my $statsFile;              # File handle
     283            open $statsFile, $ipprc->file_resolve($fpaStats) or &my_die("Can't open statistics file $fpaStats: $!", $cam_id, $PS_EXIT_SYS_ERROR);
     284            my @contents = <$statsFile>; # Contents of file
     285            close $statsFile;
     286
     287            # parse the statistics MDC file
     288            my $mdcParser = PS::IPP::Metadata::Config->new();   # Parser for metadata config files
     289            my $metadata = $mdcParser->parse(join "", @contents);
     290            unless ($metadata) {
     291                &my_die("Unable to parse metadata config doc", $cam_id, $PS_EXIT_PROG_ERROR);
     292            }
     293
     294            # extract the stats from the metadata
     295            unless ($camStats->parse($metadata)) {
     296                &my_die("Failure extracting metadata from the statistics output file.\n", $cam_id, $PS_EXIT_PROG_ERROR);
     297            }
    275298        }
    276299
    277300        # run addstar on the output fpaObjects (if a DVO database is defined)
    278         if (defined $dvodbReal) {
     301        if (defined $dvodbReal and ($run_state eq 'new')) {
    279302
    280303            ## XXX the camera analysis can either save the full set of
     
    319342}
    320343
    321 my $fpaCommand = "$camtool -addprocessedexp";
    322 $fpaCommand .= " -cam_id $cam_id";
    323 $fpaCommand .= " -uri UNKNOWN";
    324 $fpaCommand .= " -path_base $outroot";
    325 $fpaCommand .= " -hostname $host" if defined $host;
     344
     345my $fpaCommand = "$camtool -cam_id $cam_id";
     346if ($run_state eq 'new') {
     347    $fpaCommand .= " -addprocessedexp";
     348    $fpaCommand .= " -uri UNKNOWN";
     349    $fpaCommand .= " -path_base $outroot";
     350    $fpaCommand .= $chipStats->cmdflags();
     351    $fpaCommand .= $camStats->cmdflags();
     352    $fpaCommand .= " -hostname $host" if defined $host;
     353} else {
     354    $fpaCommand .= " -updaterun -state full";
     355}
    326356$fpaCommand .= " -dbname $dbname" if defined $dbname;
    327 $fpaCommand .= $chipStats->cmdflags();
    328 $fpaCommand .= $camStats->cmdflags();
    329357
    330358# Add the result into the database
     
    350378    carp($msg);
    351379    if (defined $cam_id and not $no_update) {
    352         my $command = "$camtool -addprocessedexp";
    353         $command .= " -cam_id $cam_id";
    354         $command .= " -uri UNKNOWN";
    355         $command .= " -code $exit_code";
    356         $command .= " -path_base $outroot";
     380        my $command = "$camtool -cam_id $cam_id";
     381        if ($run_state eq 'new') {
     382            $command .= " -addprocessedexp";
     383            $command .= " -uri UNKNOWN";
     384            $command .= " -code $exit_code";
     385            $command .= " -path_base $outroot";
     386            $command .= " -path_base $outroot" if defined $outroot;
     387        } else {
     388            $command .= " -updateprocessedexp";
     389            $command .= " -code $exit_code";
     390        }
    357391        $command .= " -hostname $host" if defined $host;
    358392        $command .= " -dbname $dbname" if defined $dbname;
    359         $command .= " -path_base $outroot" if defined $outroot;
    360393        system ($command);
    361394    }
Note: See TracChangeset for help on using the changeset viewer.