Changeset 28529
- Timestamp:
- Jun 28, 2010, 4:26:47 PM (16 years ago)
- Location:
- trunk/ippToPsps
- Files:
-
- 4 edited
-
scripts/ippToPsps_run.pl (modified) (6 diffs)
-
src/ippToPsps.c (modified) (5 diffs)
-
src/ippToPsps.h (modified) (1 diff)
-
src/ippToPspsBatchDetection.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/scripts/ippToPsps_run.pl
r28260 r28529 10 10 use constant DB_SOCKET => '/var/run/mysqld/mysqld.sock'; 11 11 use File::Temp qw(tempfile); 12 use XML::LibXML; 12 13 13 14 # globals … … 73 74 74 75 # make a temporary file for saving results 75 my ($resultsFile, $resultsFile Name) = tempfile( "/tmp/ippToPsps_results.XXXX", UNLINK => !$save_temps);76 my ($resultsFile, $resultsFilePath) = tempfile( "/tmp/ippToPsps_results.XXXX", UNLINK => !$save_temps); 76 77 77 78 process(); … … 118 119 } 119 120 120 121 121 ####################################################################################### 122 122 # … … 160 160 AND chipRun.exp_id = rawExp.exp_id 161 161 AND camRun.dist_group = '$survey' 162 AND rawExp.dateobs >= '2010-02-20' 162 163 GROUP BY rawExp.exp_id 163 164 ORDER BY rawExp.exp_id ASC; … … 457 458 458 459 # read results 459 open (MYFILE, $resultsFileName); 460 my $i = 0; 461 462 # detection results 463 my $minObjId; 464 my $maxObjId; 465 my $filename; 466 if($batchType eq 'det') { 467 468 while (<MYFILE>) { 469 chomp; 470 if ($i == 0) { $filename = $_; } 471 if ($i == 1) { $minObjId = $_; } 472 if ($i == 2) { $maxObjId = $_; } 473 $i++; 474 } 475 } 476 close (MYFILE); 460 my $parser = XML::LibXML->new; 461 my $doc = $parser->parse_file($resultsFilePath); 462 my $filename = $doc->findvalue('//filename'); 463 my $minObjId = $doc->findvalue('//minObjID'); 464 my $maxObjId = $doc->findvalue('//maxObjID'); 477 465 478 466 # create XML file … … 794 782 $command .= " -survey $surveyType"; 795 783 $command .= " -batch $batchType"; 796 $command .= " -results $resultsFile Name";784 $command .= " -results $resultsFilePath"; 797 785 798 786 # run command -
trunk/ippToPsps/src/ippToPsps.c
r28249 r28529 53 53 } 54 54 55 // save XML document for results 56 if (this->resultsXmlDoc) { 57 58 xmlSaveFormatFileEnc(this->resultsPath, this->resultsXmlDoc, "UTF-8", 1); 59 60 xmlFreeDoc(this->resultsXmlDoc); 61 xmlCleanupParser(); 62 xmlMemoryDump(); 63 } 64 55 65 psFree(this->fitsInPath); 56 66 psFree(this->resultsPath); … … 59 69 psFree(this->pmconfig); 60 70 61 if (this->resultsFile) fclose(this->resultsFile);62 71 63 72 for(uint32_t i=0; i<this->numOfInputFiles; i++) … … 246 255 this->fitsInPath = NULL; 247 256 this->resultsPath = NULL; 248 this->results File= NULL;257 this->resultsXmlDoc = NULL; 249 258 this->numOfInputFiles = 0; 250 259 this->inputFiles = NULL; … … 304 313 } 305 314 315 // create a config object 306 316 this->config = ippToPspsConfig_Constructor(this->configsDir); 307 317 if (this->config == NULL) { … … 311 321 } 312 322 313 // ready results file, if necessary323 // create XML document for results 314 324 if (this->resultsPath) { 315 325 316 this->resultsFile = fopen (this->resultsPath, "w+"); 317 318 if (this->resultsFile == NULL) { 319 320 psError(PS_ERR_UNKNOWN, false, "Unable to open results file at %s", this->resultsPath); 321 // not essential to write results, so don't bail out 322 } 323 else { 324 if (fprintf(this->resultsFile, "%s\n", outputName) < 1 ) 325 psError(PS_ERR_IO, false, "Unable to write FITS output filename to'%s'\n", this->resultsPath); 326 } 326 this->resultsXmlDoc = xmlNewDoc(BAD_CAST "1.0"); 327 xmlNodePtr rootNode = xmlNewNode(NULL, BAD_CAST "ippToPsps_Results"); 328 xmlDocSetRootElement(this->resultsXmlDoc, rootNode); 329 xmlNewChild(rootNode, NULL, BAD_CAST "filename", BAD_CAST outputName); 327 330 } 328 331 -
trunk/ippToPsps/src/ippToPsps.h
r28249 r28529 20 20 typedef struct { 21 21 22 uint32_t expId; // the exposure ID to be used23 psString expName; // the exposure name24 psString surveyType; // the survey type, eg 3PI, MD01, STS, SSS25 uint8_t batchType; // PSPS batch type26 psString fitsInPath; // path to FITS input27 psString resultsPath; // path to results file28 FILE* resultsFile; // file for results29 uint16_t numOfInputFiles; // number of input files30 char** inputFiles; // array of input file names31 psString fitsOutPath; // path to FITS output32 fitsfile *fitsOut; // output FITS file33 psString configsDir; // path to IPP/PSPS mapping file34 pmConfig* pmconfig; // pmConfig35 dvoConfig* dvoConfig; // dvo database36 IppToPspsConfig* config; // config structure37 int exitCode; // ps exit code22 uint32_t expId; // the exposure ID to be used 23 psString expName; // the exposure name 24 psString surveyType; // the survey type, eg 3PI, MD01, STS, SSS 25 uint8_t batchType; // PSPS batch type 26 psString fitsInPath; // path to FITS input 27 psString resultsPath; // path to results file 28 xmlDocPtr resultsXmlDoc; // pointer to XML document for results 29 uint16_t numOfInputFiles; // number of input files 30 char** inputFiles; // array of input file names 31 psString fitsOutPath; // path to FITS output 32 fitsfile *fitsOut; // output FITS file 33 psString configsDir; // path to IPP/PSPS mapping file 34 pmConfig* pmconfig; // pmConfig 35 dvoConfig* dvoConfig; // dvo database 36 IppToPspsConfig* config; // config structure 37 int exitCode; // ps exit code 38 38 39 39 int (*run)(); -
trunk/ippToPsps/src/ippToPspsBatchDetection.c
r28424 r28529 386 386 387 387 // write results 388 if (this->resultsFile) { 389 390 if (fprintf(this->resultsFile, "%ld\n", minObjID) < 1 ) 391 psError(PS_ERR_IO, false, "Unable to write min Object ID to'%s'\n", this->resultsPath); 392 if (fprintf(this->resultsFile, "%ld\n", maxObjID) < 1 ) 393 psError(PS_ERR_IO, false, "Unable to write max Object ID to'%s'\n", this->resultsPath); 394 if (fprintf(this->resultsFile, "%ld\n", totalDetectionsOut) < 1 ) 395 psError(PS_ERR_IO, false, "Unable to write totalDetectionsOut to'%s'\n", this->resultsPath); 388 if (this->resultsXmlDoc) { 389 390 xmlNodePtr rootNode = xmlDocGetRootElement(this->resultsXmlDoc); 391 char tmp[100]; 392 sprintf(tmp, "%ld", minObjID); 393 xmlNewChild(rootNode, NULL, BAD_CAST "minObjID", BAD_CAST tmp); 394 sprintf(tmp, "%ld", maxObjID); 395 xmlNewChild(rootNode, NULL, BAD_CAST "maxObjID", BAD_CAST tmp); 396 sprintf(tmp, "%ld", totalDetectionsOut); 397 xmlNewChild(rootNode, NULL, BAD_CAST "totalDetections", BAD_CAST tmp); 396 398 } 397 399
Note:
See TracChangeset
for help on using the changeset viewer.
