Changeset 33037
- Timestamp:
- Dec 30, 2011, 8:05:04 AM (15 years ago)
- Location:
- branches/eam_branches/ipp-20111122/Ohana/src/opihi/cmd.astro
- Files:
-
- 2 edited
-
spex1dgas.c (modified) (2 diffs)
-
spexseq.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20111122/Ohana/src/opihi/cmd.astro/spex1dgas.c
r32995 r33037 172 172 } 173 173 174 N = index2->elements.Int[i]; 175 if (N >= Nobject) abort(); 176 m = object[N].Nindex; 177 object[N].index[m] = index1->elements.Int[i]; 178 object[N].Dtgt[m] = distance->elements.Flt[i]; 179 object[N].Dcur[m] = 0.0; 180 object[N].Nindex ++; 181 if (object[N].Nindex == object[N].NINDEX) { 182 object[N].NINDEX += 100; 183 REALLOCATE (object[N].Dtgt, float, object[N].NINDEX); 184 REALLOCATE (object[N].Dcur, float, object[N].NINDEX); 185 REALLOCATE (object[N].index, int, object[N].NINDEX); 186 } 174 // Above we used the set (N,M,D_N,M) to assigned the distance of obj M to obj N. 175 // Below we use that set to assign the distance of obj N to obj M. IF we supply all 176 // pairwise distances, then this duplicates all entries, so we need to skip that step 177 // in such a case. 178 179 // XX N = index2->elements.Int[i]; 180 // XX if (N >= Nobject) abort(); 181 // XX m = object[N].Nindex; 182 // XX object[N].index[m] = index1->elements.Int[i]; 183 // XX object[N].Dtgt[m] = distance->elements.Flt[i]; 184 // XX object[N].Dcur[m] = 0.0; 185 // XX object[N].Nindex ++; 186 // XX if (object[N].Nindex == object[N].NINDEX) { 187 // XX object[N].NINDEX += 100; 188 // XX REALLOCATE (object[N].Dtgt, float, object[N].NINDEX); 189 // XX REALLOCATE (object[N].Dcur, float, object[N].NINDEX); 190 // XX REALLOCATE (object[N].index, int, object[N].NINDEX); 191 // XX } 187 192 } 188 193 … … 221 226 // int idx2 = object[idx1].index[(int)(0.75*object[idx1].Nindex)]; 222 227 float A = NAN; 223 for (i = 0; isnan (A) && (i < object[idx 1].Nindex); i++) {224 if (object[idx 1].index[i] == idx2) {225 A = object[idx 1].Dtgt[i];228 for (i = 0; isnan (A) && (i < object[idx2].Nindex); i++) { 229 if (object[idx2].index[i] == idx1) { 230 A = object[idx2].Dtgt[i]; 226 231 } 227 232 } -
branches/eam_branches/ipp-20111122/Ohana/src/opihi/cmd.astro/spexseq.c
r33026 r33037 36 36 float Xo, dXo; 37 37 float Yo, dYo; 38 float Srange; 39 int nSeq; 38 40 } Object; 39 41 … … 57 59 58 60 // is idx2 closer to pin1 or pin2? 59 N = object[idx2].rindex[pin1]; 60 float D1 = object[idx2].Dtgt[N]; 61 N = object[idx2].rindex[pin2]; 62 float D2 = object[idx2].Dtgt[N]; 63 64 int parity = (D1 < D2) ? +1 : -1; 61 // XX N = object[idx2].rindex[pin1]; 62 // XX float D1 = object[idx2].Dtgt[N]; 63 // XX N = object[idx2].rindex[pin2]; 64 // XX float D2 = object[idx2].Dtgt[N]; 65 // XX int parity = (D1 < D2) ? +1 : -1; 65 66 66 67 int Nfriends = 0; … … 70 71 j = object[idx2].rindex[N]; 71 72 assert (object[idx2].index[j] == N); 72 object[idx1].seq[i] = parity*(object[idx2].Dtgt[j] - A); 73 // XX object[idx1].seq[i] = parity*(object[idx2].Dtgt[j] - A); 74 object[idx1].seq[i] = (object[idx2].Dtgt[j] - A); 73 75 Nfriends ++; 74 76 } 77 assert (Nfriends <= object[idx1].Nindex); 78 assert (Nfriends <= Nobject); 75 79 fprintf (stderr, "object %d sequenced by object %d, %d friends sequenced\n", idx1, idx2, Nfriends); 76 80 return; … … 144 148 } 145 149 146 N = index2->elements.Int[i]; 147 if (N >= Nobject) abort(); 148 m = object[N].Nindex; 149 object[N].index[m] = index1->elements.Int[i]; 150 object[N].Dtgt[m] = distance->elements.Flt[i]; 151 object[N].Nindex ++; 152 if (object[N].Nindex == object[N].NINDEX) { 153 object[N].NINDEX += 100; 154 REALLOCATE (object[N].Dtgt, float, object[N].NINDEX); 155 REALLOCATE (object[N].index, int, object[N].NINDEX); 156 } 150 // Above we used the set (N,M,D_N,M) to assigned the distance of obj M to obj N. 151 // Below we use that set to assign the distance of obj N to obj M. IF we supply all 152 // pairwise distances, then this duplicates all entries, so we need to skip that step 153 // in such a case. 154 155 // XX N = index2->elements.Int[i]; 156 // XX if (N >= Nobject) abort(); 157 // XX m = object[N].Nindex; 158 // XX object[N].index[m] = index1->elements.Int[i]; 159 // XX object[N].Dtgt[m] = distance->elements.Flt[i]; 160 // XX object[N].Nindex ++; 161 // XX if (object[N].Nindex == object[N].NINDEX) { 162 // XX object[N].NINDEX += 100; 163 // XX REALLOCATE (object[N].Dtgt, float, object[N].NINDEX); 164 // XX REALLOCATE (object[N].index, int, object[N].NINDEX); 165 // XX } 157 166 } 158 167 … … 183 192 // find two objects at the opposite extremes 184 193 float Dm1 = object[0].Dtgt[object[0].Nindex - 1]; 185 for (i = 0; (object[0].Dtgt[i] < 0. 9*Dm1) && (i < object[0].Nindex); i++);194 for (i = 0; (object[0].Dtgt[i] < 0.75*Dm1) && (i < object[0].Nindex); i++); 186 195 int pin1 = object[0].index[i]; 187 196 assert (pin1 >= 0); … … 189 198 190 199 float Dm2 = object[pin1].Dtgt[object[pin1].Nindex - 1]; 191 for (i = 0; (object[pin1].Dtgt[i] < 0. 9*Dm2) && (i < object[pin1].Nindex); i++);200 for (i = 0; (object[pin1].Dtgt[i] < 0.75*Dm2) && (i < object[pin1].Nindex); i++); 192 201 int pin2 = object[pin1].index[i]; 193 202 assert (pin2 >= 0); … … 223 232 float dS2m = 0.0; 224 233 int nS = 0; 234 235 float Smin = +1000.0; 236 float Smax = -1000.0; 225 237 226 238 for (k = 0; k < object[Nj].Nindex; k++) { … … 231 243 if (isnan(object[i].seq[Nsi])) continue; 232 244 245 Smin = MIN(object[Nj].seq[k], Smin); 246 Smax = MAX(object[Nj].seq[k], Smax); 247 233 248 float dSp = object[Nj].seq[k] - object[i].seq[Nsi]; 234 249 float dSm = -object[Nj].seq[k] - object[i].seq[Nsi]; … … 243 258 float dSp = sqrt(dS2p / nS - Sp*Sp); 244 259 float dSm = sqrt(dS2m / nS - Sm*Sm); 245 fprintf (stderr, "%d: %f +/- %f or %f +/- %f\n", Nj, Sp, dSp, Sm, dSm); 246 247 // if (dSm > dSp) { 248 if (1) { 249 // parity is always 1 (based on pins) 260 fprintf (stderr, "%d: %f +/- %f or %f +/- %f : %f range, %d matches\n", Nj, Sp, dSp, Sm, dSm, Smax - Smin, nS); 261 262 if (dSm > dSp) { 263 // parity is always 1 if we use the pins (but it does not seem to work) 250 264 for (k = 0; k < object[Nj].Nindex; k++) { 251 265 if (isnan(object[Nj].seq[k])) continue; … … 263 277 object[Nj].dSo = dSm; 264 278 } 279 object[Nj].Srange = Smax - Smin; 280 object[Nj].nSeq = nS; 265 281 object[Nj].shifted = TRUE; 266 282 Nfixed ++; 267 283 } 268 fprintf (stderr, "%d used to reconcile %d friends\n", i, Nfixed);284 // fprintf (stderr, "%d used to reconcile %d friends\n", i, Nfixed); 269 285 } 270 286 … … 318 334 Vector *outdXo = SelectVector ("sp1d_dXo", ANYVECTOR, TRUE); if (!outXo) goto escape; 319 335 336 Vector *outSr = SelectVector ("sp1d_Sr", ANYVECTOR, TRUE); if (!outSr) goto escape; 337 Vector *outSn = SelectVector ("sp1d_nS", ANYVECTOR, TRUE); if (!outSn) goto escape; 338 320 339 ResetVector (outindex, OPIHI_INT, Nobject); 321 340 ResetVector (outXo, OPIHI_FLT, Nobject); … … 325 344 ResetVector (outdSo, OPIHI_FLT, Nobject); 326 345 ResetVector (outdXo, OPIHI_FLT, Nobject); 346 347 ResetVector (outSr, OPIHI_FLT, Nobject); 348 ResetVector (outSn, OPIHI_INT, Nobject); 327 349 328 350 for (i = 0; i < Nobject; i++) { … … 333 355 outdSo->elements.Flt[i] = object[i].dSo; 334 356 outdXo->elements.Flt[i] = object[i].dXo; 357 outSr->elements.Flt[i] = object[i].Srange; 358 outSn->elements.Int[i] = object[i].nSeq; 335 359 } 336 360 }
Note:
See TracChangeset
for help on using the changeset viewer.
