- Timestamp:
- Apr 24, 2021, 2:28:09 PM (5 years ago)
- Location:
- trunk/Ohana/src/relphot
- Files:
-
- 10 edited
-
include/relphot.h (modified) (6 diffs)
-
src/ImageOps.c (modified) (9 diffs)
-
src/MosaicOps.c (modified) (12 diffs)
-
src/TGroupOps.c (modified) (21 diffs)
-
src/ZeroPointModes.c (modified) (9 diffs)
-
src/args.c (modified) (2 diffs)
-
src/liststats.c (modified) (6 diffs)
-
src/load_images.c (modified) (2 diffs)
-
src/relphot_images.c (modified) (3 diffs)
-
src/setMrelCatalog.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/relphot/include/relphot.h
r41485 r41555 88 88 float dMcal; 89 89 float dMsys; 90 float stdev; 91 float dMmin; 92 float dMmax; 90 93 float McalChiSq; 91 94 float secz; … … 107 110 float dMsys; 108 111 float stdev; 112 float dMmin; 113 float dMmax; 109 114 float McalChiSq; 110 115 unsigned int nFitPhotom; … … 155 160 double min; 156 161 double max; 162 double Upper90; 157 163 double Upper80; 158 164 double Lower20; 165 double Lower10; 159 166 double total; 160 167 int Nmeas; … … 415 422 int TEST_IMAGE2; 416 423 424 int MANUAL_ITERATION; 417 425 int NLOOP; 418 426 int NGRID; … … 643 651 int setMrelOutput PROTO((Catalog *catalog, int Ncatalog, FlatCorrectionTable *flatcorr)); 644 652 653 void setMcalTest PROTO((Catalog *catalog, FlatCorrectionTable *flatcorr)); 654 645 655 int setMave PROTO((Catalog *catalog, int Ncatalog)); 646 656 void set_ZP PROTO((double ZERO)); … … 835 845 void dump_tgroups (Catalog *catalog, int Npass); 836 846 void dump_catalog (Catalog *catalog, off_t c, int Npass); 847 void dump_tgroup_imstats (int Npass); 837 848 838 849 void SetZptIteration (int current); -
trunk/Ohana/src/relphot/src/ImageOps.c
r41550 r41555 1 1 # include "relphot.h" 2 # define BASIC_STATS 03 2 4 3 // the MeasureToImage, ImageToCatalog, and ImageToMeasure arrays are a substantial part of the memory footprint. … … 631 630 int isMosaic = isMosaicChip(image[i].photcode); 632 631 632 // unset at start by default (set if actually used below) 633 image[i].flags &= ~ID_IMAGE_IMAGE_PHOTCAL; 634 633 635 // if requested, freeze mosaic chips: 634 636 if (FREEZE_IMAGES && isMosaic) continue; … … 719 721 } 720 722 723 float Moff = Mmos + Mgrp + Mgrid - Mflat; 724 721 725 PhotCode *code = GetPhotcodebyCode (catalog[c].measureT[m].photcode); 722 726 if (!code) goto skip; … … 727 731 728 732 skip: 729 psfStars.alldata-> yVector[Nref] = MsysPSF - MrelPSF - M mos - Mgrp - Mgrid + Mflat;733 psfStars.alldata-> yVector[Nref] = MsysPSF - MrelPSF - Moff; 730 734 psfStars.alldata->dyVector[Nref] = MAX (catalog[c].measureT[m].dM, MIN_ERROR); 731 735 … … 734 738 735 739 if (isfinite(MrelKron) && isfinite(MsysKron)) { 736 kronStars.alldata-> yVector[Nkron] = MsysKron - MrelKron - M mos - Mgrp - Mgrid + Mflat;740 kronStars.alldata-> yVector[Nkron] = MsysKron - MrelKron - Moff; 737 741 kronStars.alldata->dyVector[Nkron] = psfStars.alldata->dyVector[Nref]; 738 742 Nkron ++; … … 765 769 } 766 770 } 771 if (mark) continue; 767 772 768 773 // no additional weight modification (we treat all stars on an image equally -- note an image is either ubercal-tied or not) … … 776 781 // no additional weight modification (we treat all stars on an image equally -- note an image is either ubercal-tied or not) 777 782 // XXX: apply airmass from above and fit only zp? 778 fit1d_irls (&kronStars, Nkron); 779 image[i].McalAPER = kronStars.bSaveArray[0][0]; 783 // XXX EAM : temporarily use this to track calibration quality 784 if (0) { 785 fit1d_irls (&kronStars, Nkron); 786 image[i].McalAPER = kronStars.bSaveArray[0][0]; 787 } 780 788 781 789 if ((image[i].imageID == TEST_IMAGE1) || (image[i].imageID == TEST_IMAGE2)) { … … 795 803 image[i].McalPSF = 0.0; 796 804 } 805 806 image[i].flags |= ID_IMAGE_IMAGE_PHOTCAL; // set this flag 797 807 798 808 // minUbercalDist calculated here is the min value for any star owned by this image … … 814 824 FitDataSetFree (&psfStars); 815 825 826 return; 827 } 828 829 /* determine McalTEST values for all images -- this is not used to set measure.Mcal, but only to test */ 830 void setMcalTest (Catalog *catalog, FlatCorrectionTable *flatcorr) { 831 832 off_t i, j, m, c, n; 833 int Nfew, Nbad, Nmos, Ngrp, Nrel, Ngrid, Nsys; 834 835 int Nsecfilt = GetPhotcodeNsecfilt (); 836 837 off_t Nmax = 0; 838 for (i = 0; i < Nimage; i++) { 839 Nmax = MAX (Nmax, N_onImage[i]); 840 } 841 842 // we are making a 0-order fit and not doing bootstrap analysis: 843 FitDataSet psfStars; 844 FitDataSetAlloc (&psfStars, Nmax, 0, 0); 845 846 // for testing, need to allow this to be optional 847 if (FALSE && UseStandardOLS(ZPT_IMAGES)) { 848 psfStars.MaxIterations = 0; 849 } 850 psfStars.MaxIterations = 0; 851 852 Nfew = Nbad = Nmos = Ngrp = Ngrid = Nrel = Nsys = 0; 853 854 int Ncalibrated = 0; 855 for (i = 0; i < Nimage; i++) { 856 if (image[i].photcode == 0) continue; // skip the PHU images 857 858 off_t Nref = 0; // number of stars used to measure McalPSF 859 860 if (N_onImage[i] == 0) { 861 // fprintf (stderr, "image missing detections? %s %d "OFF_T_FMT"\n", image[i].name, image[i].nstar, N_onImage[i]); 862 continue; 863 } 864 865 for (j = 0; j < N_onImage[i]; j++) { 866 867 m = ImageToMeasure[i][j]; 868 c = ImageToCatalog[i][j]; 869 870 if (catalog[c].measureT[m].dbFlags & MEAS_BAD) { 871 Nbad++; 872 continue; 873 } 874 float Mmos = getMmos (m, c); 875 if (isnan(Mmos)) { 876 Nmos ++; 877 continue; 878 } 879 float Mgrp = getMgrp (m, c, catalog[c].measureT[m].airmass, NULL); // ignore error for now? 880 if (isnan(Mgrp)) { 881 Ngrp ++; 882 continue; 883 } 884 float Mgrid = getMgrid (m, c); 885 if (isnan(Mgrid)) { 886 Ngrid++; 887 continue; 888 } 889 890 // MrelPSF is the average magnitude for this star. 891 float MrelPSF = getMrel (catalog, m, c, MAG_CLASS_PSF, MAG_SRC_CHP); 892 if (isnan(MrelPSF)) { 893 Nrel ++; 894 continue; 895 } 896 897 // image.Mcal is not supposed to include the flat-field correction, so we need to 898 // apply that offset as well here for this image (in other words, each detection is 899 // being compared to the model, excluding the zero point, Mcal. The model includes 900 // the flat-correction. NOTE the sign of Mflat (Image.Mcal = Measure.Mcal - Mflat) 901 902 float Mflat = getMflat (m, c, flatcorr, catalog); 903 904 // get the PSF magnitude for thie measurement, with airmass slope applied 905 n = catalog[c].measureT[m].averef; 906 float MsysPSF = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt], MAG_CLASS_PSF); 907 if (isnan(MsysPSF)) { 908 Nsys++; 909 continue; 910 } 911 912 float Moff = Mmos + Mgrp + Mgrid - Mflat; 913 914 psfStars.alldata-> yVector[Nref] = MsysPSF - MrelPSF - Moff; 915 psfStars.alldata->dyVector[Nref] = MAX (catalog[c].measureT[m].dM, MIN_ERROR); 916 Nref++; 917 } 918 919 if (Nref < 5) { 920 // fprintf (stderr, "very few detections? %s %d "OFF_T_FMT"\n", image[i].name, image[i].nstar, Nref); 921 // continue; 922 image[i].McalAPER = NAN; 923 image[i].dMcal = NAN; 924 image[i].nFitPhotom = Nref; 925 image[i].McalChiSq = NAN; 926 continue; 927 } 928 929 // no additional weight modification (we treat all stars on an image equally -- note an image is either ubercal-tied or not) 930 fit1d_irls (&psfStars, Nref); 931 image[i].McalAPER = psfStars.bSaveArray[0][0]; 932 image[i].dMcal = psfStars.bSigma[0]; 933 image[i].nFitPhotom = psfStars.Nmeas; 934 image[i].McalChiSq = psfStars.chisq; 935 Ncalibrated ++; 936 } 937 938 fprintf (stderr, "%d images calibrated\n", Ncalibrated); 939 fprintf (stderr, "%d images marked having too few measurements (Nbad: %d, Nmos: %d, Ngrid: %d, Nrel: %d, Nsys: %d)\n", Nfew, Nbad, Nmos, Ngrid, Nrel, Nsys); 940 941 FitDataSetFree (&psfStars); 816 942 return; 817 943 } -
trunk/Ohana/src/relphot/src/MosaicOps.c
r41487 r41555 685 685 // if it helps, note that ubercal uses a single zp per exposure, so the mean of those values is the same as the value 686 686 687 if (!isfinite(image[m].McalPSF)) { 688 image[m].McalPSF = 0.0; 689 image[m].McalAPER = 0.0; 690 image[m].dMcal = 0.0; 691 image[m].McalChiSq = 0.0; 692 fprintf (stderr, "warning: resetting NAN value for Mcal %s\n", image[m].name); 693 } 694 687 695 McalPSF += image[m].McalPSF; 688 696 McalAPER += image[m].McalAPER; … … 694 702 image[m].dMcal = NAN; 695 703 image[m].McalChiSq = NAN; 704 696 705 } 697 706 dS /= MosaicN_Image[i]; … … 734 743 for (j = 0; j < MosaicN_Image[i]; j++) { 735 744 im = MosaicToImage[i][j]; 736 image[im].McalPSF += mosaic[i].McalPSF; 737 image[im].McalAPER += mosaic[i].McalAPER; 738 image[im].dMcal = mosaic[i].dMcal; 739 image[im].McalChiSq = mosaic[i].McalChiSq; 740 image[im].ubercalDist = mosaic[i].ubercalDist; 741 image[im].dMagSys = mosaic[i].dMsys; 742 image[im].nFitPhotom = mosaic[i].nFitPhotom; 745 if (mosaic[i].flags & ID_IMAGE_MOSAIC_PHOTCAL) { 746 image[im].McalPSF = mosaic[i].McalPSF; 747 image[im].McalAPER = mosaic[i].McalAPER; 748 image[im].dMcal = mosaic[i].dMcal; 749 image[im].McalChiSq = mosaic[i].McalChiSq; 750 image[im].ubercalDist = mosaic[i].ubercalDist; 751 image[im].dMagSys = mosaic[i].dMsys; 752 image[im].nFitPhotom = mosaic[i].nFitPhotom; 753 } 743 754 image[im].flags |= (mosaic[i].flags & ID_IMAGE_PHOTOM_FEW); 744 755 image[im].flags |= (mosaic[i].flags & ID_IMAGE_PHOTOM_POOR); 745 756 image[im].flags |= (mosaic[i].flags & ID_IMAGE_MOSAIC_POOR); 757 image[im].flags |= (mosaic[i].flags & ID_IMAGE_TGROUP_PHOTCAL); 758 image[im].flags |= (mosaic[i].flags & ID_IMAGE_MOSAIC_PHOTCAL); 759 image[im].flags |= (mosaic[i].flags & ID_IMAGE_IMAGE_PHOTCAL); 746 760 } 747 761 mosaic[i].McalPSF = 0.0; … … 756 770 757 771 // this mosaic has been identified as poor. 758 mosaic[myMosaic].flags |= ID_IMAGE_ PHOTOM_POOR;772 mosaic[myMosaic].flags |= ID_IMAGE_MOSAIC_POOR; 759 773 mosaic[myMosaic].McalPSF = 0.0; 760 774 mosaic[myMosaic].McalAPER = 0.0; … … 776 790 777 791 // this mosaic has been identified as good. 778 mosaic[myMosaic].flags &= ~ID_IMAGE_ PHOTOM_POOR;792 mosaic[myMosaic].flags &= ~ID_IMAGE_MOSAIC_POOR; 779 793 780 794 image = getimages (&Nimage, NULL); … … 1297 1311 assert (Nbright >= 0); 1298 1312 1299 psfStars->alldata-> yVector[N] = MsysPSF - MrelPSF - Mcal - Mgrid + Mflat; 1313 float Moff = Mcal + Mgrp + Mgrid - Mflat; 1314 1315 psfStars->alldata-> yVector[N] = MsysPSF - MrelPSF - Moff; 1300 1316 psfStars->alldata->dyVector[N] = MAX (catalog[c].measureT[m].dM, MIN_ERROR); 1301 1317 1302 kronStars->alldata-> yVector[N] = MsysKron - MrelKron - M cal - Mgrid + Mflat;1318 kronStars->alldata-> yVector[N] = MsysKron - MrelKron - Moff; 1303 1319 kronStars->alldata->dyVector[N] = psfStars->alldata->dyVector[N]; 1304 1320 … … 1337 1353 myMosaic[0].McalPSF = psfStars->bSaveArray[0][0]; 1338 1354 myMosaic[0].dMcal = psfStars->bSigma[0]; 1355 myMosaic[0].stdev = psfStars->sigma; 1339 1356 myMosaic[0].McalChiSq = psfStars->chisq; 1340 1357 myMosaic[0].nFitPhotom = psfStars->Nmeas; … … 1863 1880 void clean_mosaics () { 1864 1881 1865 off_t i, N, mark, Ntotal, Nmark, Nscatter, Noffset, Nrejects, Nchisq; 1866 double *mlist, *slist, *dlist; 1867 double MaxOffset, MedOffset, MaxScatter; 1882 double *mlist, *slist; 1868 1883 1869 1884 if (!MOSAIC_ZEROPT) return; … … 1874 1889 ALLOCATE (mlist, double, Nmosaic); 1875 1890 ALLOCATE (slist, double, Nmosaic); 1876 ALLOCATE (dlist, double, Nmosaic); 1877 1878 for (i = N= 0; i < Nmosaic; i++) {1891 1892 int N = 0; 1893 for (int i = 0; i < Nmosaic; i++) { 1879 1894 // if (mosaic[i].flags & IMAGE_BAD) continue; 1880 1895 if (!(mosaic[i].flags & ID_IMAGE_MOSAIC_PHOTCAL)) continue; 1881 1896 if (mosaic[i].skipCal) continue; 1882 mlist[N] = mosaic[i].McalPSF; 1883 slist[N] = mosaic[i].dMcal; 1884 dlist[N] = 1; 1897 mlist[N] = mosaic[i].McalChiSq; 1898 slist[N] = mosaic[i].stdev; 1885 1899 N++; 1886 1900 } … … 1889 1903 liststats_setmode (&stats, "MEAN"); 1890 1904 1891 liststats (mlist, dlist, NULL, N, &stats); 1892 MaxOffset = MAX (IMAGE_OFFSET, 2*stats.sigma); 1893 MedOffset = stats.median; 1894 1895 liststats (slist, dlist, NULL, N, &stats); 1896 MaxScatter = MAX (IMAGE_SCATTER, 2*stats.median); 1897 fprintf (stderr, "Mrel: %f, dMrel: %f, Max Scatter: %f, Max Offset: %f\n", MedOffset, stats.median, MaxScatter, MaxOffset); 1905 liststats (mlist, NULL, NULL, N, &stats); 1906 float MaxChiSq = stats.Upper90; 1907 1908 // old version based on Mcal value 1909 // MaxOffset = MAX (IMAGE_OFFSET, 2*stats.sigma); 1910 /// MedOffset = stats.median; 1911 1912 liststats (slist, NULL, NULL, N, &stats); 1913 float MaxScatter = stats.Upper90; 1914 // old: MaxScatter = MAX (IMAGE_SCATTER, 2*stats.median); 1915 1916 fprintf (stderr, "MOSAIC: Max ChiSq: %f, Max Scatter: %f\n", MaxChiSq, MaxScatter); 1898 1917 1899 // XXX this needs to be configurable 1900 float MaxChiSq = 10.0; 1901 1902 Ntotal = Nmark = Nscatter = Noffset = Nrejects = Nchisq = 0; 1903 for (i = 0; i < Nmosaic; i++) { 1918 int Ntotal = 0, Nmark = 0, Nscatter = 0, Nfew = 0, Nchisq = 0; 1919 for (int i = 0; i < Nmosaic; i++) { 1904 1920 // if we are keeping ubercal sacrosanct, then we should not be allowed to break them... 1905 1921 if (KEEP_UBERCAL && (mosaic[i].flags & ID_IMAGE_PHOTOM_UBERCAL)) continue; … … 1907 1923 Ntotal ++; 1908 1924 1925 if (mosaic[i].skipCal) continue; 1926 1927 int mark = FALSE; 1928 1909 1929 if (mosaic[i].flags & (ID_IMAGE_PHOTOM_FEW)) { 1910 continue; 1911 } 1912 if (mosaic[i].skipCal) continue; 1913 1914 mark = FALSE; 1915 if (mosaic[i].dMcal > MaxScatter) { 1930 mark = TRUE; 1931 Nfew ++; 1932 } 1933 if (mosaic[i].stdev > MaxScatter) { 1916 1934 mark = TRUE; 1917 1935 Nscatter ++; 1918 }1919 if (fabs(mosaic[i].McalPSF - MedOffset) > MaxOffset) {1920 mark = TRUE;1921 Noffset ++;1922 }1923 if (mosaic[i].nFitPhotom < 0.7*mosaic[i].nValPhotom) {1924 mark = TRUE;1925 Nrejects ++;1926 1936 } 1927 1937 if (mosaic[i].McalChiSq > MaxChiSq) { … … 1937 1947 } 1938 1948 1939 fprintf (stderr, OFF_T_FMT" of "OFF_T_FMT" mosaics marked poor ("OFF_T_FMT" scatter, "OFF_T_FMT" offset)\n", Nmark, Ntotal, Nscatter, Noffset);1949 fprintf (stderr, "%d of %d mosaics marked poor (%d scatter, %d chisq, %d few)\n", Nmark, Ntotal, Nscatter, Nchisq, Nfew); 1940 1950 1941 1951 free (mlist); 1942 1952 free (slist); 1943 free (dlist);1944 1953 } 1945 1954 -
trunk/Ohana/src/relphot/src/TGroupOps.c
r41487 r41555 2 2 3 3 void assignMosaicsToTGroups (void); 4 int save_test_night_measures (FILE *fout, TGroup *myTGroup, Catalog *catalog, FlatCorrectionTable *flatcorr); 4 5 5 6 // tgroupTimes carries the times of the tgroups (initially, just the photometric nights) … … 82 83 tgroup[j].dMcal = 0.0; // note : at the end, tgroup.Mcal is added back to the input images 83 84 tgroup[j].dMsys = 0.0; 85 tgroup[j].dMmin = NAN; 86 tgroup[j].dMmax = NAN; 84 87 tgroup[j].McalChiSq = 0.0; // NAN or 0.0? 85 88 … … 142 145 tgroup[j].dMcal = 0.0; // note : at the end, tgroup.Mcal is added back to the input images 143 146 tgroup[j].dMsys = 0.0; 147 tgroup[j].dMmin = NAN; 148 tgroup[j].dMmax = NAN; 144 149 tgroup[j].McalChiSq = 0.0; // NAN or 0.0? 145 150 … … 421 426 off_t im = tgroup[i].image[j]; 422 427 double Mgrp = (TGROUP_FIT_AIRMASS) ? tgroup[i].McalPSF + tgroup[i].dKlam*(image[im].secz - 1.0) : tgroup[i].McalPSF; 423 image[im].McalPSF += Mgrp; 424 image[im].McalAPER += Mgrp; 425 image[im].dMcal = tgroup[i].dMcal; 426 image[im].McalChiSq = tgroup[i].McalChiSq; 427 image[im].dMagSys = tgroup[i].dMsys; 428 image[im].nFitPhotom = tgroup[i].nFitPhotom; 428 if (tgroup[i].flags & ID_IMAGE_TGROUP_PHOTCAL) { 429 image[im].McalPSF = Mgrp; 430 image[im].McalAPER = Mgrp; 431 image[im].dMcal = tgroup[i].dMcal; 432 image[im].McalChiSq = tgroup[i].McalChiSq; 433 image[im].dMagSys = tgroup[i].dMsys; 434 image[im].nFitPhotom = tgroup[i].nFitPhotom; 435 } 429 436 image[im].flags |= (tgroup[i].flags & ID_IMAGE_NIGHT_POOR); // probably not necessary : it is set in markBadTGroup 430 437 image[im].flags |= (tgroup[i].flags & ID_IMAGE_MOSAIC_POOR); // probably not necessary : it is set in markBadTGroup … … 432 439 image[im].flags |= (tgroup[i].flags & ID_IMAGE_PHOTOM_POOR); 433 440 image[im].flags |= (tgroup[i].flags & ID_IMAGE_PHOTOM_UBERCAL); 441 image[im].flags |= (tgroup[i].flags & ID_IMAGE_TGROUP_PHOTCAL); 442 image[im].flags |= (tgroup[i].flags & ID_IMAGE_MOSAIC_PHOTCAL); 443 image[im].flags |= (tgroup[i].flags & ID_IMAGE_IMAGE_PHOTCAL); 434 444 435 445 // fprintf (stderr, "TG to IMAGE: %f +/- %f -> %f (%d)\n", tgroup[i].McalPSF, tgroup[i].dMcal, image[im].McalPSF, tgroup[i].nFitPhotom); … … 687 697 info->psfStars.MaxIterations = 0; 688 698 } 689 if (1) {690 FitDataSetAddPriors (&info->psfStars);699 FitDataSetAddPriors (&info->psfStars); // why only psfStars? 700 if (TGROUP_FIT_AIRMASS) { 691 701 info->psfStars.bPriorValue[1] = 0.0; // note that we are fitting relative to the nominal slope 692 702 info->psfStars.bPriorSigma[1] = 0.04; // XXX this prior sigma needs to be user-configured … … 812 822 int testImage = FALSE; 813 823 TGTimes *tgroup = (TGTimes *) myTGroup->parent; 814 // testImage |= (abs(tgroup->start - 1245283200) < 10); 824 double mjdStart = ohana_sec_to_mjd (tgroup->start); 825 826 // unset this flag at start (set below if zeropoint is calculated) 827 myTGroup->flags &= ~ID_IMAGE_TGROUP_PHOTCAL; 828 815 829 // testImage = TRUE; 830 testImage |= (abs(mjdStart - 57353) < 0.1); 831 testImage |= (abs(mjdStart - 57952) < 0.1); 832 testImage |= (abs(mjdStart - 55843) < 0.1); 833 testImage |= (abs(mjdStart - 56586) < 0.1); 834 testImage |= (abs(mjdStart - 57323) < 0.1); 835 //testImage |= (abs(mjdStart - 57971) < 0.1); 836 //testImage |= (abs(mjdStart - 57974) < 0.1); 837 //testImage |= (abs(mjdStart - 57978) < 0.1); 838 //testImage |= (abs(mjdStart - 57981) < 0.1); 816 839 817 840 FILE *fout = NULL; … … 820 843 snprintf (filename, 64, "test.%05d.%02d.dat", (int) Ngrp, npass_output); 821 844 fout = fopen (filename, "w"); 845 fprintf (fout, "# tgroup %s (%.0f)\n", ohana_sec_to_date(tgroup->start), mjdStart); 846 save_test_night_measures (fout, myTGroup, catalog, flatcorr); 847 fclose (fout); 822 848 } 823 849 … … 831 857 off_t c = myTGroup->catalog[j]; 832 858 833 // NOTE : we are only using Mcal == McalPSF in this function; we set McalAPER to McalPSF834 if (fout) {835 836 float Mcal = getMcal (m, c, MAG_CLASS_PSF); // image zero point837 float Mmos = getMmos (m, c); // mosaic zero point838 // XXX these two should both be 0.0 if we are fitting tgroups : skip those calls above?839 840 float Mgrid = getMgrid (m, c); // camera offset (deprecated?)841 float MrelPSF = getMrel (catalog, m, c, MAG_CLASS_PSF, MAG_SRC_CHP); // average magnitude842 float Mflat = getMflat (m, c, flatcorr, catalog); // flat-field correction843 844 off_t n = catalog[c].measureT[m].averef;845 846 // magnitude for this measurement847 float MsysPSF = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt], MAG_CLASS_PSF);848 849 // for historical reasons, Mflat is defined with the wrong sign850 float delta = MsysPSF - MrelPSF - Mcal - Mmos - Mgrid + Mflat;851 852 int isBad = (catalog[c].measureT[m].dbFlags & MEAS_BAD);853 854 fprintf (fout, "%f %f : %f %f %f %f %f : %f %f %d\n", catalog[c].averageT[n].R, catalog[c].averageT[n].D, MsysPSF, MrelPSF, Mcal, Mgrid, Mflat, catalog[c].measureT[m].airmass, delta, isBad);855 }856 857 859 if (catalog[c].measureT[m].dbFlags & MEAS_BAD) { 858 860 info->Nbad ++; … … 916 918 assert (Nbright >= 0); 917 919 918 psfStars->alldata-> yVector[N] = MsysPSF - MrelPSF - Mcal - Mgrid + Mflat; 919 psfStars->alldata-> xVector[N] = (catalog[c].measureT[m].airmass - 1.0); 920 float Moff = Mcal + Mmos + Mgrid - Mflat; 921 922 psfStars->alldata-> yVector[N] = MsysPSF - MrelPSF - Moff; 920 923 psfStars->alldata->dyVector[N] = MAX (catalog[c].measureT[m].dM, MIN_ERROR); 921 924 922 kronStars->alldata-> yVector[N] = MsysKron - MrelKron - Mcal - Mgrid + Mflat; 923 kronStars->alldata-> xVector[N] = psfStars->alldata-> xVector[N]; 925 kronStars->alldata-> yVector[N] = MsysKron - MrelKron - Moff; 924 926 kronStars->alldata->dyVector[N] = psfStars->alldata->dyVector[N]; 927 928 if (TGROUP_FIT_AIRMASS) { 929 psfStars->alldata-> xVector[N] = (catalog[c].measureT[m].airmass - 1.0); 930 kronStars->alldata-> xVector[N] = psfStars->alldata-> xVector[N]; 931 } 925 932 926 933 if (catalog[c].measureT[m].dM < IMFIT_SYS_SIGMA_LIM) { 927 934 brightStars->alldata-> yVector[Nbright] = psfStars->alldata-> yVector[N]; 928 brightStars->alldata-> xVector[Nbright] = psfStars->alldata-> xVector[N];929 935 brightStars->alldata->dyVector[Nbright] = psfStars->alldata->dyVector[N]; 936 if (TGROUP_FIT_AIRMASS) { 937 brightStars->alldata-> xVector[Nbright] = psfStars->alldata-> xVector[N]; 938 } 930 939 Nbright ++; 931 940 } 932 941 N++; 933 942 } 934 if (fout) { fclose (fout); }935 943 936 944 /* too few good measurements or too many bad measurements (skip in PoorImages run) */ 937 945 int mark = (N < NIGHT_TOOFEW) || (N < NIGHT_GOOD_FRACTION*myTGroup->Nmeasure); 938 946 if (mark) { 939 if ( VERBOSE2) {947 if (TRUE) { 940 948 TGTimes *mygroup = (TGTimes *) myTGroup->parent; 941 fprintf (stderr, "marked tgroup %f,%d, (%d < %d) || (%d < %f*"OFF_T_FMT")\n", ohana_sec_to_mjd(mygroup->start), myTGroup->photcode, N, NIGHT_TOOFEW, N, NIGHT_GOOD_FRACTION, myTGroup->Nmeasure); 949 if (0) { // XXX EAM 950 fprintf (stderr, "marked tgroup %f,%d, (%d < %d) || (%d < %f*"OFF_T_FMT")\n", ohana_sec_to_mjd(mygroup->start), myTGroup->photcode, N, NIGHT_TOOFEW, N, NIGHT_GOOD_FRACTION, myTGroup->Nmeasure); 951 } 942 952 } 943 953 myTGroup->flags |= ID_IMAGE_PHOTOM_FEW; 954 myTGroup->nValPhotom = N; 944 955 info->Nfew ++; 945 956 if (testImage) { … … 949 960 } else { 950 961 myTGroup->flags &= ~ID_IMAGE_PHOTOM_FEW; 962 } 963 964 /* we have a non-trivial fraction of measurements which are extreme outliers, and 965 measurements with very small errors. To avoid over-weighting measurements with very 966 small errors, let's add something in quadarature. 967 */ 968 969 // use liststats to find the 20-pct, median, 80-pct points 970 StatType stats; 971 liststats_setmode (&stats, "MEDIAN"); 972 liststats (psfStars->alldata->yVector, NULL, NULL, N, &stats); 973 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) 974 975 TGTimes *mygroup = (TGTimes *) myTGroup->parent; 976 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); 977 978 // soften the individual errors with 10% of the scatter above 979 for (j = 0; j < N; j++) { 980 double newSigma = hypot(psfStars->alldata->dyVector[j], 0.1*altSigma); 981 psfStars->alldata->dyVector[j] = newSigma; 951 982 } 952 983 … … 962 993 myTGroup->dMcal = psfStars->bSigma[0]; 963 994 myTGroup->stdev = psfStars->sigma; 995 myTGroup->dMmin = psfStars->min; 996 myTGroup->dMmax = psfStars->max; 964 997 myTGroup->McalChiSq = psfStars->chisq; 965 998 myTGroup->nFitPhotom = psfStars->Nmeas; 966 999 myTGroup->nValPhotom = N; 967 myTGroup->dKlam = psfStars->bSaveArray[1][0];1000 myTGroup->dKlam = (TGROUP_FIT_AIRMASS) ? psfStars->bSaveArray[1][0] : 0; 968 1001 969 1002 // XXX this does not make sense: I need to apply the airmass slope calculated above first … … 991 1024 } 992 1025 1026 myTGroup->flags |= ID_IMAGE_TGROUP_PHOTCAL; // set this flag 1027 993 1028 if (testImage) { 994 1029 fprintf (stderr, "%f %f : %f\n", myTGroup->McalPSF, myTGroup->dMsys, myTGroup->McalChiSq); … … 998 1033 } 999 1034 1035 int save_test_night_measures (FILE *fout, TGroup *myTGroup, Catalog *catalog, FlatCorrectionTable *flatcorr) { 1036 1037 int Nsecfilt = GetPhotcodeNsecfilt (); 1038 1039 for (int j = 0; j < myTGroup->Nmeasure; j++) { 1040 1041 off_t m = myTGroup->measure[j]; 1042 off_t c = myTGroup->catalog[j]; 1043 1044 // XXX these two should both be 0.0 if we are fitting tgroups 1045 float Mcal = getMcal (m, c, MAG_CLASS_PSF); // image zero point 1046 float Mmos = getMmos (m, c); // mosaic zero point 1047 1048 float Mgrid = getMgrid (m, c); // camera offset (deprecated?) 1049 float MrelPSF = getMrel (catalog, m, c, MAG_CLASS_PSF, MAG_SRC_CHP); // average magnitude 1050 float Mflat = getMflat (m, c, flatcorr, catalog); // flat-field correction 1051 1052 off_t n = catalog[c].measureT[m].averef; 1053 1054 // magnitude for this measurement 1055 float MsysPSF = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt], MAG_CLASS_PSF); 1056 1057 // for historical reasons, Mflat is defined with the wrong sign 1058 float delta = MsysPSF - MrelPSF - Mcal - Mmos - Mgrid + Mflat - myTGroup->McalPSF; 1059 1060 int isBad = (catalog[c].measureT[m].dbFlags & MEAS_BAD); 1061 1062 double mjdMeas = ohana_sec_to_mjd (catalog[c].measureT[m].t); 1063 1064 fprintf (fout, "%f %f : %f %f %f %f %f : %f %f %d : %f\n", 1065 catalog[c].averageT[n].R, catalog[c].averageT[n].D, 1066 MsysPSF, MrelPSF, Mcal, Mgrid, Mflat, catalog[c].measureT[m].airmass, delta, isBad, mjdMeas); 1067 1068 } 1069 return TRUE; 1070 } 1071 1000 1072 int setMgrp_threaded (Catalog *catalog, int PoorImages, FlatCorrectionTable *flatcorr) { 1001 1073 … … 1221 1293 } 1222 1294 1223 /* mark tgroup if: abs(Mcal - <Mcal>) too large, dMcal too large */ 1295 /* new rules for bad tgroups (bad nights) 1296 * too few exposures (Nmosaic < X) 1297 * dMsys or stdev > X 1298 * X%-ile of dMsys or stdev 1299 * McalChiSq > X 1300 * X%-ile of McalChiSq 1301 1302 * I can define rules for these but they would be arbitrary 1303 * I think I should do an analysis of the observed distribution 1304 1305 */ 1306 1224 1307 void clean_tgroups () { 1225 1308 1226 off_t mark, Ntotal, Nmark, Nscatter, Noffset, Nrejects, Nchisq; 1227 double *mlist, *slist, *dlist; 1228 double MaxOffset, MedOffset, MaxScatter; 1309 double *mlist, *slist; 1229 1310 1230 1311 if (!TGROUP_ZEROPT) return; … … 1234 1315 ALLOCATE (mlist, double, NtgroupTimes*Nphotcodes); 1235 1316 ALLOCATE (slist, double, NtgroupTimes*Nphotcodes); 1236 ALLOCATE (dlist, double, NtgroupTimes*Nphotcodes);1237 1317 1238 1318 int N = 0; … … 1241 1321 for (int j = 0; j < tgroupTimes[i][0].nCode; j++) { 1242 1322 if (tgroup[j].flags & IMAGE_BAD) continue; 1243 mlist[N] = tgroup[j].Mcal PSF;1244 slist[N] = tgroup[j]. dMcal;1245 dlist[N] = 1;1323 mlist[N] = tgroup[j].McalChiSq; 1324 slist[N] = tgroup[j].stdev; // stdev of all measurements 1325 // slist[N] = tgroup[j].dMsys; // stdev of bright measurements 1246 1326 N++; 1247 1327 } … … 1251 1331 liststats_setmode (&stats, "MEAN"); 1252 1332 1253 liststats (mlist, dlist, NULL, N, &stats);1254 MaxOffset = MAX (NIGHT_OFFSET, 3*stats.sigma);1255 MedOffset = stats.median; 1256 1257 liststats (slist, dlist, NULL, N, &stats);1258 MaxScatter = MAX (NIGHT_SCATTER, 2*stats.median); 1259 fprintf (stderr, "TGROUPS: median Mrel: %f, median dMrel: %f, Max Offset: %f, Max Scatter: %f\n", MedOffset, stats.median, MaxOffset, MaxScatter);1333 liststats (mlist, NULL, NULL, N, &stats); 1334 float MaxChiSq = stats.Upper90; 1335 1336 liststats (slist, NULL, NULL, N, &stats); 1337 float MaxScatter = stats.Upper90; 1338 1339 fprintf (stderr, "TGROUPS: Max ChiSq: %f, Max Scatter: %f\n", MaxChiSq, MaxScatter); 1260 1340 1261 // XXX this needs to be configurable 1262 float MaxChiSq = 10.0; 1263 1264 Ntotal = Nmark = Nscatter = Noffset = Nrejects = Nchisq = 0; 1341 int Ntotal = 0, Nmark = 0, Nscatter = 0, Nchisq = 0, NfewNights = 0, NfewExp = 0; 1265 1342 for (int i = 0; i < NtgroupTimes; i++) { 1266 1343 TGroup *tgroup = tgroupTimes[i][0].byCode; … … 1269 1346 Ntotal ++; 1270 1347 1271 // ignore the nights with too few measurements1272 // XXX what to do with nights with too few measurements? 1273 // XXX probably free the images to be fitted1348 int mark = FALSE; 1349 1350 // too few measurements (set in setMgrp_tgroup) 1274 1351 if (tgroup[j].flags & ID_IMAGE_PHOTOM_FEW) { 1275 mark BadTGroup(&tgroup[j]); // mark the image associated with a bad night1276 continue;1352 mark = TRUE; 1353 NfewNights ++; 1277 1354 } 1278 1279 mark = FALSE; 1280 if (tgroup[j].dMcal > MaxScatter) { 1355 // too few exposures (configure) 1356 if (tgroup[j].Nmosaic < 4) { 1357 mark = TRUE; 1358 NfewExp ++; 1359 } 1360 // scatter too large 1361 if (tgroup[j].stdev > MaxScatter) { 1281 1362 mark = TRUE; 1282 1363 Nscatter ++; 1283 1364 } 1284 if (fabs(tgroup[j].McalPSF - MedOffset) > MaxOffset) { 1285 mark = TRUE; 1286 Noffset ++; 1287 } 1288 if (tgroup[j].nFitPhotom < 0.7*tgroup[j].nValPhotom) { 1289 mark = TRUE; 1290 Nrejects ++; 1291 } 1365 // chisq too large 1292 1366 if (tgroup[j].McalChiSq > MaxChiSq) { 1293 1367 mark = TRUE; … … 1303 1377 } 1304 1378 1305 fprintf (stderr, OFF_T_FMT" of "OFF_T_FMT" tgroups marked poor ("OFF_T_FMT" scatter, "OFF_T_FMT" offset, "OFF_T_FMT" rejects, "OFF_T_FMT" chisq)\n", Nmark, Ntotal, Nscatter, Noffset, Nrejects, Nchisq);1379 fprintf (stderr, "%d of %d tgroups marked poor (%d scatter, %d few nights, %d few exposures, %d chisq)\n", Nmark, Ntotal, Nscatter, NfewNights, NfewExp, Nchisq); 1306 1380 1307 1381 free (mlist); 1308 1382 free (slist); 1309 free (dlist);1310 1383 } 1311 1384 … … 1465 1538 } 1466 1539 } 1540 1541 void dump_tgroup_imstats (int Npass) { 1542 1543 FILE *fout = NULL; 1544 char filename[64]; 1545 1546 snprintf (filename, 64, "imstats.grp.%02d.dat", Npass); 1547 fout = fopen (filename, "w"); 1548 1549 for (off_t i = 0; i < NtgroupTimes; i++) { 1550 1551 TGroup *tgroup = tgroupTimes[i][0].byCode; 1552 for (off_t j = 0; j < tgroupTimes[i][0].nCode; j++) { 1553 fprintf (fout, "%.0f %5d | %6ld %6d %6d %4ld %4ld | 0x%08x %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f\n", 1554 ohana_sec_to_mjd(tgroupTimes[i][0].start), tgroup[j].photcode, 1555 tgroup[j].Nmeasure, tgroup[j].nFitPhotom, tgroup[j].nValPhotom, tgroup[j].Nimage, tgroup[j].Nmosaic, 1556 tgroup[j].flags, tgroup[j].McalPSF, tgroup[j].dKlam, tgroup[j].dMcal, tgroup[j].dMsys, tgroup[j].stdev, tgroup[j].dMmin, tgroup[j].dMmax, tgroup[j].McalChiSq); 1557 } 1558 } 1559 fclose (fout); 1560 1561 // ************ mosaic stats 1562 1563 snprintf (filename, 64, "imstats.mos.%02d.dat", Npass); 1564 fout = fopen (filename, "w"); 1565 1566 for (off_t i = 0; i < NtgroupTimes; i++) { 1567 1568 TGroup *tgroup = tgroupTimes[i][0].byCode; 1569 for (off_t j = 0; j < tgroupTimes[i][0].nCode; j++) { 1570 1571 for (off_t k = 0; k < tgroup->Nmosaic; k++) { 1572 Mosaic *mosaic = tgroup[j].mosaic[k]; 1573 1574 fprintf (fout, "%4ld %3ld %3ld %.0f %5d %5d %5d | %12.5f %5.3f 0x%08x | %6.3f %6.3f %6.3f %6.3f\n", 1575 i, j, k, ohana_sec_to_mjd(tgroupTimes[i][0].start), mosaic->photcode, mosaic->nFitPhotom, mosaic->nValPhotom, 1576 ohana_sec_to_mjd(mosaic->start), mosaic->secz, mosaic->flags, 1577 mosaic->McalPSF, mosaic->dMcal, mosaic->dMsys, mosaic->McalChiSq); 1578 } 1579 } 1580 } 1581 fclose (fout); 1582 1583 // ************ image stats 1584 1585 snprintf (filename, 64, "imstats.chp.%02d.dat", Npass); 1586 fout = fopen (filename, "w"); 1587 1588 off_t Nimage = 0; 1589 Image *image = getimages (&Nimage, NULL); 1590 for (off_t i = 0; i < NtgroupTimes; i++) { 1591 1592 TGroup *tgroup = tgroupTimes[i][0].byCode; 1593 for (off_t j = 0; j < tgroupTimes[i][0].nCode; j++) { 1594 1595 for (off_t k = 0; k < tgroup->Nimage; k++) { 1596 off_t im = tgroup[j].image[k]; 1597 1598 fprintf (fout, "%4ld %3ld %3ld %.0f %5d | %12.5f %5.3f 0x%08x | %6.3f %6.3f %6.3f %6.3f %6.3f\n", 1599 i, j, k, ohana_sec_to_mjd(tgroupTimes[i][0].start), image[im].photcode, 1600 ohana_sec_to_mjd(image[im].tzero), image[im].secz, image[im].flags, 1601 image[im].McalPSF, image[im].McalAPER, image[im].dMcal, image[im].dMagSys, image[im].McalChiSq); 1602 } 1603 } 1604 } 1605 1606 fclose (fout); 1607 } -
trunk/Ohana/src/relphot/src/ZeroPointModes.c
r41473 r41555 4 4 5 5 void SetZptIteration (int current) { 6 // XXX add 'manual' option here: ask for desired zpt iteration 7 if (MANUAL_ITERATION) { 8 int newValue; 9 fprintf (stdout, "Set Iteration (current = %d): ", CurrentLoop); 10 fscanf (stdin, "%d", &newValue); 11 fprintf (stdout, "Using iteration %d\n", newValue); 12 CurrentLoop = newValue; 13 return; 14 } 15 16 // automatic iteration: 6 17 CurrentLoop = current; 7 18 } … … 14 25 15 26 if (TGROUP_ZEROPT && MOSAIC_ZEROPT) { 16 if ((CurrentLoop > 4) && (CurrentLoop <= 8)) { 27 if (CurrentLoop < 6) { 28 TGROUP_ZPT_MODE = TGROUP_ZPT_MODE_ALL; 29 IMAGE_ZPT_MODE = IMAGE_ZPT_MODE_NONE; 30 MOSAIC_ZPT_MODE = MOSAIC_ZPT_MODE_NONE; 31 } 32 if ((CurrentLoop >= 6) && (CurrentLoop < 12)) { 17 33 // after iterating a few times on the TGroup zero points: 18 34 // * identify the photometric nights … … 23 39 clean_tgroups(); // do this on every pass to update the status of nights 24 40 } 25 if ((CurrentLoop > 8) && (CurrentLoop <= 999)) {41 if ((CurrentLoop >= 12) && (CurrentLoop < 18)) { 26 42 // after iterating a few times on the TGroup & Mosaic zero points: 27 43 // * identify the good / bad Mosaics … … 33 49 clean_mosaics(); // do this on every pass 34 50 } 51 if ((CurrentLoop >= 18) && (CurrentLoop <= 999)) { 52 // after iterating a few times on the TGroup & Mosaic zero points: 53 // * identify the good / bad Mosaics 54 // * fit the chips from the bad Mosaics 55 TGROUP_ZPT_MODE = TGROUP_ZPT_MODE_GOOD_NIGHT; // stop fitting the bad nights 56 MOSAIC_ZPT_MODE = MOSAIC_ZPT_MODE_BAD_NIGHT_GOOD_MOSAIC; // only fit good mosaics on bad nights 57 IMAGE_ZPT_MODE = IMAGE_ZPT_MODE_BAD_NIGHT_BAD_MOSAIC; // only fit bad mosaics on bad nights 58 clean_tgroups(); // do this on every pass 59 clean_mosaics(); // do this on every pass 60 clean_images(); // do this on every pass 61 } 35 62 } 36 63 37 64 if (TGROUP_ZEROPT && !MOSAIC_ZEROPT) { 65 if (CurrentLoop <= 4) { 66 TGROUP_ZPT_MODE = TGROUP_ZPT_MODE_ALL; 67 IMAGE_ZPT_MODE = IMAGE_ZPT_MODE_NONE; 68 MOSAIC_ZPT_MODE = MOSAIC_ZPT_MODE_NONE; 69 } 38 70 if ((CurrentLoop > 4) && (CurrentLoop <= 999)) { 39 71 // after iterating a few times on the TGroup zero points: … … 48 80 49 81 if (!TGROUP_ZEROPT && MOSAIC_ZEROPT) { 82 if (CurrentLoop <= 4) { 83 TGROUP_ZPT_MODE = TGROUP_ZPT_MODE_NONE; 84 MOSAIC_ZPT_MODE = MOSAIC_ZPT_MODE_ALL; 85 IMAGE_ZPT_MODE = IMAGE_ZPT_MODE_NONE; 86 } 50 87 if ((CurrentLoop > 4) && (CurrentLoop <= 999)) { 51 88 // after iterating a few times on the Mosaic zero points: … … 60 97 61 98 if (!TGROUP_ZEROPT && !MOSAIC_ZEROPT) { 62 if ((CurrentLoop > 4) && (CurrentLoop <= 999)) { 63 // after iterating a few times on the Image zero points: 64 // * ??? 65 TGROUP_ZPT_MODE = TGROUP_ZPT_MODE_NONE; 66 MOSAIC_ZPT_MODE = MOSAIC_ZPT_MODE_NONE; 67 IMAGE_ZPT_MODE = IMAGE_ZPT_MODE_ALL; 68 } 99 // if we are not fitting TGROUP or MOSAIC, just fit all images 100 TGROUP_ZPT_MODE = TGROUP_ZPT_MODE_NONE; 101 MOSAIC_ZPT_MODE = MOSAIC_ZPT_MODE_NONE; 102 IMAGE_ZPT_MODE = IMAGE_ZPT_MODE_ALL; 69 103 } 70 104 } … … 83 117 return FALSE; 84 118 case ZPT_MOSAIC: 119 if (CurrentLoop < 9) return TRUE; 120 return FALSE; 121 case ZPT_IMAGES: 122 default: 123 if (CurrentLoop < 15) return TRUE; 124 return FALSE; 125 } 126 } 127 128 if (TGROUP_ZEROPT && !MOSAIC_ZEROPT) { 129 switch (mode) { 130 case ZPT_STARS: 131 if (CurrentLoop < 3) return TRUE; 132 return FALSE; 133 case ZPT_TGROUP: 134 case ZPT_MOSAIC: 135 if (CurrentLoop < 3) return TRUE; 136 return FALSE; 137 case ZPT_IMAGES: 138 default: 85 139 if (CurrentLoop < 7) return TRUE; 86 140 return FALSE; 87 case ZPT_IMAGES: 88 default: 89 if (CurrentLoop < 11) return TRUE; 90 return FALSE; 91 } 92 } 93 94 if (TGROUP_ZEROPT && !MOSAIC_ZEROPT) { 141 } 142 } 143 144 if (!TGROUP_ZEROPT && MOSAIC_ZEROPT) { 95 145 switch (mode) { 96 146 case ZPT_STARS: … … 108 158 } 109 159 110 if (!TGROUP_ZEROPT && MOSAIC_ZEROPT) {111 switch (mode) {112 case ZPT_STARS:113 if (CurrentLoop < 3) return TRUE;114 return FALSE;115 case ZPT_TGROUP:116 case ZPT_MOSAIC:117 if (CurrentLoop < 3) return TRUE;118 return FALSE;119 case ZPT_IMAGES:120 default:121 if (CurrentLoop < 7) return TRUE;122 return FALSE;123 }124 }125 126 160 if (!TGROUP_ZEROPT && !MOSAIC_ZEROPT) { 127 161 switch (mode) { … … 139 173 return FALSE; 140 174 } 175 176 /* TGROUP & MOSAIC: 177 0 - TGROUP ONLY & OLS 178 1 - TGROUP ONLY & OLS 179 2 - TGROUP ONLY & OLS 180 181 3 - TGROUP ONLY & IRLS 182 4 - TGROUP ONLY & IRLS 183 5 - TGROUP ONLY & IRLS 184 185 6 - TGROUP + MOSAIC & OLS MOSAIC 186 7 - TGROUP + MOSAIC & OLS MOSAIC 187 8 - TGROUP + MOSAIC & OLS MOSAIC 188 189 9 - TGROUP + MOSAIC & IRLS MOSAIC 190 10 - TGROUP + MOSAIC & IRLS MOSAIC 191 11 - TGROUP + MOSAIC & IRLS MOSAIC 192 193 12 - TGROUP + MOSAIC + IMAGE & OLS IMAGE 194 13 - TGROUP + MOSAIC + IMAGE & OLS IMAGE 195 14 - TGROUP + MOSAIC + IMAGE & OLS IMAGE 196 197 15 - TGROUP + MOSAIC + IMAGE & IRLS IMAGE 198 16 - TGROUP + MOSAIC + IMAGE & IRLS IMAGE 199 17 - TGROUP + MOSAIC + IMAGE & IRLS IMAGE 200 201 */ 202 -
trunk/Ohana/src/relphot/src/args.c
r41485 r41555 192 192 } 193 193 194 MANUAL_ITERATION = FALSE; 195 if ((N = get_argument (argc, argv, "-manual-iteration"))) { 196 remove_argument (N, &argc, argv); 197 MANUAL_ITERATION = TRUE; 198 } 199 194 200 NGRID = 8; 195 201 if ((N = get_argument (argc, argv, "-ngrid"))) { … … 325 331 USE_MCAL_PSF_FOR_STACK_APER = TRUE; 326 332 } 327 328 333 329 334 // default behavior is to fit all chips independently -
trunk/Ohana/src/relphot/src/liststats.c
r41462 r41555 26 26 stats->Upper80 = NAN; 27 27 stats->Lower20 = NAN; 28 stats->Upper90 = NAN; 29 stats->Lower10 = NAN; 28 30 stats->total = NAN; 29 31 stats->Nmeas = 0; … … 49 51 if (N < 1) return (FALSE); 50 52 53 int N90 = MIN (N-1, 0.9*N); 51 54 int N80 = MIN (N-1, 0.8*N); 52 55 int N20 = MAX (0, 0.2*N); 56 int N10 = MAX (0, 0.1*N); 53 57 54 58 if (weight) { … … 68 72 stats[0].Upper80 = value[N80]; 69 73 stats[0].Lower20 = value[N20]; 74 stats[0].Upper90 = value[N90]; 75 stats[0].Lower10 = value[N10]; 70 76 71 77 switch (stats->statmode) { … … 116 122 WeightedMean |= (stats->statmode == STATS_INNER_WTMEAN); 117 123 WeightedMean |= (stats->statmode == STATS_CHI_INNER_WTMEAN); 124 if (!dvalue) WeightedMean = FALSE; // warn the user? 118 125 119 126 /* calculating the per-star offset based on the desired weighting scheme */ … … 137 144 M += value[i] * weight[i]; 138 145 W += weight[i]; 139 dM += SQ (weight[i] * dvalue[i]);146 dM += dvalue ? SQ (weight[i] * dvalue[i]) : 0.0; 140 147 R += weight[i]; 141 148 Nm += 1.0; 142 149 } 143 150 Mo = M / W; 144 dMo = sqrt (dM) / R;151 dMo = dvalue ? sqrt (dM) / R : NAN; 145 152 } 146 153 } else { … … 159 166 for (i = ks; i < ke; i++) { 160 167 M += value[i]; 161 dM += SQ (dvalue[i]);168 dM += dvalue ? SQ (dvalue[i]) : 0.0; 162 169 Nm += 1.0; 163 170 } 164 171 Mo = M / Nm; 165 dMo = sqrt (dM) / Nm;172 dMo = dvalue ? sqrt (dM) / Nm : NAN; 166 173 } 167 174 } -
trunk/Ohana/src/relphot/src/load_images.c
r41404 r41555 58 58 // images / detections may have been added 59 59 for (off_t i = 0; i < Nsubset; i++) { 60 if (subset[i].flags & ID_IMAGE_PHOTOM_FEW) { 61 subset[i].flags &= ~(ID_IMAGE_PHOTOM_FEW | ID_IMAGE_PHOTOM_POOR); 62 } 60 // reset these two regardless (we will re-determine) 61 subset[i].flags &= ~(ID_IMAGE_PHOTOM_NOCAL | ID_IMAGE_PHOTOM_POOR | ID_IMAGE_PHOTOM_SKIP | ID_IMAGE_PHOTOM_FEW); 63 62 if (RESET) { 64 63 if (RESET_ZEROPTS) { … … 70 69 } 71 70 } 72 subset[i].flags &= ~ID_IMAGE_PHOTOM_POOR; 71 subset[i].flags &= ~(ID_IMAGE_MOSAIC_POOR | ID_IMAGE_NIGHT_POOR); 72 subset[i].flags &= ~(ID_IMAGE_IMAGE_PHOTCAL | ID_IMAGE_MOSAIC_PHOTCAL | ID_IMAGE_TGROUP_PHOTCAL); 73 73 subset[i].ubercalDist = 1000; 74 74 } -
trunk/Ohana/src/relphot/src/relphot_images.c
r41473 r41555 117 117 for (i = 0; i < NLOOP; i++) { 118 118 SetZptIteration (i); 119 119 120 dump_tgroups (catalog, i); 120 121 dump_catalog (catalog, 0, i); // for a test, just dump a specific catalog 122 dump_tgroup_imstats (i); 121 123 122 124 setMrel (catalog, Ncatalog, flatcorr); // threaded 125 setMcalTest (catalog, flatcorr); 126 123 127 dump_tgroups (catalog, i + 20); 124 128 dump_catalog (catalog, 0, i + 20); // for a test, just dump a specific catalog 129 dump_tgroup_imstats (i + 20); 125 130 126 131 setMcal (catalog, FALSE, flatcorr); … … 129 134 dump_tgroups (catalog, i + 40); 130 135 dump_catalog (catalog, 0, i + 40); // for a test, just dump a specific catalog 136 dump_tgroup_imstats (i + 40); 131 137 132 138 setMgrid (catalog, flatcorr); … … 143 149 144 150 global_stats (catalog, Ncatalog, flatcorr, i); 145 146 151 SetZeroPointModes (); 152 147 153 MARKTIME("-- finished loop %d: %f sec\n", i, dtime); 148 154 fprintf (stderr, "----- continue loop %d -----\n", i); -
trunk/Ohana/src/relphot/src/setMrelCatalog.c
r41473 r41555 272 272 float Map = NAN; 273 273 float dMap = NAN; 274 275 // XXX I am not convinced the sign on Mflat here is correct 276 float Moff = Mflat + Mcal + Mmos + Mgrp + Mgrid; 277 274 278 if (isSetMrelFinal) { 275 279 Map = PhotCat (&measure[k], MAG_CLASS_APER); … … 282 286 if (CHECK_VALID_MAG(Map, dMap)) { 283 287 int Nap = results->aperData[Nsec].Nlist; 284 results->aperData[Nsec].flxlist[Nap] = Map - M flat - Mcal - Mmos - Mgrp - Mgrid; // this is consistent with PhotRel288 results->aperData[Nsec].flxlist[Nap] = Map - Moff; // this is consistent with PhotRel 285 289 results->aperData[Nsec].errlist[Nap] = dMap; 286 290 results->aperData[Nsec].wgtlist[Nap] = modifiedWeight; … … 302 306 if (CHECK_VALID_MAG(Mkron, dMkron)) { 303 307 int Nkron = results->kronData[Nsec].Nlist; 304 results->kronData[Nsec].flxlist[Nkron] = Mkron - M flat - Mcal - Mmos - Mgrp - Mgrid; // this is consistent with PhotRel308 results->kronData[Nsec].flxlist[Nkron] = Mkron - Moff; // this is consistent with PhotRel 305 309 results->kronData[Nsec].errlist[Nkron] = dMkron; 306 310 results->kronData[Nsec].wgtlist[Nkron] = modifiedWeight; … … 315 319 if (CHECK_VALID_MAG(Mpsf, dMpsf)) { 316 320 int Npsf = results->psfData[Nsec].Nlist; 317 results->psfData[Nsec].flxlist[Npsf] = Mpsf - M flat - Mcal - Mmos - Mgrp - Mgrid; // this is consistent with PhotRel321 results->psfData[Nsec].flxlist[Npsf] = Mpsf - Moff; // this is consistent with PhotRel 318 322 results->psfData[Nsec].errlist[Npsf] = dMpsf; 319 323 results->psfData[Nsec].wgtlist[Npsf] = modifiedWeight;
Note:
See TracChangeset
for help on using the changeset viewer.
