Changeset 41841
- Timestamp:
- Oct 15, 2021, 6:45:21 AM (5 years ago)
- Location:
- branches/eam_branches/ppStack.20211015/src
- Files:
-
- 2 added
- 10 edited
-
ppStackCombineInitial.c (modified) (1 diff)
-
ppStackCombinePercent.c (added)
-
ppStackCombinePrepare.c (modified) (4 diffs)
-
ppStackLoop.c (modified) (5 diffs)
-
ppStackLoop.h (modified) (3 diffs)
-
ppStackLoopByPercent.c (added)
-
ppStackMatch.c (modified) (1 diff)
-
ppStackOptions.c (modified) (1 diff)
-
ppStackOptions.h (modified) (1 diff)
-
ppStackReadout.c (modified) (2 diffs)
-
ppStackSetup.c (modified) (1 diff)
-
ppStackThread.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ppStack.20211015/src/ppStackCombineInitial.c
r33093 r41841 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"); -
branches/eam_branches/ppStack.20211015/src/ppStackCombinePrepare.c
r34859 r41841 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 -
branches/eam_branches/ppStack.20211015/src/ppStackLoop.c
r41529 r41841 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 bscaleOffset136 // MEH -- see below for comment on ppStackCombineFinal and bscaleOffset 132 137 if (!ppStackCombineFinal(stack, options->convCovars, options, config, false, true, true, true)) { 133 138 psError(psErrorCodeLast(), false, "Unable to perform final combination."); … … 154 159 return false; 155 160 } 156 ppStackFileActivation(config,PPSTACK_FILES_BKG ,false); 161 ppStackFileActivation(config, PPSTACK_FILES_BKG, false); 162 157 163 // Photometry 158 164 psTrace("ppStack", 1, "Photometering stacked image....\n"); … … 184 190 return false; 185 191 } 186 // MEH -- also must uncomment back out..192 // MEH -- also must uncomment back out.. 187 193 psFree(stack); 188 194 psLogMsg("ppStack", PS_LOG_INFO, "Stage 7: Cleanup, WCS & JPEGS: %f sec", psTimerClear("PPSTACK_STEPS")); -
branches/eam_branches/ppStack.20211015/src/ppStackLoop.h
r36855 r41841 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); -
branches/eam_branches/ppStack.20211015/src/ppStackMatch.c
r36364 r41841 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 -
branches/eam_branches/ppStack.20211015/src/ppStackOptions.c
r36855 r41841 56 56 options->num = 0; 57 57 options->quality = 0; 58 59 options->clipPercent = false; 60 options->clipMinRange = 0.16; // 1-sigma default 61 options->clipMaxRange = 0.84; // 1-sigma default 62 58 63 options->psf = NULL; 59 64 options->sumExposure = NAN; -
branches/eam_branches/ppStack.20211015/src/ppStackOptions.h
r36855 r41841 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 psF32 clipMinRange; // min percentile 21 psF32 clipMaxRange; // max percentile 22 18 23 // Prepare 19 24 pmPSF *psf; // Target PSF -
branches/eam_branches/ppStack.20211015/src/ppStackReadout.c
r36886 r41841 53 53 } 54 54 55 bool ppStackReadoutPercentThread(psThreadJob *job) 56 { 57 PS_ASSERT_THREAD_JOB_NON_NULL(job, false); 58 59 psArray *args = job->args; // Arguments 60 ppStackThread *thread = args->data[0]; // Thread 61 ppStackOptions *options = args->data[1]; // Options 62 pmConfig *config = args->data[2]; // Configuration 63 64 pmReadout *outRO = options->outRO; // Output readout 65 psVector *mask = options->inputMask; // Mask for inputs 66 psVector *weightings = options->weightings; // Weightings (1/noise^2) for each image 67 psVector *exposures = options->exposures; // Exposure times for each image 68 psVector *addVariance = options->matchChi2; // Additional variance when rejecting 69 70 job->results = ppStackReadoutInitial(config, outRO, thread->readouts, mask, 71 weightings, exposures, addVariance); 72 thread->busy = false; 73 74 return job->results ? true : false; 75 } 76 77 //////////////////////////////////// 55 78 56 79 bool ppStackInspect(psThreadJob *job) … … 316 339 return true; 317 340 } 341 342 psArray *ppStackReadoutPercent(const pmConfig *config, pmReadout *outRO, const psArray *readouts, 343 const psVector *mask, const psVector *weightings, const psVector *exposures, 344 const psVector *addVariance) 345 { 346 assert(config); 347 assert(outRO); 348 assert(readouts); 349 assert(mask && mask->n == readouts->n && mask->type.type == PS_TYPE_VECTOR_MASK); 350 assert(weightings && weightings->n == readouts->n && weightings->type.type == PS_TYPE_F32); 351 assert(addVariance && addVariance->n == readouts->n && addVariance->type.type == PS_TYPE_F32); 352 static int sectionNum = 0; // Section number; for debugging outputs 353 354 // Get the recipe values 355 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe 356 psAssert(recipe, "We've thrown an error on this before."); 357 358 bool mdok; // Status of MD lookup 359 float iter = psMetadataLookupF32(NULL, recipe, "COMBINE.ITER"); // Rejection iterations 360 float minRange = psMetadataLookupF32(NULL, recipe, "COMBINE.MIN.RANGE"); // Combination threshold 361 float maxRange = psMetadataLookupF32(NULL, recipe, "COMBINE.MAX.RANGE"); // Combination threshold 362 363 psMetadata *ppsub = psMetadataLookupMetadata(NULL, config->recipes, "PPSUB"); // PPSUB recipe 364 int kernelSize = psMetadataLookupS32(NULL, ppsub, "KERNEL.SIZE"); // Kernel half-size 365 366 psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.VAL"); // Name of bits to mask for bad 367 psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels 368 369 psString maskSuspectStr = psMetadataLookupStr(NULL, recipe, "MASK.SUSPECT"); // Name of suspect mask bits 370 psImageMaskType maskSuspect = pmConfigMaskGet(maskSuspectStr, config); // Suspect bits 371 372 bool status = false; 373 psImageMaskType maskBlank; 374 psString maskBlankStr = psMetadataLookupStr(&status, recipe, "MASK.BLANK"); // Name of bits to set for empty pixels 375 if (maskBlankStr) { 376 maskBlank = pmConfigMaskGet(maskBlankStr, config); // Bits to mask for bad pixels 377 } else { 378 maskBlankStr = psMetadataLookupStr(&status, recipe, "MASK.BAD"); // Old name for MASK.BLANK 379 if (maskBlankStr) { 380 maskBlank = pmConfigMaskGet(maskBlankStr, config); // Bits to mask for bad pixels 381 } else { 382 maskBlank = pmConfigMaskGet("BLANK", config); // Bits to mask for bad pixels 383 } 384 } 385 386 int num = readouts->n; // Number of inputs 387 psArray *stack = psArrayAlloc(num); // Array for stacking 388 389 for (int i = 0; i < num; i++) { 390 pmReadout *ro = readouts->data[i]; 391 if (!ro || mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 392 // Bad image 393 continue; 394 } 395 396 // Ensure there is a mask, or pmStackCombine will complain 397 if (!ro->mask) { 398 ro->mask = psImageAlloc(ro->image->numCols, ro->image->numRows, PS_TYPE_IMAGE_MASK); 399 psImageInit(ro->mask, 0); 400 } 401 402 stack->data[i] = pmStackDataAlloc(ro, weightings->data.F32[i], exposures->data.F32[i], 403 addVariance->data.F32[i]); 404 } 405 406 if (!pmStackCombineByPercentile(outRO, stack, minRange, maxRange, maskBad, maskSuspect, maskBlank)) { 407 psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts with rejection."); 408 psFree(stack); 409 return false; 410 } 411 412 sectionNum++; 413 414 psArray *results = psArrayAlloc(2); // Array of results 415 results->data[0] = inspect; 416 results->data[1] = reject; 417 418 return results; 419 } 420 421 -
branches/eam_branches/ppStack.20211015/src/ppStackSetup.c
r35167 r41841 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? 22 options->clipMinRange = psMetadataLookupF32 (NULL, recipe, "COMBINE.MIN.RANGE"); // min percentile 23 options->clipMaxRange = psMetadataLookupF32 (NULL, recipe, "COMBINE.MAX.RANGE"); // max percentile 24 20 25 21 26 if (!psMetadataLookupBool(NULL, config->arguments, "HAVE.PSF")) { -
branches/eam_branches/ppStack.20211015/src/ppStackThread.c
r36855 r41841 283 283 } 284 284 285 { 286 psThreadTask *task = psThreadTaskAlloc("PPSTACK_PERCENT_COMBINE", 3); 287 task->function = &ppStackReadoutPercentThread; 288 psThreadTaskAdd(task); 289 psFree(task); 290 } 285 291 return; 286 292 }
Note:
See TracChangeset
for help on using the changeset viewer.
