IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38717


Ignore:
Timestamp:
Sep 8, 2015, 11:37:39 AM (11 years ago)
Author:
eugene
Message:

test for photcode = 0 before checking on uniq externID values

Location:
branches/eam_branches/ipp-20150625/Ohana/src/dvomerge
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20150625/Ohana/src/dvomerge/include/dvoutils.h

    r38622 r38717  
    2222} DVOUTILS_OP_TYPE;
    2323
     24typedef struct {
     25  int   *externID;
     26  short *photcode;
     27  int Nimages;
     28} ImageData;
     29
    2430int VERBOSE;
    2531int DVOUTILS_OP;
     
    3036int dvoutils_args (int *argc, char **argv);
    3137int dvoutils_uniq_images (char *filename);
    32 int *dvoutils_load_image_index (char *filename, int *nindex);
     38
     39ImageData *dvoutils_load_image_index (char *filename);
    3340
    3441Image *dvoutils_load_image_table (char *filename, int *nimage);
  • branches/eam_branches/ipp-20150625/Ohana/src/dvomerge/src/dvoutils_load_image_index.c

    r38441 r38717  
    22
    33// load the array of EXTERN_ID from the ImageIndex.fits tables
    4 int *dvoutils_load_image_index (char *filename, int *nindex) {
     4ImageData *dvoutils_load_image_index (char *filename) {
    55
    66  int Ncol;
    7   off_t Nrow;
     7  off_t Nrow, Nphot;
    88  Header header;
    99  Header theader;
     
    4646  fclose (f);
    4747
    48   int *externID = gfits_get_bintable_column_data (&theader, &ftable, "EXTERN_ID", type, &Nrow, &Ncol);
     48  ImageData *imdata = NULL;
     49  ALLOCATE (imdata, ImageData, 1);
     50
     51  imdata->externID = gfits_get_bintable_column_data (&theader, &ftable, "EXTERN_ID", type, &Nrow, &Ncol);
    4952  myAssert (!strcmp(type, "int"), "wrong column type");
     53
     54  imdata->photcode = gfits_get_bintable_column_data (&theader, &ftable, "PHOTCODE", type, &Nphot, &Ncol);
     55  myAssert (Nphot == Nrow, "photcode & extern_id mis-match");
     56
     57  imdata->Nimages = Nrow;
    5058
    5159  gfits_free_header (&header);
     
    5462  gfits_free_table  (&ftable);
    5563
    56   *nindex = Nrow;
    57 
    58   return externID;
     64  return imdata;
    5965}
    6066
  • branches/eam_branches/ipp-20150625/Ohana/src/dvomerge/src/dvoutils_uniq_images.c

    r38441 r38717  
    4040    }
    4141
    42     int Nimage;
    43     // Image *image = dvoutils_load_image_table (imFile, &Nimage);
    44     int *extern_id = dvoutils_load_image_index (imFile, &Nimage);
    45     if (!extern_id) continue;
     42    ImageData *imdata = dvoutils_load_image_index (imFile);
     43    if (!imdata) continue;
    4644
    4745    DBlist[Ndb] = strcreate (imFile);
     
    5755
    5856    int i;
    59     for (i = 0; i < Nimage; i++) {
    60       if (!extern_id[i]) continue;
    61       myMaxID = MAX(extern_id[i], myMaxID);
    62       myMinID = MIN(extern_id[i], myMinID);
     57    int Nbad = 0;
     58    for (i = 0; i < imdata->Nimages; i++) {
     59      if (!imdata->photcode[i] && imdata->externID[i]) myAbort ("invalid combo");
     60
     61      if (!imdata->photcode[i]) continue;
     62      if (!imdata->externID[i]) {
     63        Nbad ++;
     64        continue;
     65      }
     66      myMaxID = MAX(imdata->externID[i], myMaxID);
     67      myMinID = MIN(imdata->externID[i], myMinID);
    6368    }
    6469
    65     fprintf (stderr, "read %s, %d images, %d - %d vs %d - %d\n", imFile, (int) Nimage, myMinID, myMaxID, minID, maxID);
     70    fprintf (stderr, "read %s, %d images, %d - %d vs %d - %d\n", imFile, (int) imdata->Nimages, myMinID, myMaxID, minID, maxID);
     71
     72    if (Nbad) {
     73      fprintf (stderr, "WARNING: %d images without extern_id set\n", (int) Nbad);
     74    }
    6675
    6776    // if this is new, we treat it a bit differently
     
    124133    }
    125134
    126     for (i = 0; i < Nimage; i++) {
    127       if (!extern_id[i]) continue;
    128       int n = extern_id[i] - minID;
     135    for (i = 0; i < imdata->Nimages; i++) {
     136      if (!imdata->externID[i]) continue;
     137      int n = imdata->externID[i] - minID;
    129138      if (IDlist[n] == 0) {
    130139        DBfound[n] = Ndb;
     
    133142      IDlist[n] ++;
    134143      if (VERBOSE && (IDlist[n] > 1)) {
    135         fprintf (stderr, "duplicate ext_id %d in file %s\n", extern_id[i], imFile);
     144        fprintf (stderr, "duplicate ext_id %d in file %s\n", imdata->externID[i], imFile);
    136145      }
    137146    }
     
    140149      fprintf (stderr, "------------ %s ----------\n", imFile);
    141150
    142       for (i = 0; i < Nimage; i++) {
    143         if (!extern_id[i]) continue;
    144         fprintf (stderr, "%d => %d\n", extern_id[i], extern_id[i] - minID);
     151      for (i = 0; i < imdata->Nimages; i++) {
     152        if (!imdata->externID[i]) continue;
     153        fprintf (stderr, "%d => %d\n", imdata->externID[i], imdata->externID[i] - minID);
    145154      }
    146155
     
    165174    int n = DBfound[i];
    166175    myAssert (n > -1, "impossible!");
    167     fprintf (stdout, "%d : %d -- in %s (%d) : %d \n", i + minID, IDlist[i], DBlist[n], DBfound[i], DBindex[i]);
     176    fprintf (stdout, "primary %d : %d -- in %s (%d) : %d \n", i + minID, IDlist[i], DBlist[n], DBfound[i], DBindex[i]);
    168177  }
    169178
Note: See TracChangeset for help on using the changeset viewer.