IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33037


Ignore:
Timestamp:
Dec 30, 2011, 8:05:04 AM (15 years ago)
Author:
eugene
Message:

avoid double counting the pairs

Location:
branches/eam_branches/ipp-20111122/Ohana/src/opihi/cmd.astro
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20111122/Ohana/src/opihi/cmd.astro/spex1dgas.c

    r32995 r33037  
    172172    }
    173173
    174     N = index2->elements.Int[i];
    175     if (N >= Nobject) abort();
    176     m = object[N].Nindex;
    177     object[N].index[m] = index1->elements.Int[i];
    178     object[N].Dtgt[m] = distance->elements.Flt[i];
    179     object[N].Dcur[m] = 0.0;
    180     object[N].Nindex ++;
    181     if (object[N].Nindex == object[N].NINDEX) {
    182       object[N].NINDEX += 100;
    183       REALLOCATE (object[N].Dtgt, float, object[N].NINDEX);
    184       REALLOCATE (object[N].Dcur, float, object[N].NINDEX);
    185       REALLOCATE (object[N].index, int, object[N].NINDEX);
    186     }
     174    // Above we used the set (N,M,D_N,M) to assigned the distance of obj M to obj N.
     175    // Below we use that set to assign the distance of obj N to obj M.  IF we supply all
     176    // pairwise distances, then this duplicates all entries, so we need to skip that step
     177    // in such a case.
     178
     179    // XX N = index2->elements.Int[i];
     180    // XX if (N >= Nobject) abort();
     181    // XX m = object[N].Nindex;
     182    // XX object[N].index[m] = index1->elements.Int[i];
     183    // XX object[N].Dtgt[m] = distance->elements.Flt[i];
     184    // XX object[N].Dcur[m] = 0.0;
     185    // XX object[N].Nindex ++;
     186    // XX if (object[N].Nindex == object[N].NINDEX) {
     187    // XX   object[N].NINDEX += 100;
     188    // XX   REALLOCATE (object[N].Dtgt, float, object[N].NINDEX);
     189    // XX   REALLOCATE (object[N].Dcur, float, object[N].NINDEX);
     190    // XX   REALLOCATE (object[N].index, int, object[N].NINDEX);
     191    // XX }
    187192  }
    188193
     
    221226  // int idx2 = object[idx1].index[(int)(0.75*object[idx1].Nindex)];
    222227  float A = NAN;
    223   for (i = 0; isnan (A) && (i < object[idx1].Nindex); i++) {
    224       if (object[idx1].index[i] == idx2) {
    225           A = object[idx1].Dtgt[i];
     228  for (i = 0; isnan (A) && (i < object[idx2].Nindex); i++) {
     229      if (object[idx2].index[i] == idx1) {
     230          A = object[idx2].Dtgt[i];
    226231      }
    227232  }
  • branches/eam_branches/ipp-20111122/Ohana/src/opihi/cmd.astro/spexseq.c

    r33026 r33037  
    3636  float Xo, dXo;
    3737  float Yo, dYo;
     38  float Srange;
     39  int nSeq;
    3840} Object;
    3941
     
    5759
    5860  // is idx2 closer to pin1 or pin2?
    59   N = object[idx2].rindex[pin1];
    60   float D1 = object[idx2].Dtgt[N];
    61   N = object[idx2].rindex[pin2];
    62   float D2 = object[idx2].Dtgt[N];
    63 
    64   int parity = (D1 < D2) ? +1 : -1;
     61  // XX N = object[idx2].rindex[pin1];
     62  // XX float D1 = object[idx2].Dtgt[N];
     63  // XX N = object[idx2].rindex[pin2];
     64  // XX float D2 = object[idx2].Dtgt[N];
     65  // XX int parity = (D1 < D2) ? +1 : -1;
    6566
    6667  int Nfriends = 0;
     
    7071    j = object[idx2].rindex[N];
    7172    assert (object[idx2].index[j] == N);
    72     object[idx1].seq[i] = parity*(object[idx2].Dtgt[j] - A);
     73    // XX object[idx1].seq[i] = parity*(object[idx2].Dtgt[j] - A);
     74    object[idx1].seq[i] = (object[idx2].Dtgt[j] - A);
    7375    Nfriends ++;
    7476  }
     77  assert (Nfriends <= object[idx1].Nindex);
     78  assert (Nfriends <= Nobject);
    7579  fprintf (stderr, "object %d sequenced by object %d, %d friends sequenced\n", idx1, idx2, Nfriends);
    7680  return;
     
    144148    }
    145149
    146     N = index2->elements.Int[i];
    147     if (N >= Nobject) abort();
    148     m = object[N].Nindex;
    149     object[N].index[m] = index1->elements.Int[i];
    150     object[N].Dtgt[m] = distance->elements.Flt[i];
    151     object[N].Nindex ++;
    152     if (object[N].Nindex == object[N].NINDEX) {
    153       object[N].NINDEX += 100;
    154       REALLOCATE (object[N].Dtgt, float, object[N].NINDEX);
    155       REALLOCATE (object[N].index, int, object[N].NINDEX);
    156     }
     150    // Above we used the set (N,M,D_N,M) to assigned the distance of obj M to obj N.
     151    // Below we use that set to assign the distance of obj N to obj M.  IF we supply all
     152    // pairwise distances, then this duplicates all entries, so we need to skip that step
     153    // in such a case.
     154
     155    // XX N = index2->elements.Int[i];
     156    // XX if (N >= Nobject) abort();
     157    // XX m = object[N].Nindex;
     158    // XX object[N].index[m] = index1->elements.Int[i];
     159    // XX object[N].Dtgt[m] = distance->elements.Flt[i];
     160    // XX object[N].Nindex ++;
     161    // XX if (object[N].Nindex == object[N].NINDEX) {
     162    // XX   object[N].NINDEX += 100;
     163    // XX   REALLOCATE (object[N].Dtgt, float, object[N].NINDEX);
     164    // XX   REALLOCATE (object[N].index, int, object[N].NINDEX);
     165    // XX }
    157166  }
    158167
     
    183192  // find two objects at the opposite extremes
    184193  float Dm1 = object[0].Dtgt[object[0].Nindex - 1];
    185   for (i = 0; (object[0].Dtgt[i] < 0.9*Dm1) && (i < object[0].Nindex); i++);
     194  for (i = 0; (object[0].Dtgt[i] < 0.75*Dm1) && (i < object[0].Nindex); i++);
    186195  int pin1 = object[0].index[i];
    187196  assert (pin1 >= 0);
     
    189198
    190199  float Dm2 = object[pin1].Dtgt[object[pin1].Nindex - 1];
    191   for (i = 0; (object[pin1].Dtgt[i] < 0.9*Dm2) && (i < object[pin1].Nindex); i++);
     200  for (i = 0; (object[pin1].Dtgt[i] < 0.75*Dm2) && (i < object[pin1].Nindex); i++);
    192201  int pin2 = object[pin1].index[i];
    193202  assert (pin2 >= 0);
     
    223232      float dS2m = 0.0;
    224233      int nS = 0;
     234
     235      float Smin = +1000.0;
     236      float Smax = -1000.0;
    225237
    226238      for (k = 0; k < object[Nj].Nindex; k++) {
     
    231243        if (isnan(object[i].seq[Nsi])) continue;
    232244       
     245        Smin = MIN(object[Nj].seq[k], Smin);
     246        Smax = MAX(object[Nj].seq[k], Smax);
     247
    233248        float dSp = object[Nj].seq[k] - object[i].seq[Nsi];
    234249        float dSm = -object[Nj].seq[k] - object[i].seq[Nsi];
     
    243258      float dSp = sqrt(dS2p / nS - Sp*Sp);
    244259      float dSm = sqrt(dS2m / nS - Sm*Sm);
    245       fprintf (stderr, "%d: %f +/- %f or %f +/- %f\n", Nj, Sp, dSp, Sm, dSm);
    246 
    247       // if (dSm > dSp) {
    248       if (1) {
    249         // parity is always 1 (based on pins)
     260      fprintf (stderr, "%d: %f +/- %f or %f +/- %f : %f range, %d matches\n", Nj, Sp, dSp, Sm, dSm, Smax - Smin, nS);
     261
     262      if (dSm > dSp) {
     263        // parity is always 1 if we use the pins (but it does not seem to work)
    250264        for (k = 0; k < object[Nj].Nindex; k++) {
    251265          if (isnan(object[Nj].seq[k])) continue;
     
    263277        object[Nj].dSo = dSm;
    264278      }
     279      object[Nj].Srange = Smax - Smin;
     280      object[Nj].nSeq = nS;
    265281      object[Nj].shifted = TRUE;
    266282      Nfixed ++;
    267283    }
    268     fprintf (stderr, "%d used to reconcile %d friends\n", i, Nfixed);
     284    // fprintf (stderr, "%d used to reconcile %d friends\n", i, Nfixed);
    269285  }
    270286
     
    318334    Vector *outdXo   = SelectVector ("sp1d_dXo", ANYVECTOR, TRUE); if (!outXo) goto escape;
    319335
     336    Vector *outSr   = SelectVector ("sp1d_Sr", ANYVECTOR, TRUE); if (!outSr) goto escape;
     337    Vector *outSn   = SelectVector ("sp1d_nS", ANYVECTOR, TRUE); if (!outSn) goto escape;
     338
    320339    ResetVector (outindex, OPIHI_INT, Nobject);
    321340    ResetVector (outXo, OPIHI_FLT, Nobject);
     
    325344    ResetVector (outdSo, OPIHI_FLT, Nobject);
    326345    ResetVector (outdXo, OPIHI_FLT, Nobject);
     346
     347    ResetVector (outSr, OPIHI_FLT, Nobject);
     348    ResetVector (outSn, OPIHI_INT, Nobject);
    327349
    328350    for (i = 0; i < Nobject; i++) {
     
    333355      outdSo->elements.Flt[i] = object[i].dSo;
    334356      outdXo->elements.Flt[i] = object[i].dXo;
     357      outSr->elements.Flt[i] = object[i].Srange;
     358      outSn->elements.Int[i] = object[i].nSeq;
    335359    }
    336360  }
Note: See TracChangeset for help on using the changeset viewer.