IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 3, 2010, 2:35:32 AM (15 years ago)
Author:
eugene
Message:

merge changes from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101103/ippScripts/scripts/camera_exp.pl

    r28043 r29906  
    7070my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $cam_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
    7171
    72 my $logDest = $ipprc->filename("LOG.EXP", $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR);
    73 
    7472if (not defined $run_state) { $run_state = 'new'; }
    75 if ($run_state eq 'update') {
    76     $logDest .= '.update';
     73
     74my_die ("$run_state is an invalid value for run-state", $cam_id, $PS_EXIT_PROG_ERROR) unless ($run_state eq 'new' or $run_state eq 'update');
     75
     76
     77my $replicateOutputs = 1;
     78
     79my $logDest;
     80my $traceDest;
     81if ($run_state eq 'new') {
     82    $logDest = prepare_output("LOG.EXP", $outroot, undef, 0);
     83    $traceDest = prepare_output("TRACE.EXP", $outroot, undef, 0);
     84} else {
     85    $logDest = prepare_output("LOG.EXP.UPDATE", $outroot, undef, 0);
     86    $traceDest = prepare_output("TRACE.EXP.UPDATE", $outroot, undef, 0);
    7787}
    7888
     
    188198    print $list4File ($chipMask . "\n");
    189199
    190     push @outMasks, $ipprc->filename("PSASTRO.OUTPUT.MASK", $outroot, $class_id) if $produceMasks;
     200    push @outMasks, prepare_output("PSASTRO.OUTPUT.MASK", $outroot, $class_id, 1) if $produceMasks;
    191201}
    192202close $list1File;
     
    199209
    200210# the camera configurations should define the psastro output to be a single file (MEF), regardless of the inputs
    201 my $jpeg1      = $ipprc->filename("PPIMAGE.JPEG1",      $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR);
    202 my $jpeg2      = $ipprc->filename("PPIMAGE.JPEG2",      $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR);
    203 my $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT",     $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR);
    204 my $fpaStats   = $ipprc->filename("PSASTRO.STATS",      $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR);
    205 my $traceDest  = $ipprc->filename("TRACE.EXP",          $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR);
    206 my $configuration = $ipprc->filename("PSASTRO.CONFIG",  $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR);
    207 
    208 if ($run_state eq 'update') {
    209     $traceDest .= '.update';
    210     $fpaStats .= '.update';
    211 }
    212 
    213 # convert supplied DVO database name to UNIX filename
    214 my $dvodbReal;
    215 if (defined $dvodb) {
    216     $dvodbReal = $ipprc->dvo_catdir( $dvodb ); # catdir for DVO
    217     $dvodbReal = $ipprc->convert_filename_absolute( $dvodbReal );
    218 }
    219 
    220 #my $dtime_addstar = 0;
     211my $jpeg1      = prepare_output("PPIMAGE.JPEG1",      $outroot, undef, 1);
     212my $jpeg2      = prepare_output("PPIMAGE.JPEG2",      $outroot, undef, 1);
     213my $fpaObjects = prepare_output("PSASTRO.OUTPUT",     $outroot, undef, 1);
     214my $configuration = prepare_output("PSASTRO.CONFIG",  $outroot, undef, 1);
     215
     216my $do_stats;
     217my $fpaStats;
     218if ($run_state eq 'new') {
     219    $do_stats = 1;
     220    $fpaStats = prepare_output("PSASTRO.STATS",      $outroot, undef, 1);
     221} else {
     222    $do_stats = 0;
     223}
    221224
    222225unless ($no_op) {
     
    236239            &my_die("Unable to perform ppImage: $error_code", $cam_id, $error_code);
    237240        }
    238         &my_die("Unable to find expected output file: $jpeg1", $cam_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($jpeg1);
     241        check_output($jpeg1, $replicateOutputs);
    239242    }
    240243
     
    251254            &my_die("Unable to perform ppImage: $error_code", $cam_id, $error_code);
    252255        }
    253         &my_die("Unable to find expected output file: $jpeg2", $cam_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($jpeg2);
     256        check_output($jpeg2, $replicateOutputs);
    254257    }
    255258
     
    265268        $command .= " -dbname $dbname" if defined $dbname;
    266269
    267         my $do_stats;
    268270        if ($run_state eq 'new') {
    269             $command .= " -stats $fpaStats -recipe PPSTATS CAMSTATS";
    270271            $command .= " -dumpconfig $configuration";
    271             $do_stats = 1;
    272272        } elsif ($run_state eq 'update') {
    273273            $command .= " -ipprc $configuration";
     
    275275            &my_die("invalid value for run-state: $run_state", $cam_id, $PS_EXIT_CONFIG_ERROR);
    276276        }
     277        $command .= " -stats $fpaStats -recipe PPSTATS CAMSTATS" if $do_stats;
    277278
    278279        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    286287        my $quality;            # Quality flag
    287288        if ($do_stats) {
     289            check_output($fpaStats, $replicateOutputs);
     290
    288291            my $fpaStatsReal = $ipprc->file_resolve($fpaStats);
    289             &my_die("Couldn't find expected output file: $fpaStats", $cam_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $fpaStatsReal );
    290292
    291293            # parse stats from metadata
     
    306308
    307309        if (!$quality) {
    308             &my_die("Unable to find expected output file: $fpaObjects", $cam_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($fpaObjects);
     310            check_output($fpaObjects, $replicateOutputs);
    309311
    310312            foreach my $outMask (@outMasks) {
    311                 &my_die("Unable to find expected output file: $outMask", $cam_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outMask);
     313                check_output($outMask, $replicateOutputs);
    312314            }
    313315
    314316            if ($run_state eq 'new') {
    315                 &my_die("Couldn't find expected output file: $configuration", $cam_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($configuration);
     317                check_output($configuration, $replicateOutputs);
    316318            }
    317319        }
    318 
    319         # run addstar on the output fpaObjects (if a DVO database is defined)
    320 #         if (defined $dvodbReal and ($run_state eq 'new')) {
    321 
    322 #             ## XXX the camera analysis can either save the full set of
    323 #             ## detections, or just the image metadata, in the dvodb
    324 
    325 #             ## get the addstar recipe for this camera and CAMERA reduction
    326 #             $command = "$ppConfigDump -camera $camera -recipe ADDSTAR $recipe_addstar -dump-recipe ADDSTAR -";
    327 #             ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    328 #                 run(command => $command, verbose => $verbose);
    329 #             unless ($success) {
    330 #                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    331 #                 &my_die("Unable to perform ppConfigDump: $error_code", $cam_id, $PS_EXIT_SYS_ERROR);
    332 #             }
    333 #             my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or
    334 #                 &my_die("Unable to parse metadata config doc", $cam_id, $PS_EXIT_SYS_ERROR);
    335 
    336 #             ## allow the dvodb to save only images, or the full detection set
    337 #             my $imagesOnly = metadataLookupBool($recipeData, 'IMAGES.ONLY');
    338 
    339 #             # XXX this construct requires the user to have a valid .ptolemyrc
    340 #             # XXX which in turn points at ippconfig/dvo.site
    341 #             # require a defined output dvo database to run addstar (ie, refuse to use the .ptolemyrc default)
    342 #             # XXX this needs to be converted to addstar_client...
    343 
    344 #             my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar
    345 #             my $command;
    346 #             $command  = "$addstar -D CAMERA $camdir -update";
    347 #             $command .= " -image" if $imagesOnly;
    348 #             $command .= " -D CATDIR $dvodbReal";
    349 
    350 #             my $realFile = $ipprc->file_resolve($fpaObjects);
    351 #             $command .= " $realFile";
    352 
    353 #             my $mjd_addstar_start = DateTime->now->mjd;   # MJD of starting script
    354 
    355 #             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    356 #                 run(command => $command, verbose => $verbose);
    357 #             unless ($success) {
    358 #                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    359 #                 &my_die("Unable to perform addstar: $error_code", $cam_id, $error_code);
    360 #             }
    361 #             $dtime_addstar = 86400.0*(DateTime->now->mjd - $mjd_addstar_start);   # MJD of starting script
    362 #         }
    363320    }
    364321}
     
    374331    $fpaCommand .= " -hostname $host" if defined $host;
    375332    $fpaCommand .= " -dtime_script $dtime_script";
    376 #    $fpaCommand .= " -dtime_addstar $dtime_addstar";
    377333} else {
    378334    $fpaCommand .= " -updaterun -set_state full";
     
    393349}
    394350
     351exit 0;
     352
     353sub prepare_output
     354{
     355    my $filerule = shift;
     356    my $outroot  = shift;
     357    my $class_id = shift;
     358    my $delete = shift;
     359    $delete = 0 if !defined $delete;
     360
     361    my $error;
     362    my $output = $ipprc->prepare_output($filerule, $outroot, $class_id, $delete, \$error)
     363                    or &my_die("failed to prepare output file for: $filerule", $cam_id, $error);
     364
     365    return $output;
     366}
     367
     368sub check_output
     369{
     370    my $file = shift;
     371    my $replicate = shift;
     372
     373    if (!defined $file) {
     374        return;
     375    }
     376
     377    &my_die("Couldn't find expected output file: $file",  $cam_id, $PS_EXIT_SYS_ERROR) unless
     378        $ipprc->file_exists($file);
     379
     380    if ($replicate and (file_scheme($file) eq 'neb')) {
     381        $ipprc->replicate_file($file) or &my_die("failed to replicate: $file\n",  $cam_id, $PS_EXIT_SYS_ERROR);
     382    }
     383}
    395384
    396385sub my_die
Note: See TracChangeset for help on using the changeset viewer.