Changeset 31258
- Timestamp:
- Apr 10, 2011, 10:20:54 AM (15 years ago)
- Location:
- branches/eam_branches/ipp-20110404/Ohana/src/relphot
- Files:
-
- 9 edited
-
include/relphot.h (modified) (2 diffs)
-
src/MosaicOps.c (modified) (6 diffs)
-
src/StarOps.c (modified) (2 diffs)
-
src/args.c (modified) (1 diff)
-
src/bcatalog.c (modified) (4 diffs)
-
src/initialize.c (modified) (1 diff)
-
src/load_images.c (modified) (1 diff)
-
src/relphot.c (modified) (1 diff)
-
src/select_images.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110404/Ohana/src/relphot/include/relphot.h
r30616 r31258 90 90 91 91 PhotCode *refPhotcode; 92 93 int MaxDensityUse; 94 double MaxDensityValue; 92 95 93 96 int AreaSelect; … … 223 226 void relphot_usage (void); 224 227 void relphot_help (int argc, char **argv); 228 229 int rationalize_mosaics (); 230 int LimitDensityCatalog (Catalog *subcatalog, Catalog *catalog); -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/MosaicOps.c
r30616 r31258 302 302 return; 303 303 } 304 fprintf (stderr, "missed measurement\n"); 304 // if we miss a measurement, it might be a REF type of value 305 // fprintf (stderr, "missed measurement\n"); 305 306 return; 306 307 } … … 403 404 mark = (N < IMAGE_TOOFEW) || (N < IMAGE_GOOD_FRACTION*Nlist[i]); 404 405 if (mark) { 405 if ( VERBOSE2) { fprintf (stderr, "marked mosaic %s ("OFF_T_FMT"), ("OFF_T_FMT" < %d) || ("OFF_T_FMT" < %f*"OFF_T_FMT")\n", image[imlist[i][0]].name, i, N, IMAGE_TOOFEW, N, IMAGE_GOOD_FRACTION, Nlist[i]); }406 if (1 || VERBOSE2) { fprintf (stderr, "marked mosaic %s ("OFF_T_FMT"), ("OFF_T_FMT" < %d) || ("OFF_T_FMT" < %f*"OFF_T_FMT")\n", image[imlist[i][0]].name, i, N, IMAGE_TOOFEW, N, IMAGE_GOOD_FRACTION, Nlist[i]); } 406 407 mosaic[i].flags |= ID_IMAGE_PHOTOM_FEW; 407 408 Nfew ++; … … 433 434 } 434 435 436 // When we rationalize the images/mosaics, we are driving the negative cloud images back 437 // to 0.0. At the same time, we make a guess to the effective impact on all other images, 438 // driven by the coupling of common stars. 439 int rationalize_mosaics (Catalog *catalog, int Ncatalog) { 440 441 double *imageOffset, *starOffset; 442 int *starNcount; 443 int **Slist, *NSlist, *NSLIST; 444 int i, j, k, m, nMos; 445 446 off_t Nimage; 447 Image *image; 448 449 // set a test value for now 450 float CLOUD_TOLERANCE = 0.025; 451 452 if (!MOSAIC_ZEROPT) return (FALSE); 453 if (FREEZE_MOSAICS) return (FALSE); 454 455 image = getimages (&Nimage); 456 457 ALLOCATE (imageOffset, double, Nmosaic); 458 459 ALLOCATE ( Slist, int *, Nmosaic); // array of calibrated star indexes on this mosaic 460 ALLOCATE (NSlist, int, Nmosaic); // number of stars on mosaic 461 ALLOCATE (NSLIST, int, Nmosaic); // number of Slist entries allocated 462 463 // find the images / mosaics with negative clouds and save their offset 464 for (i = 0; i < Nmosaic; i++) { 465 466 NSlist[i] = 0; 467 NSLIST[i] = 100; 468 ALLOCATE (Slist[i], int, NSLIST[i]); 469 470 imageOffset[i] = 0.0; 471 472 if (fabs(mosaic[i].Mcal) < CLOUD_TOLERANCE) { 473 fprintf (stderr, "cloud-free: %s : %f\n", image[imlist[i][0]].name, mosaic[i].Mcal); 474 } 475 if (mosaic[i].Mcal < -CLOUD_TOLERANCE) { 476 imageOffset[i] = -mosaic[i].Mcal; 477 // NOTE the negative sign: down below, we are going to add in the negative of Mcal 478 // to this image, and the propagated mean values for other images 479 fprintf (stderr, "anti-clouds: %s : %f\n", image[imlist[i][0]].name, mosaic[i].Mcal); 480 } 481 if (mosaic[i].Mcal > CLOUD_TOLERANCE) { 482 fprintf (stderr, "cloudy : %s : %f\n", image[imlist[i][0]].name, mosaic[i].Mcal); 483 } 484 } 485 486 // allocate an array for star offset 487 int Nstars = 0; 488 int NSTARS = 1000; 489 ALLOCATE (starOffset, double, NSTARS); 490 ALLOCATE (starNcount, int, NSTARS); 491 492 // find the mean offset for each star 493 for (i = 0; i < Ncatalog; i++) { 494 for (j = 0; j < catalog[i].Naverage; j++) { 495 starOffset[Nstars] = 0.0; 496 starNcount[Nstars] = 0; 497 498 // skip bad stars 499 if (catalog[i].average[j].flags & STAR_BAD) continue; 500 m = catalog[i].average[j].measureOffset; 501 502 // determine the mosaic for each measurement 503 for (k = 0; k < catalog[i].average[j].Nmeasure; k++, m++) { 504 505 // skip unused measurements 506 if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue; 507 508 // skip REF measurements (not tied to an image) 509 if (getImageEntry (m, i) < 0) continue; 510 511 // find the source of this measurement (skip unassigned measurements) 512 nMos = bin[i][m]; 513 if (nMos == -1) continue; 514 515 // accumulate the offsets from the negative cloud images (others have 0.0 value) 516 starOffset[Nstars] += imageOffset[nMos]; 517 starNcount[Nstars] ++; 518 519 // record the mosaic->star reference 520 Slist[nMos][NSlist[nMos]] = Nstars; 521 NSlist[nMos] ++; 522 if (NSlist[nMos] == NSLIST[nMos]) { 523 NSLIST[nMos] += 100; 524 REALLOCATE (Slist[nMos], int, NSLIST[nMos]); 525 } 526 } 527 Nstars ++; 528 if (Nstars == NSTARS) { 529 NSTARS += 1000; 530 REALLOCATE (starOffset, double, NSTARS); 531 REALLOCATE (starNcount, int, NSTARS); 532 } 533 } 534 } 535 536 // find the mean offset of the images without negative clouds 537 for (i = 0; i < Nmosaic; i++) { 538 539 // a negative cloud image (cloud: Mcal > 0; anti-clouds: Mcal < 0; imageOffset = -Mcal) 540 if (imageOffset[i] > 0.0) continue; 541 542 // we need to actually have cross-references to count 543 if (NSlist[i] < 2) continue; 544 545 float dM = 0.0; 546 for (j = 0; j < NSlist[i]; j++) { 547 Nstars = Slist[i][j]; 548 if (starNcount[Nstars] > 1) { 549 dM += (starOffset[Nstars] / starNcount[Nstars]); 550 } 551 } 552 imageOffset[i] = dM / NSlist[i]; 553 fprintf (stderr, "adjust image: %s : (%f %d) : %f\n", image[imlist[i][0]].name, dM, NSlist[i], imageOffset[i]); 554 } 555 556 for (i = 0; i < Nmosaic; i++) { 557 fprintf (stderr, "correction: %s : %f\n", image[imlist[i][0]].name, imageOffset[i]); 558 } 559 560 // apply all offset values to the mosaics 561 // find the images / mosaics with negative clouds and save their offset 562 for (i = 0; i < Nmosaic; i++) { 563 mosaic[i].Mcal += imageOffset[i]; 564 } 565 566 for (i = 0; i < Nmosaic; i++){ 567 free (Slist[i]); 568 } 569 free (NSlist); 570 free (NSLIST); 571 free (imageOffset); 572 573 return (TRUE); 574 } 575 435 576 StatType statsMosaicM (Catalog *catalog) { 436 577 … … 563 704 void clean_mosaics () { 564 705 565 off_t i, N, mark, Nmark ;706 off_t i, N, mark, Nmark, Nscatter, Noffset; 566 707 double *mlist, *slist, *dlist; 567 708 double MaxOffset, MedOffset, MaxScatter; … … 592 733 fprintf (stderr, "Mrel: %f, dMrel: %f, Max Scatter: %f, Max Offset: %f\n", MedOffset, stats.median, MaxScatter, MaxOffset); 593 734 594 Nmark = 0;735 Nmark = Nscatter = Noffset = 0; 595 736 for (i = 0; i < Nmosaic; i++) { 596 737 mark = FALSE; 597 mark = (mosaic[i].dMcal > MaxScatter) || (fabs(mosaic[i].Mcal - MedOffset) > MaxOffset); 738 if (mosaic[i].dMcal > MaxScatter) { 739 mark = TRUE; 740 Nscatter ++; 741 } 742 if (fabs(mosaic[i].Mcal - MedOffset) > MaxOffset) { 743 mark = TRUE; 744 Noffset ++; 745 } 598 746 if (mark) { 599 747 Nmark ++; … … 604 752 } 605 753 606 fprintf (stderr, OFF_T_FMT" mosaics marked poor \n", Nmark);754 fprintf (stderr, OFF_T_FMT" mosaics marked poor ("OFF_T_FMT" scatter, "OFF_T_FMT" offset)\n", Nmark, Nscatter, Noffset); 607 755 initstats (STATMODE); 608 756 free (mlist); -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/StarOps.c
r29001 r31258 5 5 static double *dlist; 6 6 7 // When we rationalize the images/mosaics, we are driving the negative cloud images back 8 // to 0.0. At the same time, we make a guess to the effective impact on all other images, 9 // driven by the coupling of common stars. This array carries the impact of those offsets 10 // on each star 11 static double *Moffset; 12 7 13 void initMrel (Catalog *catalog, int Ncatalog) { 8 14 … … 16 22 } 17 23 18 ALLOCATE (list, double, MAX (1, Nmax)); 19 ALLOCATE (dlist, double, MAX (1, Nmax)); 24 ALLOCATE (list, double, MAX (1, Nmax)); 25 ALLOCATE (dlist, double, MAX (1, Nmax)); 26 ALLOCATE (Moffset, double, MAX (1, Nmax)); 20 27 } 21 28 -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/args.c
r31160 r31258 128 128 } 129 129 130 MaxDensityUse = FALSE; 131 if ((N = get_argument (argc, argv, "-max-density"))) { 132 remove_argument (N, &argc, argv); 133 MaxDensityValue = atof(argv[N]); 134 remove_argument (N, &argc, argv); 135 MaxDensityUse = TRUE; 136 } 137 130 138 SHOW_PARAMS = FALSE; 131 139 if ((N = get_argument (argc, argv, "-params"))) { -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/bcatalog.c
r31160 r31258 1 1 # include "relphot.h" 2 3 extern double drand48(); 2 4 3 5 int bcatalog (Catalog *subcatalog, Catalog *catalog) { … … 70 72 // check for galaxies 71 73 if (!isnan(catalog[0].measure[offset].Map)) { 72 if (catalog[0].measure[offset].M - catalog[0].measure[offset].Map > 0.15) {73 nEXT ++;74 } else {75 nPSF ++;76 }74 if (catalog[0].measure[offset].M - catalog[0].measure[offset].Map > 0.15) { 75 nEXT ++; 76 } else { 77 nPSF ++; 78 } 77 79 } 78 80 … … 139 141 assert (PhotNsec == catalog[0].Nsecfilt); 140 142 143 // limit the total number of stars in the catalog 144 if (MaxDensityUse) { 145 LimitDensityCatalog (subcatalog, catalog); 146 } 147 141 148 if (VERBOSE) { 142 149 fprintf (stderr, "using "OFF_T_FMT" stars ("OFF_T_FMT" measures) of "OFF_T_FMT" for catalog %s\n", … … 147 154 return (TRUE); 148 155 } 156 157 int LimitDensityCatalog (Catalog *subcatalog, Catalog *catalog) { 158 159 Catalog tmpcatalog; 160 161 double Rmin, Rmax, Dmin, Dmax; 162 163 gfits_scan (&catalog[0].header, "RA0", "%lf", 1, &Rmin); 164 gfits_scan (&catalog[0].header, "DEC0", "%lf", 1, &Dmin); 165 gfits_scan (&catalog[0].header, "RA1", "%lf", 1, &Rmax); 166 gfits_scan (&catalog[0].header, "DEC1", "%lf", 1, &Dmax); 167 168 if (VERBOSE2) fprintf (stderr, "extracting from catalog covering region %f,%f to %f,%f\n", Rmin, Dmin, Rmax, Dmax); 169 170 float AREA = fabs(Dmax - Dmin) * fabs(Rmax - Rmin) * cos (0.5*RAD_DEG*(Dmax + Dmin)); 171 assert (AREA > 0); 172 173 off_t Nmax = MaxDensityValue * AREA; 174 if (subcatalog[0].Naverage <= Nmax) { 175 if (VERBOSE) { 176 fprintf (stderr, "subcatalog has less than the max density\n"); 177 } 178 return (TRUE); 179 } 180 181 off_t Naverage = subcatalog[0].Naverage; 182 183 // select a random subset of Nmax stars from subcatalog using Fisher-Yates 184 185 // we are going to select Nmax entries by generating a random-sorted index list 186 off_t *index, tmp, i, j, ave; 187 ALLOCATE (index, off_t, Naverage); 188 for (i = 0; i < Naverage; i++) { 189 index[i] = i; 190 } 191 for (i = 0; i < Naverage; i++) { 192 j = (Naverage - i) * drand48() + i; // a number between i and Naverage 193 tmp = index[j]; 194 index[j] = index[i]; 195 index[i] = tmp; 196 } 197 198 // count the number of measurements this selection will yield 199 off_t NMEASURE = 0; 200 for (i = 0; i < Nmax; i++) { 201 ave = index[i]; 202 NMEASURE += subcatalog[0].average[ave].Nmeasure; 203 } 204 205 // allocate the output data 206 ALLOCATE (tmpcatalog.average, Average, Nmax); 207 ALLOCATE (tmpcatalog.secfilt, SecFilt, Nmax * PhotNsec); 208 ALLOCATE (tmpcatalog.measure, Measure, NMEASURE); 209 210 off_t Nmeasure = 0; 211 212 // copy the Nmax selected entries from subcatalog to tmpcatalog (adjusting links) 213 for (i = 0; i < Nmax; i++) { 214 ave = index[i]; 215 tmpcatalog.average[i] = subcatalog[0].average[ave]; 216 tmpcatalog.average[i].measureOffset = Nmeasure; 217 for (j = 0; j < tmpcatalog.average[i].Nmeasure; j++) { 218 off_t offset = subcatalog[0].average[ave].measureOffset + j; 219 tmpcatalog.measure[Nmeasure] = subcatalog[0].measure[offset]; 220 tmpcatalog.measure[Nmeasure].averef = i; 221 Nmeasure ++; 222 } 223 } 224 225 if (VERBOSE) { 226 fprintf (stderr, "limited to "OFF_T_FMT" of "OFF_T_FMT" stars ("OFF_T_FMT" of "OFF_T_FMT" measures) for catalog %s\n", 227 Nmax, subcatalog[0].Naverage, Nmeasure, subcatalog[0].Nmeasure, catalog[0].filename); 228 } 229 230 free (subcatalog[0].average); 231 free (subcatalog[0].measure); 232 free (subcatalog[0].secfilt); 233 234 subcatalog[0].average = tmpcatalog.average; 235 subcatalog[0].measure = tmpcatalog.measure; 236 subcatalog[0].secfilt = tmpcatalog.secfilt; 237 subcatalog[0].Naverage = Nmax; 238 subcatalog[0].Nmeasure = Nmeasure; 239 subcatalog[0].Nsecfilt = catalog[0].Nsecfilt; 240 subcatalog[0].Nsecf_mem = Naverage * catalog[0].Nsecfilt; 241 242 return (TRUE); 243 } -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/initialize.c
r30616 r31258 55 55 exit (0); 56 56 } 57 58 // init the random seed 59 long A, B; 60 A = time(NULL); 61 for (B = 0; A == time(NULL); B++); 62 srand48(B); 57 63 } 58 -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/load_images.c
r31160 r31258 44 44 // select the images which overlap the selected sky regions 45 45 subset = select_images (skylist, image, Nimage, &LineNumber, &Nsubset); 46 MARKTIME("selected images: %f sec\n", dtime);46 MARKTIME("selected %d overlapping images: %f sec\n", (int) Nsubset, dtime); 47 47 48 48 // generate db->vtable from db->ftable based on the selection -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/relphot.c
r30616 r31258 140 140 plot_chisq (catalog, Ncatalog); 141 141 } 142 if ((i == 1) || (i == 5) || (i == 9) || (i == 13)) clean_measures (catalog, Ncatalog, FALSE); 143 if ((i == 2) || (i == 6) || (i == 10) || (i == 14)) clean_stars (catalog, Ncatalog); 144 if ((i == 4) || (i == 8) || (i == 12) || (i == 16)) clean_mosaics (); 145 if ((i == 4) || (i == 8) || (i == 12) || (i == 16)) clean_images (); 142 if (i % 6 == 1) rationalize_mosaics (catalog, Ncatalog); 143 // if (i % 6 == 1) rationalize_images (); 144 if (i % 6 == 2) clean_measures (catalog, Ncatalog, FALSE); 145 if (i % 6 == 3) clean_stars (catalog, Ncatalog); 146 if (i % 6 == 5) clean_mosaics (); 147 if (i % 6 == 5) clean_images (); 148 149 // if ((i == 1) || (i == 5) || (i == 9) || (i == 13)) clean_measures (catalog, Ncatalog, FALSE); 150 // if ((i == 2) || (i == 6) || (i == 10) || (i == 14)) clean_stars (catalog, Ncatalog); 151 // if ((i == 4) || (i == 8) || (i == 12) || (i == 16)) clean_mosaics (); 152 // if ((i == 4) || (i == 8) || (i == 12) || (i == 16)) clean_images (); 146 153 global_stats (catalog, Ncatalog); 147 154 } 148 155 149 SAVEPLOT = TRUE; 150 plot_scatter (catalog, Ncatalog); 151 plot_grid (catalog); 152 plot_mosaics (); 153 plot_images (); 154 plot_stars (catalog, Ncatalog); 155 plot_chisq (catalog, Ncatalog); 156 156 if (PLOTSTUFF) { 157 plot_scatter (catalog, Ncatalog); 158 plot_grid (catalog); 159 plot_mosaics (); 160 plot_images (); 161 plot_stars (catalog, Ncatalog); 162 plot_chisq (catalog, Ncatalog); 163 } 164 157 165 if (USE_GRID) dump_grid (); 158 166 if (!UPDATE) exit (0); -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/select_images.c
r31160 r31258 64 64 DmaxSkyRegion = -90.0; 65 65 66 // FILE *ftest = fopen ("relphot.dump.dat", "w"); 67 66 68 /* compare with each region file */ 67 69 for (i = 0; i < skylist[0].Nregions; i++) { … … 131 133 } 132 134 135 // XXX temporary test : record center coords for each accepted and rejected chip/mosaic 136 // double RAo, DECo; 137 133 138 /* define image corners - note the DIS images (mosaic phu) are special */ 134 139 if (!strcmp(&timage[i].coords.ctype[4], "-DIS")) { … … 138 143 Xi[3] = -0.5*timage[i].NX; Yi[3] = +0.5*timage[i].NY; 139 144 Xi[4] = -0.5*timage[i].NX; Yi[4] = -0.5*timage[i].NY; 145 // XY_to_RD(&RAo, &DECo, 0.0, 0.0, &timage[i].coords); 140 146 } else { 141 147 Xi[0] = 0; Yi[0] = 0; … … 144 150 Xi[3] = 0; Yi[3] = timage[i].NY; 145 151 Xi[4] = 0; Yi[4] = 0; 152 // XY_to_RD(&RAo, &DECo, 0.5*timage[i].NX, 0.5*timage[i].NY, &timage[i].coords); 146 153 } 147 154 found = FALSE; 148 155 149 156 /* transform corners to ra,dec -- costs ~3sec for 3M images (pikake) */ 150 double RminImage = 360.0;151 double RmaxImage = 0.0;157 double RminImage = RmidSkyRegion + 180.0; 158 double RmaxImage = RmidSkyRegion - 180.0; 152 159 double DminImage = +90.0; 153 160 double DmaxImage = -90.0; … … 218 225 219 226 found_it: 227 // XXX We claim this is a good image: write to a test file 228 // fprintf (ftest, "%s : %lf %lf : %f %f %d %x\n", timage[i].name, RAo, DECo, timage[i].Mcal, timage[i].dMcal, timage[i].nstar, timage[i].flags); 229 220 230 image[nimage] = timage[i]; 221 231 /* always allow 'few' images to succeed, if possible */ … … 239 249 } 240 250 MARKTIME("finish image selection: %f sec\n", dtime); 251 252 // fclose (ftest); 241 253 242 254 if (VERBOSE) fprintf (stderr, "found "OFF_T_FMT" images\n", nimage);
Note:
See TracChangeset
for help on using the changeset viewer.
