Changeset 20711
- Timestamp:
- Nov 12, 2008, 4:59:10 PM (17 years ago)
- Location:
- trunk/ppStack/src
- Files:
-
- 5 edited
-
ppStack.h (modified) (3 diffs)
-
ppStackLoop.c (modified) (5 diffs)
-
ppStackMatch.c (modified) (2 diffs)
-
ppStackReadout.c (modified) (12 diffs)
-
ppStackThread.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppStack/src/ppStack.h
r20659 r20711 99 99 const psArray *regions, // Array with array of regions used in each PSF match 100 100 const psArray *kernels, // Array with array of kernels used in each PSF match 101 const psVector *weightings, // Weighting factors for each image 101 102 const psVector *addVariance // Additional variance for rejection 102 103 ); … … 114 115 pmReadout *outRO, // Output readout 115 116 const psArray *readouts, // Input readouts 116 const psArray *rejected // Array with pixels rejected in each image 117 const psArray *rejected, // Array with pixels rejected in each image 118 const psVector *weightings // Weighting factors for each image 117 119 ); 118 120 … … 142 144 psArray **kernels, // Array of kernels used in each PSF matching, returned 143 145 float *chi2, // Chi^2 from the stamps 146 float *weighting, // Stack weighting (1/noise^2) 144 147 const psArray *sources, // Array of sources 145 148 const pmPSF *psf, // Target PSF -
trunk/ppStack/src/ppStackLoop.c
r20659 r20711 444 444 psVector *matchChi2 = psVectorAlloc(num, PS_TYPE_F32); // chi^2 for stamps when matching 445 445 psVectorInit(matchChi2, NAN); 446 psVector *weightings = psVectorAlloc(num, PS_TYPE_F32); // Combination weightings for images (1/noise^2) 447 psVectorInit(weightings, NAN); 446 448 for (int i = 0; i < num; i++) { 447 449 psTrace("ppStack", 2, "Convolving input %d of %d to target PSF....\n", i, num); … … 482 484 psArray *sources = haveSources ? globalSources : indSources->data[i]; // Sources for matching 483 485 psTimerStart("PPSTACK_MATCH"); 484 if (!ppStackMatch(readout, ®ions, &kernels, &matchChi2->data.F32[i], 486 if (!ppStackMatch(readout, ®ions, &kernels, &matchChi2->data.F32[i], &weightings->data.F32[i], 485 487 sources, targetPSF, rng, config)) { 486 488 psErrorStackPrint(stderr, "Unable to match image %d --- ignoring.", i); … … 718 720 psArrayAdd(job->args, 1, subRegions); 719 721 psArrayAdd(job->args, 1, subKernels); 722 psArrayAdd(job->args, 1, weightings); 720 723 psArrayAdd(job->args, 1, matchChi2); 721 724 if (!psThreadJobAddPending(job)) { … … 725 728 psFree(stack); 726 729 psFree(inputMask); 730 psFree(weightings); 727 731 psFree(matchChi2); 728 732 psFree(view); … … 961 965 psArrayAdd(job->args, 1, outRO); 962 966 psArrayAdd(job->args, 1, rejected); 967 psArrayAdd(job->args, 1, weightings); 963 968 if (!psThreadJobAddPending(job)) { 964 969 psFree(job); -
trunk/ppStack/src/ppStackMatch.c
r20710 r20711 47 47 #endif 48 48 49 bool ppStackMatch(pmReadout *readout, psArray **regions, psArray **kernels, float *chi2, 49 bool ppStackMatch(pmReadout *readout, psArray **regions, psArray **kernels, float *chi2, float *weighting, 50 50 const psArray *sources, const pmPSF *psf, psRandom *rng, const pmConfig *config) 51 51 { … … 384 384 (void)psBinaryOp(readout->image, readout->image, "+", 385 385 psScalarAlloc(- psStatsGetValue(bg, PS_STAT_ROBUST_MEDIAN), PS_TYPE_F32)); 386 *weighting = 1.0 / PS_SQR(psStatsGetValue(bg, PS_STAT_ROBUST_STDEV)); 386 387 psMetadataAddF32(readout->analysis, PS_LIST_TAIL, "PPSTACK.WEIGHTING", 0, 387 388 "Weighting by 1/noise^2 for stack", -
trunk/ppStack/src/ppStackReadout.c
r20710 r20711 22 22 psArray *subRegions = args->data[3]; // Regions for PSF-matching 23 23 psArray *subKernels = args->data[4]; // Kernels for PSF-matching 24 psVector *addVariance = args->data[5]; // Additional variance when rejecting 25 26 psArray *inspect = ppStackReadoutInitial(config, outRO, thread->readouts, 27 subRegions, subKernels, addVariance); 24 psVector *weightings = args->data[5]; // Weightings (1/noise^2) for each image 25 psVector *addVariance = args->data[6]; // Additional variance when rejecting 26 27 psArray *inspect = ppStackReadoutInitial(config, outRO, thread->readouts, subRegions, subKernels, 28 weightings, addVariance); 28 29 29 30 job->results = inspect; … … 42 43 pmReadout *outRO = args->data[2]; // Output readout 43 44 psArray *rejected = args->data[3]; // Rejected pixels 44 45 bool status = ppStackReadoutFinal(config, outRO, thread->readouts, rejected); // Status of operation 45 psVector *weightings = args->data[4]; // Weighting (1/noise^2) for each image 46 47 bool status = ppStackReadoutFinal(config, outRO, thread->readouts, rejected, 48 weightings); // Status of operation 46 49 47 50 thread->busy = false; … … 77 80 78 81 psArray *ppStackReadoutInitial(const pmConfig *config, pmReadout *outRO, const psArray *readouts, 79 const psArray *regions, const psArray *kernels, const psVector *addVariance) 82 const psArray *regions, const psArray *kernels, const psVector *weightings, 83 const psVector *addVariance) 80 84 { 81 85 assert(config); … … 86 90 assert(readouts->n == regions->n); 87 91 assert(regions->n == kernels->n); 92 assert(weightings && weightings->n == readouts->n && weightings->type.type == PS_TYPE_F32); 88 93 assert(addVariance && addVariance->n == readouts->n && addVariance->type.type == PS_TYPE_F32); 89 94 static int sectionNum = 0; // Section number; for debugging outputs … … 118 123 } 119 124 125 #if 0 126 // This doesn't seem to work, so getting the weightings directly from a vector 120 127 float weighting = psMetadataLookupF32(&mdok, ro->analysis, "PPSTACK.WEIGHTING"); // Relative weight 121 128 if (!mdok || !isfinite(weighting)) { … … 125 132 psLogMsg("ppStack", PS_LOG_INFO, "Weighting for image %d is %f", i, weighting); 126 133 } 134 #endif 127 135 128 136 // Ensure there is a mask, or pmStackCombine will complain … … 132 140 } 133 141 134 stack->data[i] = pmStackDataAlloc(ro, weighting , addVariance->data.F32[i]);142 stack->data[i] = pmStackDataAlloc(ro, weightings->data.F32[i], addVariance->data.F32[i]); 135 143 } 136 144 … … 176 184 177 185 bool ppStackReadoutFinal(const pmConfig *config, pmReadout *outRO, const psArray *readouts, 178 const psArray *rejected )186 const psArray *rejected, const psVector *weightings) 179 187 { 180 188 assert(config); … … 183 191 assert(rejected); 184 192 assert(readouts->n == rejected->n); 193 assert(weightings && weightings->n == readouts->n && weightings->type.type == PS_TYPE_F32); 185 194 186 195 static int sectionNum = 0; … … 212 221 assert(ro); 213 222 223 #if 0 224 // This doesn't seem to work, so getting the weightings directly from a vector 214 225 bool mdok; // Status of MD lookup 215 226 float weighting = psMetadataLookupF32(&mdok, ro->analysis, "PPSTACK.WEIGHTING"); // Relative weight … … 218 229 weighting = 1.0; 219 230 } 231 #endif 220 232 221 233 // Ensure there is a mask, or pmStackCombine will complain … … 225 237 } 226 238 227 pmStackData *data = pmStackDataAlloc(ro, weighting , NAN);239 pmStackData *data = pmStackDataAlloc(ro, weightings->data.F32[i], NAN); 228 240 data->reject = psMemIncrRefCounter(rejected->data[i]); 229 241 stack->data[i] = data; -
trunk/ppStack/src/ppStackThread.c
r19532 r20711 235 235 236 236 { 237 psThreadTask *task = psThreadTaskAlloc("PPSTACK_INITIAL_COMBINE", 6);237 psThreadTask *task = psThreadTaskAlloc("PPSTACK_INITIAL_COMBINE", 7); 238 238 task->function = &ppStackReadoutInitialThread; 239 239 psThreadTaskAdd(task); … … 249 249 250 250 { 251 psThreadTask *task = psThreadTaskAlloc("PPSTACK_FINAL_COMBINE", 4);251 psThreadTask *task = psThreadTaskAlloc("PPSTACK_FINAL_COMBINE", 5); 252 252 task->function = &ppStackReadoutFinalThread; 253 253 psThreadTaskAdd(task);
Note:
See TracChangeset
for help on using the changeset viewer.
