Changeset 32978
- Timestamp:
- Dec 20, 2011, 8:13:23 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20111122/Ohana/src/opihi/cmd.astro/spex1dgas.c
r32969 r32978 113 113 } 114 114 115 if (argc != 9) goto usage; 116 115 if (argc != 11) goto usage; 116 117 // XXX enforce matching lengths on the three vectors 117 118 if ((index1 = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) goto escape; 118 119 if ((index2 = SelectVector (argv[2], OLDVECTOR, TRUE)) == NULL) goto escape; 119 120 if ((distance = SelectVector (argv[3], OLDVECTOR, TRUE)) == NULL) goto escape; 121 120 122 int Niter = atoi (argv[4]); 121 123 int nCloseMax = atoi (argv[5]); … … 123 125 float farFrac = atof (argv[7]); 124 126 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]); 126 130 127 131 CastVector (index1, OPIHI_INT); … … 214 218 215 219 // 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); 219 229 object[idx1].Xo = 0.0; 220 230 object[idx1].Yo = 0.0; … … 227 237 object[idx2].dPdY = 0.0; 228 238 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 229 244 for (i = 0; i < Nobject; i++) { 230 245 if (i == idx1) continue; … … 238 253 if (isnan(B) || isnan(C)) abort(); 239 254 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 240 258 float Xo = (SQ(A) + SQ(B) - SQ(C)) / (2*A); 241 259 242 260 object[i].Xo = Xo; 243 261 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; 245 270 246 271 if (Niter >= -1) { … … 389 414 390 415 usage: 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"); 392 417 return FALSE; 393 418 }
Note:
See TracChangeset
for help on using the changeset viewer.
