IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38636


Ignore:
Timestamp:
Jul 24, 2015, 8:26:59 AM (11 years ago)
Author:
eugene
Message:

working on loadgalphot

Location:
trunk/Ohana/src/addstar
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/addstar/Makefile

    r38553 r38636  
    4040# programs in 'SERVER' use the client-server concept and are out of date
    4141
    42 INSTALL = addstar sedstar loadstarpar loadstarpar_client loadICRF loadICRF_client skycells mkcmf dumpskycells findskycell
     42INSTALL = addstar sedstar loadgalphot loadstarpar loadstarpar_client loadICRF loadICRF_client skycells mkcmf dumpskycells findskycell
    4343OTHERS  = load2mass loadwise loadtycho loadsupercos
    4444SERVER  = addstar_client addstarc addstard addstart
     
    271271$(SRC)/loadgalphot_join.$(ARCH).o \
    272272$(SRC)/loadgalphot_table.$(ARCH).o \
     273$(SRC)/resort_catalog.$(ARCH).o \
    273274$(SRC)/strhash.$(ARCH).o \
    274275$(SRC)/sortIDs.$(ARCH).o \
     
    295296$(SRC)/loadstarpar_save_remote.$(ARCH).o \
    296297$(SRC)/loadstarpar_table.$(ARCH).o \
     298$(SRC)/resort_catalog.$(ARCH).o \
    297299$(SRC)/psps_ids.$(ARCH).o
    298300
     
    312314$(SRC)/loadstarpar_save_remote.$(ARCH).o \
    313315$(SRC)/loadstarpar_table.$(ARCH).o \
     316$(SRC)/resort_catalog.$(ARCH).o \
    314317$(SRC)/psps_ids.$(ARCH).o
    315318
  • trunk/Ohana/src/addstar/include/addstar.h

    r38553 r38636  
    359359Catalog *addstar_catalog_init (int Nstars);
    360360
     361void resort_catalog_measure (Catalog *catalog);
     362void resort_catalog_lensing (Catalog *catalog);
     363void resort_catalog_starpar (Catalog *catalog);
     364void resort_catalog_galphot (Catalog *catalog);
     365
    361366/**
    362367    there is an inconsistency to be resolved: fixed structures (like Image)
  • trunk/Ohana/src/addstar/src/find_matches_galphot.c

    r38553 r38636  
    199199  REALLOCATE (catalog[0].galphot, GalPhot, Ngalphot);
    200200 
    201   catalog[0].sorted = FALSE;
    202 
    203201  /* check if the catalog has changed?  if no change, no need to write */
    204202  catalog[0].objID     = objID; // new max value, save on catalog close
     
    206204  catalog[0].Ngalphot  = Ngalphot;
    207205  catalog[0].Nsecfilt_mem = Nave*Nsecfilt;
     206
     207  // we need to for
     208  catalog[0].sorted = FALSE;
     209  resort_catalog_galphot (catalog);
     210  catalog[0].sorted = TRUE;
     211
    208212  if (VERBOSE) fprintf (stderr, "Nstars, Nave, Ngalphot: %d "OFF_T_FMT" "OFF_T_FMT" ("OFF_T_FMT" matches)\n",  Nstars, Nave, Ngalphot, Nmatch);
    209213
  • trunk/Ohana/src/addstar/src/find_matches_starpar.c

    r38467 r38636  
    199199  REALLOCATE (catalog[0].starpar, StarPar, Nstarpar);
    200200 
    201   catalog[0].sorted = FALSE;
     201  resort_catalog_starpar (catalog);
     202  catalog[0].sorted = TRUE;
    202203
    203204  /* check if the catalog has changed?  if no change, no need to write */
  • trunk/Ohana/src/addstar/src/resort_catalog.c

    r38153 r38636  
    22
    33void SortAveMatch (off_t *MEAS, off_t *AVE, off_t N);
    4 void resort_catalog_measure (Catalog *catalog);
    5 void resort_catalog_lensing (Catalog *catalog);
    6 void resort_catalog_starpar (Catalog *catalog);
    7 
    8 void resort_catalog_old (Catalog *catalog) {
    9 
    10   off_t *next_meas, *next_lens;
    11   off_t Naves, Nmeas, Nlens;
    12 
    13   if (catalog[0].sorted == TRUE) return;
    14 
    15   INITTIME;
    16 
    17   /* internal counters */
    18   Nmeas = catalog[0].Nmeasure;
    19   Nlens = catalog[0].Nlensing;
    20   Naves = catalog[0].Naverage;
    21  
    22   /* set up pointers for linked list of measure, missing */
    23   next_meas = build_measure_links (catalog[0].average, Naves, catalog[0].measure, Nmeas);
    24   next_lens = build_lensing_links (catalog[0].average, Naves, catalog[0].lensing, Nlens);
    25 
    26   catalog[0].sorted = TRUE;
    27   catalog[0].measure = sort_measure (catalog[0].average, Naves, catalog[0].measure, Nmeas, next_meas);
    28   catalog[0].lensing = sort_lensing (catalog[0].average, Naves, catalog[0].lensing, Nlens, next_lens);
    29 
    30   MARKTIME ("  match time %9.4f sec for %7lld measures, %6lld average\n", dtime, (long long) Nmeas, (long long) Naves);
    31 
    32   return;
    33 }
    344
    355void resort_catalog (Catalog *catalog) {
     
    4010  resort_catalog_lensing (catalog);
    4111  resort_catalog_starpar (catalog);
    42 
    43   // XXX somehow need to set the value of lensing->measure offset here
    44 
    45 
     12  resort_catalog_galphot (catalog);
     13  catalog[0].sorted = TRUE;
    4614}
    4715
     
    8856      myAssert(average[averageSeq[i]].catID == measure[measureSeq[i]].catID, "object / detection mismatch");
    8957# if (1)
     58      myAssert (average[averageSeq[i]].objID == measure[measureSeq[i]].objID, "object ID mismatch?");
     59# endif
     60# if (0)
    9061      // myAssert(average[averageSeq[i]].objID == measure[measureSeq[i]].objID, "object / detection mismatch");
    9162      // check if the objID is correct. if not, check if it is byte-swapped (this has happened) and repair if so. 
     
    11081        }
    11182      }
    112 # else
     83# endif
     84# if (0)
    11385      // for reasons I do not understand, the mini dvodbs generated on stsci1X had a handful of detections with an inconsistency between averef and objID. 
    11486      // this happened for 28 detections in the dbs on /data/stsci1?.0/eugene/dvo3pi.20130616, but not at all (as far as I know) in the rest of LAP DVO
     
    196168  // MARKTIME("  match time %9.4f sec for %7lld measures, %6lld average\n", dtime, (long long) Nmeasure, (long long) Naverage);
    197169
    198   catalog[0].sorted = TRUE;
    199 
    200170  FREE (measureSeq);
    201171  FREE (averageSeq);
     
    245215      // earlier formats did not carry the objID or catID, so they are not available (we could assign on load, but we don't)
    246216      myAssert(average[averageSeq[i]].catID == lensing[lensingSeq[i]].catID, "object / detection mismatch");
    247 # if (1)
    248217      myAssert(average[averageSeq[i]].objID == lensing[lensingSeq[i]].objID, "object / detection mismatch");
    249 # else
    250       // for reasons I do not understand, the mini dvodbs generated on stsci1X had a handful of detections with an inconsistency between averef and objID. 
    251       // this happened for 28 detections in the dbs on /data/stsci1?.0/eugene/dvo3pi.20130616, but not at all (as far as I know) in the rest of LAP DVO
    252       if (average[averageSeq[i]].objID != lensing[lensingSeq[i]].objID) {
    253         fprintf (stderr, "R");
    254         lensing[lensingSeq[i]].objID = average[averageSeq[i]].objID; // XXX I don't really like this...
    255       }
    256 # endif
    257     }
    258   }
    259  
    260   // check that averageSeq is now in order
    261   // for (i = 1; i < Nlensing; i++) {
    262   //   if (averageSeq[i] < averageSeq[i-1]) {
    263   //     fprintf (stderr, "%d ", (int) i);
    264   //   }
    265   // }
    266   // fprintf (stderr, "\n");
    267 
     218    }
     219  }
     220 
    268221  SortAveMatch(lensingSeq, averageSeq, Nlensing);
    269   // MARKTIME("sort : %f sec\n", dtime);
    270 
    271   // check that averageSeq is now in order
    272   // for (i = 1; i < Nlensing; i++) {
    273   //   if (averageSeq[i] < averageSeq[i-1]) {
    274   //     fprintf (stderr, "%d ", (int) i);
    275   //   }
    276   // }
    277   // fprintf (stderr, "\n");
    278222
    279223  // copy the lensing entries in the sorted order
     
    283227    lensingTMP[i] = lensing[j];
    284228  }
    285   // MARKTIME("assign lensing : %f sec\n", dtime);
    286229
    287230  // update the values of average.lensingOffset and average.Nlensing
     
    302245    N++;
    303246  }
    304   // N++;
    305247  average[currentAve].Nlensing = N;
    306   // MARKTIME("update Nlensing : %f sec\n", dtime);
    307248
    308249  int NlensingTotal = 0;
     
    330271    fprintf (stderr, "ERROR: catalog %s has an invalid Nlensing\n", catalog[0].filename);
    331272  }
    332 
    333   // MARKTIME("  match time %9.4f sec for %7lld lensings, %6lld average\n", dtime, (long long) Nlensing, (long long) Naverage);
    334 
    335   catalog[0].sorted = TRUE;
    336273
    337274  FREE (lensingSeq);
     
    382319      // earlier formats did not carry the objID or catID, so they are not available (we could assign on load, but we don't)
    383320      myAssert(average[averageSeq[i]].catID == starpar[starparSeq[i]].catID, "object / detection mismatch");
    384 # if (1)
    385321      myAssert(average[averageSeq[i]].objID == starpar[starparSeq[i]].objID, "object / detection mismatch");
    386 # else
    387       // for reasons I do not understand, the mini dvodbs generated on stsci1X had a handful of detections with an inconsistency between averef and objID. 
    388       // this happened for 28 detections in the dbs on /data/stsci1?.0/eugene/dvo3pi.20130616, but not at all (as far as I know) in the rest of LAP DVO
    389       if (average[averageSeq[i]].objID != starpar[starparSeq[i]].objID) {
    390         fprintf (stderr, "R");
    391         starpar[starparSeq[i]].objID = average[averageSeq[i]].objID; // XXX I don't really like this...
    392       }
    393 # endif
    394     }
    395   }
    396  
    397   // check that averageSeq is now in order
    398   // for (i = 1; i < Nstarpar; i++) {
    399   //   if (averageSeq[i] < averageSeq[i-1]) {
    400   //     fprintf (stderr, "%d ", (int) i);
    401   //   }
    402   // }
    403   // fprintf (stderr, "\n");
    404 
     322    }
     323  }
     324 
    405325  SortAveMatch(starparSeq, averageSeq, Nstarpar);
    406   // MARKTIME("sort : %f sec\n", dtime);
    407 
    408   // check that averageSeq is now in order
    409   // for (i = 1; i < Nstarpar; i++) {
    410   //   if (averageSeq[i] < averageSeq[i-1]) {
    411   //     fprintf (stderr, "%d ", (int) i);
    412   //   }
    413   // }
    414   // fprintf (stderr, "\n");
    415326
    416327  // copy the starpar entries in the sorted order
     
    420331    starparTMP[i] = starpar[j];
    421332  }
    422   // MARKTIME("assign starpar : %f sec\n", dtime);
    423333
    424334  // update the values of average.starparOffset and average.Nstarpar
     
    439349    N++;
    440350  }
    441   // N++;
    442351  average[currentAve].Nstarpar = N;
    443   // MARKTIME("update Nstarpar : %f sec\n", dtime);
    444352
    445353  int NstarparTotal = 0;
     
    468376  }
    469377
    470   // MARKTIME("  match time %9.4f sec for %7lld starpars, %6lld average\n", dtime, (long long) Nstarpar, (long long) Naverage);
    471 
    472   catalog[0].sorted = TRUE;
    473 
    474378  FREE (starparSeq);
     379  FREE (averageSeq);
     380
     381  return;
     382}
     383
     384void resort_catalog_galphot (Catalog *catalog) {
     385
     386  off_t Naverage, Ngalphot;
     387  GalPhot *galphot;
     388  Average *average;
     389  off_t i, j, N, currentAve;
     390
     391  off_t *galphotSeq = NULL;
     392  off_t *averageSeq = NULL;
     393  GalPhot *galphotTMP = NULL;
     394
     395  // struct timeval start, stop;
     396  // gettimeofday (&start, NULL);
     397
     398  /* internal counters */
     399  Ngalphot = catalog[0].Ngalphot;
     400  Naverage = catalog[0].Naverage;
     401
     402  if (!Ngalphot) return;
     403
     404  galphot = catalog[0].galphot;
     405  average = catalog[0].average;
     406 
     407  myAbort("relphot_catalog_galphot needs to handle average entries with Ngalphot = 0");
     408
     409  // we have a table of average objects and an unsorted table of measurements.  each measurement
     410  // has a reference to the average object sequence (as well as an ID)
     411  // galphot[i].averef -> average[averef]
     412  // galphot[i].objID = average[averef].objID
     413  // galphot[i].catID = average[averef].catID
     414
     415  // we want a sorted galphot array with all averef entries in sequence
     416
     417  ALLOCATE (galphotSeq, off_t,   Ngalphot);
     418  ALLOCATE (averageSeq, off_t,   Ngalphot);
     419
     420  for (i = 0; i < Ngalphot; i++) {
     421    galphotSeq[i] = i;
     422    averageSeq[i] = galphot[i].averef;
     423   
     424    if (catalog[0].catformat >= DVO_FORMAT_PS1_V1) {
     425      // earlier formats did not carry the objID or catID, so they are not available (we could assign on load, but we don't)
     426      myAssert(average[averageSeq[i]].catID == galphot[galphotSeq[i]].catID, "object / detection mismatch");
     427      myAssert(average[averageSeq[i]].objID == galphot[galphotSeq[i]].objID, "object / detection mismatch");
     428    }
     429  }
     430 
     431  SortAveMatch(galphotSeq, averageSeq, Ngalphot);
     432
     433  // copy the galphot entries in the sorted order
     434  ALLOCATE (galphotTMP, GalPhot, Ngalphot);
     435  for (i = 0; i < Ngalphot; i++) {
     436    j = galphotSeq[i];
     437    galphotTMP[i] = galphot[j];
     438  }
     439
     440  // update the values of average.galphotOffset and average.Ngalphot
     441  FREE(galphot);
     442  catalog[0].galphot = galphotTMP;
     443
     444  N = 0;
     445  currentAve = averageSeq[0];
     446  average[currentAve].galphotOffset = 0;
     447  for (i = 0; i < Ngalphot; i++) {
     448    if (averageSeq[i] != currentAve) {
     449      // we have hit the next entry in the list
     450      average[currentAve].Ngalphot = N;
     451      N = 0;
     452      currentAve = averageSeq[i];
     453      average[currentAve].galphotOffset = i;
     454    }
     455    N++;
     456  }
     457  average[currentAve].Ngalphot = N;
     458
     459  int NgalphotTotal = 0;
     460  int galphotOffsetOK = TRUE;
     461  for (i = 0; i < Naverage; i++) {
     462    NgalphotTotal += catalog[0].average[i].Ngalphot;
     463    if (VERBOSE && !(NgalphotTotal <= catalog[0].Ngalphot)) {
     464      fprintf (stderr, "too few galphot: %d %d %d\n", (int) i, NgalphotTotal, (int) catalog[0].Ngalphot);
     465    }
     466    galphotOffsetOK &= (catalog[0].average[i].galphotOffset < catalog[0].Ngalphot);
     467    if (VERBOSE && !(catalog[0].average[i].galphotOffset < catalog[0].Ngalphot)) {
     468      fprintf (stderr, "offset too large: %d %d %d\n", (int) i, catalog[0].average[i].Ngalphot, (int) catalog[0].Ngalphot);
     469    }
     470    galphotOffsetOK &= (catalog[0].average[i].galphotOffset + catalog[0].average[i].Ngalphot <= catalog[0].Ngalphot);
     471    if (VERBOSE && !(catalog[0].average[i].galphotOffset + catalog[0].average[i].Ngalphot <= catalog[0].Ngalphot)) {
     472      fprintf (stderr, "orrset + Ngalphot too large: %d + %d > %d %d\n", (int) i, catalog[0].average[i].galphotOffset, catalog[0].average[i].Ngalphot, (int) catalog[0].Ngalphot);
     473    }
     474  }
     475
     476  if (!galphotOffsetOK) {
     477    fprintf (stderr, "ERROR: catalog %s has an invalid galphotOffset\n", catalog[0].filename);
     478  }
     479
     480  if (NgalphotTotal != catalog[0].Ngalphot) {
     481    fprintf (stderr, "ERROR: catalog %s has an invalid Ngalphot\n", catalog[0].filename);
     482  }
     483
     484  FREE (galphotSeq);
    475485  FREE (averageSeq);
    476486
  • trunk/Ohana/src/addstar/src/resort_threaded.c

    r38471 r38636  
    7272    // this is an overloaded value to mean 'force sort'
    7373    if (threadData->forcesort) catalog.sorted = FALSE;
    74 
    75     if (OLD_RESORT) {
    76       resort_catalog_old (&catalog);
    77     } else {
    78       resort_catalog (&catalog);
    79     }
     74    resort_catalog (&catalog);
    8075
    8176    /* report total updated values */
  • trunk/Ohana/src/addstar/src/resort_unthreaded.c

    r38471 r38636  
    4242    }
    4343
    44     // this is an overloaded value to mean 'force sort'
     44    // to force the sort, we need to set sorted 'false'
    4545    if (ForceSort) catalog.sorted = FALSE;
    46 
    47     if (OLD_RESORT) {
    48       resort_catalog_old (&catalog);
    49     } else {
    50       resort_catalog (&catalog);
    51     }
     46    resort_catalog (&catalog);
    5247
    5348    // report total updated values
Note: See TracChangeset for help on using the changeset viewer.