- Timestamp:
- Nov 8, 2021, 7:57:10 AM (5 years ago)
- Location:
- branches/eam_branches/ipp-20211108/ppStack
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/ppStackReadout.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20211108/ppStack
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/IPP-308_move_backups_folder/ppStack merged eligible /branches/czw_branch/20160809/ppStack merged eligible /branches/czw_branch/20170908/ppStack merged eligible /branches/eam_branches/ipp-20191011/ppStack merged eligible /branches/eam_branches/ipp-dev-20210817/ppStack merged eligible /branches/eam_branches/ppStack.20211015 merged eligible /tags/ipp-ps1-20210510/ppStack merged eligible /tags/ipp-ps1-20210708/ppStack merged eligible /branches/ipp-259_genericise_backups/ppStack 40910-40966
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/eam_branches/ipp-20211108/ppStack/src/ppStackReadout.c
r36886 r41908 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 … … 53 59 } 54 60 61 bool ppStackReadoutPercentThread(psThreadJob *job) 62 { 63 PS_ASSERT_THREAD_JOB_NON_NULL(job, false); 64 65 psArray *args = job->args; // Arguments 66 ppStackThread *thread = args->data[0]; // Thread 67 ppStackOptions *options = args->data[1]; // Options 68 pmConfig *config = args->data[2]; // Configuration 69 70 pmReadout *outRO = options->outRO; // Output readout 71 psVector *mask = options->inputMask; // Mask for inputs 72 psVector *weightings = options->weightings; // Weightings (1/noise^2) for each image 73 psVector *exposures = options->exposures; // Exposure times for each image 74 psVector *addVariance = options->matchChi2; // Additional variance when rejecting 75 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 80 thread->busy = false; 81 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; 89 } 90 91 //////////////////////////////////// 55 92 56 93 bool ppStackInspect(psThreadJob *job) … … 145 182 146 183 int num = readouts->n; // Number of inputs 147 psArray *stack = psArrayAlloc(num); // Array for stacking184 psArray *stackData = psArrayAlloc(num); // Array of data to be stacked 148 185 149 186 for (int i = 0; i < num; i++) { … … 160 197 } 161 198 162 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], 163 201 addVariance->data.F32[i]); 164 202 } 165 203 166 if (!pmStackCombine(outRO, NULL, stack , maskBad, maskSuspect, maskBlank, kernelSize, iter,204 if (!pmStackCombine(outRO, NULL, stackData, maskBad, maskSuspect, maskBlank, kernelSize, iter, 167 205 combineRej, combineSys, combineDiscard, useVariance, safe, nminpix, false)) { 168 206 psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts with rejection."); 169 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. 170 214 return false; 171 215 } … … 175 219 psArray *reject = psArrayAlloc(num); // List of pixels rejected 176 220 for (int i = 0; i < num; i++) { 177 pmStackData *data = stack ->data[i]; // Data for this image221 pmStackData *data = stackData->data[i]; // Data for this image 178 222 if (!data) { 179 223 continue; … … 186 230 reject->data[i] = psMemIncrRefCounter(data->reject); 187 231 } 188 psFree(stack );232 psFree(stackData); 189 233 190 234 //MEH change to trace … … 247 291 248 292 int num = readouts->n; // Number of inputs 249 psArray *stack = psArrayAlloc(num); // Array for stacking293 psArray *stackData = psArrayAlloc(num); // Array of data to be stacked 250 294 251 295 // We have rejection from a previous combination: combine without flagging pixels to inspect … … 272 316 addVariance ? addVariance->data.F32[i] : NAN); 273 317 data->reject = rejected ? psMemIncrRefCounter(rejected->data[i]) : NULL; 274 stack ->data[i] = data;318 stackData->data[i] = data; 275 319 276 320 //MEH -- apply bscale offset before norm … … 288 332 } 289 333 290 if (!pmStackCombine(outRO, expRO, stack , maskBad, maskSuspect, maskBlank, 0, iter, combineRej,334 if (!pmStackCombine(outRO, expRO, stackData, maskBad, maskSuspect, maskBlank, 0, iter, combineRej, 291 335 combineSys, combineDiscard, useVariance, safe, nminpix, rejected)) { 292 336 psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts."); 293 psFree(stack );337 psFree(stackData); 294 338 return false; 295 339 } … … 307 351 expChip->data_exists = true; 308 352 309 psFree(stack );353 psFree(stackData); 310 354 311 355 //MEH change to trace … … 316 360 return true; 317 361 } 362 363 bool ppStackReadoutPercent(const pmConfig *config, pmReadout *outRO, const psArray *readouts, 364 const psVector *mask, const psVector *weightings, const psVector *exposures, 365 const psVector *addVariance) 366 { 367 assert(config); 368 assert(outRO); 369 assert(readouts); 370 assert(mask && mask->n == readouts->n && mask->type.type == PS_TYPE_VECTOR_MASK); 371 assert(weightings && weightings->n == readouts->n && weightings->type.type == PS_TYPE_F32); 372 assert(addVariance && addVariance->n == readouts->n && addVariance->type.type == PS_TYPE_F32); 373 static int sectionNum = 0; // Section number; for debugging outputs 374 375 // fprintf (stderr, "starting ReadoutPercent, %d\n", sectionNum); 376 377 // Get the recipe values 378 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe 379 psAssert(recipe, "We've thrown an error on this before."); 380 381 bool mdok; // Status of MD lookup 382 psF64 minRange = psMetadataLookupF32(&mdok, recipe, "COMBINE.MIN.RANGE"); // Combination threshold 383 384 char defaultBlankStr[16] = "BLANK"; 385 386 psString maskBadStr = psMetadataLookupStr(&mdok, recipe, "MASK.VAL"); // Name of bits to mask for bad 387 psString maskSuspectStr = psMetadataLookupStr(&mdok, recipe, "MASK.SUSPECT"); // Name of suspect mask bits 388 psString maskBlankStr = psMetadataLookupStr(&mdok, recipe, "MASK.BLANK"); // Name of bits to set for empty pixels 389 if (!maskBlankStr) { 390 maskBlankStr = psMetadataLookupStr(&mdok, recipe, "MASK.BAD"); // Old name for MASK.BLANK 391 } 392 if (!maskBlankStr) { 393 maskBlankStr = defaultBlankStr; // this is statically allocated above 394 } 395 396 psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels 397 psImageMaskType maskSuspect = pmConfigMaskGet(maskSuspectStr, config); // Suspect bits 398 psImageMaskType maskBlank = pmConfigMaskGet(maskBlankStr, config); // Bits to mask for bad pixels 399 400 int num = readouts->n; // Number of inputs 401 psArray *stackData = psArrayAlloc(num); // Array of data to be stacked 402 403 for (int i = 0; i < num; i++) { 404 pmReadout *ro = readouts->data[i]; 405 if (!ro || mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 406 // Bad image 407 continue; 408 } 409 410 // Ensure there is a mask, or pmStackCombine will complain 411 if (!ro->mask) { 412 ro->mask = psImageAlloc(ro->image->numCols, ro->image->numRows, PS_TYPE_IMAGE_MASK); 413 psImageInit(ro->mask, 0); 414 } 415 416 stackData->data[i] = pmStackDataAlloc(ro, weightings->data.F32[i], exposures->data.F32[i], 417 addVariance->data.F32[i]); 418 } 419 420 // XXX rename minRange to rejectFraction 421 // XXX add expmaps 422 if (!pmStackCombineByPercentile(outRO, NULL, stackData, minRange, maskBad, maskSuspect, maskBlank)) { 423 psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts with rejection."); 424 psFree(stackData); 425 return false; 426 } 427 428 outRO->data_exists = true; // output readout 429 outRO->parent->data_exists = true; // output cell 430 outRO->parent->parent->data_exists = true; // output chip 431 432 # if 0 433 pmCell *expCell = expRO->parent; // Exposure cell 434 pmChip *expChip = expCell->parent; // Exposure chip 435 expRO->data_exists = true; 436 expCell->data_exists = true; 437 expChip->data_exists = true; 438 # endif 439 440 psFree(stackData); 441 sectionNum++; 442 443 return true; 444 } 445 446
Note:
See TracChangeset
for help on using the changeset viewer.
