Changeset 42094
- Timestamp:
- Feb 28, 2022, 3:01:31 PM (4 years ago)
- Location:
- trunk/ppStack
- Files:
-
- 20 edited
- 2 copied
-
. (modified) (1 prop)
-
src/Makefile.am (modified) (1 diff)
-
src/ppStack.h (modified) (1 diff)
-
src/ppStackArguments.c (modified) (1 diff)
-
src/ppStackCombineFinal.c (modified) (1 diff)
-
src/ppStackCombineInitial.c (modified) (1 diff)
-
src/ppStackCombinePercent.c (copied) (copied from branches/eam_branches/ipp-20211108/ppStack/src/ppStackCombinePercent.c )
-
src/ppStackCombinePrepare.c (modified) (4 diffs)
-
src/ppStackFiles.c (modified) (4 diffs)
-
src/ppStackJPEGs.c (modified) (1 diff)
-
src/ppStackLoop.c (modified) (5 diffs)
-
src/ppStackLoop.h (modified) (3 diffs)
-
src/ppStackLoopByPercent.c (copied) (copied from branches/eam_branches/ipp-20211108/ppStack/src/ppStackLoopByPercent.c )
-
src/ppStackMatch.c (modified) (1 diff)
-
src/ppStackOptions.c (modified) (1 diff)
-
src/ppStackOptions.h (modified) (1 diff)
-
src/ppStackPhotometry.c (modified) (2 diffs)
-
src/ppStackReadout.c (modified) (12 diffs)
-
src/ppStackSetup.c (modified) (1 diff)
-
src/ppStackSources.c (modified) (1 diff)
-
src/ppStackThread.c (modified) (9 diffs)
-
src/ppStackThread.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/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-20211108/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)
-
trunk/ppStack/src/Makefile.am
r38034 r42094 29 29 ppStackPrepare.c \ 30 30 ppStackConvolve.c \ 31 ppStackLoopByPercent.c \ 32 ppStackCombinePercent.c \ 31 33 ppStackCombinePrepare.c \ 32 34 ppStackCombineInitial.c \ -
trunk/ppStack/src/ppStack.h
r36855 r42094 115 115 bool ppStackReadoutFinalThread(psThreadJob *job // Job to process 116 116 ); 117 118 // Thread entry point for ppStackReadoutPercent 119 bool ppStackReadoutPercentThread(psThreadJob *job); 120 121 bool ppStackReadoutPercent(const pmConfig *config, 122 pmReadout *outRO, 123 pmReadout *expRO, 124 const psArray *readouts, 125 const psVector *mask, 126 const psVector *weightings, 127 const psVector *exposures, 128 const psVector *addVariance); 129 117 130 // Perform median stacking for background 118 131 bool ppStackCombineBackground(ppStackThreadData *stack, ppStackOptions *options, pmConfig *config); -
trunk/ppStack/src/ppStackArguments.c
r34800 r42094 197 197 } 198 198 199 // stack-type : used to define the stack for PSPS 199 // stack-type : used to define the stack for PSPS (added as metadata to header key STK_TYPE) 200 200 if ((argNum = psArgumentGet (argc, argv, "-stack-type"))) { 201 201 if (argc <= argNum+1) { -
trunk/ppStack/src/ppStackCombineFinal.c
r36855 r42094 2 2 3 3 // This is the doomsday switch. 4 // # define TESTING // Enable test output4 // # define TESTING // Enable test output 5 5 6 6 //MEH -- adhoc addition to blank mask border of final stack since rejection different/none on order of KERNEL.SIZE with overlap in CombineInitial -
trunk/ppStack/src/ppStackCombineInitial.c
r33093 r42094 9 9 psAssert(options, "Require options"); 10 10 psAssert(config, "Require configuration"); 11 12 /* if (!options->convolve) { */13 /* // No need to do initial combination when we haven't convolved */14 /* // XXX either allocate inspect and rejected here, or do not require them downstream */15 /* return true; */16 /* } */17 11 18 12 psTimerStart("PPSTACK_INITIAL"); -
trunk/ppStack/src/ppStackCombinePrepare.c
r34859 r42094 31 31 options->expRO = pmReadoutAlloc(expCell); //Output readout 32 32 } 33 /* else { */ 34 /* options->expRO = NULL; */ 35 /* } */ 33 36 34 int bkg_r0 = 0,bkg_c0 = 0; 37 35 int bkg_nC = 0,bkg_nR = 0; … … 53 51 54 52 options->bkgRO = pmReadoutAlloc(bkgCell); // BKG readout 55 // if (!pmHDUGenerateForFPA(options->bkgRO->parent->parent->parent)) {56 53 options->bkgRO->parent->parent->parent->hdu = pmHDUAlloc(NULL); 54 57 55 if (!options->bkgRO->parent->parent->parent->hdu) { 58 56 fprintf(stderr,"failed to generate a HDU for this thing.\n"); … … 68 66 ro->parent->parent->parent->concepts); 69 67 70 } 71 else { 68 } else { 72 69 options->bkgRO = NULL; 73 70 } … … 97 94 return false; 98 95 } 99 100 101 102 96 } 103 97 -
trunk/ppStack/src/ppStackFiles.c
r34800 r42094 1 1 #include "ppStack.h" 2 # define DEBUG 0 2 3 3 4 // Here follows lists of files for activation/deactivation at various stages. Each must be NULL-terminated. … … 28 29 static char *filesStack[] = { "PPSTACK.OUTPUT", "PPSTACK.OUTPUT.MASK", "PPSTACK.OUTPUT.VARIANCE", 29 30 "PPSTACK.OUTPUT.EXP", "PPSTACK.OUTPUT.EXPNUM", "PPSTACK.OUTPUT.EXPWT", 30 "PPSTACK.OUTPUT.JPEG1", "PPSTACK.OUTPUT.JPEG2",31 31 "PPSTACK.OUTPUT.BKGMODEL", 32 32 NULL }; … … 45 45 { 46 46 switch (list) { 47 case PPSTACK_FILES_NONE: return filesNOP;48 case PPSTACK_FILES_PREPARE: return filesPrepare;49 case PPSTACK_FILES_TARGET: return filesTarget;50 case PPSTACK_FILES_CONVOLVE: return filesConvolve;51 case PPSTACK_FILES_STACK: return filesStack;52 case PPSTACK_FILES_UNCONV: return filesUnconv;53 case PPSTACK_FILES_PHOT: return filesPhot;54 case PPSTACK_FILES_BKG: return filesBkg;55 case PPSTACK_FILES_MEDIAN_IN:return filesMedianIn;56 case PPSTACK_FILES_MEDIAN_OUT:return filesMedianOut;47 case PPSTACK_FILES_NONE: return filesNOP; 48 case PPSTACK_FILES_PREPARE: return filesPrepare; 49 case PPSTACK_FILES_TARGET: return filesTarget; 50 case PPSTACK_FILES_CONVOLVE: return filesConvolve; 51 case PPSTACK_FILES_STACK: return filesStack; 52 case PPSTACK_FILES_UNCONV: return filesUnconv; 53 case PPSTACK_FILES_PHOT: return filesPhot; 54 case PPSTACK_FILES_BKG: return filesBkg; 55 case PPSTACK_FILES_MEDIAN_IN: return filesMedianIn; 56 case PPSTACK_FILES_MEDIAN_OUT: return filesMedianOut; 57 57 default: 58 58 psAbort("Unrecognised file list: %x", list); … … 99 99 char **files = stackFiles(list); // Files to turn on/off 100 100 for (int i = 0; files[i] != NULL; i++) { 101 if (DEBUG) { 102 if (state) { 103 fprintf (stderr, "activate %s\n", files[i]); 104 } else { 105 fprintf (stderr, "deativate %s\n", files[i]); 106 } 107 } 101 108 pmFPAfileActivate(config->files, state, files[i]); 102 109 } -
trunk/ppStack/src/ppStackJPEGs.c
r30620 r42094 33 33 psFree(ro2); 34 34 35 pmFPAfileActivate(config->files, true, "PPSTACK.OUTPUT.JPEG1"); 36 pmFPAfileActivate(config->files, true, "PPSTACK.OUTPUT.JPEG2"); 37 35 38 return true; 36 39 } -
trunk/ppStack/src/ppStackLoop.c
r41529 r42094 31 31 ppStackMemDump("prepare"); 32 32 if (options->quality) return true; // Can't do anything else 33 34 // if we want to skip the rejection steps, and instead use a percentile clipping: 35 if (options->clipPercent) { 36 bool result = ppStackLoopByPercent (config, options); 37 return result; 38 } 33 39 34 40 // Convolve inputs … … 88 94 pmCellFreeData(options->cells->data[i]); 89 95 } 90 // MEH -- must uncomment back out -- unclear is should be moved after pixel rejection96 // MEH -- must uncomment back out -- unclear is should be moved after pixel rejection 91 97 psFree(stack); 92 98 … … 126 132 return false; 127 133 } 128 } 129 else { 134 } else { 130 135 // Since we haven't convolved, I believe we do need to normalize here. 131 //MEH -- see below for comment on ppStackCombineFinal and bscaleOffset 132 if (!ppStackCombineFinal(stack, options->convCovars, options, config, false, true, true, true)) { 136 // MEH -- see below for comment on ppStackCombineFinal and bscaleOffset 137 // last 4 parameters are: safe, normalize, grow, bscaleoffset 138 // EAM : looks like we do NOT need to normalize here eithr because ppStackConvolve is still called and 139 // the inputs are normalized 140 if (!ppStackCombineFinal(stack, options->convCovars, options, config, false, false, true, true)) { 133 141 psError(psErrorCodeLast(), false, "Unable to perform final combination."); 134 142 psFree(stack); … … 154 162 return false; 155 163 } 156 ppStackFileActivation(config,PPSTACK_FILES_BKG ,false); 164 ppStackFileActivation(config, PPSTACK_FILES_BKG, false); 165 157 166 // Photometry 158 167 psTrace("ppStack", 1, "Photometering stacked image....\n"); … … 184 193 return false; 185 194 } 186 // MEH -- also must uncomment back out..195 // MEH -- also must uncomment back out.. 187 196 psFree(stack); 188 197 psLogMsg("ppStack", PS_LOG_INFO, "Stage 7: Cleanup, WCS & JPEGS: %f sec", psTimerClear("PPSTACK_STEPS")); -
trunk/ppStack/src/ppStackLoop.h
r36855 r42094 7 7 ppStackOptions *options // Options for stacking 8 8 ); 9 9 10 // Median only loop. 10 11 bool ppStackMedianLoop( … … 12 13 ppStackOptions *options // Options for stacking 13 14 ); 15 16 // stack by percentile range 17 bool ppStackLoopByPercent( 18 pmConfig *config, 19 ppStackOptions *options 20 ); 14 21 15 22 // Setup … … 92 99 93 100 101 bool ppStackCombinePercent(ppStackThreadData *stack, ppStackOptions *options, pmConfig *config); 102 94 103 bool ppStackUpdateHeader(ppStackThreadData *stack, ppStackOptions *options, pmConfig *config); 95 104 bool ppStackJPEGs(ppStackThreadData *stack, ppStackOptions *options, pmConfig *config); -
trunk/ppStack/src/ppStackMatch.c
r36364 r42094 524 524 psFree(conv); 525 525 } else { 526 // this branch is done if options->convolve is FALSE 526 527 // Match the normalisation 527 528 float norm = powf(10.0, -0.4 * options->norm->data.F32[index]); // Normalisation -
trunk/ppStack/src/ppStackOptions.c
r36855 r42094 56 56 options->num = 0; 57 57 options->quality = 0; 58 59 options->clipPercent = false; 60 58 61 options->psf = NULL; 59 62 options->sumExposure = NAN; -
trunk/ppStack/src/ppStackOptions.h
r36855 r42094 16 16 int num; // Number of inputs 17 17 int quality; // Bad data quality flag 18 19 bool clipPercent; // use percentile range to clip? 20 18 21 // Prepare 19 22 pmPSF *psf; // Target PSF -
trunk/ppStack/src/ppStackPhotometry.c
r33702 r42094 19 19 ppStackFileActivation(config, PPSTACK_FILES_PHOT, true); 20 20 pmFPAview *photView = ppStackFilesIterateDown(config); // View to readout 21 ppStackFileActivation(config, PPSTACK_FILES_STACK, true); 21 22 ppStackFileList stackFiles = options->convolve ? PPSTACK_FILES_STACK : PPSTACK_FILES_UNCONV; 23 ppStackFileActivation(config, stackFiles, true); 22 24 23 25 pmFPAfile *photFile = psMetadataLookupPtr(NULL, config->files, "PSPHOT.INPUT"); // File for photometry … … 57 59 // psphotSetNFrames 58 60 pmReadout *photRO = pmFPAviewThisReadout(photView, photFile->fpa); 59 if (photRO && options->expRO ->mask) {61 if (photRO && options->expRO && options->expRO->mask) { 60 62 psMetadataAddImage(photRO->analysis, PS_LIST_TAIL, "EXPNUM", PS_META_REPLACE, "EXPNUM image", options->expRO->mask); 61 63 } -
trunk/ppStack/src/ppStackReadout.c
r36886 r42094 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 pmReadout *expRO = options->expRO; // Expmap readout 72 psVector *mask = options->inputMask; // Mask for inputs 73 psVector *weightings = options->weightings; // Weightings (1/noise^2) for each image 74 psVector *exposures = options->exposures; // Exposure times for each image 75 psVector *addVariance = options->matchChi2; // Additional variance when rejecting 76 77 // fprintf (stderr, "start thread %d : scan range %d - %d\n", thread->entry, thread->firstScan, thread->lastScan); 78 79 bool status = ppStackReadoutPercent(config, outRO, expRO, thread->readouts, mask, weightings, exposures, addVariance); 80 81 thread->busy = false; 82 83 thread->status = status ? PPSTACK_THREAD_SUCCESS : PPSTACK_THREAD_FAILURE; 84 85 // fprintf (stderr, "finished thread %d, status %d : scan range %d - %d\n", thread->entry, thread->status, thread->firstScan, thread->lastScan); 86 87 psAssert(status, "Stacking failed."); 88 89 return status; 90 } 91 92 //////////////////////////////////// 55 93 56 94 bool ppStackInspect(psThreadJob *job) … … 145 183 146 184 int num = readouts->n; // Number of inputs 147 psArray *stack = psArrayAlloc(num); // Array for stacking185 psArray *stackData = psArrayAlloc(num); // Array of data to be stacked 148 186 149 187 for (int i = 0; i < num; i++) { … … 160 198 } 161 199 162 stack->data[i] = pmStackDataAlloc(ro, weightings->data.F32[i], exposures->data.F32[i], 200 // stackData is an array of pmStackData structures 201 stackData->data[i] = pmStackDataAlloc(ro, weightings->data.F32[i], exposures->data.F32[i], 163 202 addVariance->data.F32[i]); 164 203 } 165 204 166 if (!pmStackCombine(outRO, NULL, stack , maskBad, maskSuspect, maskBlank, kernelSize, iter,205 if (!pmStackCombine(outRO, NULL, stackData, maskBad, maskSuspect, maskBlank, kernelSize, iter, 167 206 combineRej, combineSys, combineDiscard, useVariance, safe, nminpix, false)) { 168 207 psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts with rejection."); 169 psFree(stack); 208 psFree(stackData); 209 210 // XXX EAM : if pmStackCombine fails above this return will cause the thread to block. 211 // The failure status results in a psThread.fault. the psThreadLauncher function, which 212 // each background thread runs as a loop, will sleep until the fault is cleared externally 213 // by the handler. psThreadPoolWait() catches, counts, and clears these faults, but 214 // ppStackThreadRead does not. 170 215 return false; 171 216 } … … 175 220 psArray *reject = psArrayAlloc(num); // List of pixels rejected 176 221 for (int i = 0; i < num; i++) { 177 pmStackData *data = stack ->data[i]; // Data for this image222 pmStackData *data = stackData->data[i]; // Data for this image 178 223 if (!data) { 179 224 continue; … … 186 231 reject->data[i] = psMemIncrRefCounter(data->reject); 187 232 } 188 psFree(stack );233 psFree(stackData); 189 234 190 235 //MEH change to trace … … 247 292 248 293 int num = readouts->n; // Number of inputs 249 psArray *stack = psArrayAlloc(num); // Array for stacking294 psArray *stackData = psArrayAlloc(num); // Array of data to be stacked 250 295 251 296 // We have rejection from a previous combination: combine without flagging pixels to inspect … … 272 317 addVariance ? addVariance->data.F32[i] : NAN); 273 318 data->reject = rejected ? psMemIncrRefCounter(rejected->data[i]) : NULL; 274 stack ->data[i] = data;319 stackData->data[i] = data; 275 320 276 321 //MEH -- apply bscale offset before norm … … 288 333 } 289 334 290 if (!pmStackCombine(outRO, expRO, stack , maskBad, maskSuspect, maskBlank, 0, iter, combineRej,335 if (!pmStackCombine(outRO, expRO, stackData, maskBad, maskSuspect, maskBlank, 0, iter, combineRej, 291 336 combineSys, combineDiscard, useVariance, safe, nminpix, rejected)) { 292 337 psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts."); 293 psFree(stack );338 psFree(stackData); 294 339 return false; 295 340 } … … 307 352 expChip->data_exists = true; 308 353 309 psFree(stack );354 psFree(stackData); 310 355 311 356 //MEH change to trace … … 316 361 return true; 317 362 } 363 364 // NOTE: expRO is allowed to be NULL 365 bool ppStackReadoutPercent(const pmConfig *config, pmReadout *outRO, pmReadout *expRO, const psArray *readouts, 366 const psVector *mask, const psVector *weightings, const psVector *exposures, 367 const psVector *addVariance) 368 { 369 assert(config); 370 assert(outRO); 371 assert(readouts); 372 assert(mask && mask->n == readouts->n && mask->type.type == PS_TYPE_VECTOR_MASK); 373 assert(weightings && weightings->n == readouts->n && weightings->type.type == PS_TYPE_F32); 374 assert(addVariance && addVariance->n == readouts->n && addVariance->type.type == PS_TYPE_F32); 375 static int sectionNum = 0; // Section number; for debugging outputs 376 377 // fprintf (stderr, "starting ReadoutPercent, %d\n", sectionNum); 378 379 // Get the recipe values 380 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe 381 psAssert(recipe, "We've thrown an error on this before."); 382 383 bool mdok; // Status of MD lookup 384 psF64 rejectFraction = psMetadataLookupF32(&mdok, recipe, "COMBINE.REJECT.FRACTION"); // fraction of outliers to reject 385 386 char defaultBlankStr[16] = "BLANK"; 387 388 psString maskBadStr = psMetadataLookupStr(&mdok, recipe, "MASK.VAL"); // Name of bits to mask for bad 389 psString maskSuspectStr = psMetadataLookupStr(&mdok, recipe, "MASK.SUSPECT"); // Name of suspect mask bits 390 psString maskBlankStr = psMetadataLookupStr(&mdok, recipe, "MASK.BLANK"); // Name of bits to set for empty pixels 391 if (!maskBlankStr) { 392 maskBlankStr = psMetadataLookupStr(&mdok, recipe, "MASK.BAD"); // Old name for MASK.BLANK 393 } 394 if (!maskBlankStr) { 395 maskBlankStr = defaultBlankStr; // this is statically allocated above 396 } 397 398 psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels 399 psImageMaskType maskSuspect = pmConfigMaskGet(maskSuspectStr, config); // Suspect bits 400 psImageMaskType maskBlank = pmConfigMaskGet(maskBlankStr, config); // Bits to mask for bad pixels 401 402 int num = readouts->n; // Number of inputs 403 psArray *stackData = psArrayAlloc(num); // Array of data to be stacked 404 405 for (int i = 0; i < num; i++) { 406 stackData->data[i] = NULL; 407 408 pmReadout *ro = readouts->data[i]; 409 if (!ro || mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 410 // Bad image 411 continue; 412 } 413 414 // Ensure there is a mask, or pmStackCombine will complain 415 if (!ro->mask) { 416 ro->mask = psImageAlloc(ro->image->numCols, ro->image->numRows, PS_TYPE_IMAGE_MASK); 417 psImageInit(ro->mask, 0); 418 } 419 420 stackData->data[i] = pmStackDataAlloc(ro, weightings->data.F32[i], exposures->data.F32[i], 421 addVariance->data.F32[i]); 422 } 423 424 if (!pmStackCombineByPercentile(outRO, expRO, stackData, rejectFraction, maskBad, maskSuspect, maskBlank)) { 425 psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts with rejection."); 426 psFree(stackData); 427 return false; 428 } 429 430 outRO->data_exists = true; // output readout 431 outRO->parent->data_exists = true; // output cell 432 outRO->parent->parent->data_exists = true; // output chip 433 434 if (expRO) { 435 expRO->data_exists = true; // expmap readout 436 expRO->parent->data_exists = true; // expmap cell 437 expRO->parent->parent->data_exists = true; // expmap chip 438 } 439 440 psFree(stackData); 441 sectionNum++; 442 443 return true; 444 } 445 446 -
trunk/ppStack/src/ppStackSetup.c
r35167 r42094 18 18 options->convolve = psMetadataLookupBool(NULL, recipe, "CONVOLVE"); // Convolve images? 19 19 options->doBackground = psMetadataLookupBool(NULL, recipe, "BACKGROUND.MODEL"); 20 21 options->clipPercent = psMetadataLookupBool(NULL, recipe, "COMBINE.PERCENT"); // use percentile range to clip? 20 22 21 23 if (!psMetadataLookupBool(NULL, config->arguments, "HAVE.PSF")) { -
trunk/ppStack/src/ppStackSources.c
r41529 r42094 341 341 options->norm = psVectorAlloc(num, PS_TYPE_F32); 342 342 for (int i = 0; i < num; i++) { 343 if (!isfinite(trans->data.F32[i])) { 344 continue; 345 } 343 if (!isfinite(trans->data.F32[i])) { 344 psLogMsg("ppStack", PS_LOG_INFO, "Non-finite transparency, skipping correction for image %d: %f mag (%f) (with inputMask value %d)\n", 345 i, NAN, trans->data.F32[i], inputMask->data.U8[i]); 346 continue; 347 } 346 348 psArray *sources = sourceLists->data[i]; // Sources of interest 347 349 float magCorr = zp->data.F32[i] - trans->data.F32[i] - 2.5*log10(options->sumExposure) - airmassTerm * airmassTarget; -
trunk/ppStack/src/ppStackThread.c
r36855 r42094 19 19 thread->firstScan = 0; 20 20 thread->lastScan = 0; 21 thread->entry = -1; // this gets assigned after allocation 22 thread->status = PPSTACK_THREAD_NEW; 21 23 return thread; 22 24 } … … 124 126 readouts->data[j] = ro; 125 127 } 126 threads->data[i] = ppStackThreadAlloc(readouts); 128 ppStackThread *thread = ppStackThreadAlloc(readouts); 129 thread->entry = i; 130 threads->data[i] = thread; 127 131 psFree(readouts); // Drop reference 128 132 } … … 157 161 while (true) { 158 162 // check for any groups which can read data 163 // NOTE: threads->n is set (in ppStackThreadDataSetup) to be 1 more than the argument to -threads 159 164 for (int j = 0; j < threads->n; j++) { 160 165 ppStackThread *thread = threads->data[j]; 166 // fprintf (stderr, "grab thread %d, scan: %d - %d : busy: %d read: %d status: %d\n", thread->entry, thread->firstScan, thread->lastScan, thread->busy, thread->read, thread->status); 161 167 if (thread->read) { 162 168 continue; … … 166 172 thread->lastScan = stack->lastScan + rows; 167 173 stack->lastScan = thread->lastScan; 174 thread->status = PPSTACK_THREAD_READ; 168 175 169 176 psArray *readouts = thread->readouts; … … 172 179 173 180 psTrace("ppStack", 2, "Reading data for chunk %d into group %d....\n", numChunk, j); 181 // fprintf (stderr, "Reading data for chunk %d into group %d (thread %d, scan: %d - %d)....\n", numChunk, j, thread->entry, thread->firstScan, thread->lastScan); 174 182 for (int i = 0; i < readouts->n; i++) { 175 183 pmReadout *ro = readouts->data[i]; // Input readout … … 178 186 } 179 187 188 // fprintf (stderr, "read data for readout %d\n", i); 189 180 190 // override the recorded last scan 181 ro->thisImageScan = thread->firstScan;191 ro->thisImageScan = thread->firstScan; 182 192 ro->thisVarianceScan = thread->firstScan; 183 ro->thisMaskScan = thread->firstScan;184 ro->lastImageScan = thread->lastScan;185 ro->lastMaskScan = thread->lastScan;193 ro->thisMaskScan = thread->firstScan; 194 ro->lastImageScan = thread->lastScan; 195 ro->lastMaskScan = thread->lastScan; 186 196 ro->lastVarianceScan = thread->lastScan; 187 ro->forceScan = true;188 189 psFits *imageFits = stack->imageFits->data[i]; // FITS file for image190 psFits *maskFits = stack->maskFits->data[i]; // FITS file for mask197 ro->forceScan = true; 198 199 psFits *imageFits = stack->imageFits->data[i]; // FITS file for image 200 psFits *maskFits = stack->maskFits->data[i]; // FITS file for mask 191 201 psFits *varianceFits = stack->varianceFits->data[i]; // FITS file for variance 192 202 … … 232 242 233 243 thread->read = thread->busy = true; 244 thread->status = PPSTACK_THREAD_RUN; 234 245 return thread; 235 246 } … … 239 250 for (int j = 0; j < threads->n; j++) { 240 251 ppStackThread *thread = threads->data[j]; 252 // fprintf (stderr, "test thread %d, scan: %d - %d : busy: %d, read: %d, status: %d\n", thread->entry, thread->firstScan, thread->lastScan, thread->busy, thread->read, thread->status); 253 241 254 if (thread->busy) { 242 255 continue; 243 256 } 257 thread->status = PPSTACK_THREAD_NEW; 244 258 thread->read = false; 245 259 wait = false; … … 283 297 } 284 298 299 { 300 psThreadTask *task = psThreadTaskAlloc("PPSTACK_PERCENT_COMBINE", 3); 301 task->function = &ppStackReadoutPercentThread; 302 psThreadTaskAdd(task); 303 psFree(task); 304 } 285 305 return; 286 306 } -
trunk/ppStack/src/ppStackThread.h
r34800 r42094 11 11 int firstScan; // First row of the chunk to be read for this group 12 12 int lastScan; // Last row of the chunk to be read for this group 13 int entry; // thread number for tracking progress 14 int status; // thread number for tracking progress 13 15 } ppStackThread; 14 16 … … 47 49 48 50 51 enum {PPSTACK_THREAD_NEW, PPSTACK_THREAD_READ, PPSTACK_THREAD_RUN, PPSTACK_THREAD_SUCCESS, PPSTACK_THREAD_FAILURE}; 52 53 49 54 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
