IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 39621


Ignore:
Timestamp:
Jul 1, 2016, 4:38:39 PM (10 years ago)
Author:
eugene
Message:

add clipped version of the mean stats for warp photometry

Location:
trunk/Ohana/src/relphot/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/relphot/src/relphot_objects.c

    r39609 r39621  
    129129    initMrel (&catalog, 1);
    130130    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
    131136    // XXX if we want to have options for setting warp, chip, stack independently, we need to init only the desired ones
    132137    // NOTE flatcorr == NULL, but it should have been applied already by setphot
  • trunk/Ohana/src/relphot/src/setMrelCatalog.c

    r39620 r39621  
    11# include "relphot.h"
    22
    3 /*
    4 # define TEST_OBJ_ID 0x3ae2
    5 # define TEST_CAT_ID 0x16c5f
    6 */
     3# if (0)
     4# define TEST_OBJ_ID 0x0000000e
     5# define TEST_CAT_ID 0x000076ee
     6# else
    77# define TEST_OBJ_ID 0
    88# define TEST_CAT_ID 0
    9 
     9# endif
     10
     11int magStatsByRankingClipped (StatDataSet *dataset, StatType *stats);
    1012int markMeasureByRanking (StatDataSet *dataset, Measure *measure, int minrank, DVOMeasureFlags flags);
    1113void GetPhotFlagStats (uint32_t *photFlagUpper, uint32_t *photFlagLower, uint32_t *photflag_list, int Nphotflag);
     14void sort_entry_by_offset (double *offset, int *entry, int N);
     15void sort_StatDataSet (StatDataSet *dataset);
    1216
    1317# define UBERCAL_WEIGHT 100.0
    14 void sort_StatDataSet (StatDataSet *dataset);
    1518
    1619# define SKIP_THIS_MEAS(REASON) {                       \
     
    903906    // if too few valid measurements meet the minimum criteria, go to the next entry
    904907    StatType *psfstats = &results->psfstats;
    905     int Nranking = magStatsByRanking (&results->psfData[Nsec], psfstats);
     908    int Nranking = magStatsByRankingClipped (&results->psfData[Nsec], psfstats);
    906909    if (Nranking) {
    907910      secfilt[Nsec].FpsfWrp  = psfstats->mean;
     
    916919    // if too few valid measurements meet the minimum criteria, go to the next entry
    917920    StatType *apstats = &results->apstats;
    918     Nranking = magStatsByRanking (&results->aperData[Nsec], apstats);
     921    Nranking = magStatsByRankingClipped (&results->aperData[Nsec], apstats);
    919922    if (Nranking) {
    920923      secfilt[Nsec].FapWrp     = apstats->mean;
     
    927930    // if too few valid measurements meet the minimum criteria, go to the next entry
    928931    StatType *kronstats = &results->kronstats;
    929     Nranking = magStatsByRanking (&results->kronData[Nsec], kronstats);
     932    Nranking = magStatsByRankingClipped (&results->kronData[Nsec], kronstats);
    930933    if (Nranking) {
    931934      secfilt[Nsec].FkronWrp     = kronstats->mean;
     
    963966}
    964967
    965 # if (0)
    966968// outlier warp measurements are driving bad mean values. 
    967969int magStatsByRankingClipped (StatDataSet *dataset, StatType *stats) {
     
    985987  // 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
    986988  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
    987999    // first, measure the median of the flxlist:
    988     ALLOCATE (fluxes, double, Nranking);
    9891000    for (i = 0; i < Nranking; i++) {
    9901001      fluxes[i] = dataset->flxlist[i];
     
    9931004    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);
    9941005    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);
    9951031  }
    9961032
     
    10001036  return (Nranking);
    10011037}
    1002 # endif
    10031038
    10041039int markMeasureByRanking (StatDataSet *dataset, Measure *measure, int minrank, DVOMeasureFlags flags) {
     
    10351070}
    10361071
     1072void 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
    10371086void GetPhotFlagStats (uint32_t *photFlagUpper, uint32_t *photFlagLower, uint32_t *photflag_list, int Nphotflag) {
    10381087
Note: See TracChangeset for help on using the changeset viewer.