IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32969


Ignore:
Timestamp:
Dec 19, 2011, 7:19:36 AM (15 years ago)
Author:
eugene
Message:

try to get the starting order closer

File:
1 edited

Legend:

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

    r32967 r32969  
    8484
    8585    if (isnan(Dtgt) || isnan(dX) || isnan(Dcur) || isnan(dF) || isnan(dPdXi)) abort();
    86 
    87     if (i >= nCloseMax) {
    88       fprintf (stderr, "Dcur,Dtgt : %f %f : dX,dF : %f : %f\n", Dcur, Dtgt, dX, dF);
    89     }
    9086    dPdX += dPdXi;
    9187  }
     
    106102  int i, j, iter;
    107103  Vector *index1, *index2, *distance;
     104  float *XoList;
     105  int *IDList, *MidObj;
    108106
    109107  {
     
    215213  // coordinate
    216214 
     215  // need to get pretty close to a good starting point.  start with a guess using the first entry & its extremum
    217216  int idx1 = 0;
    218217  int idx2 = object[idx1].index[object[idx1].Nindex-1];
     
    245244  }
    246245
     246  if (Niter >= -1) {
     247    // now choose several in the middle of the range, and find the mean distance for each relative to that group
     248    ALLOCATE (XoList, float, Nobject);
     249    ALLOCATE (IDList, int, Nobject);
     250    for (i = 0; i < Nobject; i++) {
     251      XoList[i] = object[i].Xo;
     252      IDList[i] = i;
     253    }
     254    sortfriends (XoList, IDList, Nobject);
     255    float XoMid = XoList[(int)(Nobject/2)];
     256
     257# define NMID 5
     258    ALLOCATE (MidObj, int, NMID);
     259    MidObj[0] = IDList[(int)(Nobject/2) + 0];
     260    MidObj[1] = IDList[(int)(Nobject/2) + 1];
     261    MidObj[2] = IDList[(int)(Nobject/2) - 1];
     262    MidObj[3] = IDList[(int)(Nobject/2) + 2];
     263    MidObj[4] = IDList[(int)(Nobject/2) - 2];
     264
     265    for (i = 0; i < Nobject; i++) {
     266      for (j = 0; j < NMID; j++) {
     267        if (MidObj[j] == i) goto skip_object;
     268      }
     269      float Dmean = 0.0;
     270      for (j = 0; j < NMID; j++) {
     271        Dmean += object[i].Dtgt[MidObj[j]]; // desired distance between object (i) and object in middle section
     272      }
     273      Dmean = Dmean / NMID;
     274      if (object[i].Xo < XoMid) {
     275        object[i].Xo = XoMid - Dmean;
     276      } else {
     277        object[i].Xo = XoMid + Dmean;
     278      }
     279    skip_object:
     280      continue;
     281    }
     282  }
     283
     284  if (Niter >= 0) {
     285    float XoMean = 0.0;
     286    // now choose one end of the range, and find the mean distance for each relative to THAT group
     287    for (i = 0; i < Nobject; i++) {
     288      XoList[i] = object[i].Xo;
     289      IDList[i] = i;
     290      XoMean += object[i].Xo;
     291    }
     292    XoMean = XoMean / Nobject;
     293    sortfriends (XoList, IDList, Nobject);
     294    float XoMin = XoList[0];
     295
     296    MidObj[0] = IDList[0];
     297    MidObj[1] = IDList[1];
     298    MidObj[2] = IDList[2];
     299    MidObj[3] = IDList[3];
     300    MidObj[4] = IDList[4];
     301
     302    for (i = 0; i < Nobject; i++) {
     303      for (j = 0; j < NMID; j++) {
     304        if (MidObj[j] == i) goto skip_object_p2;
     305      }
     306      float Dmean = 0.0;
     307      for (j = 0; j < NMID; j++) {
     308        Dmean += object[i].Dtgt[MidObj[j]]; // desired distance between object (i) and object in middle section
     309      }
     310      Dmean = Dmean / NMID;
     311      if (object[i].Xo < XoMin) {
     312        object[i].Xo = XoMin - Dmean;
     313      } else {
     314        object[i].Xo = XoMin + Dmean;
     315      }
     316    skip_object_p2:
     317      continue;
     318    }
     319  }
     320
    247321  for (iter = 0; iter < Niter; iter ++) {
    248322    fprintf (stderr, "iter %d\n", iter);
     
    282356    }
    283357    XoSum += object[i].Xo;
    284     object[i].Yo = (dY2sum > 0.0) ? sqrt(dY2sum / Npts) : -sqrt(dY2sum / Npts);
     358    object[i].Yo = (dY2sum > 0.0) ? sqrt(fabs(dY2sum / Npts)) : -sqrt(fabs(dY2sum / Npts));
    285359  }
    286360  float XoMean = XoSum / Nobject;
Note: See TracChangeset for help on using the changeset viewer.