IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32967


Ignore:
Timestamp:
Dec 16, 2011, 7:29:55 AM (15 years ago)
Author:
eugene
Message:

fix up spex1dgas

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

Legend:

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

    r32951 r32967  
    251251
    252252    // save the result
    253     char name[64];
    254     snprintf (name, 64, "output.%02d.dat", iter);
    255     FILE *output = fopen (name, "w");
    256     for (i = 0; i < Nobject; i++) {
    257       fprintf (output, "%f %f : %f %f\n", object[i].Xo, object[i].Yo, object[i].dPdX, object[i].dPdY);
    258     }
    259     fclose (output);
    260 
    261     // measure (dP/dX),(dP/dY) for all objects
     253    if (0) {
     254      char name[64];
     255      snprintf (name, 64, "output.%02d.dat", iter);
     256      FILE *output = fopen (name, "w");
     257      for (i = 0; i < Nobject; i++) {
     258        fprintf (output, "%f %f : %f %f\n", object[i].Xo, object[i].Yo, object[i].dPdX, object[i].dPdY);
     259      }
     260      fclose (output);
     261    }
     262
     263    // measure (dP/dX) & move object
    262264    for (i = 0; i < Nobject; i++) {
    263265      get_pressure_gradient (i, nCloseMax, farFrac, nearNeighbors, maxPressure);
    264266      move_object (i);
    265267    }
    266 
    267     // given (dP/dX),(dP/dY), move each object
    268     // for (i = 0; i < Nobject; i++) {
    269     // }
     268  }
     269
     270  // find the mean Xo, Yo positions for all objects
     271  float XoSum = 0.0;
     272  for (i = 0; i < Nobject; i++) {
     273    float dY2sum = 0.0;
     274    int Npts = 0;
     275    for (j = 0; (j < nCloseMax) && (j < object[i].Nindex); j++) {
     276      int idx = object[i].index[j];
     277      float dR2 = SQ(object[i].Dtgt[j]);
     278      float dX2 = SQ(object[i].Xo - object[idx].Xo);
     279      float dY2 = dR2 - dX2;
     280      dY2sum += dY2;
     281      Npts ++;
     282    }
     283    XoSum += object[i].Xo;
     284    object[i].Yo = (dY2sum > 0.0) ? sqrt(dY2sum / Npts) : -sqrt(dY2sum / Npts);
     285  }
     286  float XoMean = XoSum / Nobject;
     287
     288  // remove the mean Xo (uninteresting)
     289  for (i = 0; i < Nobject; i++) {
     290    object[i].Xo -= XoMean;
    270291  }
    271292
    272293  // save the result
    273   FILE *output = fopen ("output.dat", "w");
    274   for (i = 0; i < Nobject; i++) {
    275     fprintf (output, "%f %f : %f %f\n", object[i].Xo, object[i].Yo, object[i].dPdX, object[i].dPdY);
    276   }
    277   fclose (output);
     294  {
     295    Vector *outindex = SelectVector ("sp1d_idx", ANYVECTOR, TRUE); if (!outindex) goto escape;
     296    Vector *outXo    = SelectVector ("sp1d_Xo",  ANYVECTOR, TRUE); if (!outXo) goto escape;
     297    Vector *outYo    = SelectVector ("sp1d_Yo",  ANYVECTOR, TRUE); if (!outYo) goto escape;
     298
     299    ResetVector (outindex, OPIHI_INT, Nobject);
     300    ResetVector (outXo, OPIHI_FLT, Nobject);
     301    ResetVector (outYo, OPIHI_FLT, Nobject);
     302
     303    for (i = 0; i < Nobject; i++) {
     304      outindex->elements.Int[i] = i;
     305      outXo->elements.Flt[i] = object[i].Xo;
     306      outYo->elements.Flt[i] = object[i].Yo;
     307    }
     308  }
    278309
    279310  return TRUE;
  • branches/eam_branches/ipp-20111122/Ohana/src/opihi/cmd.data/cursor.c

    r31635 r32967  
    44
    55  char string[20], key[20], *name;
    6   int i, N, kapa;
     6  int i, N, kapa, VERBOSE;
    77  double X, Y, R, D, Z;
    88  void *oldsignal;
     
    1313  // if ((N = get_argument (argc, argv, "-g"))) {
    1414  // if ((N = get_argument (argc, argv, "-i"))) {
     15
     16  VERBOSE = TRUE;
     17  if ((N = get_argument (argc, argv, "-a"))) {
     18    VERBOSE = FALSE;
     19  }
    1520
    1621  name = NULL;
     
    5358    set_str_variable ("KEY", key);
    5459   
    55     gprint (GP_LOG, "%s %f %f %f %f %f\n", key, X, Y, Z, R, D);
     60    if (VERBOSE) gprint (GP_LOG, "%s %f %f %f %f %f\n", key, X, Y, Z, R, D);
    5661
    5762    if (!strcasecmp (key, "Q")) break;
Note: See TracChangeset for help on using the changeset viewer.