IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 9, 2016, 9:12:10 AM (10 years ago)
Author:
eugene
Message:

adding code to match measure and lensing fields

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/dvo/mextract.c

    r39457 r39569  
    216216  int needStarpar = dbFieldNeedStarpar (fields, Nfields, FALSE);
    217217
     218  // the lensing table does not have a good index to/from the measure table.  if we need lensing
     219  // parameters, we need to generate a lookup table to avoid excess iterations
     220  mySequenceType *lensingSeq = NULL;
     221  if (needLensing) {
     222    lensingSeq = mySequenceAlloc();
     223  }
     224
    218225  // grab data from all selected sky regions
    219226  struct sigaction *old_sigaction = SetInterrupt();
     
    249256
    250257    for (j = 0; (j < catalog.Naverage) && !interrupt; j++) {
    251       m = catalog.average[j].measureOffset;
     258      Average *average = &catalog.average[j];
     259
     260      m = average->measureOffset;
    252261      if (m > catalog.Nmeasure) {
    253262        gprint (GP_ERR, "ERROR: inconsistent average->measure offset.  Unsorted database?\n");
     
    257266      dbExtractMeasuresInitAve (); // reset counters for saved fields (costs very little)
    258267
    259       for (k = 0; (k < catalog.average[j].Nmeasure); k++, m++) {
     268      off_t Lj;
     269      off_t Loff = average->lensingOffset;
     270
     271      if (needLensing) {
     272        mySequenceSetSize (lensingSeq, average->Nlensing);
     273       
     274        // generate an index for these lensing entries (based on Lj and imageID)
     275        for (Lj = 0; Lj < average->Nlensing; Lj++) {
     276          mySequenceSetValue (lensingSeq, catalog.lensing[Loff + Lj].imageID, Lj);
     277        }
     278       
     279        mySequenceSort (lensingSeq);
     280      }
     281
     282      for (k = 0; (k < average->Nmeasure); k++, m++) {
    260283        if (catalog.measure[m].averef != j) {
    261284          gprint (GP_ERR, "ERROR: inconsistent measure->average link.  Unsorted database?\n");
     
    266289        dbExtractMeasuresInitMeas (); // reset counters for saved fields  (costs very little
    267290
    268         Average *average = &catalog.average[j];
    269 
    270291        int Nstarpar = average->starparOffset;
    271         StarPar *starpar = needStarpar ? &catalog.starpar[Nstarpar] : NULL;
    272 
    273         int Nlensing = average->lensingOffset;
    274         Lensing *lensing = needLensing ? &catalog.lensing[Nlensing] : NULL;
     292        StarPar *starpar = needStarpar && average->Nstarpar ? &catalog.starpar[Nstarpar] : NULL;
     293
     294        Lensing *lensing = NULL;
     295
     296        // a gpc1 analysis specific choice: only look for lensing if photcode is a warp one
     297        if (needLensing && average->Nlensing && (catalog.measure[m].photcode >= 12000) && (catalog.measure[m].photcode <= 12500)) {
     298          Lj = mySequenceGetEntry (lensingSeq, catalog.measure[m].imageID);
     299          if (Lj >= 0) lensing = &catalog.lensing[Loff + Lj];
     300        }
    275301
    276302        int Nsec = j*Nsecfilt;
Note: See TracChangeset for help on using the changeset viewer.