- Timestamp:
- Dec 7, 2020, 5:45:21 PM (6 years ago)
- Location:
- trunk/Ohana/src/relphot/src
- Files:
-
- 2 edited
-
MosaicOps.c (modified) (6 diffs)
-
TGroupOps.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/relphot/src/MosaicOps.c
r41453 r41454 925 925 off_t Nmax; 926 926 int PoorImages; 927 double *psfMagList; 928 double *psfErrList; 929 double *brightMagList; 930 double *brightErrList; 931 double *kronMagList; 932 double *kronErrList; 927 FitDataSet psfStars; 928 FitDataSet kronStars; 929 FitDataSet brightStars; 933 930 } SetMmosInfo; 934 931 … … 961 958 962 959 if (allocLists) { 963 ALLOCATE (info->psfMagList, double, Nmax); 964 ALLOCATE (info->psfErrList, double, Nmax); 965 ALLOCATE (info->kronMagList, double, Nmax); 966 ALLOCATE (info->kronErrList, double, Nmax); 967 ALLOCATE (info->brightMagList, double, Nmax); 968 ALLOCATE (info->brightErrList, double, Nmax); 960 // we can only fit the zero point for individual exposures, not the airmass 961 FitDataSetAlloc (&info->psfStars, Nmax, 0, 0); 962 FitDataSetAlloc (&info->kronStars, Nmax, 0, 0); 963 FitDataSetAlloc (&info->brightStars, Nmax, 0, 0); 969 964 } 970 965 } 971 966 972 967 void SetMmosInfoFree (SetMmosInfo *info) { 973 free (info->psfMagList ); 974 free (info->psfErrList ); 975 free (info->kronMagList ); 976 free (info->kronErrList ); 977 free (info->brightMagList); 978 free (info->brightErrList); 968 FitDataSetFree (&info->brightStars); 969 FitDataSetFree (&info->kronStars); 970 FitDataSetFree (&info->psfStars); 979 971 } 980 972 … … 1074 1066 off_t j, NimageReal; 1075 1067 1076 StatType stats;1077 liststats_setmode (&stats, "INNER_WTMEAN");1078 1079 double *psfMagList = info->psfMagList;1080 double *psfErrList = info->psfErrList;1081 double *kronMagList = info->kronMagList;1082 double *kronErrList = info->kronErrList;1083 double *brightMagList = info->brightMagList;1084 double *brightErrList = info->brightErrList;1085 1086 assert (Nmos >= 0);1087 assert (Nmos < Nmosaic);1088 1089 // Image *imageReal = getimages (&NimageReal, NULL); returned pointer is not used1090 getimages (&NimageReal, NULL);1091 1092 1068 /* on PoorImages run, skip good images */ 1093 1069 if (info->PoorImages) { … … 1095 1071 if (!bad) return TRUE; 1096 1072 } 1073 1074 FitDataSet *psfStars = &info->psfStars; 1075 FitDataSet *kronStars = &info->kronStars; 1076 FitDataSet *brightStars = &info->brightStars; 1077 1078 assert (Nmos >= 0); 1079 assert (Nmos < Nmosaic); 1080 1081 // Image *imageReal = getimages (&NimageReal, NULL); returned pointer is not used 1082 getimages (&NimageReal, NULL); 1097 1083 1098 1084 // UBERCAL image: if this is an ubercal image, set minUbercalDist to 0: … … 1230 1216 assert (Nbright >= 0); 1231 1217 1232 psfMagList[N] = MsysPSF - MrelPSF - Mcal - Mgrid + Mflat; 1233 psfErrList[N] = MAX (catalog[c].measureT[m].dM, MIN_ERROR); 1234 kronMagList[N] = MsysKron - MrelKron - Mcal - Mgrid + Mflat; 1235 kronErrList[N] = psfErrList[N]; 1218 psfStars->alldata-> yVector[N] = MsysPSF - MrelPSF - Mcal - Mgrid + Mflat; 1219 psfStars->alldata->dyVector[N] = MAX (catalog[c].measureT[m].dM, MIN_ERROR); 1220 1221 kronStars->alldata-> yVector[N] = MsysKron - MrelKron - Mcal - Mgrid + Mflat; 1222 kronStars->alldata->dyVector[N] = psfStars->alldata->dyVector[N]; 1223 1236 1224 if (catalog[c].measureT[m].dM < IMFIT_SYS_SIGMA_LIM) { 1237 bright MagList[Nbright] = psfMagList[N];1238 bright ErrList[Nbright] = psfErrList[N];1225 brightStars->alldata-> yVector[Nbright] = psfStars->alldata-> yVector[N]; 1226 brightStars->alldata->dyVector[Nbright] = psfStars->alldata->dyVector[N]; 1239 1227 Nbright ++; 1240 1228 } 1241 1229 N++; 1230 1242 1231 } 1243 1232 /* N_onMosaic[Nmos] is all measurements, N is good measurements */ 1244 1233 1245 if (fout) { 1246 fclose (fout); 1247 } 1234 if (fout) { fclose (fout); } 1248 1235 1249 1236 /* too few good measurements or too many bad measurements (skip in PoorImages run) */ … … 1262 1249 } 1263 1250 1264 liststats (psfMagList, psfErrList, NULL, N, &stats);1265 if (VERBOSE2 && info->PoorImages) fprintf (stderr, "Mmos: %f %f %d %d\n", stats.mean, stats.sigma, stats.Nmeas, N);1251 fit1d_irls (psfStars, N); 1252 // if (VERBOSE2 && info->PoorImages) fprintf (stderr, "Mmos: %f %f %d %d\n", stats.mean, stats.sigma, stats.Nmeas, N); 1266 1253 1267 1254 // for now, I have no reason to measure these separately for camera-level images 1268 myMosaic[0].McalPSF = stats.mean;1269 myMosaic[0].dMcal = stats.error;1270 myMosaic[0].McalChiSq = stats.chisq;1271 myMosaic[0].nFitPhotom = N;1272 1273 liststats (kronMagList, kronErrList, NULL, N, &stats);1274 myMosaic[0].McalAPER = stats.mean;1255 myMosaic[0].McalPSF = psfStars->bSaveArray[0][0]; 1256 myMosaic[0].dMcal = psfStars->bSigma[0]; 1257 myMosaic[0].McalChiSq = psfStars->chisq; 1258 myMosaic[0].nFitPhotom = psfStars->Nmeas; 1259 1260 // fit1d_irls (kronStars, N); // does it make sense to calculate a zero point based kron mags? 1261 // myMosaic->McalAPER = ??? 1275 1262 1276 1263 if (testImage) { 1277 fprintf (stderr, "test image %d (%d) %f %f %d ... ", (int) Nmos, myMosaic [0].start, stats.mean, stats.error, myMosaic[0].nFitPhotom);1264 fprintf (stderr, "test image %d (%d) %f %f %d ... ", (int) Nmos, myMosaic->start, myMosaic->McalPSF, myMosaic->dMcal, myMosaic->nFitPhotom); 1278 1265 } 1279 1266 1280 1267 if (PLOTSTUFF) { 1281 fprintf (stderr, "Mmos: %6.3f %6.3f +/- %6.3f %5d %5d | %s\n", stats.mean, stats.median, stats.sigma, stats.Nmeas, N, image[MosaicToImage[Nmos][0]].name);1282 plot_setMcal (psf MagList, N);1268 fprintf (stderr, "Mmos: %6.3f +/- %6.3f %5d %5d | %s\n", myMosaic->McalPSF, myMosaic->dMcal, myMosaic->nFitPhotom, N, image[MosaicToImage[Nmos][0]].name); 1269 plot_setMcal (psfStars->alldata->yVector, N); 1283 1270 } 1284 1271 1285 1272 // bright end scatter 1286 liststats (brightMagList, brightErrList, NULL, Nbright, &stats);1287 myMosaic[0].dMsys = stats.sigma;1273 // fit1d_irls (brightStars, N); // does it make sense to calculate a separate bright star zero point? 1274 // myMosaic->dMsys = ??? 1288 1275 1289 1276 if (myMosaic[0].McalPSF < -CLOUD_TOLERANCE) { -
trunk/Ohana/src/relphot/src/TGroupOps.c
r41453 r41454 527 527 off_t Nmax; 528 528 int PoorImages; 529 double *psfMagList; 530 double *psfAirList; 531 double *psfErrList; 532 double *brightMagList; 533 double *brightErrList; 534 double *kronMagList; 535 double *kronErrList; 529 FitDataSet psfStars; 530 FitDataSet kronStars; 531 FitDataSet brightStars; 536 532 } SetMgrpInfo; 537 533 … … 565 561 566 562 if (allocLists) { 567 ALLOCATE (info->psfMagList, double, Nmax); 568 ALLOCATE (info->psfAirList, double, Nmax); 569 ALLOCATE (info->psfErrList, double, Nmax); 570 ALLOCATE (info->kronMagList, double, Nmax); 571 ALLOCATE (info->kronErrList, double, Nmax); 572 ALLOCATE (info->brightMagList, double, Nmax); 573 ALLOCATE (info->brightErrList, double, Nmax); 563 int fitOrder = TGROUP_FIT_AIRMASS ? 1 : 0; 564 565 FitDataSetAlloc (&info->psfStars, Nmax, fitOrder, 0); 566 FitDataSetAlloc (&info->kronStars, Nmax, fitOrder, 0); 567 FitDataSetAlloc (&info->brightStars, Nmax, fitOrder, 0); 568 569 if (1) { 570 FitDataSetAddPriors (&info->psfStars); 571 info->psfStars.bPriorValue[1] = 0.0; // note that we are fitting relative to the nominal slope 572 info->psfStars.bPriorSigma[1] = 0.04; // XXX this prior sigma needs to be user-configured 573 } 574 574 } 575 575 } 576 576 577 577 void SetMgrpInfoFree (SetMgrpInfo *info) { 578 free (info->psfMagList ); 579 free (info->psfAirList ); 580 free (info->psfErrList ); 581 free (info->kronMagList ); 582 free (info->kronErrList ); 583 free (info->brightMagList); 584 free (info->brightErrList); 578 FitDataSetFree (&info->brightStars); 579 FitDataSetFree (&info->kronStars); 580 FitDataSetFree (&info->psfStars); 585 581 } 586 582 … … 694 690 } 695 691 696 int fitOrder = TGROUP_FIT_AIRMASS ? 1 : 0; 697 698 // allocate the arrays used by the fit1d_irls analysis below. 699 // the last 0 means we are NOT using bootstrap analysis here 700 701 FitDataSet psfStars, kronStars, brightStars; 702 FitDataSetAlloc (&psfStars, myTGroup->Nmeasure, fitOrder, 0); 703 FitDataSetAlloc (&kronStars, myTGroup->Nmeasure, fitOrder, 0); 704 FitDataSetAlloc (&brightStars, myTGroup->Nmeasure, fitOrder, 0); 705 706 // add prior constraint on airmass: 707 if (1) { 708 FitDataSetAddPriors (&psfStars); 709 psfStars.bPriorValue[1] = 0.0; // note that we are fitting relative to the nominal slope 710 psfStars.bPriorSigma[1] = 0.04; // XXX this prior sigma needs to be user-configured 711 } 692 FitDataSet *psfStars = &info->psfStars; 693 FitDataSet *kronStars = &info->kronStars; 694 FitDataSet *brightStars = &info->brightStars; 695 696 assert (Ngrp >= 0); 697 assert (Ngrp < NtgroupTimes); 712 698 713 699 // Image *imageReal = getimages (&NimageReal, NULL); returned pointer is not used … … 820 806 assert (Nbright >= 0); 821 807 822 psfStars .alldata-> yVector[N] = MsysPSF - MrelPSF - Mcal - Mgrid + Mflat;823 psfStars .alldata-> xVector[N] = (catalog[c].measureT[m].airmass - 1.0);824 psfStars .alldata->dyVector[N] = MAX (catalog[c].measureT[m].dM, MIN_ERROR);825 826 kronStars .alldata-> yVector[N] = MsysKron - MrelKron - Mcal - Mgrid + Mflat;827 kronStars .alldata-> xVector[N] = psfStars.alldata-> xVector[N];828 kronStars .alldata->dyVector[N] = psfStars.alldata->dyVector[N];808 psfStars->alldata-> yVector[N] = MsysPSF - MrelPSF - Mcal - Mgrid + Mflat; 809 psfStars->alldata-> xVector[N] = (catalog[c].measureT[m].airmass - 1.0); 810 psfStars->alldata->dyVector[N] = MAX (catalog[c].measureT[m].dM, MIN_ERROR); 811 812 kronStars->alldata-> yVector[N] = MsysKron - MrelKron - Mcal - Mgrid + Mflat; 813 kronStars->alldata-> xVector[N] = psfStars->alldata-> xVector[N]; 814 kronStars->alldata->dyVector[N] = psfStars->alldata->dyVector[N]; 829 815 830 816 if (catalog[c].measureT[m].dM < IMFIT_SYS_SIGMA_LIM) { 831 brightStars .alldata-> yVector[Nbright] = psfStars.alldata-> yVector[N];832 brightStars .alldata-> xVector[Nbright] = psfStars.alldata-> xVector[N];833 brightStars .alldata->dyVector[Nbright] = psfStars.alldata->dyVector[N];817 brightStars->alldata-> yVector[Nbright] = psfStars->alldata-> yVector[N]; 818 brightStars->alldata-> xVector[Nbright] = psfStars->alldata-> xVector[N]; 819 brightStars->alldata->dyVector[Nbright] = psfStars->alldata->dyVector[N]; 834 820 Nbright ++; 835 821 } … … 859 845 // (myTGroup->flags & ID_IMAGE_PHOTOM_UBERCAL) 860 846 861 fit1d_irls ( &psfStars, N);847 fit1d_irls (psfStars, N); 862 848 863 849 // if (VERBOSE2 && info->PoorImages) fprintf (stderr, "Mgrp: %f %f %d %d\n", stats.mean, stats.sigma, stats.Nmeas, N); 864 850 865 851 // for now, I have no reason to measure these separately for camera-level images 866 myTGroup->McalPSF = psfStars .bSaveArray[0][0];867 myTGroup->dMcal = psfStars .bSigma[0];868 myTGroup->McalChiSq = psfStars .chisq;869 myTGroup->nFitPhotom = psfStars .Nmeas;870 myTGroup->dKlam = psfStars .bSaveArray[1][0];852 myTGroup->McalPSF = psfStars->bSaveArray[0][0]; 853 myTGroup->dMcal = psfStars->bSigma[0]; 854 myTGroup->McalChiSq = psfStars->chisq; 855 myTGroup->nFitPhotom = psfStars->Nmeas; 856 myTGroup->dKlam = psfStars->bSaveArray[1][0]; 871 857 872 858 // XXX drop this for tgroups? 873 // fit1d_irls ( &kronStars, N); // does it make sense to calculate a zero point based kron mags?859 // fit1d_irls (kronStars, N); // does it make sense to calculate a zero point based kron mags? 874 860 // myTGroup->McalAPER = stats.mean; 875 861 … … 881 867 if (PLOTSTUFF) { 882 868 fprintf (stderr, "Mgrp: %6.3f +/- %6.3f %5d of %5d | %.0f\n", myTGroup->McalPSF, myTGroup->dMcal, myTGroup->nFitPhotom, N, ohana_sec_to_mjd(tgroup->start)); 883 plot_setMcal (psfStars .alldata->yVector, N);869 plot_setMcal (psfStars->alldata->yVector, N); 884 870 } 885 871 … … 887 873 // XXX this does not make sense: I need to apply the airmass slope calculated above first 888 874 // redo this by calculating the corrected bright stars mags 889 // fit1d_irls ( &brightStars, N); // does it make sense to calculate a separate bright star zero point?875 // fit1d_irls (brightStars, N); // does it make sense to calculate a separate bright star zero point? 890 876 // myTGroup->dMsys = stats.sigma; 891 877 … … 899 885 } 900 886 901 FitDataSetFree (&brightStars);902 FitDataSetFree (&kronStars);903 FitDataSetFree (&psfStars);887 // FitDataSetFree (&brightStars); 888 // FitDataSetFree (&kronStars); 889 // FitDataSetFree (&psfStars); 904 890 905 891 return TRUE;
Note:
See TracChangeset
for help on using the changeset viewer.
