IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 6, 2011, 11:00:22 AM (15 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20110710/ippToPsps/src
Files:
18 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110710/ippToPsps/src

    • Property svn:ignore
      •  

        old new  
        55*.lo
        66*.la
        7 ippToPsps
        87config.h
        98config.h.in
        109stamp-h1
        1110VersionDefinitions.h
        12 detectionbatch
        13 initbatch
        14 stackbatch
        15 
         11dvograbber
  • branches/eam_branches/ipp-20110710/ippToPsps/src/Dvo.c

    r31265 r32337  
    2727  Gets detections for this imageid
    2828  */
    29 static bool getDetections(Dvo* this, int32_t sourceId, int32_t imageId) {
     29static bool getDetections(Dvo* this) {
    3030
    3131    SkyList* skyList = NULL;
    3232    Image* image = NULL;
    33     this->logger->print(this->logger, MSG_INFO, "Dvo", "Getting skylist from DVO database...\n");
    34     skyList = dvoSkyListByExternID(this->dvoConfig, sourceId, imageId, &image);
    35     if (!skyList) {
    36 
    37         this->logger->print(this->logger, MSG_ERROR,
    38                 "Dvo", "Could not find skylist for sourceId=%d and image ID = %d\n",
    39                 sourceId, imageId);
    40 
    41         return false;
    42     }
    43     this->logger->print(this->logger, MSG_INFO, "Dvo", "...done\n");
    44 
    45     // now get detections
    46     this->logger->print(this->logger, MSG_INFO, "Dvo", "Getting detections...\n");
    47     dvoDetection* dvoDetections = NULL;
    48     int32_t maxDetectionId = -1;
    49     int32_t numDetections =
    50         dvoGetDetections(skyList, image->imageID, &dvoDetections, &maxDetectionId);
    51 
    52     this->logger->print(this->logger, MSG_INFO, "Dvo",
    53             "Found %d detections with a max detection ID of %d\n",
    54             numDetections, maxDetectionId);
    55 
    56     if (dvoDetections) dvoFree(dvoDetections);
    57     SkyListFree(skyList);
    58 
    59     this->logger->print(this->logger, MSG_INFO, "Dvo", "Deleting everything from dvo table\n");
    60     mysql_query(this->mysql, "DELETE FROM dvo");
    61 
    62     this->logger->print(this->logger, MSG_INFO, "Dvo", "Inserting IDs into dvo table...\n");
    63    
     33
     34    this->logger->print(this->logger, MSG_INFO, "Dvo", "Deleting everything from the dvoDetection table\n");
     35    mysql_query(this->mysql, "DELETE FROM dvoDetection");
     36
     37    mysql_query(this->mysql, "SELECT sourceID, externID FROM dvoMeta");
     38    MYSQL_RES* result = mysql_store_result(this->mysql);
     39
     40    // loop through all souceID/imageIDs
     41    MYSQL_ROW row;
    6442    char sql[500];
    65     for (int i=0; i<numDetections; i++) {
     43    int sourceID, externID;
     44    while ((row = mysql_fetch_row(result))) {
     45
     46        sourceID = atoi(row[0]);
     47        externID = atoi(row[1]);
     48
     49        this->logger->print(this->logger, MSG_INFO, "Dvo", "---------------------------------------------------------------------\n");
     50        this->logger->print(this->logger, MSG_INFO, "Dvo", "Getting skylist from DVO database for source ID = %d and extern ID = %d\n",
     51                sourceID, externID);
     52        skyList = dvoSkyListByExternID(this->dvoConfig, sourceID, externID, &image);
     53        if (!skyList) {
     54
     55            this->logger->print(this->logger, MSG_ERROR,
     56                    "Dvo", "Could not find skylist for sourceId=%d and extern ID = %d\n",
     57                    sourceID, externID);
     58
     59            continue;
     60        }
    6661
    6762        sprintf(sql,
    68                 "INSERT INTO dvo (ippDetectID, ippObjID, objID) VALUES (%u, %lu, %lu)",
    69                 dvoDetections[i].meas.detID,
    70                 (uint64_t)dvoDetections[i].ave.catID*1000000000 + (uint64_t)dvoDetections[i].ave.objID,
    71                 dvoDetections[i].ave.extID);
    72 
     63                "UPDATE dvoMeta SET imageID = %d,flags = %d, photcode = %d WHERE sourceID = %d AND externID = %d",
     64                image->imageID,
     65                image->flags,
     66                image->photcode,
     67                sourceID,
     68                externID);
    7369        mysql_query(this->mysql, sql);
    74     }
    75     this->logger->print(this->logger, MSG_INFO, "Dvo", "...done\n");
    76 
    77 #if 0
    78     mysql_query(this->mysql, "SELECT * FROM Filter");
    79     MYSQL_RES* result = mysql_store_result(this->mysql);
    80 
    81     int num_fields = mysql_num_fields(result);
    82 
    83     MYSQL_ROW row;
    84 
    85     while ((row = mysql_fetch_row(result))) {
    86 
    87         for(int i = 0; i < num_fields; i++) {
    88 
    89             printf("%s ", row[i] ? row[i] : "NULL");
     70
     71        // now get detections
     72        this->logger->print(this->logger, MSG_INFO, "Dvo", "Getting detections...\n");
     73        dvoDetection* dvoDetections = NULL;
     74        int32_t maxDetectionId = -1;
     75        int32_t numDetections =
     76            dvoGetDetections(skyList, image->imageID, &dvoDetections, &maxDetectionId);
     77
     78        this->logger->print(this->logger, MSG_INFO, "Dvo",
     79                "Found %d detections with a max detection ID of %d\n",
     80                numDetections, maxDetectionId);
     81
     82
     83        this->logger->print(this->logger, MSG_INFO, "Dvo", "Inserting IDs into dvoDetection table...\n");
     84
     85        uint32_t zeroDvoCount = 0;
     86        for (int i=0; i<maxDetectionId+1; i++) {
     87
     88            if (dvoDetections[i].ave.extID == 0) {
     89                zeroDvoCount++;
     90            }
     91            else {
     92                sprintf(sql,
     93                        "INSERT INTO dvoDetection (sourceID, imageID, ippDetectID, detectID, ippObjID, objID, flags) VALUES (%d, %d, %u, %lu, %lu, %lu, %u)",
     94                        sourceID,   // sourceID
     95                        image->imageID,    // imageID
     96                        dvoDetections[i].meas.detID,   // ippDetectID
     97                        dvoDetections[i].meas.extID,   // detectID
     98                        (uint64_t)dvoDetections[i].ave.catID*1000000000 + (uint64_t)dvoDetections[i].ave.objID, // ippObjID
     99                        dvoDetections[i].ave.extID, // objID
     100                        dvoDetections[i].meas.dbFlags); // flags
     101
     102                mysql_query(this->mysql, sql);
     103            }
    90104        }
    91         printf("\n");
     105
     106        if (zeroDvoCount) this->logger->print(this->logger, MSG_ERROR, "Dvo", "Found %d 0 object IDs\n", zeroDvoCount);
     107        if (dvoDetections) dvoFree(dvoDetections);
     108        SkyListFree(skyList);
    92109    }
    93110
    94111    mysql_free_result(result);
    95 #endif
     112
    96113    return true;
    97114}
     
    100117  Constructor.
    101118  */
    102 Dvo* new_Dvo(Logger* logger, const char* dvoDatabase) {
     119Dvo* new_Dvo(Logger* logger, const char* configFile, const char* dvoDatabase) {
    103120
    104121    Dvo* this = (Dvo*)calloc(1, sizeof(Dvo));
     
    106123    this->logger->print(this->logger, MSG_DEBUG, "Dvo", "Constructor\n");
    107124
    108     const char *configFile = "jython/config.xml";
    109125    this->logger->print(this->logger, MSG_INFO, "Dvo", "Using config file here '%s'\n", configFile);
    110126    xmlDoc* doc = xmlReadFile(configFile, NULL, 0);
     
    202218}
    203219
    204 
    205220/**
    206221  Main
     
    210225    Logger* logger = new_Logger(NULL, true);
    211226
    212     Dvo * dvo = new_Dvo(logger, "/data/ipp004.0/gpc1/catdirs/ThreePi.V1");
    213     dvo->getDetections(dvo, 33, 8345290);
    214     dvo->destroy(dvo);
     227    if (argc < 3) {
     228
     229        logger->print(logger, MSG_ERROR, "Dvo", "Incorrect arguments\n");
     230        logger->print(logger, MSG_INFO, "Dvo", "Usage: ./dvo <pathToConfig> <pathToDvo>\n");
     231    }
     232    else {
     233        //Dvo * dvo = new_Dvo(logger, "/data/ipp004.0/gpc1/catdirs/ThreePi.V1");
     234        Dvo * dvo = new_Dvo(logger, argv[1], argv[2]);
     235        //dvo->getDetections(dvo, 33, 8345290);
     236        dvo->getDetections(dvo);
     237        dvo->destroy(dvo);
     238    }
    215239
    216240    logger->destroy(logger);
  • branches/eam_branches/ipp-20110710/ippToPsps/src/Dvo.h

    r31265 r32337  
    4242
    4343// constructor
    44 Dvo* new_Dvo(Logger* logger, const char* dvoDatabase);
     44Dvo* new_Dvo(Logger* logger, const char* configFile, const char* dvoDatabase);
    4545
    4646#endif // IPPTOPSPS_DVO_H
  • branches/eam_branches/ipp-20110710/ippToPsps/src/Makefile.am

    r31266 r32337  
    2121
    2222# all the programs we create
    23 bin_PROGRAMS = dvo initbatch detectionbatch stackbatch
     23bin_PROGRAMS = dvograbber
    2424
    2525
    2626# DVO
    27 dvo_CFLAGS = $(IPPTOPSPS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -I/usr/include/libxml2
    28 dvo_LDFLAGS = $(IPPTOPSPS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) -lxml2
    29 dvo_SOURCES = \
     27dvograbber_CFLAGS = $(IPPTOPSPS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -I/usr/include/libxml2
     28dvograbber_LDFLAGS = $(IPPTOPSPS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) -lxml2
     29dvograbber_SOURCES = \
    3030        Dvo.c \
    3131        Logger.c
    32 
    33 # initbatch
    34 initbatch_CFLAGS = $(IPPTOPSPS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -I/usr/include/libxml2
    35 initbatch_LDFLAGS = $(IPPTOPSPS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) -lxml2
    36 initbatch_SOURCES = \
    37         InitBatch.c \
    38         Batch.c \
    39         Version.c \
    40         Fits.c \
    41         InitData.c \
    42         Logger.c \
    43         FitsGenerator.c
    44 
    45 # detectionbatch
    46 detectionbatch_CFLAGS = $(IPPTOPSPS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -I/usr/include/libxml2
    47 detectionbatch_LDFLAGS = $(IPPTOPSPS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) -lxml2
    48 detectionbatch_SOURCES = \
    49         DetectionBatch.c \
    50         Batch.c \
    51         Version.c \
    52         Fits.c \
    53         InitData.c \
    54         Logger.c \
    55         FitsGenerator.c
    56 
    57 # stackbatch
    58 stackbatch_CFLAGS = $(IPPTOPSPS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -I/usr/include/libxml2
    59 stackbatch_LDFLAGS = $(IPPTOPSPS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) -lxml2
    60 stackbatch_SOURCES = \
    61         StackBatch.c \
    62         Batch.c \
    63         Version.c \
    64         Fits.c \
    65         InitData.c \
    66         Logger.c \
    67         FitsGenerator.c
    6832
    6933clean-local:
Note: See TracChangeset for help on using the changeset viewer.