IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32978


Ignore:
Timestamp:
Dec 20, 2011, 8:13:23 AM (15 years ago)
Author:
eugene
Message:

mods to spex1dgas

File:
1 edited

Legend:

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

    r32969 r32978  
    113113  }
    114114 
    115   if (argc != 9) goto usage;
    116 
     115  if (argc != 11) goto usage;
     116
     117  // XXX enforce matching lengths on the three vectors
    117118  if ((index1   = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) goto escape;
    118119  if ((index2   = SelectVector (argv[2], OLDVECTOR, TRUE)) == NULL) goto escape;
    119120  if ((distance = SelectVector (argv[3], OLDVECTOR, TRUE)) == NULL) goto escape;
     121
    120122  int Niter = atoi (argv[4]);
    121123  int nCloseMax = atoi (argv[5]);
     
    123125  float farFrac = atof (argv[7]);
    124126  float maxPressure = atof (argv[8]);
    125   // XXX enforce matching lengths on the three vectors
     127
     128  int idx1 = atoi(argv[9]);
     129  int idx2 = atoi(argv[10]);
    126130
    127131  CastVector (index1, OPIHI_INT);
     
    214218 
    215219  // need to get pretty close to a good starting point.  start with a guess using the first entry & its extremum
    216   int idx1 = 0;
    217   int idx2 = object[idx1].index[object[idx1].Nindex-1];
    218   float A = object[idx1].Dtgt[object[idx1].Nindex-1];
     220  // int idx1 = object[0].index[(int)(0.75*object[0].Nindex)];
     221  // int idx2 = object[idx1].index[(int)(0.75*object[idx1].Nindex)];
     222  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];
     226      }
     227  }
     228  fprintf (stderr, "idx1: %d, idx2: %d, A: %f\n", idx1, idx2, A);
    219229  object[idx1].Xo = 0.0;
    220230  object[idx1].Yo = 0.0;
     
    227237  object[idx2].dPdY = 0.0;
    228238                 
     239  Vector *tmpB = SelectVector ("sp1d_B", ANYVECTOR, TRUE);
     240  Vector *tmpC = SelectVector ("sp1d_C", ANYVECTOR, TRUE);
     241  ResetVector (tmpB, OPIHI_FLT, Nobject);
     242  ResetVector (tmpC, OPIHI_FLT, Nobject);
     243
    229244  for (i = 0; i < Nobject; i++) {
    230245    if (i == idx1) continue;
     
    238253    if (isnan(B) || isnan(C)) abort();
    239254
     255    // C^2 = A^2 + B^2 - 2AB cos(t)
     256    // Xo = B cos(t)
     257    // Xo = A^2 + B^2 - C^2 / 2 A
    240258    float Xo = (SQ(A) + SQ(B) - SQ(C)) / (2*A);
    241259
    242260    object[i].Xo = Xo;
    243261    object[i].dPdX = 0.0;
    244   }
     262
     263    tmpB->elements.Flt[i] = B;
     264    tmpC->elements.Flt[i] = C;
     265  }
     266  tmpB->elements.Flt[idx1] = 0;
     267  tmpB->elements.Flt[idx2] = A;
     268  tmpC->elements.Flt[idx1] = A;
     269  tmpC->elements.Flt[idx2] = 0;
    245270
    246271  if (Niter >= -1) {
     
    389414 
    390415usage:
    391   gprint (GP_ERR, "USAGE: spex2dgas (index1) (index2) (distance) (Niter) (nCloseMax) (nCloseIter) (farFrac) (maxPressure)\n");
     416  gprint (GP_ERR, "USAGE: spex2dgas (index1) (index2) (distance) (Niter) (nCloseMax) (nCloseIter) (farFrac) (maxPressure) (idx1) (idx2)\n");
    392417  return FALSE;
    393418}
Note: See TracChangeset for help on using the changeset viewer.