IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 16, 2008, 1:49:43 PM (18 years ago)
Author:
jhoblitt
Message:

MERGE from HEAD

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/cleanup/ippTools/src/stacktool.c

    r16940 r18153  
    3131#include "stacktool.h"
    3232
    33 static bool queueMode(pxConfig *config);
     33static bool definebyqueryMode(pxConfig *config);
    3434static bool definerunMode(pxConfig *config);
    3535static bool updaterunMode(pxConfig *config);
     
    6161
    6262    switch (config->mode) {
    63         MODECASE(STACKTOOL_MODE_QUEUE,              queueMode);
     63        MODECASE(STACKTOOL_MODE_DEFINEBYQUERY,              definebyqueryMode);
    6464        MODECASE(STACKTOOL_MODE_DEFINERUN,          definerunMode);
    6565        MODECASE(STACKTOOL_MODE_UPDATERUN,          updaterunMode);
     
    9292
    9393
    94 static bool queueMode(pxConfig *config)
     94static bool definebyqueryMode(pxConfig *config)
    9595{
    9696    PS_ASSERT_PTR_NON_NULL(config, false);
     
    107107    PXOPT_COPY_STR(config->args, whereRE, "-select_uri", "uri", "==");
    108108    PXOPT_COPY_TIME(config->args, whereRE, "-select_dateobs_begin", "dateobs", ">=");
    109     PXOPT_COPY_TIME(config->args, whereRE, "-select_dateobs_end", "dateobs", "<");
     109    PXOPT_COPY_TIME(config->args, whereRE, "-select_dateobs_end", "dateobs", "<=");
    110110    PXOPT_COPY_F32(config->args, whereRE, "-select_airmass_min", "airmass", ">=");
    111111    PXOPT_COPY_F32(config->args, whereRE, "-select_airmass_max", "airmass", "<=");
     
    120120    PXOPT_COPY_F32(config->args, whereRE, "-select_solang_max", "solang", "<=");
    121121    PXOPT_COPY_STR(config->args, whereWSF, "-select_skycell_id", "skycell_id", "==");
     122    PXOPT_LOOKUP_BOOL(randomSubset, config->args, "-random_subset", false);
     123    PXOPT_LOOKUP_S32(randomLimit, config->args, "-random_limit", false, false);
    122124
    123125    if (!psListLength(whereRE->list) && !psListLength(whereWSF->list) &&
     
    182184    }
    183185
     186    // valid_warpids should be NULL unless randomSubset is specified
     187    psVector *valid_warpids = NULL;
     188    if (randomSubset && (randomLimit < psArrayLength(output))) {
     189        // loop over the array of metadata and figure out which warp_id are in
     190        // the result set
     191        psArray *warps = psArrayAlloc(0);
     192        for (long i = 0; i < psArrayLength(output); i++) {
     193//            psMetadata *md = output->data[i];
     194
     195            // pull out the warp_id
     196            bool status = false;
     197//            psS64 warp_id = psMetadataLookupS64(&status, md, "warp_id");
     198            if (!status) {
     199                psError(PS_ERR_UNKNOWN, false, "failed to lookup warp_id");
     200                psFree(output);
     201                psFree(warps);
     202                return NULL;
     203            }
     204
     205//            psArrayAdd(warps, 0, warp_id);
     206        }
     207
     208        // generate a random-valued vector, return an index sorted by the
     209        // random values
     210        psVector *randomVector = psVectorAlloc(psArrayLength(output), PS_TYPE_F32);
     211        psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0);
     212        for (int i = 0; i < randomVector->n; i++) {
     213            randomVector->data.F32[i] = psRandomUniform(rng);
     214        }
     215        psVector *indexVector = psVectorSortIndex(NULL, randomVector);
     216        psFree(randomVector);
     217
     218        // accept for first n of the sequence
     219        valid_warpids = psVectorAlloc(randomLimit, PS_TYPE_S64);
     220        for (int i = 0; i < randomLimit; i++ ){
     221//            int j = indexVector->data.S32[i];
     222//            valid_warpids->data[i] = psMemIncrRefCounter (warps->data[j]);
     223        }
     224        psFree(indexVector);
     225        psFree(warps);
     226    }
     227
     228
    184229    psHash *stacks = psHashAlloc(psArrayLength(output));
    185230
    186     // loop over the array of metadata
     231    // loop over the array of metadata and build a hash keyed by tess_id &
     232    // skycell_id
    187233    for (long i = 0; i < psArrayLength(output); i++) {
    188234        psMetadata *md = output->data[i];
    189235
    190         // pull out the warp_id, skycell_id, & tess_id
    191236        bool status;
     237        if (valid_warpids) {
     238//            psS64 warp_id = psMetadataLookupS64(&status, md, "warp_id");
     239            if (!status) {
     240                psError(PS_ERR_UNKNOWN, false, "failed to lookup warp_id");
     241                psFree(valid_warpids);
     242                psFree(output);
     243                return NULL;
     244            }
     245
     246            // is this a warp_id that should be left out of the stack set(s)?
     247//            for (long i = 0; i < psArrayLength(valid_warpids); i++) {
     248//                if (valid_warpids->data[i] == warp_id) {
     249//                    continue;
     250//                }
     251//            }
     252        }
     253
     254        // pull out the skycell_id, & tess_id
    192255        psString skycell_id = psMetadataLookupStr(&status, md, "skycell_id");
    193256        if (!status) {
    194257            psError(PS_ERR_UNKNOWN, false, "failed to lookup skycell_id");
     258            psFree(valid_warpids);
    195259            psFree(output);
    196260            return NULL;
     
    200264        if (!status) {
    201265            psError(PS_ERR_UNKNOWN, false, "failed to lookup tess_id");
     266            psFree(valid_warpids);
    202267            psFree(output);
    203268            return NULL;
     
    220285
    221286    }
     287    psFree(valid_warpids);
    222288    psFree(output);
    223289
Note: See TracChangeset for help on using the changeset viewer.