Changeset 27710
- Timestamp:
- Apr 19, 2010, 12:15:08 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/scripts/ippToPsps_run.pl (modified) (24 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/scripts/ippToPsps_run.pl
r27699 r27710 71 71 ####################################################################################### 72 72 # 73 # Generates a PSPS-suitable survey 'type' from the IPP distribution group 74 # 75 ####################################################################################### 76 sub getSurveyTypeFromDistGroup { 77 my ($distGroup) = @_; 78 79 if ($distGroup eq "MD01") {return $distGroup;} 80 if ($distGroup eq "MD02") {return $distGroup;} 81 if ($distGroup eq "MD03") {return $distGroup;} 82 if ($distGroup eq "MD04") {return $distGroup;} 83 if ($distGroup eq "MD05") {return $distGroup;} 84 if ($distGroup eq "MD06") {return $distGroup;} 85 if ($distGroup eq "MD07") {return $distGroup;} 86 if ($distGroup eq "MD08") {return $distGroup;} 87 if ($distGroup eq "MD09") {return $distGroup;} 88 if ($distGroup eq "MD10") {return $distGroup;} 89 if ($distGroup eq "M31") {return $distGroup;} 90 if ($distGroup eq "sts") {return "STS";} 91 if ($distGroup eq "SweetSpot") {return "SS";} 92 if ($distGroup eq "3PI") {return $distGroup;} 93 if ($distGroup eq "ThreePi") {return "3PI";} 94 if ($distGroup eq "SAS") {return "3PI";} 95 96 print "* Do not understand distribution group: '$distGroup'\n"; 97 return undef; 98 } 99 100 ####################################################################################### 101 # 73 102 # Finds all exposures for the provided label and generates PSPS FITS data for them 74 103 # … … 91 120 92 121 # query to retrieve all exposures with the provided label 93 $query = 94 "SELECT DISTINCT rawExp.exp_id ". 95 "FROM camRun, chipRun, rawExp ". 96 "WHERE camRun.chip_id = chipRun.chip_id ". 97 "AND chipRun.exp_id = rawExp.exp_id ". 98 "AND camRun.label like '%$label%' ". 99 # "AND rawExp.decl >= '-0.157079633' AND rawExp.decl <= '0.157079633' ". # TODO Jim's decl range 100 "ORDER BY rawExp.exp_id ASC"; 122 $query = $db->prepare(<<SQL); 123 124 SELECT DISTINCT rawExp.exp_id, camRun.dist_group 125 FROM camRun, chipRun, rawExp 126 WHERE camRun.chip_id = chipRun.chip_id 127 AND chipRun.exp_id = rawExp.exp_id 128 AND camRun.label like '%$label%' 129 ORDER BY rawExp.exp_id ASC 130 SQL 101 131 } 102 132 else { 103 133 104 $query = "SELECT DISTINCT exp_id FROM rawExp WHERE rawExp.exp_id = $singleExpId" 105 106 } 107 108 if ($verbose) { print"$query\n";} 134 $query = $db->prepare(<<SQL); 135 136 SELECT DISTINCT exp_id FROM rawExp WHERE rawExp.exp_id = $singleExpId 137 SQL 138 } 139 140 if ($verbose) { print"* $query\n";} 109 141 110 142 my $batchId = 0; … … 114 146 my $jobId = getJobId(); 115 147 $jobId++; 116 if ($jobId < 0) { print " Cannot find sensible jobId ($jobId)\n";148 if ($jobId < 0) { print "* Cannot find sensible jobId ($jobId)\n"; 117 149 return 0; 118 150 } 119 151 120 print " ------------------------------------------------------------------------------------------\n\n";152 print "*******************************************************************************\n*\n"; 121 153 122 154 my $anyBatches = 0; 123 155 156 157 $query->execute; 158 124 159 # loop round exposures 125 my $expResults = $db->selectall_arrayref( $query ); 126 127 for my $expRow (@$expResults) { 128 129 my ($expId) = @$expRow; 130 131 print " *** Exposure ID = $expId ***\n"; 160 while (my @row = $query->fetchrow_array()) { 161 my ($expId, $distGroup) = @row; 162 163 print "* Exposure ID = $expId with dist group = '$distGroup'\n"; 164 165 my $surveyType = getSurveyTypeFromDistGroup($distGroup); 166 167 if (!$surveyType) {next;} 168 print "* Using survey type of $surveyType\n"; 132 169 133 170 # generate batch and job paths from job and batch IDs … … 137 174 my $batchOutputPath = sprintf("$jobOutputPath/%s", $batchDir); 138 175 139 print " Preparingjob '$job'...\n";176 print "* Preparing exposure as job '$job'...\n"; 140 177 141 178 # make directories … … 161 198 elsif ($anyBatches) { 162 199 163 if (writeJobManifest($output, $job )) {200 if (writeJobManifest($output, $job, $surveyType)) { 164 201 165 202 if (!$no_publish && !publishToDatastore($output, $job)) { … … 175 212 else { 176 213 177 print " No batches to publish\n"214 print "* No batches to publish\n" 178 215 } 179 216 } 180 217 181 if ($product eq "init" ) {print " Wrote initialisation batch\n"; last;}182 183 184 print " ------------------------------------------------------------------------------------------\n\n";218 if ($product eq "init" ) {print "* Wrote initialisation batch\n"; last;} 219 220 221 print "*\n*******************************************************************************\n\n"; 185 222 } 186 223 … … 204 241 close (MYFILE); 205 242 206 if ($verbose) { print " Current jobId = $jobId\n"; }243 if ($verbose) { print "* Current jobId = $jobId\n"; } 207 244 208 245 return $jobId; … … 221 258 close (MYFILE); 222 259 223 if ($verbose) { print " New jobId = $jobId\n"; }260 if ($verbose) { print "* New jobId = $jobId\n"; } 224 261 } 225 262 … … 265 302 run(command => $command, verbose => $verbose); 266 303 267 if (!$success) { print " Unable to tar up dir: $batch\n" and return 0 };304 if (!$success) { print "* Unable to tar up dir: $batch\n" and return 0 }; 268 305 269 306 # zip … … 272 309 run(command => $command, verbose => $verbose); 273 310 274 if (!$success) { print " Unable to gzip: $batchTar\n" and return 0 };311 if (!$success) { print "* Unable to gzip: $batchTar\n" and return 0 }; 275 312 276 313 $command = "rm $batchTar"; … … 278 315 run(command => $command, verbose => $verbose); 279 316 280 if (!$success) { print " Unable to remove: $batchTar\n" };317 if (!$success) { print "* Unable to remove: $batchTar\n" }; 281 318 282 319 $command = "rm -r $batchDir"; … … 284 321 run(command => $command, verbose => $verbose); 285 322 286 if (!$success) { print " Unable to remove: $batch\n"};323 if (!$success) { print "* Unable to remove: $batch\n"}; 287 324 288 325 return 1; … … 343 380 344 381 # open directory to hunt for FITS files 345 opendir(DIR, $path) or print " Cannot open '$path' to write batch manifest\n" and return 0;382 opendir(DIR, $path) or print "* Cannot open '$path' to write batch manifest\n" and return 0; 346 383 my @thefiles= readdir(DIR); 347 384 closedir(DIR); … … 353 390 if ($f =~ /\.FITS/) { 354 391 355 if ($foundFits) { print " More than one FITS file found for this batch\n"; return 0;}392 if ($foundFits) { print "* More than one FITS file found for this batch\n"; return 0;} 356 393 357 394 # get md5sum of file … … 404 441 405 442 406 if (!$foundFits) { print " Could not find any FITS files for this batch\n"; return 0;}443 if (!$foundFits) { print "* Could not find any FITS files for this batch\n"; return 0;} 407 444 return 1; 408 445 } … … 414 451 ####################################################################################### 415 452 sub writeJobManifest { 416 my ($path, $job ) = @_;453 my ($path, $job, $surveyType) = @_; 417 454 418 455 use XML::Writer; … … 433 470 $writer->startTag('manifest', 434 471 "name" => "$job", 435 "type" => "3PI", # TODO survey ID472 "type" => $surveyType, 436 473 "timestamp" => "$timeStamp"); 437 474 … … 439 476 440 477 # open directory to hunt for FITS files 441 opendir(DIR, $jobPath) or print " Cannot open '$path' to write job manifest\n" and return 0;478 opendir(DIR, $jobPath) or print "* Cannot open '$path' to write job manifest\n" and return 0; 442 479 my @thefiles= readdir(DIR); 443 480 closedir(DIR); … … 472 509 $writer->end(); 473 510 474 if (!$foundBatch) { print " Could not find any batches for this job\n"; return 0;}511 if (!$foundBatch) { print "* Could not find any batches for this job\n"; return 0;} 475 512 return 1; 476 513 } … … 489 526 490 527 # loop through all batch files in this job directory 491 opendir(DIR, $fullJobPath) or print " Cannot open '$fullJobPath' in order to publish to datastore\n" and return 0;528 opendir(DIR, $fullJobPath) or print "* Cannot open '$fullJobPath' in order to publish to datastore\n" and return 0; 492 529 my @thefiles= readdir(DIR); 493 530 closedir(DIR); … … 519 556 run(command => $command, verbose => $verbose); 520 557 521 if (!$success) { print " Unable to publish $job to datastore\n" and return 0 };522 523 print " Successfully published $job to datastore\n";558 if (!$success) { print "* Unable to publish $job to datastore\n" and return 0 }; 559 560 print "* Successfully published $job to datastore\n"; 524 561 525 562 close($tempFile); … … 558 595 "WHERE rawExp.exp_id = $expId AND camRun.magicked"; 559 596 560 if ($verbose) { print" $query\n";}597 if ($verbose) { print"* $query\n";} 561 598 562 599 … … 564 601 my $results = $db->selectall_arrayref( $query ); 565 602 my $size = @$results; 566 if ($size < 1) {print " No smf files found for this exposure\n"; return 0;}603 if ($size < 1) {print "* No smf files found for this exposure\n"; return 0;} 567 604 568 605 # loop round db results TODO should only be one result … … 604 641 "WHERE rawExp.exp_id = $expId AND camRun.magicked"; 605 642 606 if ($verbose) { print" $query\n";}643 if ($verbose) { print"* $query\n";} 607 644 608 645 # execute query and check results 609 646 my $results = $db->selectall_arrayref( $query ); 610 647 my $size = @$results; 611 if ($size < 1) {print " No cmf files found for this exposure\n"; return 0;}648 if ($size < 1) {print "* No cmf files found for this exposure\n"; return 0;} 612 649 613 650 my ($tempFile, $tempName) = tempfile( "inputFileList.XXXX", UNLINK => !$save_temps);
Note:
See TracChangeset
for help on using the changeset viewer.
