Changeset 34666
- Timestamp:
- Nov 15, 2012, 1:32:57 PM (14 years ago)
- Location:
- branches/czw_branch/20120906/ppStack/src
- Files:
-
- 12 edited
-
Makefile.am (modified) (3 diffs)
-
ppStack.h (modified) (2 diffs)
-
ppStackArguments.c (modified) (1 diff)
-
ppStackCleanup.c (modified) (1 diff)
-
ppStackCombineFinal.c (modified) (1 diff)
-
ppStackCombinePrepare.c (modified) (1 diff)
-
ppStackFiles.c (modified) (2 diffs)
-
ppStackLoop.h (modified) (1 diff)
-
ppStackPrepare.c (modified) (2 diffs)
-
ppStackSetup.c (modified) (3 diffs)
-
ppStackThread.c (modified) (2 diffs)
-
ppStackUpdateHeader.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20120906/ppStack/src/Makefile.am
r30620 r34666 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 \ -
branches/czw_branch/20120906/ppStack/src/ppStack.h
r34516 r34666 39 39 PPSTACK_FILES_UNCONV, // Unconvolved stack files 40 40 PPSTACK_FILES_PHOT, // Files for photometry 41 PPSTACK_FILES_BKG // Files for bkg 41 PPSTACK_FILES_BKG, // Files for bkg 42 PPSTACK_FILES_MEDIAN, // Files for median only stacks. 43 PPSTACK_FILES_MINIMAL // Files for median only stacks. 42 44 } ppStackFileList; 43 45 … … 114 116 // Perform median stacking for background 115 117 bool ppStackCombineBackground(ppStackThreadData *stack, ppStackOptions *options, pmConfig *config); 118 bool ppStackCombineMedian(ppStackThreadData *stack, ppStackOptions *options, pmConfig *config); 116 119 117 120 // Return software version -
branches/czw_branch/20120906/ppStack/src/ppStackArguments.c
r31422 r34666 324 324 } 325 325 326 326 327 psTrace("ppStack", 1, "Done parsing arguments\n"); 327 328 -
branches/czw_branch/20120906/ppStack/src/ppStackCleanup.c
r34623 r34666 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 30 34 if (options->bkgRO) { 31 35 options->bkgRO->data_exists = false; 32 options->bkgRO->parent->data_exists = false; 33 options->bkgRO->parent->parent->data_exists = false; 36 if (options->bkgRO->parent) { 37 options->bkgRO->parent->data_exists = false; 38 options->bkgRO->parent->parent->data_exists = false; 39 } 34 40 psFree(options->bkgRO); 35 41 options->bkgRO = NULL; -
branches/czw_branch/20120906/ppStack/src/ppStackCombineFinal.c
r34623 r34666 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 for (int i = 0; i < options->num; i++) {18 ppStackFileActivationSingle(config, PPSTACK_FILES_BKG, true, i);19 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT.BKGMODEL", i);20 pmFPAview *view = ppStackFilesIterateDown(config);21 pmReadout *ro = pmFPAviewThisReadout(view,file->fpa);22 inputs->data[i] = ro;23 pmFPAfileClose(file,view);24 }25 if (!pmStackSimpleMedianCombine(bkgRO,inputs)) {26 psFree(inputs);27 return(false);28 }29 #if 030 if (!ppStackWriteImage("/tmp/test_forced.bkgmdl.fits",31 bkgRO->parent->parent->parent->hdu->header,32 bkgRO->image,33 config)) {34 fprintf(stderr,"Failed to write image because fail.\n");35 }36 #endif37 for (int i = 0; i < options->num; i++) {38 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT.BKGMODEL", i);39 pmFPAview *view = ppStackFilesIterateDown(config);40 bool success = pmFPAfileClose(file,view);41 if (!success) {42 psTrace("ppStack",5,"I failed at closing a file.\n");43 }44 45 psFitsClose(file->fits);46 file->fits = NULL;47 file->header = NULL;48 file->state = PM_FPA_STATE_CLOSED;49 file->wrote_phu = false;50 ppStackFileActivationSingle(config, PPSTACK_FILES_BKG, false, i);51 }52 psFree(inputs);53 bkgRO->data_exists = true;54 bkgRO->parent->data_exists = true;55 bkgRO->parent->parent->data_exists = true;56 57 return(true);58 }59 60 61 62 5 63 6 bool ppStackCombineFinal(ppStackThreadData *stack, psArray *covariances, ppStackOptions *options, -
branches/czw_branch/20120906/ppStack/src/ppStackCombinePrepare.c
r34623 r34666 62 62 63 63 } 64 else { 65 options->bkgRO = NULL; 66 } 64 67 65 68 psFree(view); -
branches/czw_branch/20120906/ppStack/src/ppStackFiles.c
r34623 r34666 17 17 /// Files required for the background 18 18 static char *filesBkg[] = { "PPSTACK.INPUT.BKGMODEL", NULL }; 19 20 /// Files required for median only stacking 21 static char *filesMedian[] = { "PPSTACK.INPUT", 22 NULL }; 23 /// Files required for median only stacking 24 static char *filesMinimal[] = { "PPSTACK.OUTPUT", 25 NULL }; 19 26 20 27 /// Regular (convolved) stack files … … 46 53 case PPSTACK_FILES_PHOT: return filesPhot; 47 54 case PPSTACK_FILES_BKG: return filesBkg; 55 case PPSTACK_FILES_MEDIAN: return filesMedian; 56 case PPSTACK_FILES_MINIMAL: return filesMinimal; 48 57 default: 49 58 psAbort("Unrecognised file list: %x", list); -
branches/czw_branch/20120906/ppStack/src/ppStackLoop.h
r34516 r34666 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 -
branches/czw_branch/20120906/ppStack/src/ppStackPrepare.c
r34095 r34666 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 -
branches/czw_branch/20120906/ppStack/src/ppStackSetup.c
r34516 r34666 91 91 options->bkgImages = psArrayAlloc(num); 92 92 pmFPAview *view = pmFPAviewAlloc(0); 93 int nullMasks = 0; 94 int nullVariances = 0; 93 95 for (int i = 0; i < num; i++) { 94 96 { … … 98 100 { 99 101 // We want the convolved mask, since that defines the area that has been tested for outliers 102 if (options->convolve) { 100 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 } 101 112 } 102 113 { 103 114 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT.VARIANCE", i); 104 115 options->origVariances->data[i] = pmFPAfileName(file, view, config); 116 if (!(options->origVariances->data[i])) { 117 nullVariances++; 118 } 105 119 } 106 120 /* { */ … … 109 123 /* } */ 110 124 } 125 if (nullMasks == num) { 126 psFree(options->origMasks); 127 } 128 if (nullVariances == num) { 129 psFree(options->origVariances); 130 } 131 111 132 psFree(view); 112 133 -
branches/czw_branch/20120906/ppStack/src/ppStackThread.c
r34623 r34666 68 68 PS_ASSERT_ARRAYS_SIZE_EQUAL(cells, covariances, NULL); 69 69 } 70 70 71 71 ppStackThreadData *stack = psAlloc(sizeof(ppStackThreadData)); // Thread data, to return 72 72 psMemSetDeallocator(stack, (psFreeFunc)stackThreadDataFree); … … 97 97 psFree(resolved); \ 98 98 } 99 fprintf(stderr,"ppST:99 %s %s\n",pmConfigConvertFilename(imageNames->data[i], config, false, false), 100 (char*)imageNames->data[i]); 101 99 102 IMAGE_OPEN(imageNames, stack->imageFits, i); 100 IMAGE_OPEN(maskNames, stack->maskFits, i); 101 IMAGE_OPEN(varianceNames, stack->varianceFits, i); 103 if (maskNames) { 104 IMAGE_OPEN(maskNames, stack->maskFits, i); 105 } 106 if (varianceNames) { 107 IMAGE_OPEN(varianceNames, stack->varianceFits, i); 108 } 102 109 } 103 110 -
branches/czw_branch/20120906/ppStack/src/ppStackUpdateHeader.c
r34623 r34666 11 11 bool wcsDone = false; // Have we done the WCS? 12 12 for (int i = 0; i < options->num && !wcsDone; i++) { 13 if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {13 if ((options->inputMask)&&(options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i])) { 14 14 continue; 15 15 } … … 127 127 128 128 // Copy information into expRO, because it should be there too. 129 pmHDU *expROhdu = pmHDUFromCell(expRO->parent); 130 if (!expROhdu->header) { 131 expROhdu->header = psMetadataAlloc(); 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); 132 143 } 133 expRO->parent->parent->parent->hdu->header = psMetadataCopy(expRO->parent->parent->parent->hdu->header,134 outRO->parent->parent->parent->hdu->header);135 136 expRO->parent->concepts = psMetadataCopy(expRO->parent->concepts,137 outRO->parent->concepts);138 expRO->parent->parent->concepts = psMetadataCopy(expRO->parent->parent->concepts,139 outRO->parent->concepts);140 expRO->parent->parent->parent->concepts = psMetadataCopy(expRO->parent->parent->parent->concepts,141 outRO->parent->parent->parent->concepts);142 143 144 144 145 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
