IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28691


Ignore:
Timestamp:
Jul 20, 2010, 10:10:58 AM (16 years ago)
Author:
rhenders
Message:

Improved some SQL handling' included 'test' batch as possible output; improved instructions for usage

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/scripts/ippToPsps_run.pl

    r28661 r28691  
    4949my $quit = 0;
    5050print "\n";
    51 if (!defined $batchType) {print "* ERROR: need to define a batch type (-b)\n"; $quit=1;}
    52 if (!defined $output) {print "* ERROR: need to provide an output path (-o)\n"; $quit=1;}
    53 if (!defined $dvodb) {print "* ERROR: need to provide a DVO Db path (-d)\n"; $quit=1;}
    54 if (!defined $survey and !defined $singleExpId) {print "* ERROR: need to provide a survey type (-s) or an exposure ID (-e)\n"; $quit=1;}
     51if (!defined $batchType) {print "* REQUIRED: need to define a batch type: -b <init|det|diff|stack>\n"; $quit=1;}
     52if (!defined $output) {print "* REQUIRED: need to provide an output path: -o <path>\n"; $quit=1;}
     53if (!defined $dvodb) {print "* REQUIRED: need to provide a DVO Db path: -d <path>\n"; $quit=1;}
     54if (!defined $survey and !defined $singleExpId) {print "* REQUIRED: need to provide a survey type (-s <ThreePi|STS|SAS|etc>) or an exposure ID (-e <expID>)\n"; $quit=1;}
     55if (!defined $datastoreProduct) {print "* OPTIONAL: datastore producth: -p <product>\n";}
    5556print "\n\n";
    5657
     
    289290
    290291    my $query = $db->prepare(<<SQL);
    291 
    292292    UPDATE batches
    293293        SET processed = $processed, on_datastore = $published, total_detections = $totalDetections
     
    296296SQL
    297297
    298     $query->execute; # TODO check response of these
     298    $query->execute; # TODO check response of this
    299299}
    300300
     
    380380    elsif ($batchType =~ /diff/) {
    381381        $success = produceDiffs($gpc1Db, $expId, $expName, $surveyType, $batchDir, $resultsFilePath);
     382    }
     383    elsif ($batchType =~ /test/) {
     384        $success = produceDetections($gpc1Db, $expId, $expName, $surveyType, $batchDir, $resultsFilePath);
    382385    }
    383386
     
    622625    my ($gpc1Db, $expId, $expName, $surveyType, $outputPath, $resultsFilePath) = @_;
    623626
    624     # query to retrieve nebulous key of camera smf file for this exposure
    625     my $query =
    626         "SELECT camProcessedExp.path_base ".
    627         "FROM warpRun ".
    628         "JOIN fakeRun USING(fake_id) ".
    629         "JOIN camRun USING(cam_id) ".
    630         "JOIN camProcessedExp USING(cam_id) ".
    631         "JOIN chipRun USING(chip_id) ".
    632         "JOIN rawExp USING (exp_id) ".
    633         "WHERE rawExp.exp_id = $expId AND camRun.magicked ".
    634         "ORDER BY camRun.cam_id DESC LIMIT 1";  # make sure we get most recently processed
    635 
    636     if ($verbose) { print"* $query\n";}
    637 
    638 
    639     # execute query and check results
    640     my $results = $gpc1Db->selectall_arrayref( $query );
    641     my $size = @$results;
    642     if ($size < 1) {print "* No smf files found for this exposure\n"; return 0;}
    643 
    644     # loop round db results TODO should only be one result
     627    # DESC and LIMIT 1 is to make sure we get most recently processed
     628    my $query = $gpc1Db->prepare(<<SQL);
     629    SELECT
     630        camProcessedExp.path_base
     631        FROM warpRun
     632        JOIN fakeRun USING(fake_id)
     633        JOIN camRun USING(cam_id)
     634        JOIN camProcessedExp USING(cam_id)
     635        JOIN chipRun USING(chip_id)
     636        JOIN rawExp USING (exp_id)
     637        WHERE rawExp.exp_id = $expId AND camRun.magicked
     638        ORDER BY camRun.cam_id DESC LIMIT 1
     639SQL
     640
     641    $query->execute;
     642    my $nebPath = $query->fetchrow_array();
     643    if (!$nebPath) { print "* No smf files found for this exposure\n"; return 0; }
     644
    645645    my $success = 0;
    646     for my $row (@$results) {
    647 
    648         # get real filename from neb 'key'
    649         my ($nebPath) = @$row;
    650         my $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT",$nebPath) or return 0;
    651         my $realFile = $ipprc->file_resolve($fpaObjects) or return 0;
    652 
    653         # now write the path to this file out to temp file
    654         my ($tempFile, $tempName) = tempfile( "/tmp/ippToPsps_inputFileList.XXXX", UNLINK => !$save_temps);
    655         print $tempFile $realFile . "\n";
    656         close $tempFile;
    657 
    658         $success = runProgram($tempName, $outputPath, $expId, $expName, $surveyType, $batchType, $resultsFilePath);
    659         return $success;
    660     }
     646
     647    # get real filename from neb 'key'
     648    my $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT",$nebPath) or return 0;
     649    my $realFile = $ipprc->file_resolve($fpaObjects) or return 0;
     650
     651    # now write the path to this file out to temp file
     652    my ($tempFile, $tempName) = tempfile( "/tmp/ippToPsps_inputFileList.XXXX", UNLINK => !$save_temps);
     653    print $tempFile $realFile . "\n";
     654    close $tempFile;
     655
     656    $success = runProgram($tempName, $outputPath, $expId, $expName, $surveyType, $batchType, $resultsFilePath);
     657    return $success;
    661658}
    662659
Note: See TracChangeset for help on using the changeset viewer.