Changeset 37067 for branches/eam_branches/ipp-ops-20130712/ppStack/src
- Timestamp:
- Jul 17, 2014, 12:32:26 PM (12 years ago)
- Location:
- branches/eam_branches/ipp-ops-20130712/ppStack/src
- Files:
-
- 11 edited
-
. (modified) (1 prop)
-
ppStack.h (modified) (1 diff)
-
ppStackCombineFinal.c (modified) (4 diffs)
-
ppStackLoop.c (modified) (5 diffs)
-
ppStackLoop.h (modified) (1 diff)
-
ppStackMatch.c (modified) (2 diffs)
-
ppStackOptions.c (modified) (2 diffs)
-
ppStackOptions.h (modified) (1 diff)
-
ppStackPrepare.c (modified) (2 diffs)
-
ppStackReadout.c (modified) (10 diffs)
-
ppStackThread.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-ops-20130712/ppStack/src
- Property svn:mergeinfo changed
/trunk/ppStack/src merged: 35931,36364-36365,36610,36710,36717,36855,36886
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-ops-20130712/ppStack/src/ppStack.h
r34849 r37067 108 108 const psVector *addVariance, // Additional variance for rejection 109 109 bool safety, // Enable safety switch? 110 const psVector *norm // Normalisations to apply 110 const psVector *norm, // Normalisations to apply 111 const psVector *bscaleApplyOffset // hack for offset based on bscale 111 112 ); 112 113 -
branches/eam_branches/ipp-ops-20130712/ppStack/src/ppStackCombineFinal.c
r33093 r37067 4 4 // #define TESTING // Enable test output 5 5 6 //MEH -- adhoc addition to blank mask border of final stack since rejection different/none on order of KERNEL.SIZE with overlap in CombineInitial 7 static void stackBorderMask(psImage *image, // Image to mark as blank 8 psImage *mask, // Mask to mark as blank (or NULL) 9 psImage *variance, // Weight map to mark as blank (or NULL) 10 int numCols, int numRows, // Size of image 11 int size, // Size to mark blank 12 psImageMaskType blank // Blank mask value 13 ) 14 { 15 for (int y = size; y < numRows - size; y++) { 16 for (int x = 0; x < size; x++) { 17 image->data.F32[y][x] = NAN; 18 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = blank; 19 variance->data.F32[y][x] = NAN; 20 } 21 for (int x = numCols - size; x < numCols; x++) { 22 image->data.F32[y][x] = NAN; 23 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = blank; 24 variance->data.F32[y][x] = NAN; 25 } 26 } 27 for (int y = 0; y < size; y++) { 28 for (int x = 0; x < numCols; x++) { 29 image->data.F32[y][x] = NAN; 30 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = blank; 31 variance->data.F32[y][x] = NAN; 32 } 33 } 34 for (int y = numRows - size; y < numRows; y++) { 35 for (int x = 0; x < numCols; x++) { 36 image->data.F32[y][x] = NAN; 37 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = blank; 38 variance->data.F32[y][x] = NAN; 39 } 40 } 41 return; 42 } 43 44 6 45 bool ppStackCombineFinal(ppStackThreadData *stack, psArray *covariances, ppStackOptions *options, 7 pmConfig *config, bool safe, bool normalise, bool grow )46 pmConfig *config, bool safe, bool normalise, bool grow, bool bscaleoffset) 8 47 { 9 48 psAssert(stack, "Require stack"); … … 20 59 psAssert(recipe, "We've thrown an error on this before."); 21 60 float poorFrac = psMetadataLookupF32(NULL, recipe, "POOR.FRACTION"); // Fraction for "poor" 61 62 int sizeBlank = psMetadataLookupS32(NULL, recipe, "MASK.BLANKBORDER"); // Pixels to mask BLANK from edge 63 psImageMaskType maskBlank = pmConfigMaskGet("BLANK", config); // Bits to mask for bad pixels 22 64 23 65 // Grow the list of rejected pixels, if desired … … 65 107 PS_ARRAY_ADD_SCALAR(job->args, safe, PS_TYPE_U8); 66 108 PS_ARRAY_ADD_SCALAR(job->args, normalise, PS_TYPE_U8); 109 PS_ARRAY_ADD_SCALAR(job->args, bscaleoffset, PS_TYPE_U8); 67 110 if (!psThreadJobAddPending(job)) { 68 111 psFree(reject); … … 109 152 #endif 110 153 154 //MEH blank mask/manual reject border on final stack -- 155 if (sizeBlank > 0) { 156 stackBorderMask(outRO->image,outRO->mask,outRO->variance,numCols,numRows,sizeBlank,maskBlank); 157 stackBorderMask(expRO->image,expRO->mask,expRO->variance,numCols,numRows,sizeBlank,0); 158 } 159 111 160 if (options->stats) { 112 161 // only add the timer if it has not been set (convolved stack) -
branches/eam_branches/ipp-ops-20130712/ppStack/src/ppStackLoop.c
r35167 r37067 87 87 pmCellFreeData(options->cells->data[i]); 88 88 } 89 // psFree(stack); 89 //MEH -- must uncomment back out -- unclear is should be moved after pixel rejection 90 psFree(stack); 90 91 91 92 // Pixel rejection … … 119 120 psTrace("ppStack", 2, "Final stack of convolved images....\n"); 120 121 if (options->convolve) { 121 if (!ppStackCombineFinal(stack, options->convCovars, options, config, false, false, true )) {122 if (!ppStackCombineFinal(stack, options->convCovars, options, config, false, false, true, false)) { 122 123 psError(psErrorCodeLast(), false, "Unable to perform final combination."); 123 124 psFree(stack); … … 127 128 else { 128 129 // Since we haven't convolved, I believe we do need to normalize here. 129 if (!ppStackCombineFinal(stack, options->convCovars, options, config, false, true, true)) { 130 //MEH -- see below for comment on ppStackCombineFinal and bscaleOffset 131 if (!ppStackCombineFinal(stack, options->convCovars, options, config, false, true, true, true)) { 130 132 psError(psErrorCodeLast(), false, "Unable to perform final combination."); 131 133 psFree(stack); … … 181 183 return false; 182 184 } 183 // psFree(stack); 185 //MEH -- also must uncomment back out.. 186 psFree(stack); 184 187 psLogMsg("ppStack", PS_LOG_INFO, "Stage 7: Cleanup, WCS & JPEGS: %f sec", psTimerClear("PPSTACK_STEPS")); 185 188 ppStackMemDump("cleanup"); … … 205 208 // generate the unconvolved stack. NOTE: this one must be normalized since the inputs have not been 206 209 psTrace("ppStack", 2, "Stack of unconvolved images....\n"); 207 if (!ppStackCombineFinal(stack, options->origCovars, options, config, false, true, false)) { 210 //MEH -- terrible hack for bscale offset to input warps -- treat like normalization 211 // -- if BSCALEOFFSET TRUE, 0.5*bscale for offset values, otherwise value 0.0 212 // -- bscaleOffset set when files read in and applied in CombineFinal (if arg true, only valid for unconv case) 213 if (!ppStackCombineFinal(stack, options->origCovars, options, config, false, true, false, true)) { 208 214 psError(psErrorCodeLast(), false, "Unable to perform unconvolved combination."); 209 215 psFree(stack); -
branches/eam_branches/ipp-ops-20130712/ppStack/src/ppStackLoop.h
r34800 r37067 65 65 bool safe, // Allow safe combination? 66 66 bool norm, // Normalise images? 67 bool grow // Grow rejection masks? 67 bool grow, // Grow rejection masks? 68 bool bscaleoffset // Apply bscale offset? 68 69 ); 69 70 -
branches/eam_branches/ipp-ops-20130712/ppStack/src/ppStackMatch.c
r35908 r37067 6 6 #define COVAR_FRAC 0.01 // Truncation fraction for covariance matrix 7 7 8 // #define TESTING // Enable debugging output8 // #define TESTING // Enable debugging output 9 9 // #define TESTING_REUSE_CONV // Enable debugging for re-using convolved outputs from previous run 10 11 10 // #define TESTING_CZW 12 11 … … 156 155 if (options->convolve) { 157 156 pmReadout *conv = pmReadoutAlloc(NULL); // Conv readout, for holding results temporarily 157 158 // MEH -- earlier defn needed with new simple mode modifications to use TESTING_REUSE_CONV... 159 //const char *typeStr = psMetadataLookupStr(NULL, ppsub, "KERNEL.TYPE"); // Kernel type 160 //pmSubtractionKernelsType type = pmSubtractionKernelsTypeFromString(typeStr); // Kernel type 161 158 162 #ifdef TESTING_REUSE_CONV 159 163 // This is a hack to use the temporary convolved images and kernel generated previously. -
branches/eam_branches/ipp-ops-20130712/ppStack/src/ppStackOptions.c
r35167 r37067 19 19 psFree(options->inputMask); 20 20 psFree(options->sourceLists); 21 psFree(options->bscaleOffset); 21 22 psFree(options->norm); 22 23 psFree(options->sources); … … 65 66 options->inputMask = NULL; 66 67 options->sourceLists = NULL; 68 options->bscaleOffset = NULL; 67 69 options->norm = NULL; 68 70 options->sources = NULL; -
branches/eam_branches/ipp-ops-20130712/ppStack/src/ppStackOptions.h
r35167 r37067 35 35 float clippedMean; // clipped mean of input fwhm 36 36 float clippedStdev; // clipped stdev of input fwhm 37 psVector *bscaleOffset; // hack offset of bzero using 0.5*bscale if option, 0.0 if not 37 38 // Convolve 38 39 psArray *cells; // Cells for convolved images --- a handle for reading again -
branches/eam_branches/ipp-ops-20130712/ppStack/src/ppStackPrepare.c
r35941 r37067 148 148 } 149 149 150 //MEH -- bscale offset hack for warps 151 options->bscaleOffset = psVectorAlloc(options->num, PS_TYPE_F32); 152 psVectorInit(options->bscaleOffset, 0.0); 153 bool setbscaleoffset = psMetadataLookupBool(NULL,recipe, "BSCALEOFFSET"); 154 150 155 psArray *psfs = psArrayAlloc(num); // PSFs for PSF envelope 151 156 int numCols = 0, numRows = 0; // Size of image … … 162 167 } 163 168 options->sumExposure += options->exposures->data.F32[i]; 169 170 //MEH -- hdu get redefn again below if conv (lots of this happening..) 171 if (setbscaleoffset) { 172 pmHDU *hdu = pmHDUFromCell(cell); 173 assert(hdu && hdu->header); 174 float bscale = psMetadataLookupF32(NULL, hdu->header, "BSCALE"); 175 options->bscaleOffset->data.F32[i] = 0.5*bscale; 176 } 177 psLogMsg("ppStack", PS_LOG_INFO, "bscaleOffset: %d %f", i,options->bscaleOffset->data.F32[i]); 164 178 165 179 // Get list of PSFs, to determine target PSF -
branches/eam_branches/ipp-ops-20130712/ppStack/src/ppStackReadout.c
r34800 r37067 34 34 bool safety = PS_SCALAR_VALUE(args->data[4], U8); // Safety switch on? 35 35 bool normalise = PS_SCALAR_VALUE(args->data[5], U8); // Normalise images? 36 bool bscaleoffset = PS_SCALAR_VALUE(args->data[6], U8); // Apply bscale offset? 36 37 37 38 psVector *mask = options->inputMask; // Mask for inputs … … 40 41 psVector *addVariance = options->matchChi2; // Additional variance when rejecting 41 42 psVector *norm = normalise ? options->norm : NULL; // Normalisations to apply to images 43 psVector *bscaleApplyOffset = bscaleoffset ? options->bscaleOffset : NULL; // BSCALE offset to apply to images 42 44 43 45 bool status = ppStackReadoutFinal(config, options->outRO, options->expRO, thread->readouts, mask, reject, 44 weightings, exposures, addVariance, safety, norm ); // Status of operation46 weightings, exposures, addVariance, safety, norm, bscaleApplyOffset); // Status of operation 45 47 46 48 thread->busy = false; … … 116 118 bool useVariance = psMetadataLookupBool(&mdok, recipe, "VARIANCE"); // Use variance for rejection? 117 119 bool safe = psMetadataLookupBool(&mdok, recipe, "SAFE"); // Be safe when combining small numbers of pixels 120 121 int nminpix = psMetadataLookupS32(&mdok, recipe, "NMINPIX"); // Minimum input per pixel to combine with 118 122 119 123 psMetadata *ppsub = psMetadataLookupMetadata(NULL, config->recipes, "PPSUB"); // PPSUB recipe … … 161 165 162 166 if (!pmStackCombine(outRO, NULL, stack, maskBad, maskSuspect, maskBlank, kernelSize, iter, 163 combineRej, combineSys, combineDiscard, useVariance, safe, false)) {167 combineRej, combineSys, combineDiscard, useVariance, safe, nminpix, false)) { 164 168 psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts with rejection."); 165 169 psFree(stack); … … 184 188 psFree(stack); 185 189 190 //MEH change to trace 191 //psLogMsg("ppStack", PS_LOG_INFO, "initial stack image sectionNum %d", sectionNum); 192 186 193 sectionNum++; 187 194 … … 197 204 const psVector *mask, const psArray *rejected, const psVector *weightings, 198 205 const psVector *exposures, const psVector *addVariance, bool safety, 199 const psVector *norm )206 const psVector *norm, const psVector *bscaleApplyOffset) 200 207 { 201 208 assert(config); … … 216 223 bool useVariance = psMetadataLookupBool(&mdok, recipe, "VARIANCE"); // Use variance for rejection? 217 224 bool safe = psMetadataLookupBool(&mdok, recipe, "SAFE"); // Be safe when combining small numbers of pixels 225 226 int nminpix = psMetadataLookupS32(&mdok, recipe, "NMINPIX"); // Minimum input per pixel to combine with 218 227 219 228 psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.VAL"); // Name of bits to mask for bad … … 265 274 stack->data[i] = data; 266 275 276 //MEH -- apply bscale offset before norm 277 if (bscaleApplyOffset) { 278 //MEH change to trace 279 //psLogMsg("ppStack", PS_LOG_INFO, "bscaleApplyOffset: %d %f", i, bscaleApplyOffset->data.F32[i]); 280 psBinaryOp(ro->image, ro->image, "-", psScalarAlloc(bscaleApplyOffset->data.F32[i], PS_TYPE_F32)); 281 } 282 267 283 if (norm) { 268 284 float normalise = powf(10.0, -0.4 * norm->data.F32[i]); // Normalisation … … 273 289 274 290 if (!pmStackCombine(outRO, expRO, stack, maskBad, maskSuspect, maskBlank, 0, iter, combineRej, 275 combineSys, combineDiscard, useVariance, safe, rejected)) {291 combineSys, combineDiscard, useVariance, safe, nminpix, rejected)) { 276 292 psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts."); 277 293 psFree(stack); … … 293 309 psFree(stack); 294 310 311 //MEH change to trace 312 //psLogMsg("ppStack", PS_LOG_INFO, "final stack image sectionNum %d", sectionNum); 313 295 314 sectionNum++; 296 315 -
branches/eam_branches/ipp-ops-20130712/ppStack/src/ppStackThread.c
r34800 r37067 277 277 278 278 { 279 psThreadTask *task = psThreadTaskAlloc("PPSTACK_FINAL_COMBINE", 6);279 psThreadTask *task = psThreadTaskAlloc("PPSTACK_FINAL_COMBINE", 7); 280 280 task->function = &ppStackReadoutFinalThread; 281 281 psThreadTaskAdd(task);
Note:
See TracChangeset
for help on using the changeset viewer.
