Changeset 34516 for branches/czw_branch/20120906/ppStack/src
- Timestamp:
- Oct 5, 2012, 6:03:49 PM (14 years ago)
- Location:
- branches/czw_branch/20120906/ppStack/src
- Files:
-
- 13 edited
-
ppStack.h (modified) (2 diffs)
-
ppStackCamera.c (modified) (4 diffs)
-
ppStackCleanup.c (modified) (1 diff)
-
ppStackCombineFinal.c (modified) (1 diff)
-
ppStackCombinePrepare.c (modified) (3 diffs)
-
ppStackFiles.c (modified) (4 diffs)
-
ppStackLoop.c (modified) (5 diffs)
-
ppStackLoop.h (modified) (1 diff)
-
ppStackOptions.h (modified) (1 diff)
-
ppStackReadout.c (modified) (1 diff)
-
ppStackSetup.c (modified) (2 diffs)
-
ppStackThread.c (modified) (5 diffs)
-
ppStackThread.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20120906/ppStack/src/ppStack.h
r34092 r34516 38 38 PPSTACK_FILES_STACK, // Stack files 39 39 PPSTACK_FILES_UNCONV, // Unconvolved stack files 40 PPSTACK_FILES_PHOT // Files for photometry 40 PPSTACK_FILES_PHOT, // Files for photometry 41 PPSTACK_FILES_BKG // Files for bkg 41 42 } ppStackFileList; 42 43 … … 111 112 bool ppStackReadoutFinalThread(psThreadJob *job // Job to process 112 113 ); 114 // Perform median stacking for background 115 bool ppStackCombineBackground(ppStackThreadData *stack, ppStackOptions *options, pmConfig *config); 113 116 114 117 // Return software version -
branches/czw_branch/20120906/ppStack/src/ppStackCamera.c
r30620 r34516 156 156 psString psf = psMetadataLookupStr(&mdok, input, "PSF"); // Name of PSF 157 157 psString sources = psMetadataLookupStr(&mdok, input, "SOURCES"); // Name of sources 158 158 psString bkgmodel = psMetadataLookupStr(&mdok, input, "BKGMODEL"); // Name of warped background model 159 159 160 pmFPAfile *imageFile = defineFile(config, NULL, "PPSTACK.INPUT", 160 161 image, PM_FPA_FILE_IMAGE); // File for image … … 215 216 } 216 217 218 // Grab bkgmodel information here 219 if (!bkgmodel || strlen(bkgmodel) == 0) { 220 // We have no background models. 221 } 222 else { 223 pmFPAfile *inputBKG = defineFile(config,NULL,"PPSTACK.INPUT.BKGMODEL",bkgmodel, 224 PM_FPA_FILE_IMAGE); 225 fprintf(stderr,"ppSC: %s\n",bkgmodel); 226 if (!inputBKG) { 227 psError(psErrorCodeLast(), false, 228 "Unable to define file from bkgmodel %d (%s)",i,bkgmodel); 229 return(false); 230 } 231 }// End bkgmodel 232 233 234 235 217 236 i++; 218 237 } … … 460 479 jpeg2->save = true; 461 480 481 // Output background 482 pmFPAfile *outBkg = pmFPAfileDefineOutput(config,NULL,"PPSTACK.OUTPUT.BKGMODEL"); 483 if (!outBkg) { 484 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT.BKGMODEL")); 485 return(false); 486 } 487 if (outBkg->type != PM_FPA_FILE_IMAGE) { 488 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.BKGMODEL is not of type IMAGE"); 489 return(false); 490 } 491 outBkg->save = true; 492 pmFPAfile *outBkgRest = pmFPAfileDefineOutput(config,NULL,"PPSTACK.OUTPUT.BKGREST"); 493 if (!outBkgRest) { 494 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT.BKGREST")); 495 return(false); 496 } 497 if (outBkgRest->type != PM_FPA_FILE_IMAGE) { 498 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.BKGREST is not of type IMAGE"); 499 return(false); 500 } 501 462 502 // For photometry, we operate on the chip-mosaicked image 463 503 // we create a copy of the mosaicked image for psphot so we can write out a clean image … … 496 536 } 497 537 538 // Define output file here. 539 498 540 return true; 499 541 } -
branches/czw_branch/20120906/ppStack/src/ppStackCleanup.c
r30874 r34516 28 28 options->expRO = NULL; 29 29 30 options->bkgRO->data_exists = false; 31 options->bkgRO->parent->data_exists = false; 32 options->bkgRO->parent->parent->data_exists = false; 33 psFree(options->bkgRO); 34 options->bkgRO = NULL; 35 30 36 for (int i = 0; i < options->num; i++) { 31 37 pmCellFreeData(options->cells->data[i]); -
branches/czw_branch/20120906/ppStack/src/ppStackCombineFinal.c
r33093 r34516 3 3 // This is the doomsday switch. 4 4 // #define TESTING // Enable test output 5 bool ppStackCombineBackground(ppStackThreadData *stack, ppStackOptions *options, pmConfig *config) 6 { 7 psAssert(stack, "Require stack"); 8 psAssert(options, "Require options"); 9 psAssert(config, "Require configuration"); 10 11 psTimerStart("PPSTACK_BKGMED"); 12 13 14 pmReadout *bkgRO = options->bkgRO; 15 16 psArray *inputs = psArrayAlloc(options->num); 17 // const psArray *cells = options->cells; 18 for (int i = 0; i < options->num; i++) { 19 ppStackFileActivationSingle(config, PPSTACK_FILES_BKG, true, i); 20 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT.BKGMODEL", i); 21 pmFPAview *view = ppStackFilesIterateDown(config); 22 pmReadout *ro = pmFPAviewThisReadout(view,file->fpa); 23 inputs->data[i] = ro; 24 pmFPAfileClose(file,view); 25 ppStackFileActivationSingle(config, PPSTACK_FILES_BKG, false, i); 26 } 27 if (!pmStackSimpleMedianCombine(bkgRO,inputs)) { 28 psFree(inputs); 29 return(false); 30 } 31 /* for (int i = 0; i < options->num; i++) { */ 32 /* // ppStackFilesIterateUp(config); */ 33 /* /\* pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT.BKGMODEL", i); *\/ */ 34 /* /\* pmFPAview *view = ppStackFilesIterateDown(config); *\/ */ 35 /* pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT.BKGMODEL", i); */ 36 37 /* ppStackFileActivationSingle(config, PPSTACK_FILES_BKG, false, i); */ 38 /* } */ 39 psFree(inputs); 40 // psFree(stack->bkgFits); 41 bkgRO->data_exists = true; 42 return(true); 43 } 44 45 46 5 47 6 48 bool ppStackCombineFinal(ppStackThreadData *stack, psArray *covariances, ppStackOptions *options, -
branches/czw_branch/20120906/ppStack/src/ppStackCombinePrepare.c
r30620 r34516 1 1 #include "ppStack.h" 2 2 3 bool ppStackCombinePrepare(const char *outName, const char *expName, 3 bool ppStackCombinePrepare(const char *outName, const char *expName, const char *bkgName, 4 4 ppStackFileList files, ppStackThreadData *stack, 5 5 ppStackOptions *options, pmConfig *config) … … 26 26 pmCell *cell = pmFPAfileThisCell(config->files, view, outName); // Output cell 27 27 options->outRO = pmReadoutAlloc(cell); // Output readout 28 28 29 29 pmCell *expCell = pmFPAfileThisCell(config->files, view, expName); // Exposure cell 30 30 options->expRO = pmReadoutAlloc(expCell); // Output readout 31 32 pmCell *bkgCell; 33 if (bkgName) { 34 bkgCell = pmFPAfileThisCell(config->files, view, bkgName); // Bkg cell 35 options->bkgRO = pmReadoutAlloc(bkgCell); // BKG readout 36 } 31 37 32 38 psFree(view); … … 47 53 } 48 54 55 if (bkgName) { 56 if (!pmReadoutStackDefineOutput(options->bkgRO, col0, row0, numCols, numRows, false, false, 0)) { 57 psError(PPSTACK_ERR_ARGUMENTS, false, "Unable to prepare output."); 58 return false; 59 } 60 } 61 49 62 return true; 50 63 } -
branches/czw_branch/20120906/ppStack/src/ppStackFiles.c
r31158 r34516 14 14 /// Files required for the convolution 15 15 static char *filesConvolve[] = { "PPSTACK.INPUT", "PPSTACK.INPUT.MASK", "PPSTACK.INPUT.VARIANCE", NULL }; 16 17 /// Files required for the background 18 static char *filesBkg[] = { "PPSTACK.INPUT.BKGMODEL", NULL }; 16 19 17 20 /// Regular (convolved) stack files … … 19 22 "PPSTACK.OUTPUT.EXP", "PPSTACK.OUTPUT.EXPNUM", "PPSTACK.OUTPUT.EXPWT", 20 23 "PPSTACK.OUTPUT.JPEG1", "PPSTACK.OUTPUT.JPEG2", 24 "PPSTACK.OUTPUT.BKGMODEL", 21 25 NULL }; 22 26 /// Unconvolved stack files 23 27 static char *filesUnconv[] = { "PPSTACK.UNCONV", "PPSTACK.UNCONV.MASK", "PPSTACK.UNCONV.VARIANCE", 24 28 "PPSTACK.UNCONV.EXP", "PPSTACK.UNCONV.EXPNUM", "PPSTACK.UNCONV.EXPWT", 29 "PPSTACK.OUTPUT.BKGMODEL", 25 30 NULL }; 26 31 … … 41 46 case PPSTACK_FILES_UNCONV: return filesUnconv; 42 47 case PPSTACK_FILES_PHOT: return filesPhot; 48 case PPSTACK_FILES_BKG: return filesBkg; 43 49 default: 44 50 psAbort("Unrecognised file list: %x", list); … … 86 92 for (int i = 0; files[i] != NULL; i++) { 87 93 pmFPAfileActivate(config->files, state, files[i]); 94 fprintf(stderr,"ACTIVE: %d %s %d\n",i,files[i],state); 88 95 } 89 96 return; -
branches/czw_branch/20120906/ppStack/src/ppStackLoop.c
r31435 r34516 63 63 64 64 // Prepare for combination 65 if (!ppStackCombinePrepare("PPSTACK.OUTPUT", "PPSTACK.OUTPUT.EXP", PPSTACK_FILES_STACK, stack, options, config)) {65 if (!ppStackCombinePrepare("PPSTACK.OUTPUT", "PPSTACK.OUTPUT.EXP", "PPSTACK.OUTPUT.BKGMODEL", PPSTACK_FILES_STACK, stack, options, config)) { 66 66 psError(psErrorCodeLast(), false, "Unable to prepare for combination."); 67 67 psFree(stack); … … 84 84 pmCellFreeData(options->cells->data[i]); 85 85 } 86 psFree(stack);86 // psFree(stack); 87 87 88 88 // Pixel rejection … … 142 142 } 143 143 144 // Generate median background stack here. 145 if (!ppStackCombineBackground(stack, options, config)) { 146 psError(psErrorCodeLast(), false, "Unable to generate median of background images."); 147 psFree(stack); 148 return false; 149 } 150 ppStackFileActivation(config,PPSTACK_FILES_BKG ,false); 144 151 // Photometry 145 152 psTrace("ppStack", 1, "Photometering stacked image....\n"); … … 171 178 return false; 172 179 } 173 psFree(stack);180 // psFree(stack); 174 181 psLogMsg("ppStack", PS_LOG_INFO, "Stage 7: Cleanup, WCS & JPEGS: %f sec", psTimerClear("PPSTACK_STEPS")); 175 182 ppStackMemDump("cleanup"); … … 186 193 187 194 // Prepare for combination 188 if (!ppStackCombinePrepare("PPSTACK.UNCONV", "PPSTACK.UNCONV.EXP", PPSTACK_FILES_UNCONV,195 if (!ppStackCombinePrepare("PPSTACK.UNCONV", "PPSTACK.UNCONV.EXP", "PPSTACK.OUTPUT.BKGMODEL", PPSTACK_FILES_UNCONV, 189 196 stack, options, config)) { 190 197 psError(psErrorCodeLast(), false, "Unable to prepare for combination."); -
branches/czw_branch/20120906/ppStack/src/ppStackLoop.h
r30620 r34516 32 32 const char *outName, // Name of output file 33 33 const char *expName, // Name of exposure file 34 const char *bkgName, // Name of background file 34 35 ppStackFileList files, // Files of interest 35 36 ppStackThreadData *stack, // Stack -
branches/czw_branch/20120906/ppStack/src/ppStackOptions.h
r34093 r34516 48 48 // Rejection 49 49 psArray *rejected; // Rejected pixels 50 // Background 51 pmReadout *bkgRO; // Output background readout 52 psArray *bkgImages; // Input background images 50 53 } ppStackOptions; 51 54 -
branches/czw_branch/20120906/ppStack/src/ppStackReadout.c
r30620 r34516 194 194 195 195 196 197 196 bool ppStackReadoutFinal(const pmConfig *config, pmReadout *outRO, pmReadout *expRO, const psArray *readouts, 198 197 const psVector *mask, const psArray *rejected, const psVector *weightings, -
branches/czw_branch/20120906/ppStack/src/ppStackSetup.c
r31158 r34516 89 89 options->origMasks = psArrayAlloc(num); 90 90 options->origVariances = psArrayAlloc(num); 91 options->bkgImages = psArrayAlloc(num); 91 92 pmFPAview *view = pmFPAviewAlloc(0); 92 93 for (int i = 0; i < num; i++) { … … 103 104 options->origVariances->data[i] = pmFPAfileName(file, view, config); 104 105 } 106 /* { */ 107 /* pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT.BKGMODEL", i); */ 108 /* options->bkgImages->data[i] = pmFPAfileName(file, view, config); */ 109 /* } */ 105 110 } 106 111 psFree(view); -
branches/czw_branch/20120906/ppStack/src/ppStackThread.c
r31158 r34516 35 35 psFitsClose(stack->varianceFits->data[i]); 36 36 } 37 /* if (stack->bkgFits->data[i]) { */ 38 /* psFitsClose(stack->bkgFits->data[i]); */ 39 /* } */ 37 40 stack->imageFits->data[i] = stack->maskFits->data[i] = stack->varianceFits->data[i] = NULL; 38 41 } … … 40 43 psFree(stack->maskFits); 41 44 psFree(stack->varianceFits); 45 psFree(stack->bkgFits); 42 46 return; 43 47 } … … 53 57 const psArray *varianceNames = conv ? options->convVariances : options->origVariances; // Variance names 54 58 const psArray *covariances = conv ? options->convCovars : options->origCovars; // Covariance matrices 55 59 const psArray *bkgNames = options->bkgImages; 56 60 PS_ASSERT_ARRAY_NON_NULL(cells, NULL); 57 61 if (imageNames) { … … 77 81 stack->maskFits = psArrayAlloc(numInputs); 78 82 stack->varianceFits = psArrayAlloc(numInputs); 83 stack->bkgFits = psArrayAlloc(numInputs); 79 84 for (int i = 0; i < numInputs; i++) { 80 85 if (!cells->data[i]) { … … 95 100 psFree(resolved); \ 96 101 } 97 102 fprintf(stderr,"%d %s\n",i,(char*) bkgNames->data[i]); 98 103 IMAGE_OPEN(imageNames, stack->imageFits, i); 99 104 IMAGE_OPEN(maskNames, stack->maskFits, i); 100 105 IMAGE_OPEN(varianceNames, stack->varianceFits, i); 106 // IMAGE_OPEN(bkgNames, stack->bkgFits, i); 101 107 } 102 108 -
branches/czw_branch/20120906/ppStack/src/ppStackThread.h
r31158 r34516 25 25 psArray *maskFits; // FITS file pointers for masks 26 26 psArray *varianceFits; // FITS file pointers for variances 27 psArray *bkgFits; // FITS file pointers for background models 27 28 } ppStackThreadData; 28 29
Note:
See TracChangeset
for help on using the changeset viewer.
