Changeset 28484 for branches/pap/ippToPsps/scripts/ippToPsps_run.pl
- Timestamp:
- Jun 24, 2010, 2:59:09 PM (16 years ago)
- Location:
- branches/pap
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippToPsps/scripts/ippToPsps_run.pl (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap
- Property svn:mergeinfo changed
-
branches/pap/ippToPsps/scripts/ippToPsps_run.pl
r28120 r28484 12 12 13 13 # globals 14 my ($verbose, $save_temps, $no_op, $no_update, $camera, $batchType, $output, $dvodb, $datastoreProduct, $ label, $singleExpId, $no_publish, $force);14 my ($verbose, $save_temps, $no_op, $no_update, $camera, $batchType, $output, $dvodb, $datastoreProduct, $survey, $singleExpId, $no_publish, $force, $initBatch); 15 15 16 16 # default values for certain globals … … 25 25 $datastoreProduct = "PSPS_test"; 26 26 $force = 0; 27 $initBatch = 0; 27 28 28 29 # get user args … … 31 32 'batch|b=s' => \$batchType, 32 33 'dvodb|d=s' => \$dvodb, 33 ' label|l=s' => \$label,34 'survey|s=s' => \$survey, 34 35 'expid|e=s' => \$singleExpId, 35 36 'product|p=s' => \$datastoreProduct, … … 49 50 "--batch <init|det|diff|stack>\n". 50 51 "--output <path>\n". 51 "-- label <label> or --expid <expid>\n" .52 "--survey <ThreePi|MD01,2 etc|STS|SAS|SweetSpot> or --expid <expid>\n" . 52 53 "--dvodb <path>\n". 53 54 "\n Optional:\n\n". … … 62 63 defined $output and 63 64 defined $dvodb and 64 ( defined $label or defined $singleExpId ); 65 (( defined $survey or defined $singleExpId ) or ( $batchType eq "init")); 66 67 if ($batchType eq "init") {$initBatch = 1;} 65 68 66 69 # check we can run programs and get camera config … … 70 73 71 74 # make a temporary file for saving results 72 my ($resultsFile, $resultsFileName) = tempfile( "/tmp/ results.XXXX", UNLINK => !$save_temps);75 my ($resultsFile, $resultsFileName) = tempfile( "/tmp/ippToPsps_results.XXXX", UNLINK => !$save_temps); 73 76 74 77 process(); … … 86 89 if ($distGroup =~ m/^MD([0-1][0-9])$/i) {return "MD$1";} 87 90 if ($distGroup =~ m/^M31$/i) {return "M31";} 88 if ($distGroup =~ m/^sts$/i) {return "STS ";}91 if ($distGroup =~ m/^sts$/i) {return "STS1";} 89 92 if ($distGroup =~ m/^SweetSpot$/i) {return "SSS";} 90 93 if ($distGroup =~ m/^(3PI)|(ThreePi)|(SAS)$/i) {return "3PI";} … … 118 121 ####################################################################################### 119 122 # 120 # Finds all exposures for the provided labeland generates PSPS FITS data for them123 # Finds all exposures for the provided TODO and generates PSPS FITS data for them 121 124 # 122 125 ####################################################################################### … … 130 133 131 134 my $query; 132 if (!$singleExpId) { 133 134 # query to retrieve all exposures with the provided label 135 if ($initBatch) { 136 135 137 $query = $gpc1Db->prepare(<<SQL); 136 138 137 SELECT DISTINCT rawExp.exp_id, camRun.dist_group 138 FROM camRun, chipRun, rawExp 139 WHERE camRun.chip_id = chipRun.chip_id 140 AND chipRun.exp_id = rawExp.exp_id 141 AND camRun.dist_group LIKE 'ThreePi' 142 AND rawExp.exp_id > $lastExpId 143 ORDER BY rawExp.exp_id ASC 139 SELECT 0, 'NULL', 'ThreePi'; 144 140 SQL 141 } 142 elsif ($singleExpId) { 143 144 $query = $gpc1Db->prepare(<<SQL); 145 146 SELECT DISTINCT rawExp.exp_id, rawExp.exp_name, dist_group 147 FROM rawExp, chipRun 148 WHERE chipRun.exp_id = rawExp.exp_id 149 AND rawExp.exp_id = $singleExpId 150 SQL 151 } 152 else { 153 154 $query = $gpc1Db->prepare(<<SQL); 155 156 SELECT rawExp.exp_id, rawExp.exp_name, camRun.dist_group 157 FROM camRun, chipRun, rawExp 158 WHERE camRun.state = 'full' 159 AND camRun.chip_id = chipRun.chip_id 160 AND chipRun.exp_id = rawExp.exp_id 161 AND camRun.dist_group = '$survey' 162 GROUP BY rawExp.exp_id 163 ORDER BY rawExp.exp_id ASC; 164 SQL 165 166 #AND rawExp.dateobs <= '2010-03-12' 145 167 #AND rawExp.exp_id > $lastExpId 146 168 #AND camRun.label LIKE '%$label%' … … 149 171 #AND rawExp.decl >= '-0.157079633' AND rawExp.decl <= '0.157079633' Jims Dec range 150 172 } 151 else {152 153 $query = $gpc1Db->prepare(<<SQL);154 155 SELECT DISTINCT rawExp.exp_id, dist_group FROM rawExp, chipRun WHERE chipRun.exp_id = rawExp.exp_id AND rawExp.exp_id = $singleExpId156 SQL157 }158 173 159 174 my $batchId = 0; … … 168 183 # loop round exposures 169 184 while (my @row = $query->fetchrow_array()) { 170 my ($expId, $ distGroup) = @row;171 172 if ( isExposureAlreadyProcessed($ippToPspsDb, $expId)) {185 my ($expId, $expName, $distGroup) = @row; 186 187 if (!$initBatch && isExposureAlreadyProcessed($ippToPspsDb, $expId)) { 173 188 174 189 if ($force) {print "* Forcing....\n";} 175 190 else {next}; 176 }191 } 177 192 178 193 my $surveyType = getSurveyTypeFromDistGroup($distGroup); … … 181 196 $jobId = getNewBatchId($ippToPspsDb, $expId, $surveyType); 182 197 183 # TODO quit here if no sensible job ID198 # TODO quit here if no sensible job ID 184 199 185 200 # generate batch and job paths from job and batch IDs … … 188 203 my $batchDir = sprintf("B%03d", $batchId); 189 204 my $batchOutputPath = sprintf("$jobOutputPath/%s", $batchDir); 190 191 print "* Preparing exposure $expId as job '$job'...\n";192 193 # make directories194 205 mkdir($jobOutputPath, 0777); 195 206 mkdir($batchOutputPath, 0777); 196 207 208 print "* Preparing exposure $expId as job '$job'...\n"; 209 197 210 # run IppToPsps program 198 if (runIppToPsps($gpc1Db, $expId, $ batchOutputPath, $batchType)) {211 if (runIppToPsps($gpc1Db, $expId, $expName, $surveyType, $batchOutputPath, $batchType)) { 199 212 200 213 # write batch manifest and tar and zip up … … 232 245 } 233 246 234 if ($batchType eq "init" ) {print "* Wrote initialisation batch\n"; last;} 235 247 if ($initBatch) {print "* Wrote initialisation batch\n";} 236 248 237 249 print "*\n*******************************************************************************\n\n"; … … 358 370 ####################################################################################### 359 371 sub runIppToPsps { 360 my ($gpc1Db, $expId, $ batchOutputPath, $batchType) = @_;372 my ($gpc1Db, $expId, $expName, $surveyType, $batchOutputPath, $batchType) = @_; 361 373 362 374 my $success = 0; 363 375 364 # before anything else, we can publish the init batch365 376 if ($batchType =~ /init/) { 366 377 $success = produceInit($batchOutputPath); 367 378 } 368 379 elsif ($batchType =~ /det/) { 369 $success = produceDetections($gpc1Db, $expId, $ batchOutputPath);380 $success = produceDetections($gpc1Db, $expId, $expName, $surveyType, $batchOutputPath); 370 381 } 371 382 elsif ($batchType =~ /diff/) { 372 $success = produceDiffs($gpc1Db, $expId, $ batchOutputPath);383 $success = produceDiffs($gpc1Db, $expId, $expName, $surveyType, $batchOutputPath); 373 384 } 374 385 … … 614 625 my $fullJobPath = "$path/$job"; 615 626 616 my ($tempFile, $tempName) = tempfile( "/tmp/ dsregList.XXXX", UNLINK => !$save_temps);627 my ($tempFile, $tempName) = tempfile( "/tmp/ippToPsps_dsregList.XXXX", UNLINK => !$save_temps); 617 628 618 629 # loop through all batch files in this job directory … … 664 675 my ($outputPath) = @_; 665 676 666 my $success = runProgram( "NULL", $outputPath, 0, $batchType);677 my $success = runProgram("NULL", $outputPath, 0, "NULL", "NULL", $batchType); 667 678 return $success; 668 679 } … … 673 684 ####################################################################################### 674 685 sub produceDetections { 675 my ($gpc1Db, $expId,$outputPath) = @_;686 my ($gpc1Db, $expId, $expName, $surveyType, $outputPath) = @_; 676 687 677 688 # query to retrieve nebulous key of camera smf file for this exposure … … 705 716 706 717 # now write the path to this file out to temp file 707 my ($tempFile, $tempName) = tempfile( "/tmp/i nputFileList.XXXX", UNLINK => !$save_temps);718 my ($tempFile, $tempName) = tempfile( "/tmp/ippToPsps_inputFileList.XXXX", UNLINK => !$save_temps); 708 719 print $tempFile $realFile . "\n"; 709 720 close $tempFile; 710 721 711 $success = runProgram($tempName, $outputPath, $expId, $ batchType);722 $success = runProgram($tempName, $outputPath, $expId, $expName, $surveyType, $batchType); 712 723 return $success; 713 724 } … … 720 731 ####################################################################################### 721 732 sub produceDiffs { 722 my ($gpc1Db, $expId,$outputPath) = @_;733 my ($gpc1Db, $expId, $expName, $surveyType, $outputPath) = @_; 723 734 724 735 my $query = … … 758 769 } 759 770 760 my $ret = runProgram($tempName, $outputPath, $expId, $ batchType);771 my $ret = runProgram($tempName, $outputPath, $expId, $expName, $surveyType, $batchType); 761 772 762 773 close $tempFile; … … 771 782 ####################################################################################### 772 783 sub runProgram { 773 my ($input, $output, $expid, $ batchType) = @_;784 my ($input, $output, $expid, $expName, $surveyType, $batchType) = @_; 774 785 775 786 # build command … … 780 791 $command .= " -config config"; # TODO 781 792 $command .= " -expid $expid"; 793 $command .= " -expname $expName"; 794 $command .= " -survey $surveyType"; 782 795 $command .= " -batch $batchType"; 783 796 $command .= " -results $resultsFileName";
Note:
See TracChangeset
for help on using the changeset viewer.
