- Timestamp:
- Jul 1, 2016, 4:38:39 PM (10 years ago)
- Location:
- trunk/Ohana/src/relphot/src
- Files:
-
- 2 edited
-
relphot_objects.c (modified) (1 diff)
-
setMrelCatalog.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/relphot/src/relphot_objects.c
r39609 r39621 129 129 initMrel (&catalog, 1); 130 130 setMrelFinal (&catalog, NULL, TRUE); 131 132 // uncomment for extra verbosity 133 // MARKTIME("setMrelFinal for "OFF_T_FMT" average "OFF_T_FMT" measure : %f sec\n", catalog.Naverage, catalog.Nmeasure, dtime); 134 // gettimeofday (&startTimer, NULL); // reset timer 135 131 136 // XXX if we want to have options for setting warp, chip, stack independently, we need to init only the desired ones 132 137 // NOTE flatcorr == NULL, but it should have been applied already by setphot -
trunk/Ohana/src/relphot/src/setMrelCatalog.c
r39620 r39621 1 1 # include "relphot.h" 2 2 3 /* 4 # define TEST_OBJ_ID 0x 3ae25 # define TEST_CAT_ID 0x 16c5f6 */ 3 # if (0) 4 # define TEST_OBJ_ID 0x0000000e 5 # define TEST_CAT_ID 0x000076ee 6 # else 7 7 # define TEST_OBJ_ID 0 8 8 # define TEST_CAT_ID 0 9 9 # endif 10 11 int magStatsByRankingClipped (StatDataSet *dataset, StatType *stats); 10 12 int markMeasureByRanking (StatDataSet *dataset, Measure *measure, int minrank, DVOMeasureFlags flags); 11 13 void GetPhotFlagStats (uint32_t *photFlagUpper, uint32_t *photFlagLower, uint32_t *photflag_list, int Nphotflag); 14 void sort_entry_by_offset (double *offset, int *entry, int N); 15 void sort_StatDataSet (StatDataSet *dataset); 12 16 13 17 # define UBERCAL_WEIGHT 100.0 14 void sort_StatDataSet (StatDataSet *dataset);15 18 16 19 # define SKIP_THIS_MEAS(REASON) { \ … … 903 906 // if too few valid measurements meet the minimum criteria, go to the next entry 904 907 StatType *psfstats = &results->psfstats; 905 int Nranking = magStatsByRanking (&results->psfData[Nsec], psfstats);908 int Nranking = magStatsByRankingClipped (&results->psfData[Nsec], psfstats); 906 909 if (Nranking) { 907 910 secfilt[Nsec].FpsfWrp = psfstats->mean; … … 916 919 // if too few valid measurements meet the minimum criteria, go to the next entry 917 920 StatType *apstats = &results->apstats; 918 Nranking = magStatsByRanking (&results->aperData[Nsec], apstats);921 Nranking = magStatsByRankingClipped (&results->aperData[Nsec], apstats); 919 922 if (Nranking) { 920 923 secfilt[Nsec].FapWrp = apstats->mean; … … 927 930 // if too few valid measurements meet the minimum criteria, go to the next entry 928 931 StatType *kronstats = &results->kronstats; 929 Nranking = magStatsByRanking (&results->kronData[Nsec], kronstats);932 Nranking = magStatsByRankingClipped (&results->kronData[Nsec], kronstats); 930 933 if (Nranking) { 931 934 secfilt[Nsec].FkronWrp = kronstats->mean; … … 963 966 } 964 967 965 # if (0)966 968 // outlier warp measurements are driving bad mean values. 967 969 int magStatsByRankingClipped (StatDataSet *dataset, StatType *stats) { … … 985 987 // since we are only allowed to clip at most 25% of the points, we need to have at least 4 points to do this clipping 986 988 if (Nranking > 3) { 989 990 double *fluxes = NULL; 991 double *offset = NULL; 992 int *entry = NULL; 993 994 // now find the distances 995 ALLOCATE (entry, int, Nranking); 996 ALLOCATE (offset, double, Nranking); 997 ALLOCATE (fluxes, double, Nranking); 998 987 999 // first, measure the median of the flxlist: 988 ALLOCATE (fluxes, double, Nranking);989 1000 for (i = 0; i < Nranking; i++) { 990 1001 fluxes[i] = dataset->flxlist[i]; … … 993 1004 int Nmidpoint = (int)(0.5*Nranking); // if Nranking is odd (e.g., 5), Nmidpoint is central bin (e.g., 2); if Nranking is even (e.g., 6), Nmidpoint is central bin + 1 (e.g., 3); 994 1005 double medianFlux = (Nranking % 2) ? fluxes[Nmidpoint] : 0.5*(fluxes[Nmidpoint] + fluxes[Nmidpoint - 1]); 1006 1007 for (i = 0; i < Nranking; i++) { 1008 offset[i] = fabs((dataset->flxlist[i] - medianFlux) / dataset->errlist[i]); 1009 entry[i] = i; 1010 } 1011 1012 sort_entry_by_offset (offset, entry, Nranking); 1013 1014 // we are only going to clip at most 25% of the points. Start at the 75% point and check for outliers 1015 int Nreject = 0; 1016 for (i = 0.75*Nranking; i < Nranking; i++) { 1017 if (offset[i] > 4.0) { 1018 // this is an outlier -- add 10 to the ranking 1019 dataset->ranking[entry[i]] += 10; 1020 Nreject ++; 1021 } 1022 } 1023 Nranking -= Nreject; // the excluded points are now removed from the count 1024 1025 // re-sort by the rank so liststats below only operates on the unrejected points 1026 sort_StatDataSet (dataset); 1027 1028 free (fluxes); 1029 free (offset); 1030 free (entry); 995 1031 } 996 1032 … … 1000 1036 return (Nranking); 1001 1037 } 1002 # endif1003 1038 1004 1039 int markMeasureByRanking (StatDataSet *dataset, Measure *measure, int minrank, DVOMeasureFlags flags) { … … 1035 1070 } 1036 1071 1072 void sort_entry_by_offset (double *offset, int *entry, int N) { 1073 1074 # define SWAPFUNC(A,B){ double dtmp; int itmp; \ 1075 dtmp = offset[A]; offset[A] = offset[B]; offset[B] = dtmp; \ 1076 itmp = entry[A]; entry[A] = entry[B]; entry[B] = itmp; \ 1077 } 1078 # define COMPARE(A,B)(offset[A] < offset[B]) 1079 1080 OHANA_SORT (N, COMPARE, SWAPFUNC); 1081 1082 # undef SWAPFUNC 1083 # undef COMPARE 1084 } 1085 1037 1086 void GetPhotFlagStats (uint32_t *photFlagUpper, uint32_t *photFlagLower, uint32_t *photflag_list, int Nphotflag) { 1038 1087
Note:
See TracChangeset
for help on using the changeset viewer.
