IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 8, 2009, 5:09:53 PM (17 years ago)
Author:
eugene
Message:

updates to the addstar stage; modify flatcorr to interact correctly with the addstar stage

File:
1 edited

Legend:

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

    r25299 r25816  
    2828# Look for programs we need
    2929my $missing_tools;
    30 #my $camtool = can_run('camtool') or (warn "Can't find camtool" and $missing_tools = 1);
    3130my $addtool = can_run('addtool') or (warn "Can't find addtool" and $missing_tools = 1);
    32 #my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
    3331my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
    34 #my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
    35 #my $psastro = can_run('psastro') or (warn "Can't find psastro" and $missing_tools = 1);
    3632my $addstar = can_run('addstar') or (warn "Can't find addstar" and $missing_tools = 1);
    3733if ($missing_tools) {
     
    4036}
    4137
    42 my ( $exp_tag, $add_id, $camera, $outroot, $camroot, $recipe, $dbname, $reduction, $dvodb, $verbose, $no_update,
    43      $no_op, $redirect, $save_temps, $run_state);
     38my ( $exp_tag, $add_id, $camera, $outroot, $camroot, $dbname, $reduction, $dvodb, $image_only, $verbose, $no_update,
     39     $no_op, $redirect, $save_temps);
    4440GetOptions(
    4541    'exp_tag=s'          => \$exp_tag, # Exposure identifier
    4642    'add_id=s'          => \$add_id, # Camtool identifier
    47     'recipe=s'          => \$recipe, # Recipe to use
    4843    'camera|c=s'        => \$camera, # Camera
    4944    'dbname|d=s'        => \$dbname, # Database name
     
    5247    'reduction=s'       => \$reduction, # Reduction class
    5348    'dvodb|w=s'         => \$dvodb,  # output DVO database
    54     'run-state=s'       => \$run_state, # 'new' or 'update'
     49    'image-only'        => \$image_only,   # Print to stdout
    5550    'verbose'           => \$verbose,   # Print to stdout
    5651    'no-update'         => \$no_update, # Update the database?
     
    7469my $logDest = $ipprc->filename("LOG.EXP", $outroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR);
    7570
    76 if (not defined $run_state) { $run_state = 'new'; }
    77 if ($run_state eq 'update') {
    78     $logDest .= '.update';
    79 }
    80 
    8171if ($redirect) {
    8272    $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $add_id, $PS_EXIT_SYS_ERROR );
     
    8979$reduction = 'DEFAULT' unless defined $reduction;
    9080
     81# XXX This is now not used: do we still need it?
    9182my $recipe_addstar = $ipprc->reduction($reduction, 'ADDSTAR'); # Recipe to use
    9283&my_die("Unrecognised ADDSTAR recipe", $add_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe_addstar;
    9384
    94 #my $recipe_psastro = $ipprc->reduction($reduction, 'PSASTRO'); # Recipe to use
    95 #&my_die("Unrecognised PSASTRO recipe", $cam_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe_psastro;
    96 
    9785my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    98 
    99 my $cmdflags;
    100 
    101 # Get list of component files
    102 my $files;                      # Array of component files
    103 {
    104     my $command = "$addtool -pendingexp -add_id $add_id"; # Command to run
    105     $command .= " -dbname $dbname" if defined $dbname;
    106     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    107         run(command => $command, verbose => $verbose);
    108     unless ($success) {
    109         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    110         &my_die("Unable to perform addtool: $error_code", $add_id, $error_code);
    111     }
    112     my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
    113         &my_die("Unable to parse metadata config doc", $add_id, $PS_EXIT_PROG_ERROR);
    114    
    115     # extract the metadata for the files into a hash list
    116     $files = parse_md_list($metadata) or
    117         &my_die("Unable to parse metadata list", $add_id, $PS_EXIT_PROG_ERROR);   
    118 }
    119 
    120 my $chipObjectsExist = 0;
    12186
    12287# Output products
     
    12691my $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT",     $camroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR);
    12792my $traceDest  = $ipprc->filename("TRACE.EXP",          $outroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR);
    128 
    129 if ($run_state eq 'update') {
    130     $traceDest .= '.update';
    131 }
    13293
    13394# convert supplied DVO database name to UNIX filename
     
    141102
    142103unless ($no_op) {
    143     if (defined $dvodbReal and ($run_state eq 'new')) {
    144         ## XXX the camera analysis can either save the full set of
    145         ## detections, or just the image metadata, in the dvodb
     104    if (defined $dvodbReal) {
     105
     106        ## addstar can either save the full set of detections, or just
     107        ## the image metadata, in the dvodb.  this is set in the
     108        ## database table addRun
    146109       
    147         ## get the addstar recipe for this camera and CAMERA reduction
    148         my $command = "$ppConfigDump -camera $camera -recipe ADDSTAR $recipe_addstar -dump-recipe ADDSTAR -";
    149         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    150             run(command => $command, verbose => $verbose);
    151         unless ($success) {
    152             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    153             &my_die("Unable to perform ppConfigDump: $error_code", $add_id, $PS_EXIT_SYS_ERROR);
    154         }
    155         my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or
    156             &my_die("Unable to parse metadata config doc", $add_id, $PS_EXIT_SYS_ERROR);
    157        
    158         ## allow the dvodb to save only images, or the full detection set
    159         my $imagesOnly = metadataLookupBool($recipeData, 'IMAGES.ONLY');
    160        
    161         # XXX this construct requires the user to have a valid .ptolemyrc
    162         # XXX which in turn points at ippconfig/dvo.site
     110        # addstar requires the user to have a valid .ptolemyrc which
     111        # in turn points at ippconfig/dvo.site
     112
     113        # get the names for the camera and the real input file
     114        my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar
     115        my $realFile = $ipprc->file_resolve($fpaObjects);
     116
    163117        # require a defined output dvo database to run addstar (ie, refuse to use the .ptolemyrc default)
    164         # XXX this needs to be converted to addstar_client...
    165 
    166         my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar
    167         $command  = "$addstar -D CAMERA $camdir -update";
    168         $command .= " -image" if $imagesOnly;
     118        my $command  = "$addstar -update"; # XXX optionally set -update?
     119        $command .= " -D CAMERA $camdir";
    169120        $command .= " -D CATDIR $dvodbReal";
    170        
    171         my $realFile = $ipprc->file_resolve($fpaObjects);
    172121        $command .= " $realFile";
     122        $command .= " -use-name $fpaObjects"; # DVO wants the neb-name as a file reference
     123        $command .= " -image" if $image_only;
    173124       
    174125        my $mjd_addstar_start = DateTime->now->mjd;   # MJD of starting script
    175126       
    176         ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     127        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    177128            run(command => $command, verbose => $verbose);
    178129        unless ($success) {
     
    184135}
    185136
    186 
    187137# This needs to be updated when addtool is written. BROKEN
    188138my $fpaCommand = "$addtool -add_id $add_id";
    189 if ($run_state eq 'new') {
    190     $fpaCommand .= " -addprocessedexp";
    191     $fpaCommand .= " -path_base $outroot";
    192     $fpaCommand .= " $cmdflags";
    193     $fpaCommand .= " -dtime_addstar $dtime_addstar";
    194 } else {
    195     $fpaCommand .= " -updaterun -state full";
    196 }
     139$fpaCommand .= " -addprocessedexp";
     140$fpaCommand .= " -path_base $outroot";
     141$fpaCommand .= " -dtime_addstar $dtime_addstar";
    197142$fpaCommand .= " -dbname $dbname" if defined $dbname;
    198143
     
    223168# This needs to be updated when addtool is written. BROKEN
    224169        my $command = "$addtool -add_id $add_id";
    225         if ($run_state eq 'new') {
    226             $command .= " -addprocessedexp";
    227             $command .= " -uri UNKNOWN";
    228             $command .= " -fault $exit_code";
    229             $command .= " -path_base $outroot";
    230             $command .= " -path_base $outroot" if defined $outroot;
    231             $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400));
    232         } else {
    233             $command .= " -updateprocessedexp";
    234             $command .= " -fault $exit_code";
    235         }
     170        $command .= " -addprocessedexp";
     171        $command .= " -fault $exit_code";
     172        $command .= " -path_base $outroot" if defined $outroot;
     173        $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400));
    236174        $command .= " -dbname $dbname" if defined $dbname;
    237175        system ($command);
     
    239177    exit $exit_code;
    240178}
    241 
    242179
    243180END {
Note: See TracChangeset for help on using the changeset viewer.