Changeset 31273
- Timestamp:
- Apr 12, 2011, 3:10:26 PM (15 years ago)
- Location:
- branches/eam_branches/ipp-20110404/Ohana/src/relphot
- Files:
-
- 11 edited
-
include/relphot.h (modified) (1 diff)
-
src/GridOps.c (modified) (9 diffs)
-
src/ImageOps.c (modified) (15 diffs)
-
src/MosaicOps.c (modified) (8 diffs)
-
src/StarOps.c (modified) (19 diffs)
-
src/bcatalog.c (modified) (10 diffs)
-
src/plot_scatter.c (modified) (2 diffs)
-
src/reload_catalogs.c (modified) (2 diffs)
-
src/relphot.c (modified) (3 diffs)
-
src/setExclusions.c (modified) (4 diffs)
-
src/setMrelFinal.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110404/Ohana/src/relphot/include/relphot.h
r31272 r31273 234 234 int rationalize_mosaics (); 235 235 int LimitDensityCatalog (Catalog *subcatalog, Catalog *catalog); 236 237 int populate_tiny_values (Catalog *catalog); 238 int free_tiny_values (Catalog *catalog); -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/GridOps.c
r31272 r31273 366 366 mx = mlist[i][j]; 367 367 c = clist[i][j]; 368 n = catalog[c].measure [mx].averef;368 n = catalog[c].measureT[mx].averef; 369 369 370 370 // if we have already visited this star, skip the stuff below … … 393 393 394 394 // skip measurements marked as BAD 395 if (catalog[c].measure [m].dbFlags & MEAS_BAD) {395 if (catalog[c].measureT[m].dbFlags & MEAS_BAD) { 396 396 Nbad ++; 397 397 continue; … … 414 414 // select the color- and airmass-corrected observed magnitude for this star 415 415 // XXX need to be able to turn off the color-correction until initial average mags are found 416 Msys = PhotCat (&catalog[c].measure[m]);416 Msys = PhotCatTiny (&catalog[c].measureT[m]); 417 417 if (isnan(Msys)) { 418 418 Nsys++; … … 421 421 422 422 // mag-error for this measurement 423 Merr = MAX (catalog[c].measure [m].dM, MIN_ERROR);423 Merr = MAX (catalog[c].measureT[m].dM, MIN_ERROR); 424 424 425 425 // Wsys = 1.0 / SQ(Merr); … … 550 550 c = clist[i][j]; 551 551 552 if (catalog[c].measure [m].dbFlags & MEAS_BAD) {552 if (catalog[c].measureT[m].dbFlags & MEAS_BAD) { 553 553 Nbad ++; 554 554 continue; … … 570 570 } 571 571 572 n = catalog[c].measure [m].averef;573 Msys = PhotSys (&catalog[c].measure[m], &catalog[c].average[n], &catalog[c].secfilt[n*Nsecfilt]);572 n = catalog[c].measureT[m].averef; 573 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt]); 574 574 if (isnan(Msys)) { 575 575 Nsys++; … … 577 577 } 578 578 list[N] = Msys - Mrel - Mcal - Mmos; 579 dlist[N] = MAX (catalog[c].measure [m].dM, MIN_ERROR);579 dlist[N] = MAX (catalog[c].measureT[m].dM, MIN_ERROR); 580 580 N++; 581 581 } … … 637 637 c = clist[i][j]; 638 638 639 if (catalog[c].measure [m].dbFlags & MEAS_BAD) {639 if (catalog[c].measureT[m].dbFlags & MEAS_BAD) { 640 640 Narea ++; 641 641 continue; … … 648 648 if (isnan(Mrel)) continue; 649 649 650 n = catalog[c].measure [m].averef;651 Msys = PhotSys (&catalog[c].measure[m], &catalog[c].average[n], &catalog[c].secfilt[n*Nsecfilt]);650 n = catalog[c].measureT[m].averef; 651 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt]); 652 652 653 653 xlist[N] = Xmeas[c][m]; -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/ImageOps.c
r31272 r31273 1 1 # include "relphot.h" 2 3 # define USE_IMAGE_ID 14 2 5 3 static off_t **bin; // link from catalog,measure to image … … 12 10 static off_t Nimage; // number of available images 13 11 14 // if we search by image ID, we sort (imageIDs, imageIdx) by imageIDs to get a sorted 15 // index 16 17 # if USE_IMAGE_ID 12 // to search by image ID, we sort (imageIDs, imageIdx) by imageIDs to get a sorted index 18 13 static off_t *imageIDs; // list of all image IDs 19 14 static off_t *imageIdx; // list of index for image IDs 20 # else21 static unsigned int *start;22 static unsigned int *stop;23 # endif24 15 25 16 Image *getimages (off_t *N) { … … 40 31 Nimage = N; 41 32 42 # if USE_IMAGE_ID43 33 ALLOCATE (imageIDs, off_t, Nimage); 44 34 ALLOCATE (imageIdx, off_t, Nimage); … … 49 39 } 50 40 llsortpair (imageIDs, imageIdx, Nimage); 51 # else52 ALLOCATE (start, unsigned, Nimage);53 ALLOCATE (stop, unsigned, Nimage);54 55 for (i = 0; i < Nimage; i++) {56 start[i] = image[i].tzero - MAX(0.01*image[i].trate*image[i].NY, 1);57 stop[i] = image[i].tzero + MAX(1.01*image[i].trate*image[i].NY, 1);58 }59 # endif60 41 } 61 42 … … 65 46 // use bisection to find the specified image ID 66 47 67 # if USE_IMAGE_ID68 48 off_t Nlo, Nhi, N; 69 49 … … 82 62 return (imageIdx[N]); 83 63 } 84 # endif85 64 86 65 return (-1); … … 137 116 for (i = 0; i < Ncatalog; i++) { 138 117 for (j = 0; j < catalog[i].Nmeasure; j++) { 139 ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure [j].photcode);118 ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[j].photcode); 140 119 found = FALSE; 141 120 for (Ns = 0; !found && (Ns < Nphotcodes); Ns++) { … … 150 129 } 151 130 152 int findCCD (off_t idx, off_t meas, int cat, Measure *measure) {131 int findCCD (off_t idx, off_t meas, int cat, MeasureTiny *measure) { 153 132 154 133 int ccdnum, found, Ns, ecode; … … 186 165 187 166 // old code to add this measurement to the grid cell for this chip 188 // ave = measure [0].averef;189 // ra = catalog[cat].average [ave].R - measure[0].dR / 3600.0;190 // dec = catalog[cat].average [ave].D - measure[0].dD / 3600.0;167 // ave = measureT[0].averef; 168 // ra = catalog[cat].averageT[ave].R - measureT[0].dR / 3600.0; 169 // dec = catalog[cat].averageT[ave].D - measureT[0].dD / 3600.0; 191 170 // RD_to_XY (&X, &Y, ra, dec, &image[i].coords); 192 171 … … 199 178 } 200 179 201 # if USE_IMAGE_ID202 180 void matchImage (Catalog *catalog, off_t meas, int cat) { 203 181 204 182 off_t idx, ID; 205 183 int status; 206 Measure *measure;184 MeasureTiny *measure; 207 185 208 measure = &catalog[cat].measure [meas];186 measure = &catalog[cat].measureT[meas]; 209 187 210 188 ID = measure[0].imageID; … … 241 219 return; 242 220 } 243 244 # else245 // this is the time-based match246 void matchImage (Catalog *catalog, off_t meas, int cat) {247 248 off_t i;249 int status;250 Measure *measure;251 252 measure = &catalog[cat].measure[meas];253 for (i = 0; i < Nimage; i++) {254 if (image[0].photcode == -1) continue;255 if (measure[0].photcode != image[i].photcode) continue;256 if (measure[0].t < start[i]) continue;257 if (measure[0].t > stop[i]) continue;258 259 if (USE_GRID) {260 status = findCCD(i, meas, cat);261 if (!status) continue;262 }263 264 // index for (catalog, measure) -> image265 bin[cat][meas] = i;266 267 // index for image, Nentry -> catalog268 clist[i][Nlist[i]] = cat;269 270 // index for image, Nentry -> measure271 mlist[i][Nlist[i]] = meas;272 Nlist[i] ++;273 274 if (Nlist[i] == NLIST[i]) {275 NLIST[i] += 100;276 REALLOCATE (clist[i], off_t, NLIST[i]);277 REALLOCATE (mlist[i], off_t, NLIST[i]);278 }279 return;280 }281 /* fprintf (stderr, "can't find source image for this measurement: %d (%d)\n", measure[0].t, measure[0].photcode); */282 }283 # endif284 221 285 222 off_t getImageEntry (off_t meas, int cat) { … … 357 294 c = clist[i][j]; 358 295 359 if (catalog[c].measure [m].dbFlags & MEAS_BAD) {296 if (catalog[c].measureT[m].dbFlags & MEAS_BAD) { 360 297 Nbad++; 361 298 continue; … … 377 314 } 378 315 379 n = catalog[c].measure [m].averef;380 Msys = PhotSys (&catalog[c].measure[m], &catalog[c].average[n], &catalog[c].secfilt[n*Nsecfilt]);316 n = catalog[c].measureT[m].averef; 317 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt]); 381 318 if (isnan(Msys)) { 382 319 Nsys++; … … 384 321 } 385 322 list[N] = Msys - Mrel - Mmos - Mgrid; 386 dlist[N] = MAX (catalog[c].measure [m].dM, MIN_ERROR);387 if (catalog[c].measure [m].dM < IMFIT_SYS_SIGMA_LIM) {323 dlist[N] = MAX (catalog[c].measureT[m].dM, MIN_ERROR); 324 if (catalog[c].measureT[m].dM < IMFIT_SYS_SIGMA_LIM) { 388 325 McalBright += list[N]; 389 326 McalBright2 += SQ(list[N]); … … 650 587 return (stats); 651 588 } 652 -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/MosaicOps.c
r31272 r31273 272 272 for (j = 0; j < catalog[i].Nmeasure; j++) { 273 273 if (TimeSelect) { 274 if (catalog[i].measure [j].t < TSTART) continue;275 if (catalog[i].measure [j].t > TSTOP) continue;276 } 277 ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure [j].photcode);274 if (catalog[i].measureT[j].t < TSTART) continue; 275 if (catalog[i].measureT[j].t > TSTOP) continue; 276 } 277 ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[j].photcode); 278 278 found = FALSE; 279 279 for (Ns = 0; !found && (Ns < Nphotcodes); Ns++) { … … 289 289 } 290 290 291 # if 1292 // # if USE_IMAGE_ID293 294 291 void matchMosaics (Catalog *catalog, off_t meas, int cat) { 295 292 296 293 off_t idx, ID, mosID; 297 Measure *measure;298 299 measure = &catalog[cat].measure [meas];294 MeasureTiny *measure; 295 296 measure = &catalog[cat].measureT[meas]; 300 297 301 298 ID = measure[0].imageID; … … 336 333 } 337 334 338 # else // USE_IMAGE_ID339 340 void matchMosaics (Catalog *catalog, off_t meas, int cat) {341 342 int i;343 344 for (i = 0; i < Nmosaic; i++) {345 if (catalog[cat].measure[meas].t < mosaic[i].start) continue;346 if (catalog[cat].measure[meas].t > mosaic[i].stop) continue;347 348 # ifdef GRID_V1349 if (USE_GRID) {350 ave = catalog[cat].measure[meas].averef;351 ra = catalog[cat].average[ave].R - catalog[cat].measure[meas].dR / 3600.0;352 dec = catalog[cat].average[ave].D - catalog[cat].measure[meas].dD / 3600.0;353 354 /* X,Y always positive-definite in range 0,0 - dX, dY */355 RD_to_XY (&X, &Y, ra, dec, &mosaic[i].coords);356 setGridMeasure (meas, cat, X, Y);357 }358 # endif // GRID_V1359 360 bin[cat][meas] = i;361 362 clist[i][Nlist[i]] = cat;363 mlist[i][Nlist[i]] = meas;364 Nlist[i] ++;365 366 if (Nlist[i] == NLIST[i]) {367 NLIST[i] += 100;368 REALLOCATE (clist[i], int, NLIST[i]);369 REALLOCATE (mlist[i], off_t, NLIST[i]);370 }371 return;372 }373 // if we miss a measurement, it might be a REF type of value374 if (VERBOSE2) fprintf (stderr, "missed measurement "OFF_T_FMT", %d\n", meas, cat);375 return;376 }377 # endif // USE_IMAGE_ID378 379 335 float getMmos (off_t meas, int cat) { 380 336 … … 437 393 c = clist[i][j]; 438 394 439 if (catalog[c].measure [m].dbFlags & MEAS_BAD) {395 if (catalog[c].measureT[m].dbFlags & MEAS_BAD) { 440 396 Nbad ++; 441 397 continue; … … 457 413 } 458 414 459 n = catalog[c].measure [m].averef;460 Msys = PhotSys (&catalog[c].measure[m], &catalog[c].average[n], &catalog[c].secfilt[n*Nsecfilt]);415 n = catalog[c].measureT[m].averef; 416 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt]); 461 417 if (isnan(Msys)) { 462 418 Nsys++; … … 464 420 } 465 421 list[N] = Msys - Mrel - Mcal - Mgrid; 466 dlist[N] = MAX (catalog[c].measure [m].dM, MIN_ERROR);422 dlist[N] = MAX (catalog[c].measureT[m].dM, MIN_ERROR); 467 423 Mlist[N] = Msys; 468 424 dMlist[N] = list[N]; … … 580 536 memset (starNcount[Nstars], 0, Nphotcodes*sizeof(int)); 581 537 582 m = catalog[i].average [j].measureOffset;538 m = catalog[i].averageT[j].measureOffset; 583 539 584 540 // determine the mosaic for each measurement 585 for (k = 0; k < catalog[i].average [j].Nmeasure; k++, m++) {541 for (k = 0; k < catalog[i].averageT[j].Nmeasure; k++, m++) { 586 542 587 543 // skip unused measurements 588 if (catalog[i].measure [m].dbFlags & MEAS_BAD) continue;544 if (catalog[i].measureT[m].dbFlags & MEAS_BAD) continue; 589 545 590 546 // skip unused measurements 591 547 int Nsec; 592 int ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure [m].photcode);548 int ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[m].photcode); 593 549 found = FALSE; 594 550 for (Ns = 0; !found && (Ns < Nphotcodes); Ns ++) { … … 914 870 c = clist[i][j]; 915 871 916 if (catalog[c].measure [m].dbFlags & (ID_MEAS_AREA | ID_MEAS_NOCAL)) continue;917 918 ave = catalog[c].measure [m].averef;919 xlist[N] = catalog[c].average [ave].R - catalog[c].measure[m].dR / 3600.0;920 ylist[N] = catalog[c].average [ave].D - catalog[c].measure[m].dD / 3600.0;872 if (catalog[c].measureT[m].dbFlags & (ID_MEAS_AREA | ID_MEAS_NOCAL)) continue; 873 874 ave = catalog[c].measureT[m].averef; 875 xlist[N] = catalog[c].averageT[ave].R - catalog[c].measureT[m].dR / 3600.0; 876 ylist[N] = catalog[c].averageT[ave].D - catalog[c].measureT[m].dD / 3600.0; 921 877 N++; 922 878 } -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/StarOps.c
r31272 r31273 18 18 for (i = 0; i < Ncatalog; i++) { 19 19 for (j = 0; j < catalog[i].Naverage; j++) { 20 Nmax = MAX (Nmax, catalog[i].average [j].Nmeasure);20 Nmax = MAX (Nmax, catalog[i].averageT[j].Nmeasure); 21 21 } 22 22 } … … 33 33 float value; 34 34 35 ave = catalog[cat].measure [meas].averef;36 photcode = catalog[cat].measure [meas].photcode;35 ave = catalog[cat].measureT[meas].averef; 36 photcode = catalog[cat].measureT[meas].photcode; 37 37 38 38 int ecode = GetPhotcodeEquivCodebyCode (photcode); … … 70 70 // skip bad stars 71 71 if (catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD) continue; 72 m = catalog[i].average [j].measureOffset;72 m = catalog[i].averageT[j].measureOffset; 73 73 74 74 N = 0; 75 for (k = 0; k < catalog[i].average [j].Nmeasure; k++, m++) {75 for (k = 0; k < catalog[i].averageT[j].Nmeasure; k++, m++) { 76 76 // skip measurements that do not match the current photcode 77 int ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure [m].photcode);77 int ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[m].photcode); 78 78 if (ecode != thisCode) { continue; } 79 79 80 if (catalog[i].measure [m].dbFlags & MEAS_BAD) {80 if (catalog[i].measureT[m].dbFlags & MEAS_BAD) { 81 81 Nbad ++; 82 82 continue; … … 105 105 } 106 106 107 Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]);107 Msys = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt]); 108 108 if (isnan(Msys)) { 109 109 Nsys++; … … 111 111 } 112 112 list[N] = Msys - Mcal - Mmos - Mgrid; 113 dlist[N] = MAX (catalog[i].measure [m].dM, MIN_ERROR);113 dlist[N] = MAX (catalog[i].measureT[m].dM, MIN_ERROR); 114 114 115 115 // tie down reference photometry if the -refcode (code) option is selected 116 116 if (refPhotcode) { 117 if (GetPhotcodeEquivCodebyCode(catalog[i].measure [m].photcode) == refPhotcode[0].equiv) {117 if (GetPhotcodeEquivCodebyCode(catalog[i].measureT[m].photcode) == refPhotcode[0].equiv) { 118 118 // increase the weight by a factor of 100: 119 dlist[N] = 0.01*catalog[i].measure [m].dM;119 dlist[N] = 0.01*catalog[i].measureT[m].dM; 120 120 } 121 121 } … … 159 159 for (i = 0; i < Ncatalog; i++) { 160 160 for (j = 0; j < catalog[i].Naverage; j++) { 161 Nmax = MAX (Nmax, catalog[i].average [j].Nmeasure);161 Nmax = MAX (Nmax, catalog[i].averageT[j].Nmeasure); 162 162 } 163 163 } … … 176 176 177 177 N = 0; 178 m = catalog[i].average [j].measureOffset;179 for (k = 0; k < catalog[i].average [j].Nmeasure; k++, m++) {178 m = catalog[i].averageT[j].measureOffset; 179 for (k = 0; k < catalog[i].averageT[j].Nmeasure; k++, m++) { 180 180 // skip measurements that do not match the current photcode 181 ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure [m].photcode);181 ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[m].photcode); 182 182 if (ecode != thisCode) { continue; } 183 183 184 if (catalog[i].measure [m].dbFlags & MEAS_BAD) continue;184 if (catalog[i].measureT[m].dbFlags & MEAS_BAD) continue; 185 185 186 186 // XXX allow REF stars (no Image Entry) to be included in the calculation this … … 198 198 } 199 199 200 Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]);200 Msys = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt]); 201 201 list[N] = Msys - Mcal - Mmos - Mgrid; 202 dlist[N] = MAX (catalog[i].measure [m].dM, MIN_ERROR);202 dlist[N] = MAX (catalog[i].measureT[m].dM, MIN_ERROR); 203 203 N++; 204 204 } … … 221 221 } 222 222 223 // for each average object, set the average mags based on existing equiv photometry 223 // For each average object, set the average mags based on existing equiv photometry. 224 // NOTE: this function operates on the real Measure & Average structures, not the 225 // MeasureTiny & AverageTiny structures 224 226 int setMave (Catalog *catalog, int Ncatalog) { 225 227 … … 363 365 for (j = 0; j < catalog[i].Naverage; j++) { 364 366 365 m = catalog[i].average [j].measureOffset;366 for (k = 0; k < catalog[i].average [j].Nmeasure; k++, m++) {367 if (catalog[i].measure [m].dbFlags & MEAS_BAD) continue;367 m = catalog[i].averageT[j].measureOffset; 368 for (k = 0; k < catalog[i].averageT[j].Nmeasure; k++, m++) { 369 if (catalog[i].measureT[m].dbFlags & MEAS_BAD) continue; 368 370 Mcal = getMcal (m, i); 369 371 if (isnan(Mcal)) continue; … … 372 374 Mgrid = getMgrid (m, i); 373 375 if (isnan(Mgrid)) continue; 376 377 // set the output calibration 374 378 catalog[i].measure[m].Mcal = Mcal + Mmos + Mgrid; 375 379 } … … 469 473 for (i = 0; i < Ncatalog; i++) { 470 474 for (j = 0; j < catalog[i].Naverage; j++) { 471 Nmax = MAX (Nmax, catalog[i].average [j].Nmeasure);475 Nmax = MAX (Nmax, catalog[i].averageT[j].Nmeasure); 472 476 } 473 477 } … … 498 502 499 503 /* accumulate list of valid measurements */ 500 m = catalog[i].average [j].measureOffset;504 m = catalog[i].averageT[j].measureOffset; 501 505 N = 0; 502 for (k = 0; k < catalog[i].average [j].Nmeasure; k++, m++) {506 for (k = 0; k < catalog[i].averageT[j].Nmeasure; k++, m++) { 503 507 // skip measurements that do not match the current photcode 504 int ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure [m].photcode);508 int ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[m].photcode); 505 509 if (ecode != thisCode) { continue; } 506 510 507 /* if (catalog[i].measure [m].dbFlags & MEAS_BAD) continue; */511 /* if (catalog[i].measureT[m].dbFlags & MEAS_BAD) continue; */ 508 512 Mcal = getMcal (m, i); 509 513 if (isnan(Mcal)) { Ncal ++; continue; } … … 513 517 if (isnan(Mgrid)) { Ngrid ++; continue; } 514 518 515 Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]);519 Msys = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt]); 516 520 list[N] = Msys - Mcal - Mmos - Mgrid; 517 dlist[N] = MAX (catalog[i].measure [m].dM, MIN_ERROR);521 dlist[N] = MAX (catalog[i].measureT[m].dM, MIN_ERROR); 518 522 N++; 519 523 } … … 542 546 image_bad = IMAGE_BAD; 543 547 IMAGE_BAD = ID_IMAGE_PHOTOM_NOCAL; 544 m = catalog[i].average [j].measureOffset;548 m = catalog[i].averageT[j].measureOffset; 545 549 N = 0; 546 for (k = 0; k < catalog[i].average [j].Nmeasure; k++, m++) {550 for (k = 0; k < catalog[i].averageT[j].Nmeasure; k++, m++) { 547 551 // skip measurements that do not match the current photcode 548 int ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure [m].photcode);552 int ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[m].photcode); 549 553 if (ecode != thisCode) { continue; } 550 554 551 /* if (catalog[i].measure [m].dbFlags & MEAS_BAD) continue; */555 /* if (catalog[i].measureT[m].dbFlags & MEAS_BAD) continue; */ 552 556 Mcal = getMcal (m, i); 553 557 if (isnan(Mcal)) continue; … … 557 561 if (isnan(Mgrid)) continue; 558 562 559 Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]);563 Msys = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt]); 560 564 list[N] = Msys - Mcal - Mmos - Mgrid; 561 dlist[N] = MAX (catalog[i].measure [m].dM, MIN_ERROR);565 dlist[N] = MAX (catalog[i].measureT[m].dM, MIN_ERROR); 562 566 ilist[N] = m; 563 567 N++; … … 569 573 for (k = 0; k < N; k++) { 570 574 if (fabs (list[k] - stats.median) > NSIGMA_REJECT*stats.sigma) { 571 catalog[i].measure[ilist[k]].dbFlags |= ID_MEAS_POOR_PHOTOM; 575 catalog[i].measureT[ilist[k]].dbFlags |= ID_MEAS_POOR_PHOTOM; 576 if (final) { 577 // for the final pass, we have a duplicate set of values in measure and measureT 578 catalog[i].measure[ilist[k]].dbFlags |= ID_MEAS_POOR_PHOTOM; 579 } 572 580 Ndel ++; 573 581 } … … 609 617 /* calculate the average value for a single star */ 610 618 if (catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD) { N1++; continue; } 611 m = catalog[i].average [j].measureOffset;619 m = catalog[i].averageT[j].measureOffset; 612 620 613 621 N = 0; 614 for (k = 0; k < catalog[i].average [j].Nmeasure; k++, m++) {615 int ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure [m].photcode);622 for (k = 0; k < catalog[i].averageT[j].Nmeasure; k++, m++) { 623 int ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[m].photcode); 616 624 if (ecode != seccode) { N0++; continue;} 617 625 Mcal = getMcal (m, i); … … 816 824 for (i = 0; i < Ncatalog; i++) { 817 825 for (j = 0; j < catalog[i].Naverage; j++) { 818 xlist[N] = catalog[i].average [j].R;819 ylist[N] = catalog[i].average [j].D;826 xlist[N] = catalog[i].averageT[j].R; 827 ylist[N] = catalog[i].averageT[j].D; 820 828 N++; 821 829 } -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/bcatalog.c
r31272 r31273 2 2 3 3 extern double drand48(); 4 5 int CopyAverageTiny (AverageTiny *averageT, Average *average) { 6 7 averageT[0].R = average[0].R; 8 averageT[0].D = average[0].D; 9 averageT[0].flags = average[0].flags; 10 averageT[0].Nmeasure = average[0].Nmeasure; 11 averageT[0].measureOffset = average[0].measureOffset; 12 13 // make Nmeasure & measureOffset optional? 14 15 return (TRUE); 16 } 17 18 int CopyMeasureTiny (MeasureTiny *measureT, Measure *measure) { 19 20 measureT[0].dR = measure[0].dR; 21 measureT[0].dD = measure[0].dD; 22 measureT[0].M = measure[0].M; 23 measureT[0].Mcal = measure[0].Mcal; 24 measureT[0].dM = measure[0].dM; 25 measureT[0].airmass = measure[0].airmass; 26 measureT[0].Xccd = measure[0].Xccd; 27 measureT[0].Yccd = measure[0].Yccd; 28 measureT[0].t = measure[0].t; 29 measureT[0].dt = measure[0].dt; 30 measureT[0].averef = measure[0].averef; 31 measureT[0].imageID = measure[0].imageID; 32 measureT[0].dbFlags = measure[0].dbFlags; 33 measureT[0].photcode = measure[0].photcode; 34 35 return (TRUE); 36 } 4 37 5 38 int bcatalog (Catalog *subcatalog, Catalog *catalog) { … … 18 51 NAVERAGE = 50; 19 52 NMEASURE = 1000; 20 ALLOCATE (subcatalog[0].average, Average, NAVERAGE); 53 ALLOCATE (subcatalog[0].measureT, MeasureTiny, NMEASURE); 54 ALLOCATE (subcatalog[0].averageT, AverageTiny, NAVERAGE); 21 55 ALLOCATE (subcatalog[0].secfilt, SecFilt, NAVERAGE*Nsecfilt); 22 ALLOCATE (subcatalog[0].measure, Measure, NMEASURE);23 56 Nmeasure = Naverage = 0; 24 57 … … 30 63 31 64 /* start with all stars good */ 32 subcatalog[0].average[Naverage] = catalog[0].average[i]; 33 subcatalog[0].average[Naverage].measureOffset = Nmeasure; 65 CopyAverageTiny (&subcatalog[0].averageT[Naverage], &catalog[0].average[i]); 66 subcatalog[0].averageT[Naverage].measureOffset = Nmeasure; 67 34 68 for (j = 0; j < Nsecfilt; j++) { 35 69 subcatalog[0].secfilt[Nsecfilt*Naverage+j] = catalog[0].secfilt[Nsecfilt*i+j]; … … 103 137 } 104 138 105 subcatalog[0].measure[Nmeasure].dbFlags &= ~ID_MEAS_SKIP_PHOTOM;106 subcatalog[0].measure [Nmeasure] = catalog[0].measure[offset];107 subcatalog[0].measure [Nmeasure].averef = Naverage;139 CopyMeasureTiny (&subcatalog[0].measureT[Nmeasure], &catalog[0].measure[offset]); 140 subcatalog[0].measureT[Nmeasure].dbFlags &= ~ID_MEAS_SKIP_PHOTOM; 141 subcatalog[0].measureT[Nmeasure].averef = Naverage; 108 142 if (RESET) { 109 subcatalog[0].measure [Nmeasure].Mcal = 0;110 subcatalog[0].measure [Nmeasure].dbFlags &= 0xff00;111 subcatalog[0].measure [Nmeasure].dbFlags &= ~ID_MEAS_POOR_PHOTOM;112 subcatalog[0].measure [Nmeasure].dbFlags &= ~ID_MEAS_AREA;113 subcatalog[0].measure [Nmeasure].dbFlags &= ~ID_MEAS_NOCAL;143 subcatalog[0].measureT[Nmeasure].Mcal = 0; 144 subcatalog[0].measureT[Nmeasure].dbFlags &= 0xff00; 145 subcatalog[0].measureT[Nmeasure].dbFlags &= ~ID_MEAS_POOR_PHOTOM; 146 subcatalog[0].measureT[Nmeasure].dbFlags &= ~ID_MEAS_AREA; 147 subcatalog[0].measureT[Nmeasure].dbFlags &= ~ID_MEAS_NOCAL; 114 148 } 115 149 Nmeasure ++; … … 117 151 if (Nmeasure == NMEASURE) { 118 152 NMEASURE += 1000; 119 REALLOCATE (subcatalog[0].measure , Measure, NMEASURE);153 REALLOCATE (subcatalog[0].measureT, MeasureTiny, NMEASURE); 120 154 } 121 155 } … … 134 168 continue; 135 169 } 136 subcatalog[0].average [Naverage].Nmeasure = Nm;170 subcatalog[0].averageT[Naverage].Nmeasure = Nm; 137 171 Naverage ++; 138 172 if (Naverage == NAVERAGE) { 139 173 NAVERAGE += 50; 140 REALLOCATE (subcatalog[0].average , Average, NAVERAGE);141 REALLOCATE (subcatalog[0].secfilt, SecFilt,NAVERAGE*Nsecfilt);142 } 143 } 144 REALLOCATE (subcatalog[0].average , Average, MAX (Naverage, 1));145 REALLOCATE (subcatalog[0].measure , Measure, MAX (Nmeasure, 1));174 REALLOCATE (subcatalog[0].averageT, AverageTiny, NAVERAGE); 175 REALLOCATE (subcatalog[0].secfilt, SecFilt, NAVERAGE*Nsecfilt); 176 } 177 } 178 REALLOCATE (subcatalog[0].averageT, AverageTiny, MAX (Naverage, 1)); 179 REALLOCATE (subcatalog[0].measureT, MeasureTiny, MAX (Nmeasure, 1)); 146 180 REALLOCATE (subcatalog[0].secfilt, SecFilt, Nsecfilt*MAX (Naverage, 1)); 147 181 subcatalog[0].Naverage = Naverage; … … 211 245 for (i = 0; i < Nmax; i++) { 212 246 ave = index[i]; 213 NMEASURE += subcatalog[0].average [ave].Nmeasure;247 NMEASURE += subcatalog[0].averageT[ave].Nmeasure; 214 248 } 215 249 216 250 // allocate the output data 217 ALLOCATE (tmpcatalog.average , Average, Nmax);218 ALLOCATE (tmpcatalog. secfilt, SecFilt, Nmax * Nsecfilt);219 ALLOCATE (tmpcatalog. measure, Measure, NMEASURE);251 ALLOCATE (tmpcatalog.averageT, AverageTiny, Nmax); 252 ALLOCATE (tmpcatalog.measureT, MeasureTiny, NMEASURE); 253 ALLOCATE (tmpcatalog.secfilt, SecFilt, Nmax * Nsecfilt); 220 254 221 255 off_t Nmeasure = 0; … … 224 258 for (i = 0; i < Nmax; i++) { 225 259 ave = index[i]; 226 tmpcatalog.average [i] = subcatalog[0].average[ave];227 tmpcatalog.average [i].measureOffset = Nmeasure;228 for (j = 0; j < tmpcatalog.average [i].Nmeasure; j++) {229 off_t offset = subcatalog[0].average [ave].measureOffset + j;230 tmpcatalog.measure [Nmeasure] = subcatalog[0].measure[offset];231 tmpcatalog.measure [Nmeasure].averef = i;260 tmpcatalog.averageT[i] = subcatalog[0].averageT[ave]; 261 tmpcatalog.averageT[i].measureOffset = Nmeasure; 262 for (j = 0; j < tmpcatalog.averageT[i].Nmeasure; j++) { 263 off_t offset = subcatalog[0].averageT[ave].measureOffset + j; 264 tmpcatalog.measureT[Nmeasure] = subcatalog[0].measureT[offset]; 265 tmpcatalog.measureT[Nmeasure].averef = i; 232 266 Nmeasure ++; 233 267 } … … 239 273 } 240 274 241 free (subcatalog[0].average );242 free (subcatalog[0].measure );275 free (subcatalog[0].averageT); 276 free (subcatalog[0].measureT); 243 277 free (subcatalog[0].secfilt); 244 278 245 subcatalog[0].average = tmpcatalog.average;246 subcatalog[0].measure = tmpcatalog.measure;279 subcatalog[0].averageT = tmpcatalog.averageT; 280 subcatalog[0].measureT = tmpcatalog.measureT; 247 281 subcatalog[0].secfilt = tmpcatalog.secfilt; 248 282 subcatalog[0].Naverage = Nmax; … … 253 287 return (TRUE); 254 288 } 289 290 // for the cases where we are not using a subset of the data, we still need to have a copy of these fields 291 int populate_tiny_values (Catalog *catalog) { 292 293 off_t i; 294 295 ALLOCATE (catalog[0].measureT, MeasureTiny, catalog[0].Nmeasure); 296 ALLOCATE (catalog[0].averageT, AverageTiny, catalog[0].Naverage); 297 298 for (i = 0; i < catalog[0].Naverage; i++) { 299 CopyAverageTiny (&catalog[0].averageT[i], &catalog[0].average[i]); 300 } 301 302 for (i = 0; i < catalog[0].Nmeasure; i++) { 303 CopyMeasureTiny (&catalog[0].measureT[i], &catalog[0].measure[i]); 304 } 305 306 return (TRUE); 307 } 308 309 int free_tiny_values (Catalog *catalog) { 310 311 free (catalog[0].averageT); 312 free (catalog[0].measureT); 313 return (TRUE); 314 } 315 -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/plot_scatter.c
r31272 r31273 36 36 for (k = 0; k < catalog[i].average[j].Nmeasure; k++, m++) { 37 37 // skip measurements that do not match the current photcode 38 int ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure [m].photcode);38 int ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[m].photcode); 39 39 if (ecode != thisCode) { continue; } 40 40 41 if (catalog[i].measure [m].dbFlags & MEAS_BAD) continue;41 if (catalog[i].measureT[m].dbFlags & MEAS_BAD) continue; 42 42 Mcal = getMcal (m, i); 43 43 if (isnan(Mcal)) continue; … … 49 49 Mrel = catalog[i].secfilt[Nsecfilt*j+Nsec].M; 50 50 xlist[N] = Mrel; 51 ylist[N] = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]) - Mcal - Mmos - Mgrid - Mrel;52 ilist[N] = PhotInst (&catalog[i].measure[m]);51 ylist[N] = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt]) - Mcal - Mmos - Mgrid - Mrel; 52 ilist[N] = PhotInstTiny (&catalog[i].measureT[m]); 53 53 N++; 54 54 } -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/reload_catalogs.c
r31260 r31273 49 49 TIMESTAMP(time2); 50 50 51 populate_tiny_values(&catalog); 52 51 53 initImageBins (&catalog, 1); 52 54 initMosaicBins (&catalog, 1); 53 initGridBins (&catalog, 1); 55 initGridBins (&catalog, 1); 54 56 TIMESTAMP(time3); 55 57 56 findImages (&catalog, 1); 57 findMosaics (&catalog, 1); 58 findImages (&catalog, 1); // FX 59 findMosaics (&catalog, 1); // 58 60 TIMESTAMP(time4); 59 61 … … 63 65 dvo_catalog_save (&catalog, VERBOSE); 64 66 dvo_catalog_unlock (&catalog); 67 68 free_tiny_values(&catalog); 65 69 dvo_catalog_free (&catalog); 66 70 TIMESTAMP(time6); -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/relphot.c
r31272 r31273 94 94 int star_toofew; 95 95 96 # if (USE_DIRECT)97 // until we finish the grid analysis, do not reject stars out-of-hand based on ID_STAR_FEW98 // XXX this is kind of poor: need to have a better distinctions about STAR_BAD in setMrel vs getMrel99 star_toofew = STAR_TOOFEW;100 STAR_TOOFEW = 0;101 STAR_BAD = ID_STAR_POOR;102 103 showGridCount ();104 setMgridDirect (catalog, Ncatalog);105 106 STAR_BAD = ID_STAR_POOR | ID_STAR_FEW;107 STAR_TOOFEW = star_toofew;108 109 dump_grid ();110 exit (0);111 112 # else113 114 96 // until we finish the grid analysis, do not reject stars out-of-hand based on ID_STAR_FEW 115 97 // XXX this is kind of poor: need to have a better distinctions about STAR_BAD in setMrel vs getMrel … … 124 106 STAR_BAD = ID_STAR_POOR | ID_STAR_FEW; 125 107 STAR_TOOFEW = star_toofew; 126 # endif127 108 } 128 109 … … 175 156 176 157 /* at this point, we have correct cal coeffs in the image/mosaic structures */ 177 for (i = 0; i < Ncatalog; i++) dvo_catalog_free (&catalog[i]); 158 for (i = 0; i < Ncatalog; i++) { 159 free_tiny_values (&catalog[i]); 160 dvo_catalog_free (&catalog[i]); 161 } 178 162 freeImageBins (Ncatalog); 179 163 freeMosaicBins (Ncatalog); -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/setExclusions.c
r31261 r31273 1 1 # include "relphot.h" 2 3 // this function sets the NOCAL and AREA dbFlags bits for the MeasureTiny elements these 4 // are used elsewhere (StarOps.c, ImageOps.c, MosaicOps.c, GridOps.c, etc) to skip bad 5 // measurements. The only exception is 'setMave' which is called by 'relphot_objects', 6 // and uses the bits read from disk as the test 2 7 3 8 int setExclusions (Catalog *catalog, int Ncatalog) { … … 11 16 for (i = 0; i < Ncatalog; i++) { 12 17 for (j = 0; j < catalog[i].Naverage; j++) { 13 m = catalog[i].average [j].measureOffset;14 for (k = 0; k < catalog[i].average [j].Nmeasure; k++, m++) {18 m = catalog[i].averageT[j].measureOffset; 19 for (k = 0; k < catalog[i].averageT[j].Nmeasure; k++, m++) { 15 20 16 21 /* select measurements by photcode */ 17 ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure [m].photcode);22 ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[m].photcode); 18 23 found = FALSE; 19 24 for (Ns = 0; !found && (Ns < Nphotcodes); Ns++) { … … 24 29 /* select measurements by time */ 25 30 if (TimeSelect) { 26 if (catalog[i].measure [m].t < TSTART) goto mark_nocal;27 if (catalog[i].measure [m].t > TSTOP) goto mark_nocal;31 if (catalog[i].measureT[m].t < TSTART) goto mark_nocal; 32 if (catalog[i].measureT[m].t > TSTOP) goto mark_nocal; 28 33 } 29 34 30 35 /* select measurements by mag limit */ 31 36 if (AreaSelect) { 32 r = catalog[i].average [j].R + catalog[i].measure[m].dR / 3600.0;33 d = catalog[i].average [j].D + catalog[i].measure[m].dD / 3600.0;37 r = catalog[i].averageT[j].R + catalog[i].measureT[m].dR / 3600.0; 38 d = catalog[i].averageT[j].D + catalog[i].measureT[m].dD / 3600.0; 34 39 if ((coords = getCoords (m, i)) == NULL) goto markbad; 35 40 RD_to_XY (&x, &y, r, d, coords); … … 43 48 44 49 markbad: 45 catalog[i].measure [m].dbFlags |= ID_MEAS_AREA;50 catalog[i].measureT[m].dbFlags |= ID_MEAS_AREA; 46 51 Narea ++; 47 52 continue; 48 53 49 54 mark_nocal: 50 catalog[i].measure [m].dbFlags |= ID_MEAS_NOCAL;55 catalog[i].measureT[m].dbFlags |= ID_MEAS_NOCAL; 51 56 Nnocal ++; 52 57 continue; -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/setMrelFinal.c
r31272 r31273 1 1 # include "relphot.h" 2 3 // we've just reloaded the data from disk; we now need to apply the Image/Mosaic/Grid 4 // calibrations determined by the rest of the program. We also need to set the final 5 // output dbFlags values 2 6 3 7 void setMrelFinal (Catalog *catalog) { … … 46 50 } 47 51 52 // this sets flags in the measureT element, not the measure element 48 53 setExclusions (catalog, 1); /* mark by area */ 49 54 … … 64 69 int Nsecfilt = GetPhotcodeNsecfilt (); 65 70 66 /* clear ID_STAR_POOR, ID_STAR_FEW, ID_MEAS_NOCAL values before writing ??? */ 71 /* clear ID_STAR_POOR, ID_STAR_FEW values before writing ??? */ 72 /* ID_MEAS_NOCAL is an internal bit, so it should be cleared */ 67 73 for (i = 0; i < catalog[0].Naverage; i++) { 68 74 catalog[0].average[i].flags &= ~ID_STAR_FEW; … … 105 111 106 112 /* clear SKIP for all measures at first */ 107 catalog[0].measure [m].dbFlags &= ~ID_MEAS_SKIP_PHOTOM;113 catalog[0].measureT[m].dbFlags &= ~ID_MEAS_SKIP_PHOTOM; 108 114 109 115 /** never use these measurements (wrong photcode, bad time range) */ … … 153 159 154 160 skip: 155 catalog[0].measure[m].dbFlags |= ID_MEAS_SKIP_PHOTOM; 161 catalog[0].measure [m].dbFlags |= ID_MEAS_SKIP_PHOTOM; 162 catalog[0].measureT[m].dbFlags |= ID_MEAS_SKIP_PHOTOM; 156 163 Nskip ++; 157 164 }
Note:
See TracChangeset
for help on using the changeset viewer.
