Changeset 18153 for branches/cleanup/ippTools/src/stacktool.c
- Timestamp:
- Jun 16, 2008, 1:49:43 PM (18 years ago)
- File:
-
- 1 edited
-
branches/cleanup/ippTools/src/stacktool.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/cleanup/ippTools/src/stacktool.c
r16940 r18153 31 31 #include "stacktool.h" 32 32 33 static bool queueMode(pxConfig *config);33 static bool definebyqueryMode(pxConfig *config); 34 34 static bool definerunMode(pxConfig *config); 35 35 static bool updaterunMode(pxConfig *config); … … 61 61 62 62 switch (config->mode) { 63 MODECASE(STACKTOOL_MODE_ QUEUE, queueMode);63 MODECASE(STACKTOOL_MODE_DEFINEBYQUERY, definebyqueryMode); 64 64 MODECASE(STACKTOOL_MODE_DEFINERUN, definerunMode); 65 65 MODECASE(STACKTOOL_MODE_UPDATERUN, updaterunMode); … … 92 92 93 93 94 static bool queueMode(pxConfig *config)94 static bool definebyqueryMode(pxConfig *config) 95 95 { 96 96 PS_ASSERT_PTR_NON_NULL(config, false); … … 107 107 PXOPT_COPY_STR(config->args, whereRE, "-select_uri", "uri", "=="); 108 108 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", "<="); 110 110 PXOPT_COPY_F32(config->args, whereRE, "-select_airmass_min", "airmass", ">="); 111 111 PXOPT_COPY_F32(config->args, whereRE, "-select_airmass_max", "airmass", "<="); … … 120 120 PXOPT_COPY_F32(config->args, whereRE, "-select_solang_max", "solang", "<="); 121 121 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); 122 124 123 125 if (!psListLength(whereRE->list) && !psListLength(whereWSF->list) && … … 182 184 } 183 185 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 184 229 psHash *stacks = psHashAlloc(psArrayLength(output)); 185 230 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 187 233 for (long i = 0; i < psArrayLength(output); i++) { 188 234 psMetadata *md = output->data[i]; 189 235 190 // pull out the warp_id, skycell_id, & tess_id191 236 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 192 255 psString skycell_id = psMetadataLookupStr(&status, md, "skycell_id"); 193 256 if (!status) { 194 257 psError(PS_ERR_UNKNOWN, false, "failed to lookup skycell_id"); 258 psFree(valid_warpids); 195 259 psFree(output); 196 260 return NULL; … … 200 264 if (!status) { 201 265 psError(PS_ERR_UNKNOWN, false, "failed to lookup tess_id"); 266 psFree(valid_warpids); 202 267 psFree(output); 203 268 return NULL; … … 220 285 221 286 } 287 psFree(valid_warpids); 222 288 psFree(output); 223 289
Note:
See TracChangeset
for help on using the changeset viewer.
