Changeset 41845
- Timestamp:
- Oct 17, 2021, 1:29:19 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ppStack.20211015/src/ppStackReadout.c
r41842 r41845 19 19 weightings, exposures, addVariance); 20 20 thread->busy = false; 21 22 thread->status = job->results ? PPSTACK_THREAD_SUCCESS : PPSTACK_THREAD_FAILURE; 23 24 psAssert(job->results, "Stacking failed."); 21 25 22 26 return job->results ? true : false; … … 48 52 thread->busy = false; 49 53 54 thread->status = status ? PPSTACK_THREAD_SUCCESS : PPSTACK_THREAD_FAILURE; 55 50 56 psAssert(status, "Stacking failed."); 51 57 … … 68 74 psVector *addVariance = options->matchChi2; // Additional variance when rejecting 69 75 70 job->results = ppStackReadoutInitial(config, outRO, thread->readouts, mask, weightings, exposures, addVariance); 76 // fprintf (stderr, "start thread %d : scan range %d - %d\n", thread->entry, thread->firstScan, thread->lastScan); 77 78 bool status = ppStackReadoutPercent(config, outRO, thread->readouts, mask, weightings, exposures, addVariance); 79 71 80 thread->busy = false; 72 81 73 return job->results ? true : false; 82 thread->status = status ? PPSTACK_THREAD_SUCCESS : PPSTACK_THREAD_FAILURE; 83 84 // fprintf (stderr, "finished thread %d, status %d : scan range %d - %d\n", thread->entry, thread->status, thread->firstScan, thread->lastScan); 85 86 psAssert(status, "Stacking failed."); 87 88 return status; 74 89 } 75 90 … … 167 182 168 183 int num = readouts->n; // Number of inputs 169 psArray *stack = psArrayAlloc(num); // Array for stacking184 psArray *stackData = psArrayAlloc(num); // Array of data to be stacked 170 185 171 186 for (int i = 0; i < num; i++) { … … 182 197 } 183 198 184 stack->data[i] = pmStackDataAlloc(ro, weightings->data.F32[i], exposures->data.F32[i], 199 // stackData is an array of pmStackData structures 200 stackData->data[i] = pmStackDataAlloc(ro, weightings->data.F32[i], exposures->data.F32[i], 185 201 addVariance->data.F32[i]); 186 202 } 187 203 188 if (!pmStackCombine(outRO, NULL, stack , maskBad, maskSuspect, maskBlank, kernelSize, iter,204 if (!pmStackCombine(outRO, NULL, stackData, maskBad, maskSuspect, maskBlank, kernelSize, iter, 189 205 combineRej, combineSys, combineDiscard, useVariance, safe, nminpix, false)) { 190 206 psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts with rejection."); 191 psFree(stack); 207 psFree(stackData); 208 209 // XXX EAM : if pmStackCombine fails above this return will cause the thread to block. 210 // The failure status results in a psThread.fault. the psThreadLauncher function, which 211 // each background thread runs as a loop, will sleep until the fault is cleared externally 212 // by the handler. psThreadPoolWait() catches, counts, and clears these faults, but 213 // ppStackThreadRead does not. 192 214 return false; 193 215 } … … 197 219 psArray *reject = psArrayAlloc(num); // List of pixels rejected 198 220 for (int i = 0; i < num; i++) { 199 pmStackData *data = stack ->data[i]; // Data for this image221 pmStackData *data = stackData->data[i]; // Data for this image 200 222 if (!data) { 201 223 continue; … … 208 230 reject->data[i] = psMemIncrRefCounter(data->reject); 209 231 } 210 psFree(stack );232 psFree(stackData); 211 233 212 234 //MEH change to trace … … 269 291 270 292 int num = readouts->n; // Number of inputs 271 psArray *stack = psArrayAlloc(num); // Array for stacking293 psArray *stackData = psArrayAlloc(num); // Array of data to be stacked 272 294 273 295 // We have rejection from a previous combination: combine without flagging pixels to inspect … … 294 316 addVariance ? addVariance->data.F32[i] : NAN); 295 317 data->reject = rejected ? psMemIncrRefCounter(rejected->data[i]) : NULL; 296 stack ->data[i] = data;318 stackData->data[i] = data; 297 319 298 320 //MEH -- apply bscale offset before norm … … 310 332 } 311 333 312 if (!pmStackCombine(outRO, expRO, stack , maskBad, maskSuspect, maskBlank, 0, iter, combineRej,334 if (!pmStackCombine(outRO, expRO, stackData, maskBad, maskSuspect, maskBlank, 0, iter, combineRej, 313 335 combineSys, combineDiscard, useVariance, safe, nminpix, rejected)) { 314 336 psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts."); 315 psFree(stack );337 psFree(stackData); 316 338 return false; 317 339 } … … 329 351 expChip->data_exists = true; 330 352 331 psFree(stack );353 psFree(stackData); 332 354 333 355 //MEH change to trace … … 338 360 return true; 339 361 } 340 341 bool pmStackCombineByPercentile(pmReadout *outRO, psArray *stack, float minRange, float maxRange, psImageMaskType maskBad, psImageMaskType maskSuspect, psImageMaskType maskBlank);342 362 343 363 bool ppStackReadoutPercent(const pmConfig *config, pmReadout *outRO, const psArray *readouts, … … 353 373 static int sectionNum = 0; // Section number; for debugging outputs 354 374 375 // fprintf (stderr, "starting ReadoutPercent, %d\n", sectionNum); 376 355 377 // Get the recipe values 356 378 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe … … 358 380 359 381 bool mdok; // Status of MD lookup 360 floatminRange = psMetadataLookupF32(&mdok, recipe, "COMBINE.MIN.RANGE"); // Combination threshold361 floatmaxRange = psMetadataLookupF32(&mdok, recipe, "COMBINE.MAX.RANGE"); // Combination threshold382 psF64 minRange = psMetadataLookupF32(&mdok, recipe, "COMBINE.MIN.RANGE"); // Combination threshold 383 psF64 maxRange = psMetadataLookupF32(&mdok, recipe, "COMBINE.MAX.RANGE"); // Combination threshold 362 384 363 385 char defaultBlankStr[16] = "BLANK"; … … 378 400 379 401 int num = readouts->n; // Number of inputs 380 psArray *stack = psArrayAlloc(num); // Array for stacking402 psArray *stackData = psArrayAlloc(num); // Array of data to be stacked 381 403 382 404 for (int i = 0; i < num; i++) { … … 393 415 } 394 416 395 stack ->data[i] = pmStackDataAlloc(ro, weightings->data.F32[i], exposures->data.F32[i],396 addVariance->data.F32[i]);397 } 398 399 if (!pmStackCombineByPercentile(outRO, stack , minRange, maxRange, maskBad, maskSuspect, maskBlank)) {417 stackData->data[i] = pmStackDataAlloc(ro, weightings->data.F32[i], exposures->data.F32[i], 418 addVariance->data.F32[i]); 419 } 420 421 if (!pmStackCombineByPercentile(outRO, stackData, minRange, maxRange, maskBad, maskSuspect, maskBlank)) { 400 422 psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts with rejection."); 401 psFree(stack );423 psFree(stackData); 402 424 return false; 403 425 } 404 426 427 outRO->data_exists = true; // output readout 428 outRO->parent->data_exists = true; // output cell 429 outRO->parent->parent->data_exists = true; // output chip 430 431 # if 0 432 pmCell *expCell = expRO->parent; // Exposure cell 433 pmChip *expChip = expCell->parent; // Exposure chip 434 expRO->data_exists = true; 435 expCell->data_exists = true; 436 expChip->data_exists = true; 437 # endif 438 439 psFree(stackData); 405 440 sectionNum++; 406 441
Note:
See TracChangeset
for help on using the changeset viewer.
