IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 11, 2008, 3:35:57 PM (18 years ago)
Author:
eugene
Message:

add -random_subst and -random_limit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/dettool.c

    r16868 r18088  
    535535    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    536536
     537    PXOPT_LOOKUP_BOOL(randomSubset, config->args, "-random_subset", false);
     538    PXOPT_LOOKUP_S32(randomLimit, config->args, "-random_limit", false, false);
     539
    537540    PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false);
    538541    PXOPT_LOOKUP_TIME(time_begin, config->args, "-time_begin", false, false);
     
    557560    PXOPT_COPY_F32(config->args, where, "-select_ccd_temp_min", "ccd_temp", ">=");
    558561    PXOPT_COPY_F32(config->args, where, "-select_ccd_temp_max", "ccd_temp", "<=");
     562    PXOPT_COPY_F32(config->args, where, "-select_pon_time_min", "pon_time", ">=");
     563    PXOPT_COPY_F32(config->args, where, "-select_pon_time_max", "pon_time", "<=");
    559564    PXOPT_COPY_F32(config->args, where, "-select_posang_min", "posang", ">=");
    560565    PXOPT_COPY_F32(config->args, where, "-select_posang_max", "posang", "<=");
     
    584589        psFree(detrendExps);
    585590        return true;
     591    }
     592
     593    if (randomSubset && (randomLimit < detrendExps->n)) {
     594      // generate a random-valued vector, return an index sorted by the random values
     595      psVector *randomVector = psVectorAlloc(detrendExps->n, PS_TYPE_F32); // random values
     596      psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0);
     597      for (int i = 0; i < randomVector->n; i++) {
     598        randomVector->data.F32[i] = psRandomUniform(rng);
     599      }
     600      psVector *indexVector = psVectorSortIndex(NULL, randomVector);
     601
     602      // accept for first n of the sequence
     603      psArray *subset = psArrayAlloc (randomLimit);
     604      for (int i = 0; i < randomLimit; i++ ){
     605        int j = indexVector->data.S32[i];
     606        subset->data[i] = psMemIncrRefCounter (detrendExps->data[j]);
     607      }
     608      psFree (detrendExps);
     609      detrendExps = subset;
    586610    }
    587611
Note: See TracChangeset for help on using the changeset viewer.