Changeset 41557
- Timestamp:
- Apr 27, 2021, 4:25:16 PM (5 years ago)
- Location:
- trunk/Ohana/src/relphot
- Files:
-
- 8 edited
-
include/relphot.h (modified) (1 diff)
-
src/ImageOps.c (modified) (1 diff)
-
src/MagResidSave.c (modified) (14 diffs)
-
src/MosaicOps.c (modified) (2 diffs)
-
src/TGroupOps.c (modified) (1 diff)
-
src/bcatalog.c (modified) (1 diff)
-
src/fit1d_irls.c (modified) (1 diff)
-
src/setMrelCatalog.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/relphot/include/relphot.h
r41556 r41557 598 598 void FitDataSetAlloc PROTO((FitDataSet *dataset, int Nmax, int order, int Nbootstrap)); 599 599 void FitDataSetAddPriors PROTO((FitDataSet *dataset)); 600 StatType FitDataSetSoften PROTO((FitDataSet *dataset, int Nvalues)); 600 601 601 602 unsigned int *ReadTGroupFile PROTO((FILE *f, int *nelem)); -
trunk/Ohana/src/relphot/src/ImageOps.c
r41556 r41557 784 784 } 785 785 786 // no additional weight modification (we treat all stars on an image equally -- note an image is either ubercal-tied or not) 787 // XXX: apply airmass from above and fit only zp? 788 789 // XXX soften the stats? 786 // soften the errors based on the scatter 787 FitDataSetSoften (&psfStars, Nref); 790 788 791 789 fit1d_irls (&psfStars, Nref); -
trunk/Ohana/src/relphot/src/MagResidSave.c
r41556 r41557 12 12 float dMresid; 13 13 float Mchisq; 14 float Mmedian; 15 float Maltsig; 14 16 int Nfit; 15 17 } MagResidResult; … … 39 41 } 40 42 41 // we are making a 0-order fit and not doing bootstrap analysis , using OLS43 // we are making a 0-order fit and not doing bootstrap analysis 42 44 FitDataSet psfStars; 43 45 FitDataSetAlloc (&psfStars, Nmax, 0, 0); 44 psfStars.MaxIterations = 0; 46 // By default, we use IRLS; if MaxIterations = 0, then we use OLS 47 // psfStars.MaxIterations = 0; 45 48 46 49 gfits_init_header (&header); … … 56 59 gfits_define_bintable_column (&theader, "E", "MAG_ERROR", "magnitude error", "magnitudes", 1.0, 0.0); 57 60 gfits_define_bintable_column (&theader, "E", "MAG_CHISQ", "magnitude resid chisq", "unitless", 1.0, 0.0); 61 gfits_define_bintable_column (&theader, "E", "MAG_MEDIAN", "median magnitude residual", "magnitudes", 1.0, 0.0); 62 gfits_define_bintable_column (&theader, "E", "MAG_ALTSIG", "68 percentile range as sigma", "magnitudes", 1.0, 0.0); 58 63 gfits_define_bintable_column (&theader, "E", "AIRMASS", "", "unitless", 1.0, 0.0); 59 64 gfits_define_bintable_column (&theader, "D", "MJD", "", "unitless", 1.0, 0.0); … … 62 67 gfits_define_bintable_column (&theader, "J", "FLAGS", "image flags", "unitless", 1.0, 0.0); 63 68 gfits_define_bintable_column (&theader, "J", "NFIT", "number of stars fitted", NULL, 1.0, FT_BZERO_INT32); 69 gfits_define_bintable_column (&theader, "J", "NMEAS", "number of stars on image", NULL, 1.0, FT_BZERO_INT32); 64 70 65 71 // generate the output array that carries the data … … 73 79 ALLOCATE_PTR (dMresid, float, Nimage); 74 80 ALLOCATE_PTR (Mchisq, float, Nimage); 81 ALLOCATE_PTR (Mmedian, float, Nimage); 82 ALLOCATE_PTR (Maltsig, float, Nimage); 75 83 ALLOCATE_PTR (airmass, float, Nimage); 76 84 ALLOCATE_PTR (mjd, double, Nimage); … … 79 87 ALLOCATE_PTR (flags, int, Nimage); 80 88 ALLOCATE_PTR (Nfit, int, Nimage); 89 ALLOCATE_PTR (Nmeas, int, Nimage); 81 90 82 91 // XXXX fill in the vectors here … … 94 103 Mchisq[i] = NAN; 95 104 dMresid[i] = NAN; 105 Mmedian[i] = NAN; 106 Maltsig[i] = NAN; 96 107 Nfit[i] = 0; 97 108 Nmeas[i] = N_onImage[i]; … … 110 121 Mchisq[i] = result.Mchisq; 111 122 dMresid[i] = result.dMresid; 123 Mmedian[i] = result.Mmedian; 124 Maltsig[i] = result.Maltsig; 112 125 Nfit[i] = result.Nfit; 113 126 } 114 127 115 128 // add the columns to the output array 116 gfits_set_bintable_column (&theader, &ftable, "RA", Rs, Nimage);117 gfits_set_bintable_column (&theader, &ftable, "DEC", Ds, Nimage);129 gfits_set_bintable_column (&theader, &ftable, "RA", Rs, Nimage); 130 gfits_set_bintable_column (&theader, &ftable, "DEC", Ds, Nimage); 118 131 gfits_set_bintable_column (&theader, &ftable, "MAG_RESID", Mresid, Nimage); 119 132 gfits_set_bintable_column (&theader, &ftable, "MAG_ERROR", dMresid, Nimage); 120 133 gfits_set_bintable_column (&theader, &ftable, "MAG_CHISQ", Mchisq, Nimage); 134 gfits_set_bintable_column (&theader, &ftable, "MAG_MEDIAN", Mmedian, Nimage); 135 gfits_set_bintable_column (&theader, &ftable, "MAG_ALTSIG", Maltsig, Nimage); 121 136 gfits_set_bintable_column (&theader, &ftable, "AIRMASS", airmass, Nimage); 122 137 gfits_set_bintable_column (&theader, &ftable, "MJD", mjd, Nimage); … … 125 140 gfits_set_bintable_column (&theader, &ftable, "FLAGS", flags, Nimage); 126 141 gfits_set_bintable_column (&theader, &ftable, "NFIT", Nfit, Nimage); 142 gfits_set_bintable_column (&theader, &ftable, "NMEAS", Nmeas, Nimage); 127 143 128 144 free (Rs); … … 131 147 free (dMresid ); 132 148 free (Mchisq ); 149 free (Mmedian ); 150 free (Maltsig ); 133 151 free (airmass ); 134 152 free (mjd ); … … 137 155 free (flags ); 138 156 free (Nfit ); 157 free (Nmeas ); 139 158 140 159 FILE *f = fopen (filename, "w"); … … 185 204 result.dMresid = NAN; 186 205 result.Mchisq = NAN; 206 result.Mmedian = NAN; 207 result.Maltsig = NAN; 187 208 result.Nfit = 0; 188 209 … … 239 260 result.dMresid = NAN; 240 261 result.Mchisq = NAN; 262 result.Mmedian = NAN; 263 result.Maltsig = NAN; 241 264 result.Nfit = Nref; 242 265 return result; 243 266 } 267 268 StatType stats = FitDataSetSoften (psfStars, Nref); 269 double altSigma = (stats.Upper80 - stats.Lower20) / 1.6; 244 270 245 271 // no additional weight modification (we treat all stars on an image equally -- note an image is either ubercal-tied or not) … … 249 275 result.Nfit = psfStars->Nmeas; 250 276 result.Mchisq = psfStars->chisq; 277 result.Mmedian = stats.median; 278 result.Maltsig = altSigma; 251 279 252 280 return result; -
trunk/Ohana/src/relphot/src/MosaicOps.c
r41556 r41557 1161 1161 1162 1162 // in GOOD_MOSAIC mode, we fit good mosaics ignoring night state 1163 // This case should only be used when not fitting nights / tgroups 1163 1164 if ((MOSAIC_ZPT_MODE == MOSAIC_ZPT_MODE_GOOD_MOSAIC)) { 1164 1165 if (badMosaic) useMmos = FALSE; // do not fit bad mosaics … … 1312 1313 } 1313 1314 1314 StatType stats; 1315 liststats_setmode (&stats, "MEDIAN"); 1316 liststats (psfStars->alldata->yVector, NULL, NULL, N, &stats); 1317 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) 1318 1319 // soften the individual errors with 10% of the scatter above 1320 for (j = 0; j < N; j++) { 1321 double newSigma = hypot(psfStars->alldata->dyVector[j], 0.1*altSigma); 1322 psfStars->alldata->dyVector[j] = newSigma; 1323 } 1324 1315 // soften the errors based on the scatter 1316 FitDataSetSoften (psfStars, N); 1317 1325 1318 fit1d_irls (psfStars, N); 1326 1319 fit1d_irls (brightStars, Nbright); -
trunk/Ohana/src/relphot/src/TGroupOps.c
r41556 r41557 927 927 */ 928 928 929 // use liststats to find the 20-pct, median, 80-pct points 930 StatType stats; 931 liststats_setmode (&stats, "MEDIAN"); 932 liststats (psfStars->alldata->yVector, NULL, NULL, N, &stats); 933 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) 929 StatType stats = FitDataSetSoften (psfStars, N); 930 double altSigma = (stats.Upper80 - stats.Lower20) / 1.6; 934 931 935 932 TGTimes *mygroup = (TGTimes *) myTGroup->parent; 936 933 fprintf (stderr, "TGroup Stats %f,%d : %d %d %6.3f %6.3f\n", ohana_sec_to_mjd(mygroup->start), myTGroup->photcode, (int) N, (int) myTGroup->Nmeasure, stats.median, altSigma); 937 938 // soften the individual errors with 10% of the scatter above939 for (j = 0; j < N; j++) {940 double newSigma = hypot(psfStars->alldata->dyVector[j], 0.1*altSigma);941 psfStars->alldata->dyVector[j] = newSigma;942 }943 934 944 935 // do anything special with identified good nights? -
trunk/Ohana/src/relphot/src/bcatalog.c
r40291 r41557 106 106 107 107 // skip garbage measurements 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; }108 if (isnan(catalog[0].measure[offset].psfQF) || (catalog[0].measure[offset].psfQF < 0.95)) { Npsfqf ++; continue; } 109 if (isnan(catalog[0].measure[offset].psfQFperf) || (catalog[0].measure[offset].psfQFperf < 0.95)) { Npsfqf ++; continue; } 110 110 if (isnan(catalog[0].measure[offset].M)) { Nnan ++; continue; } 111 111 -
trunk/Ohana/src/relphot/src/fit1d_irls.c
r41462 r41557 368 368 } 369 369 } 370 371 StatType FitDataSetSoften (FitDataSet *dataset, int Nvalues) { 372 373 // use liststats to find the 20-pct, median, 80-pct points 374 StatType stats; 375 liststats_setmode (&stats, "MEDIAN"); 376 liststats (dataset->alldata->yVector, NULL, NULL, Nvalues, &stats); 377 378 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) 379 380 // soften the individual errors with 10% of the scatter above 381 for (int j = 0; j < Nvalues; j++) { 382 double newSigma = hypot(dataset->alldata->dyVector[j], 0.1*altSigma); 383 dataset->alldata->dyVector[j] = newSigma; 384 } 385 386 return stats; 387 } -
trunk/Ohana/src/relphot/src/setMrelCatalog.c
r41555 r41557 267 267 if (USE_REFERENCE_WEIGHT && (code->type == PHOT_REF)) modifiedWeight = code->photomErrSys; // we are overloading this field for now 268 268 269 // XXX I should probably do something more clever with the measured scatter in the nights, mosaics, images 270 269 271 // combine the various errors in quadrature here: 270 272 float dMsys = hypot (code->photomErrSys, dMgrp);
Note:
See TracChangeset
for help on using the changeset viewer.
