- Timestamp:
- Dec 17, 2010, 10:07:26 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20101205/ppSub/src/ppSubLoop.c
r29937 r30106 36 36 psAssert(config, "Require configuration."); 37 37 38 bool success = true; 39 38 40 pmConfigCamerasCull(config, NULL); 39 41 pmConfigRecipesCull(config, "PPSUB,PPSTATS,PSPHOT,PSASTRO,MASKS,JPEG"); … … 61 63 if (!ppSubInputDetections(&foundDetections, "PPSUB.POS1.SOURCES", "PPSUB.INPUT", data)) { 62 64 psError(psErrorCodeLast(), false, "Unable to measure positive detections (1)"); 63 return false; 65 success = false; 66 goto ESCAPE; 64 67 } 65 68 // if nothing was found, don't bother doing the forced photometry below … … 70 73 } 71 74 if (data->forcedPhot2) { 75 // Change the recipe to use a higher nsigma limit and quit after pass1 76 psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSPHOT_RECIPE); 77 78 psF32 nsigma_peak_save = psMetadataLookupF32 (NULL, recipe, "PEAKS_NSIGMA_LIMIT"); 79 char *breakPt_save = psMetadataLookupStr (NULL, recipe, "BREAK_POINT"); 80 81 bool mdok; 82 psF32 pos2_nsigma_peak = psMetadataLookupF32 (&mdok, recipe, "PEAKS_POS2_NSIGMA_LIMIT"); 83 if (!mdok) { 84 psWarning("PEAKS_POS2_NSIGMA_LIMIT not found in recipe. Will use 25.\n"); 85 pos2_nsigma_peak = 25.; 86 } 87 psMetadataAddF32(recipe, PS_LIST_TAIL, "PEAKS_NSIGMA_LIMIT", PS_META_REPLACE, "", pos2_nsigma_peak); 88 psMetadataAddStr(recipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_REPLACE, "", "PASS1"); 89 72 90 bool foundDetections = false; 73 91 if (!ppSubInputDetections(&foundDetections, "PPSUB.POS2.SOURCES", "PPSUB.REF", data)) { 74 92 psError(psErrorCodeLast(), false, "Unable to measure positive detections (2)"); 75 return false; 76 } 93 psMetadataAddF32(recipe, PS_LIST_TAIL, "PEAKS_NSIGMA_LIMIT", PS_META_REPLACE, "", nsigma_peak_save); 94 psMetadataAddStr(recipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_REPLACE, "", breakPt_save); 95 success = false; 96 goto ESCAPE; 97 } 98 psMetadataAddF32(recipe, PS_LIST_TAIL, "PEAKS_NSIGMA_LIMIT", PS_META_REPLACE, "", nsigma_peak_save); 99 psMetadataAddStr(recipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_REPLACE, "", breakPt_save); 77 100 // if nothing was found, don't bother doing the forced photometry below 78 101 if (!foundDetections) { 79 psWarning ("no sources found in positive image 1, skipping forced photometry");80 data->forcedPhot 1= false;81 } 82 } 83 84 // XXX if it exists, use the POS1, POS2 results for the FWHMs102 psWarning ("no sources found in positive image 2, skipping forced photometry"); 103 data->forcedPhot2 = false; 104 } 105 } 106 107 // XXX if it exists, use the POS1, POS2 successs for the FWHMs 85 108 if (!ppSubMatchPSFs(data)) { 86 109 psError(psErrorCodeLast(), false, "Unable to match PSFs."); 87 return false; 110 success = false; 111 goto ESCAPE; 88 112 } 89 113 if (data->quality) { 90 114 // Can't do anything at all 91 return true; 115 success = false; 116 goto ESCAPE; 92 117 } 93 118 // generate the residual stamp grid for visualization 94 119 if (!ppSubResidualSampleJpeg(config)) { 95 120 psError(psErrorCodeLast(), false, "Unable to update."); 96 return false; 121 success = false; 122 goto ESCAPE; 97 123 } 98 124 … … 106 132 if (!ppSubFilesIterateUp(config, PPSUB_FILES_INPUT)) { 107 133 psError(PPSUB_ERR_IO, false, "Unable to close input files."); 108 return false; 134 success = false; 135 goto ESCAPE; 109 136 } 110 137 111 138 if (!ppSubLowThreshold(data)) { 112 139 psError(psErrorCodeLast(), false, "Unable to threshold images."); 113 return false; 140 success = false; 141 goto ESCAPE; 114 142 } 115 143 … … 117 145 if (!ppSubFilesIterateDown(config, PPSUB_FILES_SUB)) { 118 146 psError(PPSUB_ERR_IO, false, "Unable to set up subtraction files."); 119 return false; 147 success = false; 148 goto ESCAPE; 120 149 } 121 150 122 151 if (!ppSubDefineOutput("PPSUB.OUTPUT", config)) { 123 152 psError(psErrorCodeLast(), false, "Unable to define output."); 124 return false; 153 success = false; 154 goto ESCAPE; 125 155 } 126 156 127 157 if (!data->quality && !ppSubMakePSF(data)) { 128 158 psError(psErrorCodeLast(), false, "Unable to generate PSF."); 129 return false; 159 success = false; 160 goto ESCAPE; 130 161 } 131 162 … … 142 173 if (!ppSubReadoutSubtract(config)) { 143 174 psError(psErrorCodeLast(), false, "Unable to subtract images."); 144 return false; 175 success = false; 176 goto ESCAPE; 145 177 } 146 178 // dumpout(config, "diff.1.fits"); … … 149 181 if (!ppSubFilesIterateUp(config, PPSUB_FILES_PSF | PPSUB_FILES_CONV)) { 150 182 psError(PPSUB_ERR_IO, false, "Unable to close input files."); 151 return false; 183 success = false; 184 goto ESCAPE; 152 185 } 153 186 // dumpout(config, "diff.2a.fits"); … … 156 189 if (!ppSubBackground(config)) { 157 190 psError(psErrorCodeLast(), false, "Unable to subtract background."); 158 return false; 191 success = false; 192 goto ESCAPE; 159 193 } 160 194 // dumpout(config, "diff.2b.fits"); … … 163 197 if (!ppSubVarianceRescale(config, data)) { 164 198 psError(psErrorCodeLast(), false, "Unable to rescale variance."); 165 return false; 199 success = false; 200 goto ESCAPE; 166 201 } 167 202 // dumpout(config, "diff.2c.fits"); … … 169 204 if (data->quality) { 170 205 // Done all we can do up to this point 171 return true; 206 success = false; 207 goto ESCAPE; 172 208 } 173 209 174 210 if (!ppSubFilesIterateDown(config, PPSUB_FILES_PHOT_SUB)) { 175 211 psError(PPSUB_ERR_IO, false, "Unable to set up photometry files."); 176 return false; 212 success = false; 213 goto ESCAPE; 177 214 } 178 215 179 216 if (!data->quality && !ppSubReadoutPhotometry("PPSUB.OUTPUT", data)) { 180 217 psError(psErrorCodeLast(), false, "Unable to perform photometry."); 181 return false; 218 success = false; 219 goto ESCAPE; 182 220 } 183 221 // dumpout(config, "diff.3.fits"); … … 187 225 if (!ppSubReadoutForcedPhot("PPSUB.FORCED1.SOURCES", "PPSUB.OUTPUT", "PPSUB.POS1.SOURCES", data)) { 188 226 psError(psErrorCodeLast(), false, "Unable to perform photometry."); 189 return false; 227 success = false; 228 goto ESCAPE; 190 229 } 191 230 } … … 195 234 if (!ppSubReadoutForcedPhot("PPSUB.FORCED2.SOURCES", "PPSUB.OUTPUT", "PPSUB.POS2.SOURCES", data)) { 196 235 psError(psErrorCodeLast(), false, "Unable to perform photometry."); 197 return false; 236 success = false; 237 goto ESCAPE; 198 238 } 199 239 } … … 201 241 if (!ppSubFilesIterateUp(config, PPSUB_FILES_PHOT_SUB)) { 202 242 psError(PPSUB_ERR_IO, false, "Unable to set up photometry files."); 203 return false; 243 success = false; 244 goto ESCAPE; 204 245 } 205 246 … … 207 248 if (!ppSubReadoutStats(data)) { 208 249 psError(psErrorCodeLast(), false, "Unable to collect statistics"); 209 return false; 250 success = false; 251 goto ESCAPE; 210 252 } 211 253 // Do Mask Stats … … 214 256 if (!ppSubMaskStats(config, view,data->stats)) { 215 257 psError(psErrorCodeLast(), false, "Unable to generate mask statistics"); 216 return(false); 258 success = false; 259 goto ESCAPE; 217 260 } 218 261 } … … 222 265 if (!ppSubReadoutJpeg(config)) { 223 266 psError(psErrorCodeLast(), false, "Unable to update."); 224 return false; 267 success = false; 268 goto ESCAPE; 225 269 } 226 270 … … 229 273 if (!ppSubFilesIterateDown(config, PPSUB_FILES_INV)) { 230 274 psError(PPSUB_ERR_IO, false, "Unable to set up inverse files."); 231 return false; 275 success = false; 276 goto ESCAPE; 232 277 } 233 278 234 279 if (data->inverse && !ppSubDefineOutput("PPSUB.INVERSE", config)) { 235 280 psError(psErrorCodeLast(), false, "Unable to define inverse."); 236 return false; 281 success = false; 282 goto ESCAPE; 237 283 } 238 284 239 285 if (!ppSubReadoutInverse(config)) { 240 286 psError(psErrorCodeLast(), false, "Unable to invert images."); 241 return false; 287 success = false; 288 goto ESCAPE; 242 289 } 243 290 … … 245 292 if (!ppSubFilesIterateUp(config, PPSUB_FILES_SUB)) { 246 293 psError(PPSUB_ERR_IO, false, "Unable to close subtraction files."); 247 return false; 294 success = false; 295 goto ESCAPE; 248 296 } 249 297 250 298 if (!ppSubFilesIterateDown(config, PPSUB_FILES_PHOT_INV)) { 251 299 psError(PPSUB_ERR_IO, false, "Unable to set up inverse files."); 252 return false; 300 success = false; 301 goto ESCAPE; 253 302 } 254 303 255 304 if (!data->quality && !ppSubReadoutPhotometry("PPSUB.INVERSE", data)) { 256 305 psError(psErrorCodeLast(), false, "Unable to perform photometry."); 257 return false; 306 success = false; 307 goto ESCAPE; 258 308 } 259 309 … … 261 311 if (!ppSubFilesIterateUp(config, PPSUB_FILES_INV | PPSUB_FILES_PHOT_INV)) { 262 312 psError(PPSUB_ERR_IO, false, "Unable to close subtraction files."); 263 return false; 313 success = false; 314 goto ESCAPE; 264 315 } 265 316 } else { … … 268 319 if (!ppSubFilesIterateUp(config, PPSUB_FILES_SUB)) { 269 320 psError(PPSUB_ERR_IO, false, "Unable to close subtraction files."); 270 return false; 271 } 272 } 273 321 success = false; 322 goto ESCAPE; 323 } 324 } 325 326 ESCAPE: 274 327 pmFPAfileDropInternal(config->files, "PSPHOT.BACKGND"); 275 328 pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL"); 276 329 pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL.STDEV"); 277 330 278 return true;331 return success; 279 332 }
Note:
See TracChangeset
for help on using the changeset viewer.
