Changeset 41637
- Timestamp:
- Jun 4, 2021, 10:46:36 AM (5 years ago)
- Location:
- branches/eam_branches/relphot.20210521
- Files:
-
- 8 edited
-
include/relphot.h (modified) (1 diff)
-
src/ConfigInit.c (modified) (2 diffs)
-
src/GridOps.c (modified) (6 diffs)
-
src/MosaicOps.c (modified) (4 diffs)
-
src/StarOps.c (modified) (4 diffs)
-
src/TGroupOps.c (modified) (4 diffs)
-
src/initialize.c (modified) (1 diff)
-
src/relphot_images.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/relphot.20210521/include/relphot.h
r41625 r41637 411 411 double IMAGE_OFFSET; 412 412 double NIGHT_SCATTER; 413 double NIGHT_OFFSET; 413 double NIGHT_CHISQ; 414 double MOSAIC_SCATTER; 415 double MOSAIC_CHISQ; 414 416 double STAR_SCATTER; 415 417 double STAR_CHISQ; -
branches/eam_branches/relphot.20210521/src/ConfigInit.c
r41603 r41637 26 26 GetConfig (config, "SIGMA_LIM", "%lf", 0, &SIGMA_LIM); 27 27 28 DefConfig ("STAR_SCATTER", "%lf", 0.1, STAR_SCATTER); 29 DefConfig ("STAR_CHISQ", "%lf", 10.0, STAR_CHISQ); 28 30 29 GetConfig (config, "STAR_SCATTER", "%lf", 0, &STAR_SCATTER); 31 DefConfig ("NIGHT_SCATTER", "%lf", 0.1, NIGHT_SCATTER); 32 DefConfig ("NIGHT_CHISQ", "%lf", 10.0, NIGHT_CHISQ); 33 34 DefConfig ("MOSAIC_SCATTER", "%lf", 0.1, MOSAIC_SCATTER); 35 DefConfig ("MOSAIC_CHISQ", "%lf", 10.0, MOSAIC_CHISQ); 30 36 31 37 GetConfig (config, "IMAGE_SCATTER", "%lf", 0, &IMAGE_SCATTER); 32 38 GetConfig (config, "IMAGE_OFFSET", "%lf", 0, &IMAGE_OFFSET); 33 39 34 GetConfig (config, "STAR_CHISQ", "%lf", 0, &STAR_CHISQ);35 40 GetConfig (config, "GRID_TOOFEW", "%d", 0, &GRID_TOOFEW); 36 41 GetConfig (config, "STAR_TOOFEW", "%d", 0, &STAR_TOOFEW); … … 54 59 55 60 DefConfig ("RELPHOT_IMFIT_SYS_SIGMA_LIM", "%lf", 0.01, IMFIT_SYS_SIGMA_LIM); 56 DefConfig ("NIGHT_SCATTER", "%lf", 0.05, NIGHT_SCATTER);57 DefConfig ("NIGHT_OFFSET", "%lf", 0.50, NIGHT_OFFSET);58 61 DefConfig ("SKY_DEPTH", "%d", 2, SKY_DEPTH); 59 62 -
branches/eam_branches/relphot.20210521/src/GridOps.c
r41632 r41637 60 60 GridCorr[i] = NULL; 61 61 } 62 63 fprintf (stderr, "Generating grid corrections for %d photcodes\n", NGridCorr); 62 64 return; 63 65 } … … 102 104 result = GridCorr[i]; 103 105 *Nlast = i; 106 break; 104 107 } 105 108 return result; … … 127 130 Image *images = getimages (&Nimages, NULL); 128 131 132 int NGridReal = 0; 133 129 134 for (int i = 0; i < Nimages; i++) { 130 int code = images[ 0].photcode;135 int code = images[i].photcode; 131 136 myAssert (code >= 0, "oops"); 132 137 myAssert (code < NGridCorr, "oops"); … … 137 142 138 143 if (GridCorr[code]) continue; // already created this one 144 145 NGridReal ++; 139 146 140 147 ALLOCATE(GridCorr[code], GridCorrectionType, 1); … … 157 164 } 158 165 resetMgrid(); // start with values of 0 166 fprintf (stderr, "Init grid corrections for %d photcodes\n", NGridReal); 159 167 } 160 168 … … 274 282 GridCorr[code]-> Mgrid[ix][iy] = Mgrid; 275 283 GridCorr[code]->dMgrid[ix][iy] = sqrt(r*(Mgrid2 - Mgrid*Mgrid)); // sample stdev 276 fprintf (stderr, "grid code %d, %d x %d : %f +/- %f : %d\n", code, ix, iy, 277 GridCorr[code]-> Mgrid[ix][iy], GridCorr[code]->dMgrid[ix][iy], GridCorr[code]->nMgrid[ix][iy]); 284 // fprintf (stderr, "grid code %d, %d x %d : %f +/- %f : %d\n", code, ix, iy, GridCorr[code]-> Mgrid[ix][iy], GridCorr[code]->dMgrid[ix][iy], GridCorr[code]->nMgrid[ix][iy]); 278 285 } 279 286 } -
branches/eam_branches/relphot.20210521/src/MosaicOps.c
r41625 r41637 1483 1483 /* mark mosaic if: abs(Mcal - <Mcal>) too large, dMcal too large */ 1484 1484 1485 static float MinMaxChiSq = NAN; 1486 static float MinMaxScatter = NAN; 1485 static float MinChiSqLim = NAN; 1486 static float MaxChiSqLim = NAN; 1487 static float MinScatterLim = NAN; 1488 static float MaxScatterLim = NAN; 1487 1489 1488 1490 void clean_mosaics () { … … 1494 1496 1495 1497 if (VERBOSE) fprintf (stderr, "marking poor mosaics\n"); 1498 1499 if (isnan (MaxChiSqLim)) MaxChiSqLim = MOSAIC_CHISQ; 1500 if (isnan (MaxScatterLim)) MaxScatterLim = MOSAIC_SCATTER; 1496 1501 1497 1502 ALLOCATE (mlist, double, Nmosaic); … … 1516 1521 liststats (mlist, NULL, NULL, N, &stats); 1517 1522 float ChiSqUpper90 = stats.Upper90; 1518 if (isnan (Min MaxChiSq)) MinMaxChiSq = 2.0*stats.median;1519 float MaxChiSq = MAX (MinMaxChiSq, ChiSqUpper90);1523 if (isnan (MinChiSqLim)) MinChiSqLim = 2.0*stats.median; // chi-square cut cannot fall below this value (even if this is > MaxChiSqLim) 1524 float ChiSqLimit = MAX(MinChiSqLim, MIN(MaxChiSqLim, ChiSqUpper90)); // chi-square cut should be between MinChiSqLim and MaxChiSqLim 1520 1525 1521 1526 liststats (slist, NULL, NULL, N, &stats); 1522 1527 float ScatterUpper90 = stats.Upper90; 1523 if (isnan (Min MaxScatter)) MinMaxScatter = 2.0*stats.median;1524 float MaxScatter = MAX (MinMaxScatter, ScatterUpper90);1525 1526 fprintf (stderr, "MOSAIC: Max ChiSq: %f, Max Scatter: %f | ChiSquare Upper 90: %f, Scatter Upper 90: %f\n", MaxChiSq, MaxScatter, ChiSqUpper90, ScatterUpper90);1528 if (isnan (MinScatterLim)) MinScatterLim = 2.0*stats.median; // scatter cut cannto fall below this value (even if this is > MaxScatterLim) 1529 float ScatterLimit = MAX(MinScatterLim, MIN(MaxScatterLim, ScatterUpper90)); 1530 1531 fprintf (stderr, "MOSAIC: ChiSqLimit: %f, ScatterLimit: %f | ChiSquare Upper 90: %f, Scatter Upper 90: %f\n", ChiSqLimit, ScatterLimit, ChiSqUpper90, ScatterUpper90); 1527 1532 1528 1533 int Ntotal = 0, Npoor = 0, Nmark = 0, Nscatter = 0, Nfew = 0, Nchisq = 0; … … 1547 1552 Nfew ++; 1548 1553 } 1549 if (mosaic[i].stdev > MaxScatter) {1554 if (mosaic[i].stdev > ScatterLimit) { 1550 1555 mark = TRUE; 1551 1556 Nscatter ++; 1552 1557 } 1553 if (mosaic[i].McalChiSq > MaxChiSq) {1558 if (mosaic[i].McalChiSq > ChiSqLimit) { 1554 1559 mark = TRUE; 1555 1560 Nchisq ++; -
branches/eam_branches/relphot.20210521/src/StarOps.c
r41625 r41637 576 576 } 577 577 578 static float MinChiSqLim = NAN; 579 static float MaxChiSqLim = NAN; 580 static float MinScatterLim = NAN; 581 static float MaxScatterLim = NAN; 582 578 583 void clean_stars (Catalog *catalog, int Ncatalog) { 579 584 580 int i, j, Ndel, Nave, Ntot, mark, Ns, Nscat, Nchi, Nnan; 581 float dM; 582 double MaxScatter, MaxChisq; 583 double *xlist, *slist, *dlist; 585 int Ndel, Nave, Ntot, Nscat, Nchi, Nnan; 586 double *xlist, *slist; 587 588 if (isnan (MaxChiSqLim)) MaxChiSqLim = STAR_CHISQ; 589 if (isnan (MaxScatterLim)) MaxScatterLim = STAR_SCATTER; 584 590 585 591 StatType stats; … … 589 595 590 596 /* find Mchisq median -> ChiSq lim must be > median */ 591 for (i = Ntot = 0; i < Ncatalog; i++) {597 for (int i = Ntot = 0; i < Ncatalog; i++) { 592 598 Ntot += catalog[i].Naverage; 593 599 } 594 600 ALLOCATE (xlist, double, Ntot); 595 601 ALLOCATE (slist, double, Ntot); 596 ALLOCATE (dlist, double, Ntot);597 602 598 603 int Nsecfilt = GetPhotcodeNsecfilt (); 599 604 600 605 // eliminate bad stars using the stats for a single secfilt at a time 601 for ( Ns = 0; Ns < Nphotcodes; Ns ++) {606 for (int Ns = 0; Ns < Nphotcodes; Ns ++) { 602 607 603 608 int thisCode = photcodes[Ns][0].code; 604 609 int Nsec = GetPhotcodeNsec(thisCode); 605 610 606 for (i = Ntot = 0; i < Ncatalog; i++) {607 for ( j = 0; j < catalog[i].Naverage; j++) {611 for (int i = Ntot = 0; i < Ncatalog; i++) { 612 for (int j = 0; j < catalog[i].Naverage; j++) { 608 613 if (catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD) continue; 609 614 float Mchisq = catalog[i].secfilt[Nsecfilt*j+Nsec].Mchisq; … … 611 616 xlist[Ntot] = Mchisq; 612 617 slist[Ntot] = catalog[i].secfilt[Nsecfilt*j+Nsec].dMpsfChp; 613 dlist[Ntot] = 1;614 618 Ntot ++; 615 619 } 616 620 } 617 621 618 // XXX the limits for MaxChisq and MaxScatter should be 619 // user-defined. This uses 620 liststats (xlist, dlist, NULL, Ntot, &stats); 621 float ChiSqUpper90 = stats.Upper90; 622 MaxChisq = MAX (STAR_CHISQ, ChiSqUpper90); 623 624 liststats (slist, dlist, NULL, Ntot, &stats); 622 liststats (xlist, NULL, NULL, Ntot, &stats); 623 float ChiSqUpper90 = stats.Upper90; 624 if (isnan (MinChiSqLim)) MinChiSqLim = 2.0*stats.median; // chi-square cut cannot fall below this value (even if this is > MaxChiSqLim) 625 float ChiSqLimit = MAX(MinChiSqLim, MIN(MaxChiSqLim, ChiSqUpper90)); // chi-square cut should be between MinChiSqLim and MaxChiSqLim 626 627 liststats (slist, NULL, NULL, Ntot, &stats); 625 628 float ScatterUpper90 = stats.Upper90; 626 MaxScatter = MAX (STAR_SCATTER, ScatterUpper90); 627 fprintf (stderr, "Max Scatter: %f, Max Chisq: %f\n", MaxScatter, MaxChisq); 629 if (isnan (MinScatterLim)) MinScatterLim = 2.0*stats.median; // scatter cut cannto fall below this value (even if this is > MaxScatterLim) 630 float ScatterLimit = MAX(MinScatterLim, MIN(MaxScatterLim, ScatterUpper90)); 631 632 fprintf (stderr, "STARS: ChiSqLimit: %f, ScatterLimit: %f | ChiSquare Upper 90: %f, Scatter Upper 90: %f\n", ChiSqLimit, ScatterLimit, ChiSqUpper90, ScatterUpper90); 628 633 629 634 Ndel = Nave = Nscat = Nnan = Nchi = 0; 630 for (i = 0; i < Ncatalog; i++) {631 for ( j = 0; j < catalog[i].Naverage; j++) {632 dM = catalog[i].secfilt[Nsecfilt*j+Nsec].dMpsfChp;635 for (int i = 0; i < Ncatalog; i++) { 636 for (int j = 0; j < catalog[i].Naverage; j++) { 637 float dM = catalog[i].secfilt[Nsecfilt*j+Nsec].dMpsfChp; 633 638 float Mchisq = catalog[i].secfilt[Nsecfilt*j+Nsec].Mchisq; 634 mark = (dM > MaxScatter) || (isnan(Mchisq)) || (Mchisq > MaxChisq);639 int mark = (dM > ScatterLimit) || (isnan(Mchisq)) || (Mchisq > ChiSqLimit); 635 640 if (mark) { 636 641 catalog[i].secfilt[Nsecfilt*j+Nsec].flags |= ID_SECF_STAR_POOR; 637 642 Ndel ++; 638 if (dM > MaxScatter) { Nscat ++; }639 if (isnan(Mchisq)) { Nnan ++; }640 if (Mchisq > MaxChisq) { Nchi ++; }643 if (dM > ScatterLimit) { Nscat ++; } 644 if (isnan(Mchisq)) { Nnan ++; } 645 if (Mchisq > ChiSqLimit) { Nchi ++; } 641 646 } else { 642 647 catalog[i].secfilt[Nsecfilt*j+Nsec].flags &= ~ID_SECF_STAR_POOR; … … 645 650 } 646 651 } 647 fprintf (stderr, "%d stars marked variable (%d scat, %d nan, %d chi), %d total\n", Ndel, Nscat, Nnan, Nchi, Nave);652 fprintf (stderr, "%d of %d stars marked variable (%d scat, %d nan, %d chi)\n", Ndel, Nave, Nscat, Nnan, Nchi); 648 653 } 649 654 free (xlist); 650 655 free (slist); 651 free (dlist);652 656 } 653 657 -
branches/eam_branches/relphot.20210521/src/TGroupOps.c
r41625 r41637 1265 1265 */ 1266 1266 1267 static float Min MaxChiSq= NAN;1268 static float Max MaxChiSq = 6.0;1269 static float Min MaxScatter= NAN;1270 static float Max MaxScatter = 0.1;1267 static float MinChiSqLim = NAN; 1268 static float MaxChiSqLim = NAN; 1269 static float MinScatterLim = NAN; 1270 static float MaxScatterLim = NAN; 1271 1271 1272 1272 void clean_tgroups () { … … 1277 1277 1278 1278 if (VERBOSE) fprintf (stderr, "marking poor tgroups\n"); 1279 1280 if (isnan (MaxChiSqLim)) MaxChiSqLim = NIGHT_CHISQ; 1281 if (isnan (MaxScatterLim)) MaxScatterLim = NIGHT_SCATTER; 1279 1282 1280 1283 ALLOCATE (mlist, double, NtgroupTimes*Nphotcodes); … … 1300 1303 liststats (mlist, NULL, NULL, N, &stats); 1301 1304 float ChiSqUpper90 = stats.Upper90; 1302 if (isnan (Min MaxChiSq)) MinMaxChiSq = 2.0*stats.median;1303 float MaxChiSq = MIN(MaxMaxChiSq, MAX (MinMaxChiSq, ChiSqUpper90)); // the upper limit should be between MinMaxChiSq and MaxMaxChiSq1305 if (isnan (MinChiSqLim)) MinChiSqLim = 2.0*stats.median; // chi-square cut cannot fall below this value (even if this is > MaxChiSqLim) 1306 float ChiSqLimit = MAX(MinChiSqLim, MIN(MaxChiSqLim, ChiSqUpper90)); // chi-square cut should be between MinChiSqLim and MaxChiSqLim 1304 1307 1305 1308 liststats (slist, NULL, NULL, N, &stats); 1306 1309 float ScatterUpper90 = stats.Upper90; 1307 if (isnan (Min MaxScatter)) MinMaxScatter = 2.0*stats.median;1308 float MaxScatter = MIN(MaxMaxScatter, MAX (MinMaxScatter, ScatterUpper90));1309 1310 fprintf (stderr, "TGROUPS: Max ChiSq: %f, Max Scatter: %f | ChiSquare Upper 90: %f, Scatter Upper 90: %f\n", MaxChiSq, MaxScatter, ChiSqUpper90, ScatterUpper90);1310 if (isnan (MinScatterLim)) MinScatterLim = 2.0*stats.median; // scatter cut cannto fall below this value (even if this is > MaxScatterLim) 1311 float ScatterLimit = MAX(MinScatterLim, MIN(MaxScatterLim, ScatterUpper90)); 1312 1313 fprintf (stderr, "TGROUPS: ChiSqLimit: %f, ScatterLimit: %f | ChiSquare Upper 90: %f, Scatter Upper 90: %f\n", ChiSqLimit, ScatterLimit, ChiSqUpper90, ScatterUpper90); 1311 1314 1312 1315 int Ntotal = 0, Npoor = 0, Nmark = 0, Nscatter = 0, Nchisq = 0, NfewNights = 0, NfewExp = 0; … … 1337 1340 } 1338 1341 // scatter too large 1339 if (tgroup[j].stdev > MaxScatter) {1342 if (tgroup[j].stdev > ScatterLimit) { 1340 1343 mark = TRUE; 1341 1344 Nscatter ++; 1342 1345 } 1343 1346 // chisq too large 1344 if (tgroup[j].McalChiSq > MaxChiSq) {1347 if (tgroup[j].McalChiSq > ChiSqLimit) { 1345 1348 mark = TRUE; 1346 1349 Nchisq ++; -
branches/eam_branches/relphot.20210521/src/initialize.c
r41625 r41637 60 60 61 61 fprintf (stderr, "STAR_SCATTER %lf\n", STAR_SCATTER); 62 fprintf (stderr, "STAR_CHISQ %lf\n", STAR_CHISQ); 63 64 fprintf (stderr, "MOSAIC_SCATTER %lf\n", MOSAIC_SCATTER); 65 fprintf (stderr, "MOSAIC_CHISQ %lf\n", MOSAIC_CHISQ); 66 67 fprintf (stderr, "NIGHT_SCATTER %lf\n", NIGHT_SCATTER); 68 fprintf (stderr, "NIGHT_CHISQ %lf\n", NIGHT_CHISQ); 69 62 70 fprintf (stderr, "IMAGE_SCATTER %lf\n", IMAGE_SCATTER); 63 71 fprintf (stderr, "IMAGE_OFFSET %lf\n", IMAGE_OFFSET); -
branches/eam_branches/relphot.20210521/src/relphot_images.c
r41631 r41637 55 55 56 56 if (CALIBRATE_STACKS_AND_WARPS || (NLOOP > 0)) { 57 initGrid (); // allocate grid correction entries for existing photcodes 58 57 59 /* load catalog data from region files (hostID is 0 since we are not a client */ 58 60 catalog = load_catalogs (skylist, &Ncatalog, 0, NULL, NULL); … … 78 80 findTGroups (catalog, Ncatalog); 79 81 MARKTIME("-- set up mosaic indexes: %f sec\n", dtime); 80 81 initGrid (); // allocate grid correction entries for existing photcodes82 82 83 83 SAVEPLOT = FALSE;
Note:
See TracChangeset
for help on using the changeset viewer.
