Changeset 42705
- Timestamp:
- Jun 27, 2024, 10:28:50 AM (2 years ago)
- Location:
- branches/eam_branches/ipp-20230313/Ohana/src/relphot/src
- Files:
-
- 3 edited
-
ImageOps.c (modified) (3 diffs)
-
bcatalog.c (modified) (13 diffs)
-
fit1d_irls.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20230313/Ohana/src/relphot/src/ImageOps.c
r41664 r42705 531 531 532 532 // until the analysis has converged a bit, do not use the IRLS analysis 533 // default is MaxIterations = 10 534 if (UseStandardOLS(ZPT_IMAGES)) { 533 // default is MaxIterations = 10. 534 535 // However, for stack and warp calibration, we are not iteratively solving for the 536 // zero points. In this case, use IRLS in a single pass 537 if (!CALIBRATE_STACKS_AND_WARPS && UseStandardOLS(ZPT_IMAGES)) { 535 538 brightStars.MaxIterations = 0; 536 539 kronStars.MaxIterations = 0; … … 672 675 673 676 if ((image[i].imageID == TEST_IMAGE1) || (image[i].imageID == TEST_IMAGE2)) { 674 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, MsysKron, MrelKron, Mmos, Mgrid, Mflat, kronStars.alldata->yVector[Nkron]);677 fprintf (stderr, "%1d, %3d : %3d, %3d : %10.6f %10.6f : %6.3f %6.3f | %6.3f %6.3f | %6.3f %6.3f %6.3f %6.3f | %5.3f\n", (int) i, (int) j, (int) c, (int) m, catalog[c].averageT[n].R, catalog[c].averageT[n].D, MsysPSF, MrelPSF, MsysKron, MrelKron, Mmos, Mgrid, Mflat, Moff, psfStars.alldata->dyVector[Nref]); 675 678 } 676 679 … … 702 705 if (mark) continue; 703 706 704 // use liststats to find the 20-pct, median, 80-pct points 705 StatType stats; 706 liststats_setmode (&stats, "MEDIAN"); 707 liststats (psfStars.alldata->yVector, NULL, NULL, Nref, &stats); 708 double altSigma = (stats.Upper80 - stats.Lower20) / 1.6; // 20% to 80% encompasses 60% of the values, corresponds to the range (-0.85 sigma : +0.85 sigma) 709 710 // soften the individual errors with 10% of the scatter above 711 for (j = 0; j < Nref; j++) { 712 double newSigma = hypot(psfStars.alldata->dyVector[j], 0.1*altSigma); 713 psfStars.alldata->dyVector[j] = newSigma; 714 } 715 716 // soften the errors based on the scatter 707 // soften the errors based on the core scatter 717 708 FitDataSetSoften (&psfStars, Nref); 718 709 -
branches/eam_branches/ipp-20230313/Ohana/src/relphot/src/bcatalog.c
r42696 r42705 1 1 # include "relphot.h" 2 3 # define BAD_COUNT(FIELD) \ 4 badCount.FIELD ++; \ 5 if (doTest1 && (catalog[0].measure[offset].imageID == TEST_IMAGE1)) { badTest1.FIELD ++; } \ 6 if (doTest2 && (catalog[0].measure[offset].imageID == TEST_IMAGE2)) { badTest2.FIELD ++; } 7 8 typedef struct { 9 int Ncode; 10 int Ntime; 11 int Ndophot; 12 int Nmag; 13 int Nsigma; 14 int Nimag; 15 int Nfew; 16 int Ngalaxy; 17 int Npsfqf; 18 int Nnan; 19 int Nbad; 20 int Npoor; 21 } MyBadCountType; 2 22 3 23 int LimitDensityCatalog_ByNmeasure (Catalog *subcatalog, Catalog *oldcatalog); … … 9 29 off_t NAVERAGE, NMEASURE, Naverage, Nmeasure, Nm; 10 30 float mag; 11 int Ncode, Ntime, Ndophot, Nmag, Nsigma, Nimag, Nfew, Ngalaxy, Npsfqf, Nnan, Nbad, Npoor; 31 32 // int Ncode, Ntime, Ndophot, Nmag, Nsigma, Nimag, Nfew, Ngalaxy, Npsfqf, Nnan, Nbad, Npoor; 12 33 13 34 int Nsecfilt = GetPhotcodeNsecfilt (); … … 26 47 int NmMin = catalog[0].Nmeasure; 27 48 28 Ncode = Ntime = Ndophot = Nmag = Nsigma = Nimag = Nfew = Npsfqf = Ngalaxy = Nnan = Nbad = Npoor = 0; 49 MyBadCountType badCount = {0,0,0, 0,0,0, 0,0,0, 0,0,0}; 50 MyBadCountType badTest1 = {0,0,0, 0,0,0, 0,0,0, 0,0,0}; 51 MyBadCountType badTest2 = {0,0,0, 0,0,0, 0,0,0, 0,0,0}; 52 53 int doTest1 = (TEST_IMAGE1 >= 0); 54 int doTest2 = (TEST_IMAGE2 >= 0); 55 56 FILE *ftest1 = (doTest1) ? fopen ("test1.meas.dat", "a") : NULL; 57 FILE *ftest2 = (doTest2) ? fopen ("test2.meas.dat", "a") : NULL; 58 59 // Ncode = Ntime = Ndophot = Nmag = Nsigma = Nimag = Nfew = Npsfqf = Ngalaxy = Nnan = Nbad = Npoor = 0; 29 60 30 61 // copy the following fields to the subcatalog: … … 57 88 58 89 offset = catalog[0].average[i].measureOffset + j; 90 91 if (doTest1) { 92 Measure *m = &catalog[0].measure[offset]; 93 if (m->imageID == TEST_IMAGE1) { 94 fprintf (ftest1, "%5d %5d %5d | %5d %12d %5.3f %5.3f %5.3f %5.3f %4.3f %4.3f 0x%08x\n", m->detID, m->objID, m->catID, m->photcode, m->t, m->M, m->Map, m->Mkron, m->dM, m->psfQF, m->psfQFperf, m->photFlags); 95 } 96 } 97 if (doTest2) { 98 Measure *m = &catalog[0].measure[offset]; 99 if (m->imageID == TEST_IMAGE2) { 100 fprintf (ftest2, "%5d %5d %5d | %5d %12d %5.3f %5.3f %5.3f %5.3f %4.3f %4.3f 0x%08x\n", m->detID, m->objID, m->catID, m->photcode, m->t, m->M, m->Map, m->Mkron, m->dM, m->psfQF, m->psfQFperf, m->photFlags); 101 } 102 } 59 103 60 104 /* select measurements by photcode */ … … 69 113 } 70 114 if (!found) { 71 Ncode ++;115 BAD_COUNT(Ncode); 72 116 continue; 73 117 } … … 75 119 /* select measurements by time */ 76 120 if (TimeSelect) { 77 if (catalog[0].measure[offset].t < TSTART) { Ntime ++; continue; }78 if (catalog[0].measure[offset].t > TSTOP) { Ntime ++; continue; }121 if (catalog[0].measure[offset].t < TSTART) { BAD_COUNT(Ntime); continue; } 122 if (catalog[0].measure[offset].t > TSTOP) { BAD_COUNT(Ntime); continue; } 79 123 } 80 124 81 125 /* select measurements by quality */ 82 if (DophotSelect && ((catalog[0].measure[offset].photFlags >> 16) != DophotValue)) { Ndophot ++; continue; }126 if (DophotSelect && ((catalog[0].measure[offset].photFlags >> 16) != DophotValue)) { BAD_COUNT(Ndophot); continue; } 83 127 84 128 float Maper = USE_APER_FOR_STARGAL ? catalog[0].measure[offset].Map : catalog[0].measure[offset].Mkron; 85 129 86 130 // skip garbage measurements 87 if (isnan(catalog[0].measure[offset].psfQF) || (catalog[0].measure[offset].psfQF < PSF_QF_MIN)) { Npsfqf ++; continue; }88 if (isnan(catalog[0].measure[offset].psfQFperf) || (catalog[0].measure[offset].psfQFperf < PSF_QF_MIN)) { Npsfqf ++; continue; }89 if (isnan(catalog[0].measure[offset].M)) { Nnan ++; continue; }90 if (isnan(Maper)) { Nnan ++; continue; }131 if (isnan(catalog[0].measure[offset].psfQF) || (catalog[0].measure[offset].psfQF < PSF_QF_MIN)) { BAD_COUNT(Npsfqf); continue; } 132 if (isnan(catalog[0].measure[offset].psfQFperf) || (catalog[0].measure[offset].psfQFperf < PSF_QF_MIN)) { BAD_COUNT(Npsfqf); continue; } 133 if (isnan(catalog[0].measure[offset].M)) { BAD_COUNT(Nnan); continue; } 134 if (isnan(Maper)) { BAD_COUNT(Nnan); continue; } 91 135 92 136 // require 0x01 in photFlags (fitted with a PSF) -- add to the test data 93 if (REQUIRE_PSFFIT && (catalog[0].measure[offset].photFlags & 0x01) == 0) { Nbad ++; continue; }137 if (REQUIRE_PSFFIT && (catalog[0].measure[offset].photFlags & 0x01) == 0) { BAD_COUNT(Nbad); continue; } 94 138 95 139 // very loose cut on PSF - APER mag (Map or Mkron) -- this lightly rejects galaxies & other oddities 96 140 float Mkp = catalog[0].measure[offset].M - Maper; 97 if (fabs(Mkp) > 1.0) { Nbad ++; continue; }141 if (fabs(Mkp) > 1.0) { BAD_COUNT(Nbad); continue; } 98 142 99 143 if (catalog[0].measure[offset].photFlags & code->photomBadMask) { 100 Nbad++;144 BAD_COUNT(Nbad); 101 145 continue; 102 146 } 103 if (catalog[0].measure[offset].photFlags & code->photomPoorMask) { Npoor++; continue;}147 if (catalog[0].measure[offset].photFlags & code->photomPoorMask) { BAD_COUNT(Npoor); continue;} 104 148 105 149 // weak test for galaxies … … 112 156 /* select measurements by mag limit */ 113 157 mag = PhotCat (&catalog[0].measure[offset], MAG_CLASS_PSF); 114 if (mag > MAG_LIM) { Nmag ++; continue; }115 if (mag < MAG_MIN) { Nmag ++; continue; }158 if (mag > MAG_LIM) { BAD_COUNT(Nmag); continue; } 159 if (mag < MAG_MIN) { BAD_COUNT(Nmag); continue; } 116 160 // note that these two cuts are applied to all photcodes. these are also applied to 117 161 // the nominal apparent mags : if the expected sensitivity is very different between … … 120 164 121 165 /* select measurements by measurement error */ 122 if ((SIGMA_LIM > 0) && (catalog[0].measure[offset].dM > SIGMA_LIM)) { Nsigma ++; continue; }166 if ((SIGMA_LIM > 0) && (catalog[0].measure[offset].dM > SIGMA_LIM)) { BAD_COUNT(Nsigma); continue; } 123 167 124 168 /* select measurements by mag limit */ 125 169 if (ImagSelect) { 126 170 mag = PhotInst (&catalog[0].measure[offset], MAG_CLASS_PSF); 127 if (mag < ImagMin) { Nimag ++; continue; }128 if (mag > ImagMax) { Nimag ++; continue; }171 if (mag < ImagMin) { BAD_COUNT(Nimag); continue; } 172 if (mag > ImagMax) { BAD_COUNT(Nimag); continue; } 129 173 } 130 174 // note that instrumental mag cuts are reasonable for individual exposures using the same … … 155 199 if (nEXT >= nPSF) { 156 200 Nmeasure -= Nm; 157 Ngalaxy ++;201 BAD_COUNT(Ngalaxy); 158 202 continue; 159 203 } … … 165 209 if (Nm <= STAR_TOOFEW) { /* enough measurements total? */ 166 210 Nmeasure -= Nm; 167 Nfew ++;211 BAD_COUNT(Nfew); 168 212 continue; 169 213 } … … 175 219 if (!anySecfiltGood) { 176 220 Nmeasure -= Nm; 177 Nfew ++;221 BAD_COUNT(Nfew); 178 222 continue; 179 223 } … … 212 256 subcatalog[0].Naverage, subcatalog[0].Nmeasure, catalog[0].Naverage, catalog[0].Nmeasure, catalog[0].filename, NmMin, NmMax); 213 257 fprintf (stderr, "rejections: %d stars have too few measures:\n %d code, %d time, %d dophot, %d mag, %d sigma, %d imag, %d psfqf, %d Nnan, %d galaxies, %d bad, %d poor\n", 214 Nfew, Ncode, Ntime, Ndophot, Nmag, Nsigma, Nimag, Npsfqf, Nnan, Ngalaxy, Nbad, Npoor); 258 badCount.Nfew, badCount.Ncode, badCount.Ntime, badCount.Ndophot, badCount.Nmag, badCount.Nsigma, badCount.Nimag, badCount.Npsfqf, badCount.Nnan, badCount.Ngalaxy, badCount.Nbad, badCount.Npoor); 259 } 260 261 if (doTest1) { 262 fprintf (stderr, "TEST1 rejections: %d stars have too few measures: %d code, %d time, %d dophot, %d mag, %d sigma, %d imag, %d psfqf, %d Nnan, %d galaxies, %d bad, %d poor\n", 263 badTest1.Nfew, badTest1.Ncode, badTest1.Ntime, badTest1.Ndophot, badTest1.Nmag, badTest1.Nsigma, badTest1.Nimag, badTest1.Npsfqf, badTest1.Nnan, badTest1.Ngalaxy, badTest1.Nbad, badTest1.Npoor); 264 } 265 if (doTest2) { 266 fprintf (stderr, "TEST2 rejections: %d stars have too few measures: %d code, %d time, %d dophot, %d mag, %d sigma, %d imag, %d psfqf, %d Nnan, %d galaxies, %d bad, %d poor\n", 267 badTest2.Nfew, badTest2.Ncode, badTest2.Ntime, badTest2.Ndophot, badTest2.Nmag, badTest2.Nsigma, badTest2.Nimag, badTest2.Npsfqf, badTest2.Nnan, badTest2.Ngalaxy, badTest2.Nbad, badTest2.Npoor); 215 268 } 216 269 … … 220 273 } 221 274 222 free (Nvalid) 275 free (Nvalid); 276 277 if (ftest1) { fclose (ftest1); } 278 if (ftest2) { fclose (ftest2); } 223 279 224 280 return (TRUE); -
branches/eam_branches/ipp-20230313/Ohana/src/relphot/src/fit1d_irls.c
r41557 r42705 374 374 StatType stats; 375 375 liststats_setmode (&stats, "MEDIAN"); 376 liststats (dataset->alldata->yVector, NULL, NULL, Nvalues, &stats); 376 liststats (dataset->alldata->yVector, dataset->alldata->dyVector, NULL, Nvalues, &stats); 377 // liststats sorts yVector and dyVector together 377 378 378 379 double altSigma = (stats.Upper80 - stats.Lower20) / 1.6; // 20% to 80% encompasses 60% of the values, corresponds to the range (-0.85 sigma : +0.85 sigma) … … 380 381 // soften the individual errors with 10% of the scatter above 381 382 for (int j = 0; j < Nvalues; j++) { 382 double newSigma = hypot(dataset->alldata->dyVector[j], 0. 1*altSigma);383 double newSigma = hypot(dataset->alldata->dyVector[j], 0.5*altSigma); 383 384 dataset->alldata->dyVector[j] = newSigma; 384 385 }
Note:
See TracChangeset
for help on using the changeset viewer.
