IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28529


Ignore:
Timestamp:
Jun 28, 2010, 4:26:47 PM (16 years ago)
Author:
rhenders
Message:

Now storing results in XML format

Location:
trunk/ippToPsps
Files:
4 edited

Legend:

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

    r28260 r28529  
    1010use constant DB_SOCKET => '/var/run/mysqld/mysqld.sock';
    1111use File::Temp qw(tempfile);
     12use XML::LibXML;
    1213
    1314# globals
     
    7374
    7475# make a temporary file for saving results
    75 my ($resultsFile, $resultsFileName) = tempfile( "/tmp/ippToPsps_results.XXXX", UNLINK => !$save_temps);
     76my ($resultsFile, $resultsFilePath) = tempfile( "/tmp/ippToPsps_results.XXXX", UNLINK => !$save_temps);
    7677
    7778process();
     
    118119}
    119120
    120 
    121121#######################################################################################
    122122#
     
    160160            AND chipRun.exp_id = rawExp.exp_id
    161161            AND camRun.dist_group = '$survey'   
     162            AND rawExp.dateobs >= '2010-02-20'
    162163            GROUP BY  rawExp.exp_id
    163164            ORDER BY rawExp.exp_id ASC;
     
    457458
    458459    # 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');
    477465
    478466    # create XML file
     
    794782    $command .= " -survey $surveyType";
    795783    $command .= " -batch $batchType";
    796     $command .= " -results $resultsFileName";
     784    $command .= " -results $resultsFilePath";
    797785
    798786    # run command
  • trunk/ippToPsps/src/ippToPsps.c

    r28249 r28529  
    5353    }
    5454
     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
    5565    psFree(this->fitsInPath);
    5666    psFree(this->resultsPath);
     
    5969    psFree(this->pmconfig);
    6070
    61     if (this->resultsFile) fclose(this->resultsFile);
    6271
    6372    for(uint32_t i=0; i<this->numOfInputFiles; i++)
     
    246255    this->fitsInPath = NULL;
    247256    this->resultsPath = NULL;
    248     this->resultsFile = NULL;
     257    this->resultsXmlDoc = NULL;
    249258    this->numOfInputFiles = 0;
    250259    this->inputFiles = NULL;
     
    304313    }
    305314
     315    // create a config object
    306316    this->config = ippToPspsConfig_Constructor(this->configsDir);
    307317    if (this->config == NULL) {
     
    311321    }
    312322
    313     // ready results file, if necessary
     323    // create XML document for results
    314324    if (this->resultsPath) {
    315325
    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);
    327330    }
    328331
  • trunk/ippToPsps/src/ippToPsps.h

    r28249 r28529  
    2020typedef struct {
    2121
    22     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     FILE* resultsFile;         // file 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
     22    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
    3838
    3939    int (*run)();
  • trunk/ippToPsps/src/ippToPspsBatchDetection.c

    r28424 r28529  
    386386
    387387    // 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);
    396398    }
    397399
Note: See TracChangeset for help on using the changeset viewer.