Changeset 27400
- Timestamp:
- Mar 22, 2010, 8:34:28 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 23 edited
-
ippconfig/recipes/filerules-mef.mdc (modified) (1 diff)
-
ippconfig/recipes/filerules-simple.mdc (modified) (1 diff)
-
ippconfig/recipes/filerules-split.mdc (modified) (1 diff)
-
ppStack/src/ppStack.h (modified) (2 diffs)
-
ppStack/src/ppStackCamera.c (modified) (3 diffs)
-
ppStack/src/ppStackCleanup.c (modified) (1 diff)
-
ppStack/src/ppStackCombineFinal.c (modified) (8 diffs)
-
ppStack/src/ppStackCombineInitial.c (modified) (1 diff)
-
ppStack/src/ppStackCombinePrepare.c (modified) (3 diffs)
-
ppStack/src/ppStackFiles.c (modified) (1 diff)
-
ppStack/src/ppStackLoop.c (modified) (5 diffs)
-
ppStack/src/ppStackLoop.h (modified) (2 diffs)
-
ppStack/src/ppStackOptions.c (modified) (4 diffs)
-
ppStack/src/ppStackOptions.h (modified) (2 diffs)
-
ppStack/src/ppStackPrepare.c (modified) (6 diffs)
-
ppStack/src/ppStackReadout.c (modified) (8 diffs)
-
ppStack/src/ppStackReject.c (modified) (1 diff)
-
ppStack/src/ppStackSources.c (modified) (7 diffs)
-
ppStack/src/ppStackThread.c (modified) (1 diff)
-
psModules/src/imcombine/pmStack.c (modified) (28 diffs)
-
psModules/src/imcombine/pmStack.h (modified) (3 diffs)
-
psModules/src/imcombine/pmSubtractionMask.c (modified) (1 diff)
-
psModules/src/imcombine/pmSubtractionStamps.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippconfig/recipes/filerules-mef.mdc
r27365 r27400 265 265 PPSTACK.OUTPUT.MASK OUTPUT {OUTPUT}.mk.fits MASK COMP_MASK FPA TRUE NONE 266 266 PPSTACK.OUTPUT.VARIANCE OUTPUT {OUTPUT}.wt.fits VARIANCE COMP_WT FPA TRUE NONE 267 PPSTACK.OUTPUT.EXP OUTPUT {OUTPUT}.exp.fits IMAGE NONE FPA TRUE NONE 268 PPSTACK.OUTPUT.EXPNUM OUTPUT {OUTPUT}.num.fits MASK NONE FPA TRUE NONE 267 269 PPSTACK.UNCONV OUTPUT {OUTPUT}.unconv.fits IMAGE COMP_IMG FPA TRUE NONE 268 270 PPSTACK.UNCONV.MASK OUTPUT {OUTPUT}.unconv.mask.fits MASK COMP_MASK FPA TRUE NONE 269 271 PPSTACK.UNCONV.VARIANCE OUTPUT {OUTPUT}.unconv.wt.fits VARIANCE COMP_WT FPA TRUE NONE 272 PPSTACK.UNCONV.EXP OUTPUT {OUTPUT}.unconv.exp.fits IMAGE NONE FPA TRUE NONE 273 PPSTACK.UNCONV.EXPNUM OUTPUT {OUTPUT}.unconv.num.fits MASK NONE FPA TRUE NONE 270 274 PPSTACK.TARGET.PSF OUTPUT {OUTPUT}.target.psf PSF NONE CHIP TRUE NONE 271 275 PPSTACK.CONV.KERNEL OUTPUT {OUTPUT}.{FILE.INDEX}.kernel SUBKERNEL NONE FPA TRUE NONE -
trunk/ippconfig/recipes/filerules-simple.mdc
r27365 r27400 214 214 PPSTACK.OUTPUT.MASK OUTPUT {OUTPUT}.mask.fits MASK NONE FPA TRUE NONE 215 215 PPSTACK.OUTPUT.VARIANCE OUTPUT {OUTPUT}.weight.fits VARIANCE NONE FPA TRUE NONE 216 PPSTACK.OUTPUT.EXP OUTPUT {OUTPUT}.exp.fits IMAGE NONE FPA TRUE NONE 217 PPSTACK.OUTPUT.EXPNUM OUTPUT {OUTPUT}.num.fits MASK NONE FPA TRUE NONE 216 218 PPSTACK.UNCONV OUTPUT {OUTPUT}.unconv.fits IMAGE COMP_IMG FPA TRUE NONE 217 219 PPSTACK.UNCONV.MASK OUTPUT {OUTPUT}.unconv.mask.fits MASK COMP_MASK FPA TRUE NONE 218 220 PPSTACK.UNCONV.VARIANCE OUTPUT {OUTPUT}.unconv.wt.fits VARIANCE COMP_WT FPA TRUE NONE 221 PPSTACK.UNCONV.EXP OUTPUT {OUTPUT}.unconv.exp.fits IMAGE NONE FPA TRUE NONE 222 PPSTACK.UNCONV.EXPNUM OUTPUT {OUTPUT}.unconv.num.fits MASK NONE FPA TRUE NONE 219 223 PPSTACK.TARGET.PSF OUTPUT {OUTPUT}.target.psf PSF NONE CHIP TRUE NONE 220 224 PPSTACK.CONV.KERNEL OUTPUT {OUTPUT}.{FILE.INDEX}.kernel SUBKERNEL NONE FPA TRUE NONE -
trunk/ippconfig/recipes/filerules-split.mdc
r27365 r27400 233 233 PPSTACK.OUTPUT.MASK OUTPUT {OUTPUT}.mask.fits MASK COMP_MASK FPA TRUE NONE 234 234 PPSTACK.OUTPUT.VARIANCE OUTPUT {OUTPUT}.wt.fits VARIANCE COMP_WT FPA TRUE NONE 235 PPSTACK.OUTPUT.EXP OUTPUT {OUTPUT}.exp.fits IMAGE NONE FPA TRUE NONE 236 PPSTACK.OUTPUT.EXPNUM OUTPUT {OUTPUT}.num.fits MASK NONE FPA TRUE NONE 235 237 PPSTACK.UNCONV OUTPUT {OUTPUT}.unconv.fits IMAGE COMP_IMG FPA TRUE NONE 236 238 PPSTACK.UNCONV.MASK OUTPUT {OUTPUT}.unconv.mask.fits MASK COMP_MASK FPA TRUE NONE 237 239 PPSTACK.UNCONV.VARIANCE OUTPUT {OUTPUT}.unconv.wt.fits VARIANCE COMP_WT FPA TRUE NONE 240 PPSTACK.UNCONV.EXP OUTPUT {OUTPUT}.unconv.exp.fits IMAGE NONE FPA TRUE NONE 241 PPSTACK.UNCONV.EXPNUM OUTPUT {OUTPUT}.unconv.num.fits MASK NONE FPA TRUE NONE 238 242 PPSTACK.TARGET.PSF OUTPUT {OUTPUT}.target.psf PSF NONE CHIP TRUE NONE 239 243 PPSTACK.CONV.KERNEL OUTPUT {OUTPUT}.{FILE.INDEX}.kernel SUBKERNEL NONE FPA TRUE NONE -
trunk/ppStack/src/ppStack.h
r27319 r27400 69 69 const psVector *mask, // Mask for input readouts 70 70 const psVector *weightings, // Weighting factors for each image 71 const psVector *exposures, // Exposure time for each image 71 72 const psVector *addVariance // Additional variance for rejection 72 73 ); … … 83 84 bool ppStackReadoutFinal(const pmConfig *config, // Configuration 84 85 pmReadout *outRO, // Output readout 86 pmReadout *expRO, // Exposure readout 85 87 const psArray *readouts, // Input readouts 86 88 const psVector *mask, // Mask for input readouts 87 89 const psArray *rejected, // Array with pixels rejected in each image 88 90 const psVector *weightings, // Weighting factors for each image 91 const psVector *exposures, // Exposure times for each image 89 92 const psVector *addVariance, // Additional variance for rejection 90 93 bool safety, // Enable safety switch? -
trunk/ppStack/src/ppStackCamera.c
r27075 r27400 283 283 } 284 284 285 286 // Exposure image 287 pmFPA *expFPA = pmFPAConstruct(config->camera, config->cameraName); // FPA to contain the output 288 if (!expFPA) { 289 psError(psErrorCodeLast(), false, "Unable to construct an FPA from camera configuration."); 290 return false; 291 } 292 pmFPAfile *exp = pmFPAfileDefineOutput(config, expFPA, "PPSTACK.OUTPUT.EXP"); 293 psFree(expFPA); // Drop reference 294 if (!exp) { 295 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT.EXP")); 296 return false; 297 } 298 if (exp->type != PM_FPA_FILE_IMAGE) { 299 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.EXP is not of type IMAGE"); 300 return false; 301 } 302 exp->save = true; 303 304 if (!pmFPAAddSourceFromFormat(expFPA, "Stack", exp->format)) { 305 psError(psErrorCodeLast(), false, "Unable to generate output FPA."); 306 return false; 307 } 308 309 // Exposure numbers 310 pmFPAfile *expNum = pmFPAfileDefineOutput(config, exp->fpa, "PPSTACK.OUTPUT.EXPNUM"); 311 if (!expNum) { 312 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT.MASK")); 313 return false; 314 } 315 if (expNum->type != PM_FPA_FILE_MASK) { 316 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.EXPNUM is not of type MASK"); 317 return false; 318 } 319 expNum->save = true; 320 321 322 285 323 if (havePSFs) { 286 324 pmFPA *psfFPA = pmFPAConstruct(config->camera, config->cameraName); // FPA to contain PSF … … 302 340 } 303 341 304 #if 1305 342 // Unconvolved stack 306 343 pmFPA *unconvFPA = pmFPAConstruct(config->camera, config->cameraName); // FPA to contain unconvolved output … … 351 388 unconvVariance->save = true; 352 389 } 353 #endif 390 391 392 // Exposure image 393 pmFPA *unconvExpFPA = pmFPAConstruct(config->camera, config->cameraName); // FPA to contain the output 394 if (!unconvExpFPA) { 395 psError(psErrorCodeLast(), false, "Unable to construct an FPA from camera configuration."); 396 return false; 397 } 398 pmFPAfile *unconvExp = pmFPAfileDefineOutput(config, unconvExpFPA, "PPSTACK.UNCONV.EXP"); 399 psFree(unconvExpFPA); // Drop reference 400 if (!unconvExp) { 401 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.UNCONV.EXP")); 402 return false; 403 } 404 if (unconvExp->type != PM_FPA_FILE_IMAGE) { 405 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.UNCONV.EXP is not of type IMAGE"); 406 return false; 407 } 408 unconvExp->save = true; 409 410 if (!pmFPAAddSourceFromFormat(unconvExpFPA, "Stack", unconvExp->format)) { 411 psError(psErrorCodeLast(), false, "Unable to generate output FPA."); 412 return false; 413 } 414 415 // Output mask 416 pmFPAfile *unconvExpNum = pmFPAfileDefineOutput(config, unconvExp->fpa, "PPSTACK.UNCONV.EXPNUM"); 417 if (!unconvExpNum) { 418 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.UNCONV.MASK")); 419 return false; 420 } 421 if (unconvExpNum->type != PM_FPA_FILE_MASK) { 422 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.UNCONV.EXPNUM is not of type MASK"); 423 return false; 424 } 425 unconvExpNum->save = true; 426 354 427 355 428 // Output JPEGs -
trunk/ppStack/src/ppStackCleanup.c
r27343 r27400 86 86 options->outRO = NULL; 87 87 88 options->expRO->data_exists = false; 89 options->expRO->parent->data_exists = false; 90 options->expRO->parent->parent->data_exists = false; 91 psFree(options->expRO); 92 options->expRO = NULL; 93 88 94 pmFPAview *view = pmFPAviewAlloc(0);// Pointer into FPA hierarchy 89 95 view->chip = view->cell = 0; // pmFPAviewFreeData doesn't want to deal with readouts -
trunk/ppStack/src/ppStackCombineFinal.c
r27319 r27400 14 14 //#define TESTING // Enable test output 15 15 16 bool ppStackCombineFinal(p mReadout *target, ppStackThreadData *stack, psArray *covariances,17 p pStackOptions *options, pmConfig *config, bool safe, bool normalise, bool grow)16 bool ppStackCombineFinal(ppStackThreadData *stack, psArray *covariances, ppStackOptions *options, 17 pmConfig *config, bool safe, bool normalise, bool grow) 18 18 { 19 19 psAssert(stack, "Require stack"); … … 21 21 psAssert(config, "Require configuration"); 22 22 23 int numCols = target->image->numCols, numRows = target->image->numRows; // Size of image 23 pmReadout *outRO = options->outRO; // Output readout 24 pmReadout *expRO = options->expRO; // Exposure readout 25 int numCols = outRO->image->numCols, numRows = outRO->image->numRows; // Size of image 24 26 25 27 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe … … 43 45 } 44 46 45 if (!target->mask) { 46 target->mask = psImageAlloc(target->image->numCols, target->image->numRows, PS_TYPE_IMAGE_MASK); 47 if (!outRO->mask) { 48 outRO->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); 49 } 50 if (!expRO->mask) { 51 expRO->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); 47 52 } 48 53 … … 62 67 } 63 68 64 // call: ppStackReadoutFinal(config, target, readouts, rejected)69 // call: ppStackReadoutFinal(config, outRO, readouts, rejected) 65 70 psThreadJob *job = psThreadJobAlloc("PPSTACK_FINAL_COMBINE"); // Job to start 66 psArrayAdd(job->args, 1, target);67 71 psArrayAdd(job->args, 1, thread); 68 72 psArrayAdd(job->args, 1, reject); … … 105 109 } 106 110 if (sumWeights > 0.0) { 107 target->covariance = psImageCovarianceSum(covariances);108 psBinaryOp( target->covariance->image, target->covariance->image, "/",111 outRO->covariance = psImageCovarianceSum(covariances); 112 psBinaryOp(outRO->covariance->image, outRO->covariance->image, "/", 109 113 psScalarAlloc(sumWeights, PS_TYPE_F32)); 110 psImageCovarianceTransfer( target->variance, target->covariance);114 psImageCovarianceTransfer(outRO->variance, outRO->covariance); 111 115 } 112 116 } else { 113 target->covariance = psImageCovarianceNone();117 outRO->covariance = psImageCovarianceNone(); 114 118 } 115 119 … … 127 131 wcsDone = true; 128 132 pmHDU *inHDU = pmHDUFromCell(inRO->parent); // Template HDU 129 pmHDU *outHDU = pmHDUFromCell( target->parent); // Output HDU130 pmChip *outChip = target->parent->parent; // Output chip133 pmHDU *outHDU = pmHDUFromCell(outRO->parent); // Output HDU 134 pmChip *outChip = outRO->parent->parent; // Output chip 131 135 pmFPA *outFPA = outChip->parent; // Output FPA 132 136 if (!outHDU || !inHDU) { … … 151 155 } 152 156 157 // Set exposure time correctly 158 { 159 float exptime = 0.0; // Summed exposure time 160 for (int i = 0; i < options->num; i++) { 161 if (options->inputMask) { 162 continue; 163 } 164 exptime += options->exposures->data.F32[i]; 165 } 166 167 { 168 psMetadataItem *item = psMetadataLookup(outRO->parent->concepts, "CELL.EXPOSURE"); 169 item->data.F32 = exptime; 170 } 171 { 172 psMetadataItem *item = psMetadataLookup(outRO->parent->parent->parent->concepts, "FPA.EXPOSURE"); 173 item->data.F32 = exptime; 174 } 175 } 176 153 177 // Put version information into the header 154 pmHDU *hdu = pmHDUFromCell( target->parent);178 pmHDU *hdu = pmHDUFromCell(outRO->parent); 155 179 if (!hdu) { 156 180 psError(PPSTACK_ERR_PROG, false, "Unable to find HDU for output."); … … 168 192 psStringAppend(&name, "combined_image_final_%d.fits", pass); 169 193 pass++; 170 ppStackWriteImage(name, NULL, target->image, config);194 ppStackWriteImage(name, NULL, outRO->image, config); 171 195 psStringSubstitute(&name, "mask", "image"); 172 ppStackWriteImage(name, NULL, target->mask, config);196 ppStackWriteImage(name, NULL, outRO->mask, config); 173 197 psStringSubstitute(&name, "variance", "mask"); 174 ppStackWriteImage(name, NULL, target->variance, config);198 ppStackWriteImage(name, NULL, outRO->variance, config); 175 199 psFree(name); 176 200 177 pmStackVisualPlotTestImage( target->image, "combined_image_final.fits");201 pmStackVisualPlotTestImage(outRO->image, "combined_image_final.fits"); 178 202 #endif 179 203 -
trunk/ppStack/src/ppStackCombineInitial.c
r27309 r27400 89 89 } 90 90 91 ppStackMemDump("initial"); 92 91 93 #ifdef TESTING 92 94 ppStackWriteImage("combined_image_initial.fits", NULL, options->outRO->image, config); -
trunk/ppStack/src/ppStackCombinePrepare.c
r27319 r27400 10 10 #include "ppStackLoop.h" 11 11 12 bool ppStackCombinePrepare(pmReadout **ro, const char *name, ppStackFileList files, ppStackThreadData *stack, 12 bool ppStackCombinePrepare(const char *outName, const char *expName, 13 ppStackFileList files, ppStackThreadData *stack, 13 14 ppStackOptions *options, pmConfig *config) 14 15 { … … 32 33 } 33 34 34 pmCell *cell = pmFPAfileThisCell(config->files, view, name); // Output cell 35 *ro = pmReadoutAlloc(cell); // Output readout 35 pmCell *cell = pmFPAfileThisCell(config->files, view, outName); // Output cell 36 options->outRO = pmReadoutAlloc(cell); // Output readout 37 38 pmCell *expCell = pmFPAfileThisCell(config->files, view, expName); // Exposure cell 39 options->expRO = pmReadoutAlloc(expCell); // Output readout 36 40 37 41 psFree(view); … … 42 46 psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels 43 47 44 if (!pmReadoutStackDefineOutput(*ro, col0, row0, numCols, numRows, true, true, maskBad)) { 48 if (!pmReadoutStackDefineOutput(options->outRO, col0, row0, numCols, numRows, true, true, maskBad)) { 49 psError(PPSTACK_ERR_ARGUMENTS, false, "Unable to prepare output."); 50 return false; 51 } 52 53 if (!pmReadoutStackDefineOutput(options->expRO, col0, row0, numCols, numRows, true, true, 0)) { 45 54 psError(PPSTACK_ERR_ARGUMENTS, false, "Unable to prepare output."); 46 55 return false; -
trunk/ppStack/src/ppStackFiles.c
r27319 r27400 23 23 /// Regular (convolved) stack files 24 24 static char *filesStack[] = { "PPSTACK.OUTPUT", "PPSTACK.OUTPUT.MASK", "PPSTACK.OUTPUT.VARIANCE", 25 "PPSTACK.OUTPUT.JPEG1", "PPSTACK.OUTPUT.JPEG2", NULL }; 25 "PPSTACK.OUTPUT.EXP", "PPSTACK.OUTPUT.EXPNUM", 26 "PPSTACK.OUTPUT.JPEG1", "PPSTACK.OUTPUT.JPEG2", 27 NULL }; 26 28 /// Unconvolved stack files 27 static char *filesUnconv[] = { "PPSTACK.UNCONV", "PPSTACK.UNCONV.MASK", "PPSTACK.UNCONV.VARIANCE", NULL }; 29 static char *filesUnconv[] = { "PPSTACK.UNCONV", "PPSTACK.UNCONV.MASK", "PPSTACK.UNCONV.VARIANCE", 30 "PPSTACK.UNCONV.EXP", "PPSTACK.UNCONV.EXPNUM", NULL }; 28 31 29 32 /// Files for photometry -
trunk/ppStack/src/ppStackLoop.c
r27343 r27400 111 111 112 112 // Prepare for combination 113 if (!ppStackCombinePrepare( &options->outRO, "PPSTACK.OUTPUT", PPSTACK_FILES_STACK,113 if (!ppStackCombinePrepare("PPSTACK.OUTPUT", "PPSTACK.OUTPUT.EXP", PPSTACK_FILES_STACK, 114 114 stack, options, config)) { 115 115 psError(psErrorCodeLast(), false, "Unable to prepare for combination."); … … 160 160 // Final combination 161 161 psTrace("ppStack", 2, "Final stack of convolved images....\n"); 162 if (!ppStackCombineFinal(options->outRO, stack, options->convCovars, options, config, 163 false, false, true)) { 162 if (!ppStackCombineFinal(stack, options->convCovars, options, config, false, false, true)) { 164 163 psError(psErrorCodeLast(), false, "Unable to perform final combination."); 165 164 psFree(stack); … … 203 202 204 203 // Prepare for combination 205 if (!ppStackCombinePrepare( &options->unconvRO, "PPSTACK.UNCONV", PPSTACK_FILES_UNCONV,204 if (!ppStackCombinePrepare("PPSTACK.UNCONV", "PPSTACK.UNCONV.EXP", PPSTACK_FILES_UNCONV, 206 205 stack, options, config)) { 207 206 psError(psErrorCodeLast(), false, "Unable to prepare for combination."); … … 211 210 212 211 psTrace("ppStack", 2, "Stack of unconvolved images....\n"); 213 if (!ppStackCombineFinal( options->unconvRO,stack, options->origCovars, options, config,212 if (!ppStackCombineFinal(stack, options->origCovars, options, config, 214 213 false, true, false)) { 215 214 psError(psErrorCodeLast(), false, "Unable to perform unconvolved combination."); … … 226 225 } 227 226 ppStackFileActivation(config, PPSTACK_FILES_UNCONV, false); 228 options->unconvRO->data_exists = false; 229 options->unconvRO->parent->data_exists = false; 230 options->unconvRO->parent->parent->data_exists = false; 231 psFree(options->unconvRO); 232 options->unconvRO = NULL; 227 options->outRO->data_exists = false; 228 options->outRO->parent->data_exists = false; 229 options->outRO->parent->parent->data_exists = false; 230 psFree(options->outRO); 231 options->outRO = NULL; 232 options->expRO->data_exists = false; 233 options->expRO->parent->data_exists = false; 234 options->expRO->parent->parent->data_exists = false; 235 psFree(options->expRO); 236 options->expRO = NULL; 233 237 234 238 for (int i = 0; i < options->num; i++) { -
trunk/ppStack/src/ppStackLoop.h
r27319 r27400 38 38 // Prepare for combination 39 39 bool ppStackCombinePrepare( 40 pmReadout **readout, // Readout to set41 const char * name, // Name offile40 const char *outName, // Name of output file 41 const char *expName, // Name of exposure file 42 42 ppStackFileList files, // Files of interest 43 43 ppStackThreadData *stack, // Stack … … 61 61 // Final combination 62 62 bool ppStackCombineFinal( 63 pmReadout *target, // Target readout64 63 ppStackThreadData *stack, // Stack 65 64 psArray *covariances, // Covariances -
trunk/ppStack/src/ppStackOptions.c
r27218 r27400 21 21 psFree(options->psf); 22 22 psFree(options->inputSeeing); 23 psFree(options->exposures); 23 24 psFree(options->inputMask); 24 25 psFree(options->sourceLists); … … 32 33 psFree(options->convCovars); 33 34 psFree(options->outRO); 34 psFree(options-> unconvRO);35 psFree(options->expRO); 35 36 psFree(options->inspect); 36 37 psFree(options->rejected); … … 61 62 options->zp = NAN; 62 63 options->inputSeeing = NULL; 64 options->exposures = NULL; 63 65 options->targetSeeing = NAN; 64 66 options->inputMask = NULL; … … 75 77 options->convCovars = NULL; 76 78 options->outRO = NULL; 77 options-> unconvRO = NULL;79 options->expRO = NULL; 78 80 options->inspect = NULL; 79 81 options->rejected = NULL; -
trunk/ppStack/src/ppStackOptions.h
r27218 r27400 22 22 psVector *inputSeeing; // Input seeing FWHMs 23 23 float targetSeeing; // Target seeing FWHM 24 psVector *exposures; // Exposure times 24 25 float sumExposure; // Sum of exposure times 25 26 float zp; // Zero point for output … … 38 39 // Combine initial 39 40 pmReadout *outRO; // Output readout 40 pmReadout * unconvRO; // Unconvolvedreadout41 pmReadout *expRO; // Exposure readout 41 42 psArray *inspect; // Array of arrays of pixels to inspect 42 43 // Rejection -
trunk/ppStack/src/ppStackPrepare.c
r27075 r27400 126 126 options->inputMask = psVectorAlloc(num, PS_TYPE_VECTOR_MASK); // Mask for inputs 127 127 psVectorInit(options->inputMask, 0); 128 options->exposures = psVectorAlloc(options->num, PS_TYPE_F32); 129 psVectorInit(options->exposures, NAN); 128 130 129 131 pmFPAfileActivate(config->files, false, NULL); … … 134 136 } 135 137 136 psMetadataIterator *fileIter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD, "^PPSTACK.INPUT$");137 psMetadataItem *fileItem; // Item from iteration138 138 psArray *psfs = psArrayAlloc(num); // PSFs for PSF envelope 139 139 int numCols = 0, numRows = 0; // Size of image 140 int index = 0; // Index for file 141 while ((fileItem = psMetadataGetAndIncrement(fileIter))) { 142 assert(fileItem->type == PS_DATA_UNKNOWN); 143 pmFPAfile *inputFile = fileItem->data.V; // An input file 140 options->sumExposure = 0.0; 141 for (int i = 0; i < num; i++) { 142 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT", i); // File of interest 143 pmCell *cell = pmFPAviewThisCell(view, file->fpa); // Cell of interest 144 145 options->exposures->data.F32[i] = psMetadataLookupF32(NULL, cell->concepts, "CELL.EXPOSURE"); 146 options->sumExposure += options->exposures->data.F32[i]; 144 147 145 148 // Get list of PSFs, to determine target PSF 146 149 if (options->convolve) { 147 pmChip *chip = pmFPAviewThisChip(view, inputFile->fpa); // The chip: holds the PSF150 pmChip *chip = pmFPAviewThisChip(view, file->fpa); // The chip: holds the PSF 148 151 pmPSF *psf = psMetadataLookupPtr(NULL, chip->analysis, "PSPHOT.PSF"); // PSF 149 152 if (!psf) { 150 153 psError(PPSTACK_ERR_PROG, false, "Unable to find PSF."); 151 154 psFree(view); 152 psFree(fileIter);153 155 psFree(psfs); 154 156 return false; 155 157 } 156 psfs->data[i ndex] = psMemIncrRefCounter(psf);158 psfs->data[i] = psMemIncrRefCounter(psf); 157 159 psMetadataRemoveKey(chip->analysis, "PSPHOT.PSF"); 158 160 159 pmCell *cell = pmFPAviewThisCell(view, inputFile->fpa); // Cell of interest161 pmCell *cell = pmFPAviewThisCell(view, file->fpa); // Cell of interest 160 162 pmHDU *hdu = pmHDUFromCell(cell); 161 163 assert(hdu && hdu->header); … … 165 167 psError(PPSTACK_ERR_PROG, false, "Unable to determine size of image from PSF."); 166 168 psFree(view); 167 psFree(fileIter);168 169 psFree(psfs); 169 170 return false; … … 180 181 pmDetections *detections = NULL; 181 182 if (options->convolve || options->matchZPs || options->photometry || redoPhot) { 182 pmReadout *ro = pmFPAviewThisReadout(view, inputFile->fpa); // Readout with sources183 pmReadout *ro = pmFPAviewThisReadout(view, file->fpa); // Readout with sources 183 184 detections = psMetadataLookupPtr(NULL, ro->analysis, "PSPHOT.DETECTIONS"); // Sources 184 185 if (!detections) { … … 188 189 psAssert (detections->allSources, "missing sources?"); 189 190 190 options->sourceLists->data[i ndex] = psMemIncrRefCounter(detections->allSources);191 options->sourceLists->data[i] = psMemIncrRefCounter(detections->allSources); 191 192 } 192 193 193 194 // Re-do photometry if we don't trust the source lists 194 195 if (redoPhot) { 195 psTrace("ppStack", 2, "Photometering input %d of %d....\n", i ndex, num);196 psTrace("ppStack", 2, "Photometering input %d of %d....\n", i, num); 196 197 pmFPAfileActivate(config->files, false, NULL); 197 ppStackFileActivationSingle(config, PPSTACK_FILES_CONVOLVE, true, i ndex);198 ppStackFileActivationSingle(config, PPSTACK_FILES_CONVOLVE, true, i); 198 199 if (options->convolve) { 199 200 pmFPAfileActivate(config->files, true, "PPSTACK.CONV.KERNEL"); 200 201 } 201 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT", i ndex); // File202 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT", i); // File 202 203 pmFPAview *photView = ppStackFilesIterateDown(config); 203 204 if (!photView) { … … 223 224 ppStackFileActivation(config, PPSTACK_FILES_PREPARE, true); 224 225 } 225 226 index++; 227 } 228 psFree(fileIter); 226 } 229 227 230 228 psString log = psStringCopy("Input seeing FWHMs:\n"); // Log message -
trunk/ppStack/src/ppStackReadout.c
r27319 r27400 23 23 psVector *mask = options->inputMask; // Mask for inputs 24 24 psVector *weightings = options->weightings; // Weightings (1/noise^2) for each image 25 psVector *exposures = options->exposures; // Exposure times for each image 25 26 psVector *addVariance = options->matchChi2; // Additional variance when rejecting 26 27 27 28 job->results = ppStackReadoutInitial(config, outRO, thread->readouts, mask, 28 weightings, addVariance);29 weightings, exposures, addVariance); 29 30 thread->busy = false; 30 31 … … 37 38 38 39 psArray *args = job->args; // Arguments 39 pmReadout *target = args->data[0]; // Output readout 40 ppStackThread *thread = args->data[1]; // Thread 41 psArray *reject = args->data[2]; // Rejected pixels for each image 42 ppStackOptions *options = args->data[3]; // Options 43 pmConfig *config = args->data[4]; // Configuration 44 bool safety = PS_SCALAR_VALUE(args->data[5], U8); // Safety switch on? 45 bool normalise = PS_SCALAR_VALUE(args->data[6], U8); // Normalise images? 40 ppStackThread *thread = args->data[0]; // Thread 41 psArray *reject = args->data[1]; // Rejected pixels for each image 42 ppStackOptions *options = args->data[2]; // Options 43 pmConfig *config = args->data[3]; // Configuration 44 bool safety = PS_SCALAR_VALUE(args->data[4], U8); // Safety switch on? 45 bool normalise = PS_SCALAR_VALUE(args->data[5], U8); // Normalise images? 46 46 47 47 psVector *mask = options->inputMask; // Mask for inputs 48 48 psVector *weightings = options->weightings; // Weightings (1/noise^2) for each image 49 psVector *exposures = options->exposures; // Exposure times for each image 49 50 psVector *addVariance = options->matchChi2; // Additional variance when rejecting 50 51 psVector *norm = normalise ? options->norm : NULL; // Normalisations to apply to images 51 52 52 bool status = ppStackReadoutFinal(config, target, thread->readouts, mask, reject,53 weightings, addVariance, safety, norm); // Status of operation53 bool status = ppStackReadoutFinal(config, options->outRO, options->expRO, thread->readouts, mask, reject, 54 weightings, exposures, addVariance, safety, norm); // Status of operation 54 55 55 56 thread->busy = false; 57 58 psAssert(status, "Stacking failed."); 56 59 57 60 return status; … … 101 104 102 105 psArray *ppStackReadoutInitial(const pmConfig *config, pmReadout *outRO, const psArray *readouts, 103 const psVector *mask, const psVector *weightings, const psVector *addVariance) 106 const psVector *mask, const psVector *weightings, const psVector *exposures, 107 const psVector *addVariance) 104 108 { 105 109 assert(config); … … 149 153 } 150 154 151 stack->data[i] = pmStackDataAlloc(ro, weightings->data.F32[i], addVariance->data.F32[i]); 152 } 153 154 if (!pmStackCombine(outRO, stack, maskVal | maskBad, maskSuspect, maskBad, kernelSize, iter, 155 stack->data[i] = pmStackDataAlloc(ro, weightings->data.F32[i], exposures->data.F32[i], 156 addVariance->data.F32[i]); 157 } 158 159 if (!pmStackCombine(outRO, NULL, stack, maskVal | maskBad, maskSuspect, maskBad, kernelSize, iter, 155 160 combineRej, combineSys, combineDiscard, useVariance, safe, false)) { 156 161 psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts with rejection."); … … 187 192 188 193 189 bool ppStackReadoutFinal(const pmConfig *config, pmReadout *outRO, const psArray *readouts,194 bool ppStackReadoutFinal(const pmConfig *config, pmReadout *outRO, pmReadout *expRO, const psArray *readouts, 190 195 const psVector *mask, const psArray *rejected, const psVector *weightings, 191 const psVector *addVariance, bool safety, const psVector *norm) 196 const psVector *exposures, const psVector *addVariance, bool safety, 197 const psVector *norm) 192 198 { 193 199 assert(config); 194 200 assert(outRO); 201 assert(expRO); 195 202 assert(readouts); 196 203 assert(!rejected || readouts->n == rejected->n); … … 238 245 } 239 246 240 pmStackData *data = pmStackDataAlloc(ro, weightings->data.F32[i], 247 pmStackData *data = pmStackDataAlloc(ro, weightings->data.F32[i], exposures->data.F32[i], 241 248 addVariance ? addVariance->data.F32[i] : NAN); 242 249 data->reject = rejected ? psMemIncrRefCounter(rejected->data[i]) : NULL; … … 250 257 } 251 258 252 if (!pmStackCombine(outRO, stack, maskVal | maskBad, maskSuspect, maskBad, 0, iter, combineRej,259 if (!pmStackCombine(outRO, expRO, stack, maskVal | maskBad, maskSuspect, maskBad, 0, iter, combineRej, 253 260 combineSys, combineDiscard, useVariance, safe, rejected)) { 254 261 psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts."); … … 259 266 pmCell *outCell = outRO->parent; // Output cell 260 267 pmChip *outChip = outCell->parent; // Output chip 261 262 268 outRO->data_exists = true; 263 269 outCell->data_exists = true; 264 270 outChip->data_exists = true; 265 271 272 pmCell *expCell = expRO->parent; // Exposure cell 273 pmChip *expChip = expCell->parent; // Exposure chip 274 expRO->data_exists = true; 275 expCell->data_exists = true; 276 expChip->data_exists = true; 277 266 278 psFree(stack); 267 279 -
trunk/ppStack/src/ppStackReject.c
r27319 r27400 162 162 psLogMsg("ppStack", PS_LOG_INFO, "Time to perform rejection on image %d: %f sec", i, 163 163 psTimerClear("PPSTACK_REJECT")); 164 165 ppStackMemDump("reject");166 164 } 167 165 -
trunk/ppStack/src/ppStackSources.c
r27329 r27400 64 64 65 65 if (!options->matchZPs && !options->photometry) { 66 int num = psMetadataLookupS32(NULL, config->arguments, "INPUTS.NUM"); // Number of inputs 67 options->norm = psVectorAlloc(num, PS_TYPE_F32); 68 psVectorInit (options->norm, 0.0); 69 70 // XXX do I need to set this? 71 // options->sumExposure = sumExpTime; 72 66 options->norm = psVectorAlloc(options->num, PS_TYPE_F32); 67 psVectorInit(options->norm, 0.0); 73 68 return true; 74 69 } … … 137 132 } 138 133 139 int num = psMetadataLookupS32(NULL, config->arguments, "INPUTS.NUM");// Number of inputs134 int num = options->num; // Number of inputs 140 135 psAssert(num == sourceLists->n, "Wrong number of source lists: %ld\n", sourceLists->n); 141 136 … … 146 141 float airmassTerm = NAN; // Airmass term 147 142 float zpTarget = NAN; // Target zero point 148 float sumExpTime = 0.0; // Sum of the exposure time149 143 int numGoodImages = 0; // Number of good images 150 144 for (int i = 0; i < num; i++) { … … 160 154 161 155 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT", i); // File of interest 162 pmCell *cell = pmFPAviewThisCell(view, file->fpa); // Cell of interest163 156 164 157 #if defined(TESTING) && 0 … … 177 170 #endif 178 171 179 float exptime = psMetadataLookupF32(NULL, cell->concepts, "CELL.EXPOSURE"); // Exposure time172 float exptime = options->exposures->data.F32[i]; // Exposure time 180 173 float airmass = psMetadataLookupF32(NULL, file->fpa->concepts, "FPA.AIRMASS"); // Airmass 181 174 const char *expFilter = psMetadataLookupStr(NULL, file->fpa->concepts, "FPA.FILTER"); // Filter name … … 221 214 222 215 zp->data.F32[i] = airmassTerm * airmass + 2.5 * log10(exptime); 223 sumExpTime += exptime; 224 225 } 226 227 options->sumExposure = sumExpTime; 216 } 228 217 229 218 if (numGoodImages == 0) { … … 291 280 } 292 281 psArray *sources = sourceLists->data[i]; // Sources of interest 293 float magCorr = zp->data.F32[i] + trans->data.F32[i] - 2.5*log10( sumExpTime);282 float magCorr = zp->data.F32[i] + trans->data.F32[i] - 2.5*log10(options->sumExposure); 294 283 if (zpExpNum == numGoodImages) { 295 284 // Using measured zero points, so attempt to set target zero point -
trunk/ppStack/src/ppStackThread.c
r27319 r27400 284 284 285 285 { 286 psThreadTask *task = psThreadTaskAlloc("PPSTACK_FINAL_COMBINE", 7);286 psThreadTask *task = psThreadTaskAlloc("PPSTACK_FINAL_COMBINE", 6); 287 287 task->function = &ppStackReadoutFinalThread; 288 288 psThreadTaskAdd(task); -
trunk/psModules/src/imcombine/pmStack.c
r27310 r27400 35 35 36 36 //#define TESTING // Enable test output 37 //#define TEST_X 2148-1 // x coordinate to examine38 //#define TEST_Y 248-1 // y coordinate to examine37 //#define TEST_X 843-1 // x coordinate to examine 38 //#define TEST_Y 813-1 // y coordinate to examine 39 39 //#define TEST_RADIUS 0 // Radius to examine 40 40 … … 46 46 psVector *variances; // Pixel variances 47 47 psVector *weights; // Pixel weightings 48 psVector *exps; // Pixel exposures 48 49 psVector *sources; // Pixel sources (which image did they come from?) 49 50 psVector *limits; // Rejection limits … … 57 58 psFree(buffer->variances); 58 59 psFree(buffer->weights); 60 psFree(buffer->exps); 59 61 psFree(buffer->sources); 60 62 psFree(buffer->limits); … … 73 75 buffer->variances = psVectorAlloc(numImages, PS_TYPE_F32); 74 76 buffer->weights = psVectorAlloc(numImages, PS_TYPE_F32); 77 buffer->exps = psVectorAlloc(numImages, PS_TYPE_F32); 75 78 buffer->sources = psVectorAlloc(numImages, PS_TYPE_U16); 76 79 buffer->limits = psVectorAlloc(numImages, PS_TYPE_F32); … … 95 98 static bool combinationMeanVariance(float *mean, // Mean value, to return 96 99 float *var, // Variance value, to return 100 float *exp, // Exposure time, to return 101 float *expWeight, // Weighted exposure time, to return 97 102 const psVector *values, // Values to combine 98 103 const psVector *variances, // Pixel variances to combine 104 const psVector *exps, // Exposure times to combine 99 105 const psVector *weights // Weights to apply 100 106 ) … … 121 127 float sumVarianceWeight = 0.0; // Sum of the pixel variances multiplied by the global weights 122 128 float sumWeight = 0.0; // Sum of the image weights 129 float sumExp = 0.0; // Sum of the exposure time 130 float sumExpWeight = 0.0; // Sum of the exposure time multiplied by the global weights 123 131 for (int i = 0; i < values->n; i++) { 124 132 sumValueWeight += values->data.F32[i] * weights->data.F32[i]; … … 127 135 sumVarianceWeight += variances->data.F32[i] * PS_SQR(weights->data.F32[i]); 128 136 } 137 if (exps) { 138 sumExp += exps->data.F32[i]; 139 sumExpWeight += exps->data.F32[i] * weights->data.F32[i]; 140 } 129 141 } 130 142 … … 136 148 if (var) { 137 149 *var = sumVarianceWeight / PS_SQR(sumWeight); 150 } 151 if (exp) { 152 *exp = sumExp; 153 } 154 if (expWeight) { 155 *expWeight = sumExpWeight / sumWeight; 138 156 } 139 157 return true; … … 276 294 const psArray *inputs, // Stack data 277 295 const psVector *weights, // Global (single value) weights for data, or NULL 296 const psVector *exps, // Exposures for data, or NULL 278 297 const psVector *addVariance, // Additional variance for data 279 298 const psVector *reject, // Indices of pixels to reject, or NULL … … 292 311 psVector *pixelVariances = variance ? buffer->variances : NULL; // Variances for the pixel of interest 293 312 psVector *pixelWeights = buffer->weights; // Image weights for the pixel of interest 313 psVector *pixelExps = buffer->exps; // Exposure times 294 314 psVector *pixelSources = buffer->sources; // Sources for the pixel of interest 295 315 psVector *pixelLimits = buffer->limits; // Limits for the pixel of interest … … 331 351 } 332 352 pixelWeights->data.F32[numGood] = data->weight; 353 pixelExps->data.F32[numGood] = data->exp; 333 354 pixelSources->data.U16[numGood] = i; 334 355 numGood++; … … 347 368 if (PS_SQR(x - TEST_X) + PS_SQR(y - TEST_Y) <= PS_SQR(TEST_RADIUS)) { 348 369 for (int i = 0; i < numGood; i++) { 349 fprintf(stderr, "Input %d, pixel %d,%d (%" PRIu16 "): %f %f (%f) %f % d\n",370 fprintf(stderr, "Input %d, pixel %d,%d (%" PRIu16 "): %f %f (%f) %f %f %d\n", 350 371 i, x, y, pixelSources->data.U16[i], pixelData->data.F32[i], pixelVariances->data.F32[i], 351 addVariance->data.F32[i], pixelWeights->data.F32[i], pixelSuspects->data.U8[i]); 372 addVariance->data.F32[i], pixelWeights->data.F32[i], pixelExps->data.F32[i], 373 pixelSuspects->data.U8[i]); 352 374 } 353 375 } … … 362 384 psImage *mask, // Combined mask, for output 363 385 psImage *variance, // Combined variance map, for output 386 psImage *exp, // Exposure map (time), for output 387 psImage *expnum, // Exposure map (number) for output 388 psImage *expweight, // Exposure map (weighted time) for output 364 389 int num, // Number of good pixels 365 390 combineBuffer *buffer, // Buffer with vectors … … 372 397 psVector *pixelVariances = variance ? buffer->variances : NULL; // Variances for the pixel of interest 373 398 psVector *pixelWeights = buffer->weights; // Image weights for the pixel of interest 399 psVector *pixelExps = buffer->exps; // Exposure times 374 400 375 401 // Default option is that the pixel is bad 376 402 float imageValue = NAN, varianceValue = NAN; // Value for combined image and variance map 377 403 psImageMaskType maskValue = bad; // Value for combined mask 404 float expValue = 0.0, expWeightValue = NAN; // Exposure value (straight, and weighted) 405 378 406 switch (num) { 379 407 case 0: { … … 393 421 varianceValue = pixelVariances->data.F32[0]; 394 422 } 423 if (exp) { 424 expValue = pixelExps->data.F32[0]; 425 } 395 426 maskValue = 0; 396 427 #ifdef TESTING … … 411 442 // Automatically accept the mean of the pixels only if we're not playing safe 412 443 if (!safe) { 413 float mean, var; // Mean and variance from combination 414 if (combinationMeanVariance(&mean, &var, pixelData, pixelVariances, pixelWeights)) { 415 imageValue = mean; 416 varianceValue = var; 444 if (combinationMeanVariance(&imageValue, &varianceValue, &expValue, &expWeightValue, 445 pixelData, pixelVariances, pixelExps, pixelWeights)) { 417 446 maskValue = 0; 418 447 #ifdef TESTING 419 448 if (PS_SQR(x - TEST_X) + PS_SQR(y - TEST_Y) <= PS_SQR(TEST_RADIUS)) { 420 449 fprintf(stderr, "Two inputs to combine using unsafe, pixel %d,%d --> %f %f\n", 421 x, y, mean, var);450 x, y, imageValue, varianceValue); 422 451 } 423 452 #endif … … 435 464 default: { 436 465 // Can combine without too much worrying 437 float mean, var; // Mean and variance of the combination438 if (!combinationMeanVariance(&mean, &var, pixelData, pixelVariances, pixelWeights)) {466 if (!combinationMeanVariance(&imageValue, &varianceValue, &expValue, &expWeightValue, 467 pixelData, pixelVariances, pixelExps, pixelWeights)) { 439 468 break; 440 469 } 441 imageValue = mean;442 varianceValue = var;443 470 maskValue = 0; 444 471 #ifdef TESTING 445 472 if (PS_SQR(x - TEST_X) + PS_SQR(y - TEST_Y) <= PS_SQR(TEST_RADIUS)) { 446 fprintf(stderr, "Combined inputs, pixel %d,%d --> %f %f\n", x, y, mean, var);473 fprintf(stderr, "Combined inputs, pixel %d,%d --> %f %f\n", x, y, imageValue, varianceValue); 447 474 } 448 475 #endif … … 456 483 variance->data.F32[y][x] = varianceValue; 457 484 } 458 459 #ifdef TESTING 460 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = num; 461 #endif 462 485 if (exp) { 486 exp->data.F32[y][x] = expValue; 487 } 488 if (expnum) { 489 expnum->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = num; 490 } 491 if (expweight) { 492 expweight->data.F32[y][x] = expWeightValue; 493 } 463 494 464 495 return; … … 803 834 int *numCols, int *numRows, // Size of (sky) images 804 835 const psArray *input, // Input array of pmStackData to validate 805 const pmReadout *output // Output readout 836 const pmReadout *output, // Output readout 837 const pmReadout *exp // Exposure map 806 838 ) 807 839 { … … 869 901 } 870 902 903 if (exp) { 904 PM_ASSERT_READOUT_NON_NULL(exp, false); 905 if (exp->image) { 906 PS_ASSERT_IMAGES_SIZE_EQUAL(exp->image, output->image, false); 907 } 908 if (exp->mask) { 909 PS_ASSERT_IMAGES_SIZE_EQUAL(exp->mask, output->image, false); 910 } 911 } 912 871 913 return true; 872 914 } … … 937 979 938 980 /// Constructor 939 pmStackData *pmStackDataAlloc(pmReadout *readout, float weight, float addVariance)981 pmStackData *pmStackDataAlloc(pmReadout *readout, float weight, float exp, float addVariance) 940 982 { 941 983 pmStackData *data = psAlloc(sizeof(pmStackData)); // Stack data, to return … … 946 988 data->inspect = NULL; 947 989 data->weight = weight; 990 data->exp = exp; 948 991 data->addVariance = addVariance; 949 992 … … 952 995 953 996 /// Stack input images 954 bool pmStackCombine(pmReadout *combined, psArray *input, psImageMaskType maskVal, psImageMaskType maskSuspect, 955 psImageMaskType bad, int kernelSize, float iter, float rej, float sys, float olympic, 997 bool pmStackCombine(pmReadout *combined, pmReadout *expmaps, psArray *input, 998 psImageMaskType maskVal, psImageMaskType maskSuspect, 999 psImageMaskType bad, int kernelSize, 1000 float iter, float rej, float sys, float olympic, 956 1001 bool useVariance, bool safe, bool rejection) 957 1002 { … … 959 1004 int num; // Number of inputs 960 1005 int numCols, numRows; // Size of (sky) images 961 if (!validateInputData(&haveVariances, &num, &numCols, &numRows, input, combined )) {1006 if (!validateInputData(&haveVariances, &num, &numCols, &numRows, input, combined, expmaps)) { 962 1007 return false; 963 1008 } … … 977 1022 psVector *addVariance = psVectorAlloc(num, PS_TYPE_F32); // Additional variance for each image 978 1023 psVector *weights = psVectorAlloc(num, PS_TYPE_F32); // Relative weighting for each image 1024 psVector *exps = psVectorAlloc(num, PS_TYPE_F32); // Exposure times for each image 979 1025 psArray *stack = psArrayAlloc(num); // Stack of readouts 980 1026 for (int i = 0; i < num; i++) { … … 982 1028 if (!data) { 983 1029 weights->data.F32[i] = 0.0; 1030 exps->data.F32[i] = NAN; 984 1031 continue; 985 1032 } 986 1033 weights->data.F32[i] = data->weight; 1034 exps->data.F32[i] = data->exp; 987 1035 pmReadout *ro = data->readout; // Readout of interest 988 1036 stack->data[i] = psMemIncrRefCounter(ro); … … 1045 1093 combined->variance = psImageAlloc(numCols, numRows, PS_TYPE_F32); 1046 1094 combinedVariance = combined->variance; 1095 } 1096 1097 psImage *exp = NULL, *expnum = NULL; // Exposure map and exposure number 1098 if (expmaps) { 1099 if (!expmaps->image) { 1100 expmaps->image = psImageAlloc(numCols, numRows, PS_TYPE_F32); 1101 } 1102 exp = expmaps->image; 1103 1104 if (!expmaps->mask) { 1105 expmaps->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); 1106 } 1107 expnum = expmaps->mask; 1047 1108 } 1048 1109 … … 1083 1144 bool suspect; // Suspect pixels in stack? 1084 1145 combineExtract(&num, &suspect, buffer, combinedImage, combinedMask, combinedVariance, 1085 input, weights, addVariance, reject, x, y, maskVal, maskSuspect); 1086 combinePixels(combinedImage, combinedMask, combinedVariance, num, buffer, x, y, bad, safe); 1146 input, weights, exps, addVariance, reject, x, y, maskVal, maskSuspect); 1147 combinePixels(combinedImage, combinedMask, combinedVariance, exp, expnum, NULL, 1148 num, buffer, x, y, bad, safe); 1087 1149 1088 1150 if (iter > 0) { -
trunk/psModules/src/imcombine/pmStack.h
r26260 r27400 31 31 psPixels *inspect; ///< Pixels to inspect 32 32 float weight; ///< Relative weighting for image 33 float exp; ///< Exposure for image 33 34 float addVariance; ///< Additional variance when rejecting 34 35 } pmStackData; … … 37 38 pmStackData *pmStackDataAlloc(pmReadout *readout, ///< Warped readout (sky cell) 38 39 float weight, ///< Weight to apply 40 float exp, ///< Exposure time for input 39 41 float addVariance ///< Additional variance when rejecting 40 42 ); … … 42 44 /// Stack input images 43 45 bool pmStackCombine(pmReadout *combined,///< Combined readout (output) 46 pmReadout *expmap, ///< Exposure map (output) 44 47 psArray *input, ///< Input array of pmStackData 45 48 psImageMaskType maskVal, ///< Mask value of bad pixels -
trunk/psModules/src/imcombine/pmSubtractionMask.c
r27365 r27400 92 92 continue; 93 93 } 94 if (imageData1[y][x] > 50000) { 95 maskData1[y][x] = maskVal; 96 numBad++; 97 continue; 98 } 99 if (imageData2[y][x] > 50000) { 100 maskData2[y][x] = maskVal; 101 numBad++; 102 continue; 103 } 94 104 xMin = PS_MIN(xMin, x); 95 105 xMax = PS_MAX(xMax, x); -
trunk/psModules/src/imcombine/pmSubtractionStamps.c
r27323 r27400 107 107 if ((image1 && image1->data.F32[y][x] < thresh1) || 108 108 (image2 && image2->data.F32[y][x] < thresh2)) { 109 continue; 110 } 111 if ((image1 && image1->data.F32[y][x] > 30000) || 112 (image2 && image2->data.F32[y][x] > 30000)) { 109 113 continue; 110 114 }
Note:
See TracChangeset
for help on using the changeset viewer.
