IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32918


Ignore:
Timestamp:
Dec 9, 2011, 11:15:39 AM (15 years ago)
Author:
eugene
Message:

updates

File:
1 edited

Legend:

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

    r32909 r32918  
    4949void sortfriends (float *X, int *IDX1, int N);
    5050
    51 void get_pressure_gradient (int iObj) {
     51void get_pressure_gradient (int iObj, int nCloseMax, float farFrac, int nearNeighbors, float maxPressure) {
    5252
    5353  int i;
     
    5757
    5858  // only use the first N friends
    59   for (i = 0; (i < 10) && (i < object[iObj].Nindex); i++) {
     59  for (i = 0; (i < object[iObj].Nindex); i++) {
    6060    int jObj = object[iObj].index[i];
    6161
    62     // only use the 0th object?
    63     // if (jObj != 0) continue;
    64 
     62    // some options:
     63    // if the iterations are small, we should only worry about getting the near neighbors right
     64    // if the iterations are large, we should add in more distant objects
     65    if (nearNeighbors && (i >= nCloseMax)) break;
     66    if (!nearNeighbors && (i >= nCloseMax)) {
     67      if (drand48() > farFrac) continue;
     68    }
    6569
    6670    float Dtgt = object[iObj].Dtgt[i];
     
    7276    // float dF = (Dcur < 0.01*Dtgt) ? -100.0 : (Dcur - Dtgt) / Dcur; XXX modified spring constant : too crazy
    7377    float dF = (Dcur - Dtgt);
    74     dF = MIN (100.0, MAX (-100.0, dF));
     78    dF = MIN (maxPressure, MAX (-maxPressure, dF));
    7579
    7680    float dPdXi = dF * dX / Dcur;
     
    8387    }
    8488
    85     // fprintf (stderr, "Dcur,Dtgt : %f %f : dX,dY,dP : %f %f : %f : %f %f\n", Dcur, Dtgt, dX, dY, dF, dPdXi, dPdYi);
     89    if (i >= nCloseMax) {
     90      fprintf (stderr, "Dcur,Dtgt : %f %f : dX,dY,dP : %f %f : %f : %f %f\n", Dcur, Dtgt, dX, dY, dF, dPdXi, dPdYi);
     91    }
    8692    dPdX += dPdXi;
    8793    dPdY += dPdYi;
     
    111117  srand48(B);
    112118 
    113   if (argc != 5) goto usage;
     119  if (argc != 9) goto usage;
    114120
    115121  if ((index1   = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) goto escape;
     
    117123  if ((distance = SelectVector (argv[3], OLDVECTOR, TRUE)) == NULL) goto escape;
    118124  int Niter = atoi (argv[4]);
     125  int nCloseMax = atoi (argv[5]);
     126  int nCloseIter = atoi (argv[6]);
     127  float farFrac = atof (argv[7]);
     128  float maxPressure = atof (argv[8]);
    119129  // XXX enforce matching lengths on the three vectors
    120130
     
    204214    fprintf (stderr, "iter %d\n", iter);
    205215
     216    int nearNeighbors = (iter < nCloseIter);
     217
    206218    // measure (dP/dX),(dP/dY) for all objects
    207219    for (i = 0; i < Nobject; i++) {
    208       get_pressure_gradient (i);
     220      get_pressure_gradient (i, nCloseMax, farFrac, nearNeighbors, maxPressure);
    209221      move_object (i);
    210222    }
     
    229241 
    230242usage:
    231   gprint (GP_ERR, "USAGE: mkclusters (index1) (index2) (distance) scale\n");
     243  gprint (GP_ERR, "USAGE: spex2dgas (index1) (index2) (distance) (Niter) (nCloseMax) (nCloseIter) (farFrac) (maxPressure)\n");
    232244  return FALSE;
    233245}
Note: See TracChangeset for help on using the changeset viewer.