- Timestamp:
- Jul 29, 2016, 8:07:10 AM (10 years ago)
- Location:
- trunk/Ohana/src/relphot
- Files:
-
- 7 edited
-
include/relphot.h (modified) (3 diffs)
-
src/ImageOps.c (modified) (10 diffs)
-
src/args.c (modified) (4 diffs)
-
src/bcatalog.c (modified) (1 diff)
-
src/liststats.c (modified) (5 diffs)
-
src/load_catalogs.c (modified) (1 diff)
-
src/relphot_images.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/relphot/include/relphot.h
r39636 r39641 276 276 int PARALLEL_MANUAL; 277 277 int PARALLEL_SERIAL; 278 char *MANUAL_UNIQUER; 278 279 279 280 int PARALLEL_REGIONS_MANUAL; … … 286 287 int MOSAIC_ZEROPT; 287 288 288 int TEST_IMAGE; 289 int TEST_IMAGE1; 290 int TEST_IMAGE2; 289 291 290 292 int NLOOP; … … 309 311 int FREEZE_IMAGES; 310 312 int FREEZE_MOSAICS; 313 int CALIBRATE_STACKS_AND_WARPS; 311 314 int USE_GRID; 312 315 int KEEP_UBERCAL; -
trunk/Ohana/src/relphot/src/ImageOps.c
r39632 r39641 1 1 # include "relphot.h" 2 # define BASIC_STATS 0 3 2 4 void plot_setMcal (double *list, int Npts, StatType *stats, float clouds); 3 5 … … 614 616 615 617 off_t i, j, m, c, n, N, Nmax; 616 int mark, bad, Nfew, Nbad, Nmos, Nrel, Ngrid, Nsys , Nbright;618 int mark, bad, Nfew, Nbad, Nmos, Nrel, Ngrid, Nsys; 617 619 float Msys, Mrel, Mmos, Mgrid, Mflat; 618 double *list, *dlist, *Mlist, *dMlist;620 // double *list, *dlist, *Mlist, *dMlist; 619 621 620 622 StatType stats; … … 637 639 Nmax = MAX (Nmax, N_onImage[i]); 638 640 } 639 ALLOCATE (list, double, Nmax); 640 ALLOCATE (dlist, double, Nmax); 641 ALLOCATE (Mlist, double, Nmax); 642 ALLOCATE (dMlist, double, Nmax); 641 StatDataSet *refStars = StatDataSetAlloc (1, Nmax); 642 StatDataSet *brightStars = StatDataSetAlloc (1, Nmax); 643 643 644 644 Nfew = Nbad = Nmos = Ngrid = Nrel = Nsys = 0; … … 647 647 for (i = 0; i < Nimage; i++) { 648 648 649 if (image[i].imageID == TEST_IMAGE1) { 650 fprintf (stderr, "test image 1\n"); 651 } 652 if (image[i].imageID == TEST_IMAGE2) { 653 fprintf (stderr, "test image 1\n"); 654 } 655 649 656 /* on PoorImages run, skip good images */ 650 657 if (PoorImages) { … … 664 671 665 672 int minUbercalDist = 1000; 666 667 // number of stars to measure the bright-end scatter 668 Nbright = 0; 669 670 N = 0; 673 674 off_t Nref = 0; // total number of reference stars on the image 675 int Nbright = 0; // number of stars to measure the bright-end scatter 676 671 677 for (j = 0; j < N_onImage[i]; j++) { 672 678 … … 716 722 717 723 skip: 718 list[N] = Msys - Mrel - Mmos - Mgrid + Mflat; 719 dlist[N] = MAX (catalog[c].measureT[m].dM, MIN_ERROR); 720 if (fabs(list[N]) > 0.03) { 724 refStars->flxlist[Nref] = Msys - Mrel - Mmos - Mgrid + Mflat; 725 refStars->errlist[Nref] = MAX (catalog[c].measureT[m].dM, MIN_ERROR); 726 refStars->wgtlist[Nref] = 1; 727 refStars->msklist[Nref] = 0; 728 if (fabs(refStars->flxlist[Nref]) > 0.03) { 721 729 // fprintf (stderr, "deviant\n"); 722 730 } 723 731 724 if ( image[i].imageID == TEST_IMAGE) {725 fprintf (stderr, "%1d, %3d : %3d, %3d : %10.6f %10.6f : %6.3f %6.3f %6.3f %6.3f %6.3f : %6.3f\n", (int) i, (int) j, (int) c, (int) m, catalog[c].averageT[n].R, catalog[c].averageT[n].D, Msys, Mrel, Mmos, Mgrid, Mflat, list[N]);732 if ((image[i].imageID == TEST_IMAGE1) || (image[i].imageID == TEST_IMAGE2)) { 733 fprintf (stderr, "%1d, %3d : %3d, %3d : %10.6f %10.6f : %6.3f %6.3f %6.3f %6.3f %6.3f : %6.3f\n", (int) i, (int) j, (int) c, (int) m, catalog[c].averageT[n].R, catalog[c].averageT[n].D, Msys, Mrel, Mmos, Mgrid, Mflat, refStars->flxlist[Nref]); 726 734 } 727 735 728 736 if (catalog[c].measureT[m].dM < IMFIT_SYS_SIGMA_LIM) { 729 Mlist[Nbright] = list[N]; 730 dMlist[Nbright] = dlist[N]; 737 brightStars->flxlist[Nbright] = refStars->flxlist[Nref]; 738 brightStars->errlist[Nbright] = refStars->errlist[Nref]; 739 brightStars->wgtlist[Nbright] = 1; 740 brightStars->msklist[Nbright] = 0; 731 741 Nbright ++; 732 742 } 733 N ++;743 Nref++; 734 744 } 735 745 /* N_onImage[i] is all measurements, N is good measurements */ … … 740 750 mark = FALSE; 741 751 if (!PoorImages) { 742 mark = (N < IMAGE_TOOFEW) || (N< IMAGE_GOOD_FRACTION*N_onImage[i]);752 mark = (Nref < IMAGE_TOOFEW) || (Nref < IMAGE_GOOD_FRACTION*N_onImage[i]); 743 753 if (mark) { 744 754 image[i].flags |= ID_IMAGE_PHOTOM_FEW; … … 750 760 751 761 // no additional weight modification (we treat all stars on an image equally -- note an image is either ubercal-tied or not) 752 liststats (list, dlist, NULL, N, &stats); 753 image[i].Mcal = stats.mean; 754 image[i].dMcal = stats.error; 755 image[i].nFitPhotom = N; 756 image[i].Xm = 100.0*log10(stats.chisq); 762 # if (BASIC_STATS) 763 liststats (refStars->flxlist, refStars->errlist, NULL, Nref, &stats); 764 # else 765 liststats_irls (refStars, Nref, &stats); 766 # endif 767 image[i].Mcal = stats.mean; 768 image[i].dMcal = stats.error; 769 image[i].nFitPhotom = Nref; 770 image[i].Xm = 100.0*log10(stats.chisq); 757 771 Ncalibrated ++; 758 772 759 if (image[i].imageID == TEST_IMAGE) { 773 if ((image[i].imageID == TEST_IMAGE1) || (image[i].imageID == TEST_IMAGE2)) { 774 for (j = 0; j < Nref; j++) { 775 fprintf (stderr, "%1d, %8d : %6.3f %6.3f %6.3f %d\n", (int) i, (int) image[i].imageID, refStars->flxlist[j], refStars->errlist[j], refStars->wgtlist[j], refStars->msklist[j]); 776 } 777 } 778 779 if ((image[i].imageID == TEST_IMAGE1) || (image[i].imageID == TEST_IMAGE2)) { 760 780 fprintf (stderr, "Mcal for : %s : %7.4f %7.4f\n", image[i].name, image[i].Mcal, image[i].dMcal); 761 781 } … … 767 787 if (PLOTSTUFF) { 768 788 fprintf (stderr, "Mcal for : %s : %7.4f %7.4f\n", image[i].name, image[i].Mcal, image[i].dMcal); 769 plot_setMcal ( list, N, &stats, CLOUD_TOLERANCE);789 plot_setMcal (refStars->flxlist, N, &stats, CLOUD_TOLERANCE); 770 790 } 771 791 772 792 // bright end scatter 773 liststats ( Mlist, dMlist, NULL, Nbright, &stats);793 liststats (brightStars->flxlist, brightStars->errlist, NULL, Nbright, &stats); 774 794 image[i].dMagSys = stats.sigma; 775 795 … … 782 802 image[i].ubercalDist = minUbercalDist + 1; 783 803 } 784 free (list); 785 free (dlist); 786 free (Mlist); 787 free (dMlist); 804 805 StatDataSetFree (brightStars, 1); 806 StatDataSetFree (refStars, 1); 788 807 789 808 fprintf (stderr, "%d images calibrated\n", Ncalibrated); -
trunk/Ohana/src/relphot/src/args.c
r39511 r39641 128 128 } 129 129 130 // elements needed for parallel regions / parallel images 131 MANUAL_UNIQUER = NULL; 132 if ((N = get_argument (argc, argv, "-manual-uniquer"))) { 133 remove_argument (N, &argc, argv); 134 MANUAL_UNIQUER = strcreate (argv[N]); 135 remove_argument (N, &argc, argv); 136 } 137 130 138 PLOTSTUFF = FALSE; 131 139 if ((N = get_argument (argc, argv, "-plot"))) { … … 176 184 } 177 185 178 TEST_IMAGE = -1; 179 if ((N = get_argument (argc, argv, "-test-image"))) { 180 remove_argument (N, &argc, argv); 181 TEST_IMAGE = atoi(argv[N]); 186 TEST_IMAGE1 = -1; 187 if ((N = get_argument (argc, argv, "-test-image1"))) { 188 char *endptr; 189 remove_argument (N, &argc, argv); 190 TEST_IMAGE1 = strtol(argv[N], &endptr, 0); 191 if (*endptr) relphot_usage (); 192 remove_argument (N, &argc, argv); 193 } 194 TEST_IMAGE2 = -1; 195 if ((N = get_argument (argc, argv, "-test-image2"))) { 196 char *endptr; 197 remove_argument (N, &argc, argv); 198 TEST_IMAGE2 = strtol(argv[N], &endptr, 0); 199 if (*endptr) relphot_usage (); 182 200 remove_argument (N, &argc, argv); 183 201 } … … 283 301 FREEZE_IMAGES = TRUE; 284 302 } 285 286 303 FREEZE_MOSAICS = FALSE; 287 304 if ((N = get_argument (argc, argv, "-mosfreeze"))) { 288 305 remove_argument (N, &argc, argv); 289 306 FREEZE_MOSAICS = TRUE; 307 } 308 CALIBRATE_STACKS_AND_WARPS = FALSE; 309 if ((N = get_argument (argc, argv, "-only-stacks-and-warps"))) { 310 remove_argument (N, &argc, argv); 311 CALIBRATE_STACKS_AND_WARPS = TRUE; 290 312 } 291 313 … … 620 642 } 621 643 622 TEST_IMAGE = -1; 644 TEST_IMAGE1 = -1; 645 TEST_IMAGE2 = -1; 623 646 624 647 RESET = FALSE; -
trunk/Ohana/src/relphot/src/bcatalog.c
r39478 r39641 106 106 107 107 // skip garbage measurements 108 if (catalog[0].measure[offset].psfQF < 0.85) { Npsfqf ++; continue; } 108 if (isnan(catalog[0].measure[offset].psfQF) || (catalog[0].measure[offset].psfQF < 0.85)) { Npsfqf ++; continue; } 109 if (isnan(catalog[0].measure[offset].psfQFperf) || (catalog[0].measure[offset].psfQFperf < 0.85)) { Npsfqf ++; continue; } 109 110 if (isnan(catalog[0].measure[offset].M)) { Nnan ++; continue; } 110 111 -
trunk/Ohana/src/relphot/src/liststats.c
r39636 r39641 210 210 211 211 // XXX add to dataset elements? 212 ALLOCATE_PTR (wt, double, Npoints); 212 ALLOCATE_PTR (wtvals, double, Npoints); 213 ALLOCATE_PTR (wtlist, double, Npoints); 213 214 214 215 int converged = FALSE; … … 217 218 for (int i = 0; i < Npoints; i++) { 218 219 // we are only including the formal error, not the weight in the definition of wt[] 219 wt [i] = weight_cauchy ((dataset->flxlist[i] - value) / dataset->errlist[i]);220 wtvals[i] = weight_cauchy ((dataset->flxlist[i] - value) / dataset->errlist[i]); 220 221 } 221 222 222 223 double oldValue = value; 223 if (!fit_least_squares (&value, dataset->flxlist, dataset->errlist, dataset->wgtlist, wt , Npoints)) {224 if (!fit_least_squares (&value, dataset->flxlist, dataset->errlist, dataset->wgtlist, wtvals, Npoints)) { 224 225 value = oldValue; 225 226 break; … … 235 236 236 237 // calculate the weight thresholds to mask the bad points: 237 double Sum_W = 0.0;238 // double Sum_W = 0.0; 238 239 for (int i = 0; i < Npoints; i++) { 239 wt[i] = weight_cauchy ((dataset->flxlist[i] - value) / dataset->errlist[i]); 240 Sum_W += wt[i]; 241 } 242 double WtThreshold = WEIGHT_THRESHOLD * Sum_W / (1.0 * Npoints); 240 wtvals[i] = weight_cauchy ((dataset->flxlist[i] - value) / dataset->errlist[i]); 241 wtlist[i] = wtvals[i]; 242 // Sum_W += wtvals[i]; 243 } 244 dsort (wtlist, Npoints); 245 int midpt = 0.5 * Npoints; 246 double WtMedian = (Npoints % 2) ? wtlist[midpt] : 0.5*(wtlist[midpt] + wtlist[midpt-1]); 247 // double WtThreshold = WEIGHT_THRESHOLD * Sum_W / (1.0 * Npoints); 248 double WtThreshold = WEIGHT_THRESHOLD * WtMedian; 243 249 244 250 // generate the unmasked subset … … 255 261 double dSig = 0.0; 256 262 for (int i = 0; i < Npoints; i++) { 257 if ((wt [i] < WtThreshold) || !isfinite(dataset->flxlist[i])) {263 if ((wtvals[i] < WtThreshold) || !isfinite(dataset->flxlist[i])) { 258 264 dataset->msklist[i] = TRUE; // mark the masked points 259 265 continue; … … 313 319 free (dykeep); 314 320 free (wtkeep); 315 free (wt); 321 free (wtvals); 322 free (wtlist); 316 323 317 324 return TRUE; -
trunk/Ohana/src/relphot/src/load_catalogs.c
r39478 r39641 115 115 int TIME = time(NULL); 116 116 int PID = getpid(); 117 snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000); 117 118 if (PARALLEL_MANUAL && MANUAL_UNIQUER) { 119 snprintf (uniquer, 12, "%11s", MANUAL_UNIQUER); 120 } else { 121 snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000); 122 } 118 123 119 124 int Nsecfilt = GetPhotcodeNsecfilt (); // set the desired number in case we need to create the catalog -
trunk/Ohana/src/relphot/src/relphot_images.c
r39481 r39641 53 53 FlatCorrectionTable *flatcorr = NULL; 54 54 55 if ( NLOOP > 0) {55 if (CALIBRATE_STACKS_AND_WARPS || (NLOOP > 0)) { 56 56 /* load catalog data from region files (hostID is 0 since we are not a client */ 57 57 catalog = load_catalogs (skylist, &Ncatalog, 0, NULL, NULL); … … 154 154 155 155 /* set Mcal & Mmos for bad images */ 156 setMcal (catalog, TRUE, flatcorr); 157 setMmos (catalog, TRUE, flatcorr); 156 int onlyPoorImages = !CALIBRATE_STACKS_AND_WARPS; 157 setMcal (catalog, onlyPoorImages, flatcorr); 158 setMmos (catalog, onlyPoorImages, flatcorr); 158 159 MARKTIME("-- finalize Mcal values: %f sec\n", dtime); 159 160 … … 248 249 context, this function writes the image parameters as a subset table for the remote 249 250 clients */ 250 reload_catalogs (skylist, flatcorr, 0, NULL); 251 MARKTIME("-- updated all catalogs: %f sec\n", dtime); 251 if (!CALIBRATE_STACKS_AND_WARPS) { 252 reload_catalogs (skylist, flatcorr, 0, NULL); 253 MARKTIME("-- updated all catalogs: %f sec\n", dtime); 254 } 252 255 253 256 if (UPDATE_CATFORMAT) { … … 255 258 db.format = dvo_catalog_catformat (UPDATE_CATFORMAT); 256 259 } 257 if ( NLOOP > 0) {260 if (CALIBRATE_STACKS_AND_WARPS || (NLOOP > 0)) { 258 261 // do not save changes if we did not make changes. 259 262 dvo_image_update (&db, VERBOSE);
Note:
See TracChangeset
for help on using the changeset viewer.
