Changeset 34800 for trunk/ppStack/src
- Timestamp:
- Dec 11, 2012, 2:04:31 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 17 edited
- 3 copied
-
. (modified) (1 prop)
-
ppStack/src/Makefile.am (modified) (3 diffs)
-
ppStack/src/ppStack.h (modified) (2 diffs)
-
ppStack/src/ppStackArguments.c (modified) (1 diff)
-
ppStack/src/ppStackCamera.c (modified) (4 diffs)
-
ppStack/src/ppStackCleanup.c (modified) (3 diffs)
-
ppStack/src/ppStackCombineAlternate.c (copied) (copied from branches/czw_branch/20120906/ppStack/src/ppStackCombineAlternate.c )
-
ppStack/src/ppStackCombinePrepare.c (modified) (3 diffs)
-
ppStack/src/ppStackFiles.c (modified) (3 diffs)
-
ppStack/src/ppStackLoop.c (modified) (5 diffs)
-
ppStack/src/ppStackLoop.h (modified) (2 diffs)
-
ppStack/src/ppStackMedian.c (copied) (copied from branches/czw_branch/20120906/ppStack/src/ppStackMedian.c )
-
ppStack/src/ppStackMedianLoop.c (copied) (copied from branches/czw_branch/20120906/ppStack/src/ppStackMedianLoop.c )
-
ppStack/src/ppStackOptions.h (modified) (1 diff)
-
ppStack/src/ppStackPrepare.c (modified) (2 diffs)
-
ppStack/src/ppStackReadout.c (modified) (1 diff)
-
ppStack/src/ppStackSetup.c (modified) (2 diffs)
-
ppStack/src/ppStackThread.c (modified) (4 diffs)
-
ppStack/src/ppStackThread.h (modified) (1 diff)
-
ppStack/src/ppStackUpdateHeader.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
trunk/ppStack/src/Makefile.am
r30620 r34800 1 bin_PROGRAMS = ppStack 1 bin_PROGRAMS = ppStack ppStackMedian 2 2 3 3 if HAVE_SVNVERSION … … 25 25 ppStack_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PSPHOT_LIBS) $(PPSTATS_LIBS) $(PPSTACK_LIBS) 26 26 27 ppStackMedian_CFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PPSTATS_CFLAGS) $(PPSTACK_CFLAGS) 28 ppStackMedian_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PSPHOT_LIBS) $(PPSTATS_LIBS) $(PPSTACK_LIBS) 29 27 30 ppStack_SOURCES = \ 28 31 ppStack.c \ … … 43 46 ppStackCombinePrepare.c \ 44 47 ppStackCombineInitial.c \ 48 ppStackCombineAlternate.c \ 49 ppStackReject.c \ 50 ppStackCombineFinal.c \ 51 ppStackCleanup.c \ 52 ppStackPhotometry.c \ 53 ppStackFinish.c \ 54 ppStackTarget.c \ 55 ppStackUpdateHeader.c \ 56 ppStackJPEGs.c \ 57 ppStackStats.c \ 58 ppStackErrorCodes.c 59 60 ppStackMedian_SOURCES = \ 61 ppStackMedian.c \ 62 ppStackArguments.c \ 63 ppStackCamera.c \ 64 ppStackFiles.c \ 65 ppStackMedianLoop.c \ 66 ppStackPSF.c \ 67 ppStackReadout.c \ 68 ppStackVersion.c \ 69 ppStackMatch.c \ 70 ppStackSources.c \ 71 ppStackThread.c \ 72 ppStackOptions.c \ 73 ppStackSetup.c \ 74 ppStackPrepare.c \ 75 ppStackConvolve.c \ 76 ppStackCombinePrepare.c \ 77 ppStackCombineInitial.c \ 78 ppStackCombineAlternate.c \ 45 79 ppStackReject.c \ 46 80 ppStackCombineFinal.c \ -
trunk/ppStack/src/ppStack.h
r34092 r34800 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 42 PPSTACK_FILES_MEDIAN_IN, // Files for median only stacks. 43 PPSTACK_FILES_MEDIAN_OUT // Files for median only stacks. 41 44 } ppStackFileList; 42 45 … … 111 114 bool ppStackReadoutFinalThread(psThreadJob *job // Job to process 112 115 ); 116 // Perform median stacking for background 117 bool ppStackCombineBackground(ppStackThreadData *stack, ppStackOptions *options, pmConfig *config); 118 bool ppStackCombineMedian(ppStackThreadData *stack, ppStackOptions *options, pmConfig *config); 113 119 114 120 // Return software version -
trunk/ppStack/src/ppStackArguments.c
r31422 r34800 324 324 } 325 325 326 326 327 psTrace("ppStack", 1, "Done parsing arguments\n"); 327 328 -
trunk/ppStack/src/ppStackCamera.c
r30620 r34800 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 if (!inputBKG) { 226 psError(psErrorCodeLast(), false, 227 "Unable to define file from bkgmodel %d (%s)",i,bkgmodel); 228 return(false); 229 } 230 }// End bkgmodel 231 232 233 234 217 235 i++; 218 236 } … … 460 478 jpeg2->save = true; 461 479 480 // Output background 481 pmFPAfile *outBkg = pmFPAfileDefineOutput(config,NULL,"PPSTACK.OUTPUT.BKGMODEL"); 482 if (!outBkg) { 483 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT.BKGMODEL")); 484 return(false); 485 } 486 if (outBkg->type != PM_FPA_FILE_IMAGE) { 487 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.BKGMODEL is not of type IMAGE"); 488 return(false); 489 } 490 outBkg->save = true; 491 pmFPAfile *outBkgRest = pmFPAfileDefineOutput(config,NULL,"PPSTACK.OUTPUT.BKGREST"); 492 if (!outBkgRest) { 493 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT.BKGREST")); 494 return(false); 495 } 496 if (outBkgRest->type != PM_FPA_FILE_IMAGE) { 497 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.BKGREST is not of type IMAGE"); 498 return(false); 499 } 500 462 501 // For photometry, we operate on the chip-mosaicked image 463 502 // we create a copy of the mosaicked image for psphot so we can write out a clean image … … 496 535 } 497 536 537 // Define output file here. 538 498 539 return true; 499 540 } -
trunk/ppStack/src/ppStackCleanup.c
r30874 r34800 22 22 options->outRO = NULL; 23 23 24 options->expRO->data_exists = false; 25 options->expRO->parent->data_exists = false; 26 options->expRO->parent->parent->data_exists = false; 27 psFree(options->expRO); 28 options->expRO = NULL; 24 if (options->expRO) { 25 options->expRO->data_exists = false; 26 if (options->expRO->parent) { 27 options->expRO->parent->data_exists = false; 28 options->expRO->parent->parent->data_exists = false; 29 } 30 psFree(options->expRO); 31 options->expRO = NULL; 32 } 29 33 34 if (options->bkgRO) { 35 options->bkgRO->data_exists = false; 36 if (options->bkgRO->parent) { 37 options->bkgRO->parent->data_exists = false; 38 options->bkgRO->parent->parent->data_exists = false; 39 } 40 psFree(options->bkgRO); 41 options->bkgRO = NULL; 42 } 43 30 44 for (int i = 0; i < options->num; i++) { 31 45 pmCellFreeData(options->cells->data[i]); … … 62 76 63 77 bool ppStackCleanup (pmConfig *config, ppStackOptions *options) { 64 65 78 psExit exitValue = ppStackExitCode(PS_EXIT_SUCCESS); // Exit code 66 79 67 80 // Ensure everything closes 68 81 if (config) { … … 72 85 ppStackFileActivation(config, PPSTACK_FILES_UNCONV, true); 73 86 ppStackFileActivation(config, PPSTACK_FILES_PHOT, true); 87 ppStackFileActivation(config, PPSTACK_FILES_MEDIAN_IN, true); 88 ppStackFileActivation(config, PPSTACK_FILES_MEDIAN_OUT, true); 74 89 if (!ppStackFilesIterateUp(config)) { 75 90 psError(psErrorCodeLast(), false, "Unable to close files."); -
trunk/ppStack/src/ppStackCombinePrepare.c
r30620 r34800 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) … … 27 27 options->outRO = pmReadoutAlloc(cell); // Output readout 28 28 29 pmCell *expCell = pmFPAfileThisCell(config->files, view, expName); // Exposure cell 30 options->expRO = pmReadoutAlloc(expCell); // Output readout 29 if (expName) { 30 pmCell *expCell = pmFPAfileThisCell(config->files, view, expName); // Exposure cell 31 options->expRO = pmReadoutAlloc(expCell); //Output readout 32 } 33 /* else { */ 34 /* options->expRO = NULL; */ 35 /* } */ 36 pmCell *bkgCell; 37 int bkg_r0,bkg_c0; 38 int bkg_nC,bkg_nR; 39 if (bkgName) { 40 ppStackFileActivationSingle(config, PPSTACK_FILES_BKG, true, 0); 41 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT.BKGMODEL", 0); 42 pmFPAview *view = ppStackFilesIterateDown(config); 43 pmReadout *ro = pmFPAviewThisReadout(view,file->fpa); 44 45 bkg_r0 = ro->image->row0; 46 bkg_c0 = ro->image->col0; 47 bkg_nC = ro->image->numCols; 48 bkg_nR = ro->image->numRows; 49 bkgCell = pmFPAfileThisCell(config->files, view, bkgName); // Bkg cell 50 51 options->bkgRO = pmReadoutAlloc(bkgCell); // BKG readout 52 // if (!pmHDUGenerateForFPA(options->bkgRO->parent->parent->parent)) { 53 options->bkgRO->parent->parent->parent->hdu = pmHDUAlloc(NULL); 54 if (!options->bkgRO->parent->parent->parent->hdu) { 55 fprintf(stderr,"failed to generate a HDU for this thing.\n"); 56 } 57 options->bkgRO->parent->parent->parent->hdu->header = psMetadataCopy(options->bkgRO->parent->parent->parent->hdu->header, 58 ro->parent->parent->parent->hdu->header); 59 60 options->bkgRO->parent->concepts = psMetadataCopy(options->bkgRO->parent->concepts, 61 ro->parent->concepts); 62 options->bkgRO->parent->parent->concepts = psMetadataCopy(options->bkgRO->parent->parent->concepts, 63 ro->parent->parent->concepts); 64 options->bkgRO->parent->parent->parent->concepts = psMetadataCopy(options->bkgRO->parent->parent->parent->concepts, 65 ro->parent->parent->parent->concepts); 66 67 } 68 else { 69 options->bkgRO = NULL; 70 } 31 71 32 72 psFree(view); … … 42 82 } 43 83 44 if (!pmReadoutStackDefineOutput(options->expRO, col0, row0, numCols, numRows, true, true, 0)) { 84 if (expName) { 85 if (!pmReadoutStackDefineOutput(options->expRO, col0, row0, numCols, numRows, true, true, 0)) { 45 86 psError(PPSTACK_ERR_ARGUMENTS, false, "Unable to prepare output."); 46 87 return false; 88 } 89 } 90 91 if (bkgName) { 92 if (!pmReadoutStackDefineOutput(options->bkgRO, bkg_c0, bkg_r0, bkg_nC, bkg_nR, false, false, 0)) { 93 psError(PPSTACK_ERR_ARGUMENTS, false, "Unable to prepare output."); 94 return false; 95 } 96 97 98 47 99 } 48 100 -
trunk/ppStack/src/ppStackFiles.c
r31158 r34800 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 }; 19 20 /// Files required for median only stacking 21 static char *filesMedianIn[] = { "PPSTACK.INPUT", 22 NULL }; 23 /// Files required for median only stacking 24 static char *filesMedianOut[] = { "PPSTACK.OUTPUT", 25 NULL }; 16 26 17 27 /// Regular (convolved) stack files … … 19 29 "PPSTACK.OUTPUT.EXP", "PPSTACK.OUTPUT.EXPNUM", "PPSTACK.OUTPUT.EXPWT", 20 30 "PPSTACK.OUTPUT.JPEG1", "PPSTACK.OUTPUT.JPEG2", 31 "PPSTACK.OUTPUT.BKGMODEL", 21 32 NULL }; 22 33 /// Unconvolved stack files … … 41 52 case PPSTACK_FILES_UNCONV: return filesUnconv; 42 53 case PPSTACK_FILES_PHOT: return filesPhot; 54 case PPSTACK_FILES_BKG: return filesBkg; 55 case PPSTACK_FILES_MEDIAN_IN: return filesMedianIn; 56 case PPSTACK_FILES_MEDIAN_OUT: return filesMedianOut; 43 57 default: 44 58 psAbort("Unrecognised file list: %x", list); -
trunk/ppStack/src/ppStackLoop.c
r31435 r34800 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", NULL, PPSTACK_FILES_UNCONV, 189 196 stack, options, config)) { 190 197 psError(psErrorCodeLast(), false, "Unable to prepare for combination."); -
trunk/ppStack/src/ppStackLoop.h
r30620 r34800 4 4 // Loop over the inputs, doing the combination 5 5 bool ppStackLoop( 6 pmConfig *config, // Configuration 7 ppStackOptions *options // Options for stacking 8 ); 9 // Median only loop. 10 bool ppStackMedianLoop( 6 11 pmConfig *config, // Configuration 7 12 ppStackOptions *options // Options for stacking … … 32 37 const char *outName, // Name of output file 33 38 const char *expName, // Name of exposure file 39 const char *bkgName, // Name of background file 34 40 ppStackFileList files, // Files of interest 35 41 ppStackThreadData *stack, // Stack -
trunk/ppStack/src/ppStackOptions.h
r34093 r34800 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 -
trunk/ppStack/src/ppStackPrepare.c
r34095 r34800 132 132 psVectorInit(options->inputMask, 0); 133 133 options->exposures = psVectorAlloc(options->num, PS_TYPE_F32); 134 134 135 psVectorInit(options->exposures, NAN); 135 136 … … 150 151 151 152 options->exposures->data.F32[i] = psMetadataLookupF32(NULL, cell->concepts, "CELL.EXPOSURE"); 153 if ((options->exposures->data.F32[i] == 0)|| 154 (!(isfinite(options->exposures->data.F32[i])))){ 155 options->exposures->data.F32[i] = psMetadataLookupF32(NULL,recipe,"DEFAULT.EXPTIME"); 156 } 152 157 options->sumExposure += options->exposures->data.F32[i]; 153 158 -
trunk/ppStack/src/ppStackReadout.c
r30620 r34800 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, -
trunk/ppStack/src/ppStackSetup.c
r31158 r34800 89 89 options->origMasks = psArrayAlloc(num); 90 90 options->origVariances = psArrayAlloc(num); 91 options->bkgImages = psArrayAlloc(num); 91 92 pmFPAview *view = pmFPAviewAlloc(0); 93 int nullMasks = 0; 94 int nullVariances = 0; 92 95 for (int i = 0; i < num; i++) { 93 96 { … … 97 100 { 98 101 // We want the convolved mask, since that defines the area that has been tested for outliers 102 if (options->convolve) { 99 103 options->origMasks->data[i] = psMemIncrRefCounter(options->convMasks->data[i]); 104 } 105 else { 106 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT.MASK", i); 107 options->origMasks->data[i] = pmFPAfileName(file, view, config); 108 } 109 if (!(options->origMasks->data[i])) { 110 nullMasks++; 111 } 100 112 } 101 113 { 102 114 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT.VARIANCE", i); 103 115 options->origVariances->data[i] = pmFPAfileName(file, view, config); 116 if (!(options->origVariances->data[i])) { 117 nullVariances++; 118 } 104 119 } 120 /* { */ 121 /* pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT.BKGMODEL", i); */ 122 /* options->bkgImages->data[i] = pmFPAfileName(file, view, config); */ 123 /* } */ 105 124 } 125 if (nullMasks == num) { 126 psFree(options->origMasks); 127 } 128 if (nullVariances == num) { 129 psFree(options->origVariances); 130 } 131 106 132 psFree(view); 107 133 -
trunk/ppStack/src/ppStackThread.c
r31158 r34800 40 40 psFree(stack->maskFits); 41 41 psFree(stack->varianceFits); 42 psFree(stack->bkgFits); 42 43 return; 43 44 } … … 67 68 PS_ASSERT_ARRAYS_SIZE_EQUAL(cells, covariances, NULL); 68 69 } 69 70 70 71 ppStackThreadData *stack = psAlloc(sizeof(ppStackThreadData)); // Thread data, to return 71 72 psMemSetDeallocator(stack, (psFreeFunc)stackThreadDataFree); … … 77 78 stack->maskFits = psArrayAlloc(numInputs); 78 79 stack->varianceFits = psArrayAlloc(numInputs); 80 stack->bkgFits = psArrayAlloc(numInputs); 79 81 for (int i = 0; i < numInputs; i++) { 80 82 if (!cells->data[i]) { … … 95 97 psFree(resolved); \ 96 98 } 97 99 98 100 IMAGE_OPEN(imageNames, stack->imageFits, i); 99 IMAGE_OPEN(maskNames, stack->maskFits, i); 100 IMAGE_OPEN(varianceNames, stack->varianceFits, i); 101 if (maskNames) { 102 IMAGE_OPEN(maskNames, stack->maskFits, i); 103 } 104 if (varianceNames) { 105 IMAGE_OPEN(varianceNames, stack->varianceFits, i); 106 } 101 107 } 102 108 -
trunk/ppStack/src/ppStackThread.h
r31158 r34800 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 -
trunk/ppStack/src/ppStackUpdateHeader.c
r31158 r34800 6 6 7 7 pmReadout *outRO = options->outRO; // Output readout 8 pmReadout *expRO = options->expRO; 8 9 9 10 // Propagate WCS 10 11 bool wcsDone = false; // Have we done the WCS? 11 12 for (int i = 0; i < options->num && !wcsDone; i++) { 12 if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {13 if ((options->inputMask)&&(options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i])) { 13 14 continue; 14 15 } … … 123 124 snprintf (field, 64, "AIR_%04d", i); 124 125 psMetadataAddF32(hdu->header, PS_LIST_TAIL, field, PS_META_REPLACE, "input image airmass", value); 125 } 126 } 127 128 // Copy information into expRO, because it should be there too. 129 if ((expRO)&&(expRO->parent)) { 130 pmHDU *expROhdu = pmHDUFromCell(expRO->parent); 131 if (!expROhdu->header) { 132 expROhdu->header = psMetadataAlloc(); 133 } 134 expRO->parent->parent->parent->hdu->header = psMetadataCopy(expRO->parent->parent->parent->hdu->header, 135 outRO->parent->parent->parent->hdu->header); 136 137 expRO->parent->concepts = psMetadataCopy(expRO->parent->concepts, 138 outRO->parent->concepts); 139 expRO->parent->parent->concepts = psMetadataCopy(expRO->parent->parent->concepts, 140 outRO->parent->concepts); 141 expRO->parent->parent->parent->concepts = psMetadataCopy(expRO->parent->parent->parent->concepts, 142 outRO->parent->parent->parent->concepts); 143 } 144 126 145 return true; 127 146 }
Note:
See TracChangeset
for help on using the changeset viewer.
