IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34303


Ignore:
Timestamp:
Aug 13, 2012, 8:34:55 PM (14 years ago)
Author:
eugene
Message:

adding ImageID check options

Location:
branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/src/dvoverify.c

    r34260 r34303  
    4242  }
    4343
     44  if (CHECK_IMAGE_ID) {
     45    LoadImageIDs (CATDIR);
     46  }
     47
    4448  // load the sky table for the existing database
    4549  sky = SkyTableLoadOptimal (CATDIR, NULL, NULL, FALSE, SKY_DEPTH_HST, VERBOSE);
  • branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/src/dvoverify_args.c

    r34260 r34303  
    5353  if ((N = get_argument (*argc, argv, "-skip-toplevel"))) {
    5454    CHECK_TOPLEVEL = FALSE;
     55    remove_argument (N, argc, argv);
     56  }
     57
     58  CHECK_IMAGE_ID = TRUE;
     59  if ((N = get_argument (*argc, argv, "-skip-image-ids"))) {
     60    CHECK_IMAGE_ID = FALSE;
    5561    remove_argument (N, argc, argv);
    5662  }
  • branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/src/dvoverify_catalogs.c

    r34260 r34303  
    100100
    101101    char tmpline[DVO_MAX_PATH];
    102     if (VERBOSE)      { snprintf (tmpline, DVO_MAX_PATH, "%s -v", command); strcpy (command, tmpline); }
    103     if (CHECKSORTED)  { snprintf (tmpline, DVO_MAX_PATH, "%s -s", command); strcpy (command, tmpline); }
    104     if (LIST_MISSING) { snprintf (tmpline, DVO_MAX_PATH, "%s -list-missing", command); strcpy (command, tmpline); }
     102    if (VERBOSE)         { snprintf (tmpline, DVO_MAX_PATH, "%s -v", command); strcpy (command, tmpline); }
     103    if (CHECKSORTED)     { snprintf (tmpline, DVO_MAX_PATH, "%s -s", command); strcpy (command, tmpline); }
     104    if (!CHECK_IMAGE_ID) { snprintf (tmpline, DVO_MAX_PATH, "%s -skip-image-ids", command); strcpy (command, tmpline); }
     105    if (LIST_MISSING)    { snprintf (tmpline, DVO_MAX_PATH, "%s -list-missing", command); strcpy (command, tmpline); }
    105106
    106107    fprintf (stderr, "command: %s\n", command);
  • branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/src/dvoverify_client.c

    r34260 r34303  
    1919  skylist = SkyListByPatch (sky, -1, &UserPatch);
    2020 
     21  if (CHECK_IMAGE_ID) {
     22    // XXX in client mode, we should be reading a reduced table generated by the calling
     23    // serial program
     24    LoadImageIDs (CATDIR);
     25  }
     26
    2127  dvoverify_catalogs (skylist, &Nbad);
    2228
  • branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/src/dvoverify_utils.c

    r34260 r34303  
    4949
    5050// is this file a consistent FITS file?
     51// note that VerifyTableFile only has to read the headers,
     52// not the data blocks (it uses stat for sizes)
    5153int VerifyTableFile (char *filename) {
    5254
     
    194196  // \sum average[].Nmeasure = Nmeasure
    195197
    196   // if the table is NOT SORTED, we have a subset of checks we can make
     198  // if the table is NOT SORTED, do we have a subset of checks we can make?
    197199  if (!catalog.sorted) {
    198200    fprintf (stderr, "!");
     
    231233  }
    232234
     235  // if we have a problem with Nmeasure and/or measureOffset values, we
     236  // cannot do any further check -- we risk segfaults
    233237  if (!status) {
    234238    dvo_catalog_unlock (&catalog);
     
    263267  }
    264268
    265 //  for (i = 0; i < catalog.Naverage; i++) {
    266 //    m = catalog.average[i].measureOffset;
    267 //    for (j = 0; i < catalog.Nmeasure; i++) {
    268 //      objIDsOK &= (catalog.average[i].objID == catalog.measure[m+j].objID);
    269 //      catIDsOK &= (catalog.average[i].catID == catalog.measure[m+j].catID);
    270 //      averefOK &= (catalog.measure[m+j].averef = i);
    271 //    }
    272 //  }
     269  // check the image ID here?
     270  if (CHECK_IMAGE_ID) {
     271    int Nfail = CheckImageID (&catalog);
     272    if (Nfail > 0) {
     273      fprintf (stderr, "ERROR: catalog %s has invalid %d unmatched image IDs\n", catalog.filename, Nfail);
     274      status = FALSE;
     275    }
     276  }
    273277
    274278  dvo_catalog_unlock (&catalog);
     
    278282}
    279283
    280 // gfits_scan(&cpmHeaderTBL, "NAXIS1", "%d", 1, &NbytesPerRow);
    281 // gfits_scan(&cpmHeaderTBL, "NAXIS2", "%d", 1, &Nrows);
    282    
     284static int maxID = 0;
     285static int *IDlist = NULL;
     286
     287// check that every measure->imageID (if set) matches an existing
     288// image->ID.  return the number of failures.
     289int CheckImageID (Catalog *catalog) {
     290
     291  off_t i, j, m, id;
     292  int Nfail = 0;
     293
     294  for (i = 0; i < catalog[0].Naverage; i++) {
     295    m = catalog[0].average[i].measureOffset;
     296    for (j = 0; j < catalog[0].average[i].Nmeasure; j++) {
     297      id = catalog[0].measure[m+j].imageID;
     298      if (id > maxID) {
     299        Nfail ++;
     300        continue;
     301        // is this sufficient to catch IDs set without an image table?
     302      }
     303      if (IDlist) {
     304        if (IDlist[id] < 0) {
     305          Nfail ++;
     306          continue;
     307        }
     308      } else {
     309        if (id > 0) {
     310          Nfail ++;
     311          continue;
     312        }
     313      }
     314    }
     315  }
     316  return Nfail;
     317}
     318
     319int LoadImageIDs (char *catdir) {
     320
     321  int status;
     322  off_t Nimages, i;
     323  Image *images;
     324  FITS_DB inDB;
     325
     326  char ImageCat[DVO_MAX_PATH];
     327  snprintf (ImageCat, DVO_MAX_PATH, "%s/Images.dat", catdir);
     328
     329  // load the iage database table
     330  status = dvo_image_lock (&inDB, ImageCat, 3600.0, LCK_SOFT);  // shorter timeout?
     331  if (!status) {
     332    fprintf (stderr, "ERROR: failure to lock image catalog %s", inDB.filename);
     333    exit (3);
     334  }
     335
     336  // load the image table
     337  if (inDB.dbstate == LCK_EMPTY) {
     338    dvo_image_unlock (&inDB); // unlock input
     339    // this is not an error: we can have no image table for, eg, 2MASS only db
     340    return TRUE;
     341  }
     342  if (!dvo_image_load (&inDB, VERBOSE, TRUE)) {
     343    fprintf (stderr, "can't read input image catalog %s", inDB.filename);
     344    exit (4);
     345  }
     346
     347  images = gfits_table_get_Image (&inDB.ftable, &Nimages, &inDB.swapped);
     348  if (!images) {
     349    fprintf (stderr, "ERROR: failed to read images from src\n");
     350    exit (2);
     351  }
     352
     353  // generate a lookup table for the images
    283354 
     355  // first, find the max imageID
     356  for (i = 0; i < Nimages; i++) {
     357    maxID = MAX(maxID, images[i].imageID);
     358  }
     359
     360  ALLOCATE (IDlist, int, maxID + 1);
     361  for (i = 0; i < maxID + 1; i++) {
     362    IDlist[i] = -1;
     363  }
     364
     365  for (i = 0; i < Nimages; i++) {
     366    int id = images[i].imageID;
     367    IDlist[id] = i;
     368  }
     369
     370  // free image table here?
     371  // (in the future, I'll have to do the image table read in segments
     372  // it is just getting to be too large...)
     373  dvo_image_unlock (&inDB); // unlock input
     374
     375  return TRUE;
     376}
Note: See TracChangeset for help on using the changeset viewer.