IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 3, 2010, 8:50:52 AM (16 years ago)
Author:
eugene
Message:

updates from trunk

Location:
branches/simtest_nebulous_branches
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/simtest_nebulous_branches

  • branches/simtest_nebulous_branches/ippScripts/scripts/camera_exp.pl

    r24465 r27840  
    88use Sys::Hostname;
    99my $host = hostname();
     10my $date = `date`;
    1011print "\n\n";
    11 print "Starting script $0 on $host\n\n";
     12print "Starting script $0 on $host at $date\n\n";
    1213
    1314use DateTime;
     
    3940}
    4041
    41 my ( $exp_tag, $cam_id, $camera, $outroot, $recipe, $dbname, $reduction, $dvodb, $verbose, $no_update,
     42my ( $exp_tag, $cam_id, $camera, $outroot, $dbname, $reduction, $dvodb, $verbose, $no_update,
    4243     $no_op, $redirect, $save_temps, $run_state);
    4344GetOptions(
    4445    'exp_tag=s'          => \$exp_tag, # Exposure identifier
    4546    'cam_id=s'          => \$cam_id, # Camtool identifier
    46     'recipe=s'          => \$recipe, # Recipe to use
    4747    'camera|c=s'        => \$camera, # Camera
    4848    'dbname|d=s'        => \$dbname, # Database name
     
    9393&my_die("Unrecognised JPEG recipe", $cam_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe2;
    9494
    95 my $recipe_addstar = $ipprc->reduction($reduction, 'ADDSTAR'); # Recipe to use
    96 &my_die("Unrecognised ADDSTAR recipe", $cam_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe_addstar;
     95#my $recipe_addstar = $ipprc->reduction($reduction, 'ADDSTAR'); # Recipe to use
     96#&my_die("Unrecognised ADDSTAR recipe", $cam_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe_addstar;
    9797
    9898my $recipe_psastro = $ipprc->reduction($reduction, 'PSASTRO'); # Recipe to use
     
    145145}
    146146
     147
     148my $produceMasks;               # Produce masks?
     149{
     150    # Get the PSASTRO recipe
     151    my $command = "$ppConfigDump -camera $camera -recipe PSASTRO $recipe_psastro -dump-recipe PSASTRO -";
     152    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     153        run(command => $command, verbose => $verbose);
     154    unless ($success) {
     155        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     156        &my_die("Unable to perform ppConfigDump: $error_code", $cam_id, $PS_EXIT_CONFIG_ERROR);
     157    }
     158    my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or
     159        &my_die("Unable to parse metadata config doc", $cam_id, $PS_EXIT_CONFIG_ERROR);
     160
     161    $produceMasks = metadataLookupBool($recipeData, 'REFSTAR_MASK');
     162}
     163
     164
    147165### not needed to have such an extensive temp file name.
    148166my ($list1File, $list1Name) = tempfile( "/tmp/$exp_tag.cm.$cam_id.b1.list.XXXX", UNLINK => !$save_temps ); # For binning 1
     
    154172
    155173# XXX we perform astrometry iff photometry output exists
    156 my $chipObjectsExist = 0;
     174my @outMasks;                   # Names of output masks
    157175foreach my $file (@$files) {
     176    next if $file->{quality} != 0;
    158177    # use the path_base as OUTPUT root and convert the filenames with ipprc->filename:
    159178    my $class_id = $file->{class_id};
     
    164183    my $chipMask   = $ipprc->filename("PPIMAGE.CHIP.MASK", $file->{path_base}, $class_id);
    165184
    166     # if any of the output chip photometry files exist, we can run psastro / addstar below
    167     if ($ipprc->file_exists($chipObjects)) {
    168         $chipObjectsExist = 1;
    169     } else {
    170         if ($verbose) { print "skipping $chipObjects (not found)\n"; }
    171         next;
    172     }
    173 
    174185    print $list1File ($ipprc->filename("PPIMAGE.BIN1", $file->{path_base}, $class_id) . "\n");
    175186    print $list2File ($ipprc->filename("PPIMAGE.BIN2", $file->{path_base}, $class_id) . "\n");
    176187    print $list3File ($chipObjects . "\n");
    177188    print $list4File ($chipMask . "\n");
     189
     190    push @outMasks, $ipprc->filename("PSASTRO.OUTPUT.MASK", $outroot, $class_id) if $produceMasks;
    178191}
    179192close $list1File;
     
    205218}
    206219
    207 my $dtime_addstar = 0;
     220#my $dtime_addstar = 0;
    208221
    209222unless ($no_op) {
     
    223236            &my_die("Unable to perform ppImage: $error_code", $cam_id, $error_code);
    224237        }
    225         &my_die("Unable to find expected output file: $jpeg1", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($jpeg1);
     238        &my_die("Unable to find expected output file: $jpeg1", $cam_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($jpeg1);
    226239    }
    227240
     
    238251            &my_die("Unable to perform ppImage: $error_code", $cam_id, $error_code);
    239252        }
    240         &my_die("Unable to find expected output file: $jpeg2", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($jpeg2);
    241     }
    242 
    243     # only run psastro / addstar if any of the output chip astrometry files exist (should we test for successful astrometry?)
    244     if ($chipObjectsExist) {
     253        &my_die("Unable to find expected output file: $jpeg2", $cam_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($jpeg2);
     254    }
     255
     256    {
    245257        # run psastro on the chipObjects, producing fpaObjects
    246258        my $command;
    247259        $command  = "$psastro";
    248         $command .= " -list $list3Name";
    249         $command .= " -masklist $list4Name";
    250         $command .= " $outroot";
     260        $command .= " -list $list3Name";
     261        $command .= " -masklist $list4Name";
     262        $command .= " $outroot";
    251263        $command .= " -recipe PSASTRO $recipe_psastro";
    252264        $command .= " -tracedest $traceDest -log $logDest";
     
    274286        if ($do_stats) {
    275287            my $fpaStatsReal = $ipprc->file_resolve($fpaStats);
    276             &my_die("Couldn't find expected output file: $fpaStats", $cam_id, $PS_EXIT_SYS_ERROR) unless -f $fpaStatsReal;
     288            &my_die("Couldn't find expected output file: $fpaStats", $cam_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $fpaStatsReal );
    277289
    278290            # parse stats from metadata
     
    293305
    294306        if (!$quality) {
    295             &my_die("Unable to find expected output file: $fpaObjects", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($fpaObjects);
     307            &my_die("Unable to find expected output file: $fpaObjects", $cam_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($fpaObjects);
     308
     309            foreach my $outMask (@outMasks) {
     310                &my_die("Unable to find expected output file: $outMask", $cam_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outMask);
     311            }
     312
     313            if ($run_state eq 'new') {
     314                &my_die("Couldn't find expected output file: $configuration", $cam_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($configuration);
     315            }
    296316        }
    297317
    298318        # run addstar on the output fpaObjects (if a DVO database is defined)
    299         if (defined $dvodbReal and ($run_state eq 'new')) {
    300 
    301             ## XXX the camera analysis can either save the full set of
    302             ## detections, or just the image metadata, in the dvodb
    303 
    304             ## get the addstar recipe for this camera and CAMERA reduction
    305             $command = "$ppConfigDump -camera $camera -recipe ADDSTAR $recipe_addstar -dump-recipe ADDSTAR -";
    306             ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    307                 run(command => $command, verbose => $verbose);
    308             unless ($success) {
    309                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    310                 &my_die("Unable to perform ppConfigDump: $error_code", $cam_id, $PS_EXIT_SYS_ERROR);
    311             }
    312             my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or
    313                 &my_die("Unable to parse metadata config doc", $cam_id, $PS_EXIT_SYS_ERROR);
    314 
    315             ## allow the dvodb to save only images, or the full detection set
    316             my $imagesOnly = metadataLookupBool($recipeData, 'IMAGES.ONLY');
    317 
    318             # XXX this construct requires the user to have a valid .ptolemyrc
    319             # XXX which in turn points at ippconfig/dvo.site
    320             # require a defined output dvo database to run addstar (ie, refuse to use the .ptolemyrc default)
    321             # XXX this needs to be converted to addstar_client...
    322 
    323             my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar
    324             my $command;
    325             $command  = "$addstar -D CAMERA $camdir -update";
    326             $command .= " -image" if $imagesOnly;
    327             $command .= " -D CATDIR $dvodbReal";
    328 
    329             my $realFile = $ipprc->file_resolve($fpaObjects);
    330             $command .= " $realFile";
    331 
    332             my $mjd_addstar_start = DateTime->now->mjd;   # MJD of starting script
    333 
    334             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    335                 run(command => $command, verbose => $verbose);
    336             unless ($success) {
    337                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    338                 &my_die("Unable to perform addstar: $error_code", $cam_id, $error_code);
    339             }
    340             $dtime_addstar = 86400.0*(DateTime->now->mjd - $mjd_addstar_start);   # MJD of starting script
    341         }
     319#         if (defined $dvodbReal and ($run_state eq 'new')) {
     320
     321#             ## XXX the camera analysis can either save the full set of
     322#             ## detections, or just the image metadata, in the dvodb
     323
     324#             ## get the addstar recipe for this camera and CAMERA reduction
     325#             $command = "$ppConfigDump -camera $camera -recipe ADDSTAR $recipe_addstar -dump-recipe ADDSTAR -";
     326#             ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     327#                 run(command => $command, verbose => $verbose);
     328#             unless ($success) {
     329#                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     330#                 &my_die("Unable to perform ppConfigDump: $error_code", $cam_id, $PS_EXIT_SYS_ERROR);
     331#             }
     332#             my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or
     333#                 &my_die("Unable to parse metadata config doc", $cam_id, $PS_EXIT_SYS_ERROR);
     334
     335#             ## allow the dvodb to save only images, or the full detection set
     336#             my $imagesOnly = metadataLookupBool($recipeData, 'IMAGES.ONLY');
     337
     338#             # XXX this construct requires the user to have a valid .ptolemyrc
     339#             # XXX which in turn points at ippconfig/dvo.site
     340#             # require a defined output dvo database to run addstar (ie, refuse to use the .ptolemyrc default)
     341#             # XXX this needs to be converted to addstar_client...
     342
     343#             my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar
     344#             my $command;
     345#             $command  = "$addstar -D CAMERA $camdir -update";
     346#             $command .= " -image" if $imagesOnly;
     347#             $command .= " -D CATDIR $dvodbReal";
     348
     349#             my $realFile = $ipprc->file_resolve($fpaObjects);
     350#             $command .= " $realFile";
     351
     352#             my $mjd_addstar_start = DateTime->now->mjd;   # MJD of starting script
     353
     354#             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     355#                 run(command => $command, verbose => $verbose);
     356#             unless ($success) {
     357#                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     358#                 &my_die("Unable to perform addstar: $error_code", $cam_id, $error_code);
     359#             }
     360#             $dtime_addstar = 86400.0*(DateTime->now->mjd - $mjd_addstar_start);   # MJD of starting script
     361#         }
    342362    }
    343363}
     
    353373    $fpaCommand .= " -hostname $host" if defined $host;
    354374    $fpaCommand .= " -dtime_script $dtime_script";
    355     $fpaCommand .= " -dtime_addstar $dtime_addstar";
     375#    $fpaCommand .= " -dtime_addstar $dtime_addstar";
    356376} else {
    357     $fpaCommand .= " -updaterun -state full";
     377    $fpaCommand .= " -updaterun -set_state full";
    358378}
    359379$fpaCommand .= " -dbname $dbname" if defined $dbname;
Note: See TracChangeset for help on using the changeset viewer.