- Timestamp:
- Mar 29, 2010, 3:55:49 PM (16 years ago)
- Location:
- branches/eam_branches/20100225
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ppStack/src/ppStackLoop.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20100225
- Property svn:mergeinfo changed
-
branches/eam_branches/20100225/ppStack/src/ppStackLoop.c
r27075 r27517 18 18 psString summary = NULL; // Summary of images 19 19 for (int i = 0; i < options->num; i++) { 20 char *reason; // Reason for rejecting 21 switch (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 22 case PPSTACK_MASK_NONE: 23 reason = "Good"; 20 psString reason = NULL; // Reason for rejecting 21 if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) { 22 psStringAppend(&reason, " Good."); 24 23 numGood++; 25 break; 26 case PPSTACK_MASK_CAL: 27 reason = "Calibration failed"; 28 break; 29 case PPSTACK_MASK_PSF: 30 reason = "PSF measurement failed"; 31 break; 32 case PPSTACK_MASK_MATCH: 33 reason = "PSF matching failed"; 34 break; 35 case PPSTACK_MASK_CHI2: 36 reason = "PSF matching chi^2 deviant"; 37 break; 38 case PPSTACK_MASK_REJECT: 39 reason = "Rejection exceeded threshold"; 40 break; 41 default: 42 psAbort("Unrecognised mask value: %x", options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]); 24 } else { 25 if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PPSTACK_MASK_CAL) { 26 psStringAppend(&reason, " Calibration failed."); 27 } 28 if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PPSTACK_MASK_PSF) { 29 psStringAppend(&reason, " PSF measurement failed."); 30 } 31 if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PPSTACK_MASK_MATCH) { 32 psStringAppend(&reason, " PSF matching failed."); 33 } 34 if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PPSTACK_MASK_CHI2) { 35 psStringAppend(&reason, " PSF matching chi^2 deviant."); 36 } 37 if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PPSTACK_MASK_REJECT) { 38 psStringAppend(&reason, " Rejection exceeded threshold."); 39 } 43 40 } 44 41 psStringAppend(&summary, "Image %d: %s\n", i, reason); 42 psFree(reason); 45 43 } 46 44 psLogMsg("ppStack", PS_LOG_INFO, "Summary of images for %s:\n%s", place, summary); … … 52 50 53 51 54 bool ppStackLoop(pmConfig *config )52 bool ppStackLoop(pmConfig *config, ppStackOptions *options) 55 53 { 56 54 assert(config); … … 58 56 psTimerStart("PPSTACK_TOTAL"); 59 57 psTimerStart("PPSTACK_STEPS"); 60 61 ppStackOptions *options = ppStackOptionsAlloc(); // Options for stacking62 58 63 59 // Setup … … 65 61 if (!ppStackSetup(options, config)) { 66 62 psError(psErrorCodeLast(), false, "Unable to setup."); 67 psFree(options);68 63 return false; 69 64 } … … 76 71 if (!ppStackPrepare(options, config)) { 77 72 psError(psErrorCodeLast(), false, "Unable to prepare for stacking."); 78 psFree(options);79 73 return false; 80 74 } … … 82 76 psTimerClear("PPSTACK_STEPS")); 83 77 ppStackMemDump("prepare"); 84 78 if (options->quality) { 79 // Can't do anything else 80 return true; 81 } 85 82 86 83 // Convolve inputs … … 88 85 if (!ppStackConvolve(options, config)) { 89 86 psError(psErrorCodeLast(), false, "Unable to convolve images."); 90 psFree(options);91 87 return false; 92 88 } … … 111 107 if (!stack) { 112 108 psError(psErrorCodeLast(), false, "Unable to initialise stack threads."); 113 psFree(options);114 109 return false; 115 110 } 116 111 117 112 // Prepare for combination 118 if (!ppStackCombinePrepare(stack, options, config)) { 113 if (!ppStackCombinePrepare("PPSTACK.OUTPUT", "PPSTACK.OUTPUT.EXP", PPSTACK_FILES_STACK, 114 stack, options, config)) { 119 115 psError(psErrorCodeLast(), false, "Unable to prepare for combination."); 120 116 psFree(stack); 121 psFree(options);122 117 return false; 123 118 } … … 128 123 psError(psErrorCodeLast(), false, "Unable to perform initial combination."); 129 124 psFree(stack); 130 psFree(options); 131 return false; 132 } 133 ppStackMemDump("convolve"); 125 return false; 126 } 127 ppStackMemDump("initial"); 134 128 psLogMsg("ppStack", PS_LOG_INFO, "Stage 3: Make Initial Stack: %f sec", psTimerClear("PPSTACK_STEPS")); 135 129 130 // Done with stack inputs for now 131 for (int i = 0; i < options->num; i++) { 132 pmCellFreeData(options->cells->data[i]); 133 } 134 psFree(stack); 136 135 137 136 // Pixel rejection … … 140 139 psError(psErrorCodeLast(), false, "Unable to reject pixels."); 141 140 psFree(stack); 142 psFree(options);143 141 return false; 144 142 } 145 143 psLogMsg("ppStack", PS_LOG_INFO, "Stage 4: Pixel Rejection: %f sec", psTimerClear("PPSTACK_STEPS")); 146 ppStackMemDump("reject");147 144 148 145 // Check inputs … … 155 152 } 156 153 154 stack = ppStackThreadDataSetup(options, config, true); 155 if (!stack) { 156 psError(psErrorCodeLast(), false, "Unable to initialise stack threads."); 157 return false; 158 } 159 157 160 // Final combination 158 161 psTrace("ppStack", 2, "Final stack of convolved images....\n"); 159 if (!ppStackCombineFinal( options->outRO, stack, options->convCovars, options, config, false, false)) {162 if (!ppStackCombineFinal(stack, options->convCovars, options, config, false, false, true)) { 160 163 psError(psErrorCodeLast(), false, "Unable to perform final combination."); 161 164 psFree(stack); 162 psFree(options);163 165 return false; 164 166 } 165 167 psLogMsg("ppStack", PS_LOG_INFO, "Stage 5: Final Stack: %f sec", psTimerClear("PPSTACK_STEPS")); 166 168 ppStackMemDump("final"); 169 170 // Photometry 171 psTrace("ppStack", 1, "Photometering stacked image....\n"); 172 if (!ppStackPhotometry(options, config)) { 173 psError(psErrorCodeLast(), false, "Unable to perform photometry."); 174 return false; 175 } 176 psLogMsg("ppStack", PS_LOG_INFO, "Stage 6: Photometry Analysis: %f sec", psTimerClear("PPSTACK_STEPS")); 177 ppStackMemDump("photometry"); 167 178 168 179 // Clean up … … 171 182 psError(psErrorCodeLast(), false, "Unable to clean up."); 172 183 psFree(stack); 173 psFree(options); 174 return false; 175 } 176 psLogMsg("ppStack", PS_LOG_INFO, "Stage 6: Cleanup, WCS & JPEGS: %f sec", psTimerClear("PPSTACK_STEPS")); 184 return false; 185 } 186 for (int i = 0; i < options->num; i++) { 187 pmCellFreeData(options->cells->data[i]); 188 } 189 psFree(stack); 190 psLogMsg("ppStack", PS_LOG_INFO, "Stage 7: Cleanup, WCS & JPEGS: %f sec", psTimerClear("PPSTACK_STEPS")); 177 191 ppStackMemDump("cleanup"); 178 179 psFree(stack);180 192 181 193 #if 1 … … 186 198 if (!stack) { 187 199 psError(psErrorCodeLast(), false, "Unable to initialise stack threads."); 188 psFree(options); 189 return false; 190 } 200 return false; 201 } 202 203 // Prepare for combination 204 if (!ppStackCombinePrepare("PPSTACK.UNCONV", "PPSTACK.UNCONV.EXP", PPSTACK_FILES_UNCONV, 205 stack, options, config)) { 206 psError(psErrorCodeLast(), false, "Unable to prepare for combination."); 207 psFree(stack); 208 return false; 209 } 210 191 211 psTrace("ppStack", 2, "Stack of unconvolved images....\n"); 192 if (!ppStackCombineFinal(options->unconvRO, stack, options->origCovars, options, config, false, true)) { 212 if (!ppStackCombineFinal(stack, options->origCovars, options, config, 213 false, true, false)) { 193 214 psError(psErrorCodeLast(), false, "Unable to perform unconvolved combination."); 194 215 psFree(stack); 195 psFree(options); 196 return false; 197 } 198 psLogMsg("ppStack", PS_LOG_INFO, "Stage 7: Unconvolved Stack: %f sec", psTimerClear("PPSTACK_STEPS")); 216 return false; 217 } 218 psLogMsg("ppStack", PS_LOG_INFO, "Stage 8: Unconvolved Stack: %f sec", psTimerClear("PPSTACK_STEPS")); 199 219 ppStackMemDump("unconv"); 200 220 221 if (!ppStackFilesIterateUp(config)) { 222 psError(psErrorCodeLast(), false, "Unable to close files."); 223 psFree(stack); 224 return false; 225 } 226 ppStackFileActivation(config, PPSTACK_FILES_UNCONV, false); 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; 237 238 for (int i = 0; i < options->num; i++) { 239 pmCellFreeData(options->cells->data[i]); 240 } 201 241 psFree(stack); 202 242 } 203 243 psFree(options->cells); options->cells = NULL; 204 244 #endif 205 206 // Photometry207 psTrace("ppStack", 1, "Photometering stacked image....\n");208 if (!ppStackPhotometry(options, config)) {209 psError(psErrorCodeLast(), false, "Unable to perform photometry.");210 psFree(options);211 return false;212 }213 psLogMsg("ppStack", PS_LOG_INFO, "Stage 8: Photometry Analysis: %f sec", psTimerClear("PPSTACK_STEPS"));214 ppStackMemDump("photometry");215 245 216 246 // Finish up … … 218 248 if (!ppStackFinish(options, config)) { 219 249 psError(psErrorCodeLast(), false, "Unable to finish up."); 220 psFree(options); 221 return false; 222 } 223 psLogMsg("ppStack", PS_LOG_INFO, "Stage 9: Final output: %f sec", psTimerClear("PPSTACK_STEPS")); 250 return false; 251 } 224 252 ppStackMemDump("finish"); 225 226 psFree(options);227 253 228 254 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
