Changeset 36922
- Timestamp:
- Jun 20, 2014, 11:30:04 AM (12 years ago)
- Location:
- branches/eam_branches/ipp-20140610/Ohana/src
- Files:
-
- 6 edited
-
addstar/src/build_links.c (modified) (3 diffs)
-
addstar/src/find_matches_closest.c (modified) (3 diffs)
-
addstar/src/resort_catalog.c (modified) (7 diffs)
-
addstar/src/resort_threaded.c (modified) (1 diff)
-
addstar/src/resort_unthreaded_catalogs.c (modified) (1 diff)
-
libdvo/include/dvo.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20140610/Ohana/src/addstar/src/build_links.c
r36921 r36922 237 237 238 238 ALLOCATE (next_lens, off_t, Nlensing); 239 for (i = 0; i < Naverage; i++, N++) { 239 for (i = 0; i < Naverage; i++) { 240 if (!average[i].Nlensing) continue; 240 241 for (j = 0; j < average[i].Nlensing - 1; j++, N++) { 241 242 next_lens[N] = N + 1; … … 253 254 abort (); 254 255 } 256 N++; 255 257 } 256 258 return (next_lens); … … 346 348 ALLOCATE (tmplensing, Lensing, Nlensing); 347 349 for (i = 0; i < Naverage; i++) { 350 if (!average[i].Nlensing) continue; 348 351 n = average[i].lensingOffset; 349 352 average[i].lensingOffset = N; -
branches/eam_branches/ipp-20140610/Ohana/src/addstar/src/find_matches_closest.c
r36921 r36922 182 182 if (Nlens >= NLENS) { 183 183 NLENS = Nlens + 1000; 184 //REALLOCATE (next_lens, off_t, NLENS);184 REALLOCATE (next_lens, off_t, NLENS); 185 185 REALLOCATE (catalog[0].lensing, Lensing, NLENS); 186 186 } … … 188 188 /* add to end of measurement list */ 189 189 add_meas_link (&catalog[0].average[n], next_meas, Nmeas, NMEAS); 190 add_lens_link (&catalog[0].average[n], next_lens, Nlens, NLENS); // ?191 190 192 191 /** add measurements for this star **/ … … 232 231 // add the lensing values if they exist 233 232 if (stars[N].lensing) { 233 add_lens_link (&catalog[0].average[n], next_lens, Nlens, NLENS); // ? 234 234 catalog[0].lensing[Nlens] = stars[N].lensing[0]; 235 235 -
branches/eam_branches/ipp-20140610/Ohana/src/addstar/src/resort_catalog.c
r35760 r36922 1 1 # include "addstar.h" 2 3 void SortAveMatch (off_t *MEAS, off_t *AVE, off_t N); 4 void resort_catalog_measure (Catalog *catalog); 5 void resort_catalog_lensing (Catalog *catalog); 2 6 3 7 void resort_catalog_old (Catalog *catalog) { … … 27 31 28 32 return; 29 }30 31 // sort the measure Sequence based on the average Sequence entries32 void SortAveMeasMatch (off_t *MEAS, off_t *AVE, off_t N) {33 34 # define SWAPFUNC(A,B){ off_t tmp_meas; off_t tmp_ave; \35 tmp_meas = MEAS[A]; MEAS[A] = MEAS[B]; MEAS[B] = tmp_meas; \36 tmp_ave = AVE[A]; AVE[A] = AVE[B]; AVE[B] = tmp_ave; \37 }38 # define COMPARE(A,B)(AVE[A] < AVE[B])39 OHANA_SORT (N, COMPARE, SWAPFUNC);40 # undef SWAPFUNC41 # undef COMPARE42 33 } 43 34 … … 53 44 void resort_catalog (Catalog *catalog) { 54 45 46 if (catalog[0].sorted == TRUE) return; 47 48 resort_catalog_measure (catalog); 49 resort_catalog_lensing (catalog); 50 } 51 52 void resort_catalog_measure (Catalog *catalog) { 53 55 54 off_t Naverage, Nmeasure; 56 55 Measure *measure; … … 62 61 Measure *measureTMP = NULL; 63 62 64 if (catalog[0].sorted == TRUE) return;65 66 63 // struct timeval start, stop; 67 64 // gettimeofday (&start, NULL); … … 70 67 Nmeasure = catalog[0].Nmeasure; 71 68 Naverage = catalog[0].Naverage; 69 70 if (!Nmeasure) return; 72 71 73 72 measure = catalog[0].measure; … … 113 112 // fprintf (stderr, "\n"); 114 113 115 SortAveM easMatch(measureSeq, averageSeq, Nmeasure);114 SortAveMatch(measureSeq, averageSeq, Nmeasure); 116 115 // MARKTIME("sort : %f sec\n", dtime); 117 116 … … 188 187 } 189 188 189 void resort_catalog_lensing (Catalog *catalog) { 190 191 off_t Naverage, Nlensing; 192 Lensing *lensing; 193 Average *average; 194 off_t i, j, N, currentAve; 195 196 off_t *lensingSeq = NULL; 197 off_t *averageSeq = NULL; 198 Lensing *lensingTMP = NULL; 199 200 // struct timeval start, stop; 201 // gettimeofday (&start, NULL); 202 203 /* internal counters */ 204 Nlensing = catalog[0].Nlensing; 205 Naverage = catalog[0].Naverage; 206 207 if (!Nlensing) return; 208 209 lensing = catalog[0].lensing; 210 average = catalog[0].average; 211 212 // we have a table of average objects and an unsorted table of measurements. each measurement 213 // has a reference to the average object sequence (as well as an ID) 214 // lensing[i].averef -> average[averef] 215 // lensing[i].objID = average[averef].objID 216 // lensing[i].catID = average[averef].catID 217 218 // we want a sorted lensing array with all averef entries in sequence 219 220 ALLOCATE (lensingSeq, off_t, Nlensing); 221 ALLOCATE (averageSeq, off_t, Nlensing); 222 223 for (i = 0; i < Nlensing; i++) { 224 lensingSeq[i] = i; 225 averageSeq[i] = lensing[i].averef; 226 227 if (catalog[0].catformat >= DVO_FORMAT_PS1_V1) { 228 // earlier formats did not carry the objID or catID, so they are not available (we could assign on load, but we don't) 229 myAssert(average[averageSeq[i]].catID == lensing[lensingSeq[i]].catID, "object / detection mismatch"); 230 # if (1) 231 myAssert(average[averageSeq[i]].objID == lensing[lensingSeq[i]].objID, "object / detection mismatch"); 232 # else 233 // for reasons I do not understand, the mini dvodbs generated on stsci1X had a handful of detections with an inconsistency between averef and objID. 234 // this happened for 28 detections in the dbs on /data/stsci1?.0/eugene/dvo3pi.20130616, but not at all (as far as I know) in the rest of LAP DVO 235 if (average[averageSeq[i]].objID != lensing[lensingSeq[i]].objID) { 236 fprintf (stderr, "R"); 237 lensing[lensingSeq[i]].objID = average[averageSeq[i]].objID; // XXX I don't really like this... 238 } 239 # endif 240 } 241 } 242 243 // check that averageSeq is now in order 244 // for (i = 1; i < Nlensing; i++) { 245 // if (averageSeq[i] < averageSeq[i-1]) { 246 // fprintf (stderr, "%d ", (int) i); 247 // } 248 // } 249 // fprintf (stderr, "\n"); 250 251 SortAveMatch(lensingSeq, averageSeq, Nlensing); 252 // MARKTIME("sort : %f sec\n", dtime); 253 254 // check that averageSeq is now in order 255 // for (i = 1; i < Nlensing; i++) { 256 // if (averageSeq[i] < averageSeq[i-1]) { 257 // fprintf (stderr, "%d ", (int) i); 258 // } 259 // } 260 // fprintf (stderr, "\n"); 261 262 // copy the lensing entries in the sorted order 263 ALLOCATE (lensingTMP, Lensing, Nlensing); 264 for (i = 0; i < Nlensing; i++) { 265 j = lensingSeq[i]; 266 lensingTMP[i] = lensing[j]; 267 } 268 // MARKTIME("assign lensing : %f sec\n", dtime); 269 270 // update the values of average.lensingOffset and average.Nlensing 271 FREE(lensing); 272 catalog[0].lensing = lensingTMP; 273 274 N = 0; 275 currentAve = averageSeq[0]; 276 average[currentAve].lensingOffset = 0; 277 for (i = 0; i < Nlensing; i++) { 278 if (averageSeq[i] != currentAve) { 279 // we have hit the next entry in the list 280 average[currentAve].Nlensing = N; 281 N = 0; 282 currentAve = averageSeq[i]; 283 average[currentAve].lensingOffset = i; 284 } 285 N++; 286 } 287 // N++; 288 average[currentAve].Nlensing = N; 289 // MARKTIME("update Nlensing : %f sec\n", dtime); 290 291 int NlensingTotal = 0; 292 int lensingOffsetOK = TRUE; 293 for (i = 0; i < Naverage; i++) { 294 NlensingTotal += catalog[0].average[i].Nlensing; 295 if (VERBOSE && !(NlensingTotal <= catalog[0].Nlensing)) { 296 fprintf (stderr, "too few lensing: %d %d %d\n", (int) i, NlensingTotal, (int) catalog[0].Nlensing); 297 } 298 lensingOffsetOK &= (catalog[0].average[i].lensingOffset < catalog[0].Nlensing); 299 if (VERBOSE && !(catalog[0].average[i].lensingOffset < catalog[0].Nlensing)) { 300 fprintf (stderr, "offset too large: %d %d %d\n", (int) i, catalog[0].average[i].Nlensing, (int) catalog[0].Nlensing); 301 } 302 lensingOffsetOK &= (catalog[0].average[i].lensingOffset + catalog[0].average[i].Nlensing <= catalog[0].Nlensing); 303 if (VERBOSE && !(catalog[0].average[i].lensingOffset + catalog[0].average[i].Nlensing <= catalog[0].Nlensing)) { 304 fprintf (stderr, "orrset + Nlensing too large: %d + %d > %d %d\n", (int) i, catalog[0].average[i].lensingOffset, catalog[0].average[i].Nlensing, (int) catalog[0].Nlensing); 305 } 306 } 307 308 if (!lensingOffsetOK) { 309 fprintf (stderr, "ERROR: catalog %s has an invalid lensingOffset\n", catalog[0].filename); 310 } 311 312 if (NlensingTotal != catalog[0].Nlensing) { 313 fprintf (stderr, "ERROR: catalog %s has an invalid Nlensing\n", catalog[0].filename); 314 } 315 316 // MARKTIME(" match time %9.4f sec for %7lld lensings, %6lld average\n", dtime, (long long) Nlensing, (long long) Naverage); 317 318 catalog[0].sorted = TRUE; 319 320 FREE (lensingSeq); 321 FREE (averageSeq); 322 323 return; 324 } 325 326 // sort the measure or lensing Sequence based on the average Sequence entries 327 void SortAveMatch (off_t *MEAS, off_t *AVE, off_t N) { 328 329 # define SWAPFUNC(A,B){ off_t tmp_meas; off_t tmp_ave; \ 330 tmp_meas = MEAS[A]; MEAS[A] = MEAS[B]; MEAS[B] = tmp_meas; \ 331 tmp_ave = AVE[A]; AVE[A] = AVE[B]; AVE[B] = tmp_ave; \ 332 } 333 # define COMPARE(A,B)(AVE[A] < AVE[B]) 334 OHANA_SORT (N, COMPARE, SWAPFUNC); 335 # undef SWAPFUNC 336 # undef COMPARE 337 } 338 -
branches/eam_branches/ipp-20140610/Ohana/src/addstar/src/resort_threaded.c
r29938 r36922 41 41 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 42 42 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 43 catalog.catflags = LOAD_AVES | LOAD_MEAS ;43 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_LENSING; 44 44 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 45 45 -
branches/eam_branches/ipp-20140610/Ohana/src/addstar/src/resort_unthreaded_catalogs.c
r33963 r36922 30 30 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 31 31 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 32 catalog.catflags = LOAD_AVES | LOAD_MEAS ;32 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_LENSING; 33 33 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 34 34 -
branches/eam_branches/ipp-20140610/Ohana/src/libdvo/include/dvo.h
r36921 r36922 606 606 char catmode; /* storage mode (raw, mef, split, mysql) */ 607 607 char catformat; /* storage format (elixir, panstarrs, etc) */ 608 char sorted; /* is measure table average-sorted?*/608 int sorted; /* is measure table average-sorted? (NOTE this is an int only because gfits_scan %t requires it) */ 609 609 610 610 short catflags; /* choices to be loaded */
Note:
See TracChangeset
for help on using the changeset viewer.
