Changeset 27004 for trunk/ppStack/src
- Timestamp:
- Feb 18, 2010, 6:42:01 PM (16 years ago)
- Location:
- trunk/ppStack/src
- Files:
-
- 3 added
- 21 edited
-
. (modified) (1 prop)
-
Makefile.am (modified) (2 diffs)
-
ppStack.c (modified) (3 diffs)
-
ppStack.h (modified) (1 diff)
-
ppStackArguments.c (modified) (7 diffs)
-
ppStackCamera.c (modified) (30 diffs)
-
ppStackCleanup.c (modified) (1 diff)
-
ppStackCombineFinal.c (modified) (3 diffs)
-
ppStackCombineInitial.c (modified) (3 diffs)
-
ppStackCombinePrepare.c (modified) (2 diffs)
-
ppStackConvolve.c (modified) (8 diffs)
-
ppStackErrorCodes.c.in (added)
-
ppStackErrorCodes.dat (added)
-
ppStackErrorCodes.h.in (added)
-
ppStackFiles.c (modified) (4 diffs)
-
ppStackLoop.c (modified) (13 diffs)
-
ppStackMatch.c (modified) (14 diffs)
-
ppStackPSF.c (modified) (3 diffs)
-
ppStackPhotometry.c (modified) (3 diffs)
-
ppStackPrepare.c (modified) (9 diffs)
-
ppStackReject.c (modified) (2 diffs)
-
ppStackSetup.c (modified) (5 diffs)
-
ppStackSources.c (modified) (8 diffs)
-
ppStackThread.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppStack/src
- Property svn:ignore
-
old new 10 10 stamp-h1 11 11 ppStackVersionDefinitions.h 12 ppStackErrorCodes.c 13 ppStackErrorCodes.h
-
- Property svn:ignore
-
trunk/ppStack/src/Makefile.am
r23808 r27004 47 47 ppStackCleanup.c \ 48 48 ppStackPhotometry.c \ 49 ppStackFinish.c 49 ppStackFinish.c \ 50 ppStackErrorCodes.c 50 51 51 52 noinst_HEADERS = \ … … 53 54 ppStackLoop.h \ 54 55 ppStackOptions.h \ 55 ppStackThread.h 56 ppStackThread.h \ 57 ppStackErrorCodes.h 58 59 ### Error codes. 60 BUILT_SOURCES = ppStackErrorCodes.h ppStackErrorCodes.c 61 CLEANFILES = ppStackErrorCodes.h ppStackErrorCodes.c 62 63 ppStackErrorCodes.h : ppStackErrorCodes.dat ppStackErrorCodes.h.in 64 $(ERRORCODES) --data=ppStackErrorCodes.dat --outdir=. ppStackErrorCodes.h 65 66 ppStackErrorCodes.c : ppStackErrorCodes.dat ppStackErrorCodes.c.in ppStackErrorCodes.h 67 $(ERRORCODES) --data=ppStackErrorCodes.dat --outdir=. ppStackErrorCodes.c 68 56 69 57 70 CLEANFILES = *~ -
trunk/ppStack/src/ppStack.c
r23341 r27004 15 15 int main(int argc, char *argv[]) 16 16 { 17 ps Exit exitValue = PS_EXIT_SUCCESS; // Exit value17 psLibInit(NULL); 18 18 psTimerStart(TIMER_NAME); 19 19 psTimerStart("PPSTACK_STEPS"); 20 psLibInit(NULL);21 20 22 21 pmConfig *config = pmConfigRead(&argc, argv, PPSTACK_RECIPE); // Configuration 23 22 if (!config) { 24 psErrorStackPrint(stderr, "Error reading configuration.");25 exitValue = PS_EXIT_CONFIG_ERROR;26 goto die;27 }28 29 (void) psTraceSetLevel("ppStack", 5);30 31 if (!ppStackArgumentsSetup(argc, argv, config)) {32 psErrorStackPrint(stderr, "Error reading arguments.\n");33 exitValue = PS_EXIT_CONFIG_ERROR;34 23 goto die; 35 24 } … … 38 27 39 28 if (!pmModelClassInit()) { 40 psErrorStackPrint(stderr, "Error initialising model classes.\n"); 41 exitValue = PS_EXIT_PROG_ERROR; 29 psError(PPSTACK_ERR_PROG, false, "Unable to initialise model classes."); 42 30 goto die; 43 31 } 44 32 45 33 if (!psphotInit()) { 46 psErrorStackPrint(stderr, "Error initialising psphot.\n"); 47 exitValue = PS_EXIT_PROG_ERROR; 34 psError(PPSTACK_ERR_PROG, false, "Error initialising psphot."); 35 goto die; 36 } 37 38 (void)psTraceSetLevel("ppStack", 5); 39 40 if (!ppStackArgumentsSetup(argc, argv, config)) { 48 41 goto die; 49 42 } 50 43 51 44 if (!ppStackCamera(config)) { 52 psErrorStackPrint(stderr, "Error setting up input files.\n");53 exitValue = PS_EXIT_CONFIG_ERROR;54 45 goto die; 55 46 } 56 47 57 48 if (!ppStackArgumentsParse(config)) { 58 psErrorStackPrint(stderr, "Error reading arguments.\n");59 exitValue = PS_EXIT_CONFIG_ERROR;60 49 goto die; 61 50 } 62 51 63 52 if (!ppStackLoop(config)) { 64 psErrorStackPrint(stderr, "Error performing combination.\n");65 exitValue = PS_EXIT_DATA_ERROR;66 53 goto die; 67 54 } … … 78 65 psLibFinalize(); 79 66 pmVisualClose(); 67 68 psExit exitValue = PS_EXIT_SUCCESS; // Exit value for program 69 psErrorCode errorCode = psErrorCodeLast(); // Error code 70 if (errorCode != PS_ERR_NONE) { 71 psErrorStackPrint(stderr, "Unable to perform stack."); 72 switch (errorCode) { 73 case PPSTACK_ERR_UNKNOWN: 74 case PS_ERR_UNKNOWN: 75 exitValue = PS_EXIT_UNKNOWN_ERROR; 76 break; 77 case PS_ERR_IO: 78 case PS_ERR_DB_CLIENT: 79 case PS_ERR_DB_SERVER: 80 case PS_ERR_BAD_FITS: 81 case PS_ERR_OS_CALL_FAILED: 82 case PPSTACK_ERR_IO: 83 exitValue = PS_EXIT_SYS_ERROR; 84 break; 85 case PS_ERR_BAD_PARAMETER_VALUE: 86 case PS_ERR_BAD_PARAMETER_TYPE: 87 case PS_ERR_BAD_PARAMETER_NULL: 88 case PS_ERR_BAD_PARAMETER_SIZE: 89 case PPSTACK_ERR_ARGUMENTS: 90 case PPSTACK_ERR_CONFIG: 91 exitValue = PS_EXIT_CONFIG_ERROR; 92 break; 93 case PPSTACK_ERR_PSF: 94 case PPSTACK_ERR_REJECTED: 95 case PPSTACK_ERR_DATA: 96 exitValue = PS_EXIT_DATA_ERROR; 97 break; 98 case PS_ERR_UNEXPECTED_NULL: 99 case PS_ERR_PROGRAMMING: 100 case PPSTACK_ERR_NOT_IMPLEMENTED: 101 case PPSTACK_ERR_PROG: 102 default: 103 // It's a programming error if we're not dealing with the error correctly 104 exitValue = PS_EXIT_PROG_ERROR; 105 break; 106 } 107 } 108 80 109 exit(exitValue); 81 110 } -
trunk/ppStack/src/ppStack.h
r26898 r27004 9 9 10 10 #include "ppStackOptions.h" 11 #include "ppStackErrorCodes.h" 11 12 12 13 // Mask values for inputs -
trunk/ppStack/src/ppStackArguments.c
r26078 r27004 43 43 value = psMetadataLookup##TYPE(&mdok, recipe, RECIPENAME); \ 44 44 if (!mdok) { \ 45 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "Unable to find %s in recipe %s", \45 psError(PPSTACK_ERR_CONFIG, true, "Unable to find %s in recipe %s", \ 46 46 RECIPENAME, PPSTACK_RECIPE); \ 47 47 goto ERROR; \ … … 58 58 value = psMetadataLookup##TYPE(&mdok, recipe, RECIPENAME); \ 59 59 if (!mdok) { \ 60 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "Unable to find %s in recipe %s", \60 psError(PPSTACK_ERR_CONFIG, true, "Unable to find %s in recipe %s", \ 61 61 RECIPENAME, PPSTACK_RECIPE); \ 62 62 goto ERROR; \ … … 73 73 name = psMetadataLookupStr(NULL, recipe, RECIPENAME); \ 74 74 if (!name) { \ 75 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "Unable to find %s in recipe %s", \76 RECIPENAME, PPSTACK_RECIPE);\75 psError(PPSTACK_ERR_CONFIG, true, "Unable to find %s in recipe %s", \ 76 RECIPENAME, PPSTACK_RECIPE); \ 77 77 goto ERROR; \ 78 78 } \ … … 108 108 value = psMetadataLookupStr(NULL, recipe, mdName); 109 109 if (!value) { 110 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "Unable to find %s in recipe %s",110 psError(PPSTACK_ERR_CONFIG, true, "Unable to find %s in recipe %s", 111 111 mdName, PPSTACK_RECIPE); 112 112 return false; … … 207 207 psMetadata *inputs = psMetadataConfigRead(NULL, &numBad, argv[argNum], false); // Input file info 208 208 if (!inputs || numBad > 0) { 209 psError(P S_ERR_BAD_PARAMETER_VALUE, false, "Unable to cleanly read MDC file with inputs.");209 psError(PPSTACK_ERR_ARGUMENTS, false, "Unable to cleanly read MDC file with inputs."); 210 210 return false; 211 211 } … … 229 229 int numThreads = psMetadataLookupS32(NULL, arguments, "-threads"); // Number of threads 230 230 if (numThreads > 0 && !psThreadPoolInit(numThreads)) { 231 psError(P S_ERR_UNKNOWN, false, "Unable to setup %d threads", numThreads);231 psError(PPSTACK_ERR_ARGUMENTS, false, "Unable to setup %d threads", numThreads); 232 232 return false; 233 233 } … … 247 247 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // Recipe 248 248 if (!recipe) { 249 psError(P S_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSTACK_RECIPE);249 psError(PPSTACK_ERR_CONFIG, false, "Unable to find recipe %s", PPSTACK_RECIPE); 250 250 goto ERROR; 251 251 } -
trunk/ppStack/src/ppStackCamera.c
r26898 r27004 30 30 pmFPAfileDefineFromArgs(&found, config, name, "FILENAMES"); 31 31 if (!file || !found) { 32 psError( PS_ERR_UNKNOWN, false, "Unable to define file %s from %s", name, filename);32 psError(psErrorCodeLast(), false, "Unable to define file %s from %s", name, filename); 33 33 return NULL; 34 34 } 35 35 if (file->type != type) { 36 psError(PS_ERR_IO, true, "%s is not of type %s", name, pmFPAfileStringFromType(type));36 psError(PS_ERR_IO, PPSTACK_ERR_CONFIG, "%s is not of type %s", name, pmFPAfileStringFromType(type)); 37 37 return NULL; 38 38 } … … 53 53 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // Recipe for ppSim 54 54 if (!recipe) { 55 psError(P S_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSTACK_RECIPE);55 psError(PPSTACK_ERR_CONFIG, false, "Unable to find recipe %s", PPSTACK_RECIPE); 56 56 return false; 57 57 } … … 67 67 "PPSTACK.INPUT.MASK"); // Input masks 68 68 if (!status) { 69 psError( PS_ERR_UNKNOWN, false, "Unable to define input masks from RUN metadata.");69 psError(psErrorCodeLast(), false, "Unable to define input masks from RUN metadata."); 70 70 psFree(runImages); 71 71 return false; … … 76 76 "PPSTACK.INPUT.VARIANCE"); // Input variances 77 77 if (!status) { 78 psError( PS_ERR_UNKNOWN, false, "Unable to define input variances from RUN metadata.");78 psError(psErrorCodeLast(), false, "Unable to define input variances from RUN metadata."); 79 79 psFree(runImages); 80 80 return false; … … 88 88 "PPSTACK.INPUT.SOURCES"); // Input sources 89 89 if (!status) { 90 psError( PS_ERR_UNKNOWN, false, "Unable to define input sources from RUN metadata.");90 psError(psErrorCodeLast(), false, "Unable to define input sources from RUN metadata."); 91 91 psFree(runImages); 92 92 return false; 93 93 } 94 94 if (!runSrc) { 95 psError(P S_ERR_UNEXPECTED_NULL, true, "Unable to define input sources from RUN metadata.");95 psError(PPSTACK_ERR_CONFIG, true, "Unable to define input sources from RUN metadata."); 96 96 psFree(runImages); 97 97 return false; … … 104 104 "PPSTACK.INPUT.PSF"); // Input PSFs 105 105 if (!status) { 106 psError( PS_ERR_UNKNOWN, false, "Unable to define input PSFs from RUN metadata.");106 psError(psErrorCodeLast(), false, "Unable to define input PSFs from RUN metadata."); 107 107 psFree(runImages); 108 108 return false; … … 118 118 "PPSTACK.CONV.KERNEL"); // Conv'n kernels 119 119 if (!status) { 120 psError(PS_ERR_UNKNOWN, false, "Unable to define convolution kernels from RUN metadata."); 120 psError(psErrorCodeLast(), false, 121 "Unable to define convolution kernels from RUN metadata."); 121 122 psFree(runImages); 122 123 return false; 123 124 } 124 125 if (!runKernel) { 125 psError(P S_ERR_UNEXPECTED_NULL, true,126 psError(PPSTACK_ERR_CONFIG, true, 126 127 "Unable to define convolution kernels from RUN metadata."); 127 128 psFree(runImages); … … 137 138 psMetadata *inputs = psMetadataLookupMetadata(NULL, config->arguments, "INPUTS"); // The inputs info 138 139 if (!inputs) { 139 psError(P S_ERR_UNEXPECTED_NULL, false, "Unable to find inputs.");140 psError(PPSTACK_ERR_ARGUMENTS, false, "Unable to find inputs."); 140 141 return false; 141 142 } … … 145 146 while ((item = psMetadataGetAndIncrement(iter))) { 146 147 if (item->type != PS_DATA_METADATA) { 147 psError(P S_ERR_BAD_PARAMETER_TYPE, true,148 psError(PPSTACK_ERR_ARGUMENTS, true, 148 149 "Component %s of the input metadata is not of type METADATA", item->name); 149 150 psFree(iter); … … 155 156 psString image = psMetadataLookupStr(NULL, input, "IMAGE"); // Name of image 156 157 if (!image || strlen(image) == 0) { 157 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "Component %s lacks IMAGE of type STR", item->name);158 psError(PPSTACK_ERR_ARGUMENTS, true, "Component %s lacks IMAGE of type STR", item->name); 158 159 psFree(iter); 159 160 return false; … … 169 170 image, PM_FPA_FILE_IMAGE); // File for image 170 171 if (!imageFile) { 171 psError( PS_ERR_UNKNOWN, false, "Unable to define file from image %d (%s)", i, image);172 psError(psErrorCodeLast(), false, "Unable to define file from image %d (%s)", i, image); 172 173 return false; 173 174 } … … 175 176 if (mask && strlen(mask) > 0 && 176 177 !defineFile(config, imageFile, "PPSTACK.INPUT.MASK", mask, PM_FPA_FILE_MASK)) { 177 psError( PS_ERR_UNKNOWN, false, "Unable to define file from mask %d (%s)", i, mask);178 psError(psErrorCodeLast(), false, "Unable to define file from mask %d (%s)", i, mask); 178 179 return false; 179 180 } … … 183 184 if (!defineFile(config, imageFile, "PPSTACK.INPUT.VARIANCE", variance, 184 185 PM_FPA_FILE_VARIANCE)) { 185 psError( PS_ERR_UNKNOWN, false,186 psError(psErrorCodeLast(), false, 186 187 "Unable to define file from variance %d (%s)", i, variance); 187 188 return false; … … 195 196 havePSFs = true; 196 197 if (!defineFile(config, imageFile, "PPSTACK.INPUT.PSF", psf, PM_FPA_FILE_PSF)) { 197 psError( PS_ERR_UNKNOWN, false, "Unable to define file from psf %d (%s)", i, psf);198 psError(psErrorCodeLast(), false, "Unable to define file from psf %d (%s)", i, psf); 198 199 return false; 199 200 } 200 201 } 201 202 } else if (havePSFs) { 202 psError(P S_ERR_UNEXPECTED_NULL, true, "Unable to find PSF %d", i);203 psError(PPSTACK_ERR_CONFIG, true, "Unable to find PSF %d", i); 203 204 return false; 204 205 } 205 206 206 207 if (!sources || strlen(sources) == 0) { 207 psError(P S_ERR_UNEXPECTED_NULL, true, "SOURCES not provided for file %d", i);208 psError(PPSTACK_ERR_CONFIG, true, "SOURCES not provided for file %d", i); 208 209 return false; 209 210 } 210 211 if (!defineFile(config, imageFile, "PPSTACK.INPUT.SOURCES", sources, PM_FPA_FILE_CMF)) { 211 psError( PS_ERR_UNKNOWN, false, "Unable to define file from sources %d (%s)",212 psError(psErrorCodeLast(), false, "Unable to define file from sources %d (%s)", 212 213 i, sources); 213 214 return false; … … 217 218 pmFPAfile *kernel = pmFPAfileDefineOutput(config, imageFile->fpa, "PPSTACK.CONV.KERNEL"); 218 219 if (!kernel) { 219 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.CONV.KERNEL")); 220 psError(psErrorCodeLast(), false, 221 "Unable to generate output file from PPSTACK.CONV.KERNEL"); 220 222 return false; 221 223 } … … 235 237 pmFPA *outFPA = pmFPAConstruct(config->camera, config->cameraName); // FPA to contain the output 236 238 if (!outFPA) { 237 psError( PS_ERR_UNEXPECTED_NULL, false, "Unable to construct an FPA from camera configuration.");239 psError(psErrorCodeLast(), false, "Unable to construct an FPA from camera configuration."); 238 240 return false; 239 241 } … … 241 243 psFree(outFPA); // Drop reference 242 244 if (!output) { 243 psError( PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.OUTPUT"));245 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT")); 244 246 return false; 245 247 } 246 248 if (output->type != PM_FPA_FILE_IMAGE) { 247 psError(P S_ERR_IO, true, "PPSTACK.OUTPUT is not of type IMAGE");249 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT is not of type IMAGE"); 248 250 return false; 249 251 } … … 251 253 252 254 if (!pmFPAAddSourceFromFormat(outFPA, "Stack", output->format)) { 253 psError( PS_ERR_UNKNOWN, false, "Unable to generate output FPA.");255 psError(psErrorCodeLast(), false, "Unable to generate output FPA."); 254 256 return false; 255 257 } … … 258 260 pmFPAfile *outMask = pmFPAfileDefineOutput(config, output->fpa, "PPSTACK.OUTPUT.MASK"); 259 261 if (!outMask) { 260 psError( PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.OUTPUT.MASK"));262 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT.MASK")); 261 263 return false; 262 264 } 263 265 if (outMask->type != PM_FPA_FILE_MASK) { 264 psError(P S_ERR_IO, true, "PPSTACK.OUTPUT.MASK is not of type MASK");266 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.MASK is not of type MASK"); 265 267 return false; 266 268 } … … 271 273 pmFPAfile *outVariance = pmFPAfileDefineOutput(config, output->fpa, "PPSTACK.OUTPUT.VARIANCE"); 272 274 if (!outVariance) { 273 psError( PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.OUTPUT.VARIANCE"));275 psError(psErrorCodeLast(), false, "Unable to generate output file from PPSTACK.OUTPUT.VARIANCE"); 274 276 return false; 275 277 } 276 278 if (outVariance->type != PM_FPA_FILE_VARIANCE) { 277 psError(P S_ERR_IO, true, "PPSTACK.OUTPUT.VARIANCE is not of type VARIANCE");279 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.VARIANCE is not of type VARIANCE"); 278 280 return false; 279 281 } … … 284 286 pmFPAfile *targetPSF = pmFPAfileDefineOutput(config, output->fpa, "PPSTACK.TARGET.PSF"); 285 287 if (!targetPSF) { 286 psError( PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.TARGET.PSF"));288 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.TARGET.PSF")); 287 289 return false; 288 290 } 289 291 if (targetPSF->type != PM_FPA_FILE_PSF) { 290 psError(P S_ERR_IO, true, "PPSTACK.TARGET.PSF is not of type PSF");292 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.TARGET.PSF is not of type PSF"); 291 293 return false; 292 294 } … … 298 300 pmFPA *unconvFPA = pmFPAConstruct(config->camera, config->cameraName); // FPA to contain unconvolved output 299 301 if (!unconvFPA) { 300 psError( PS_ERR_UNEXPECTED_NULL, false, "Unable to construct an FPA from camera configuration.");302 psError(psErrorCodeLast(), false, "Unable to construct an FPA from camera configuration."); 301 303 return false; 302 304 } … … 304 306 psFree(unconvFPA); // Drop reference 305 307 if (!unConv) { 306 psError( PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.UNCONV"));308 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.UNCONV")); 307 309 return false; 308 310 } 309 311 if (unConv->type != PM_FPA_FILE_IMAGE) { 310 psError(P S_ERR_IO, true, "PPSTACK.UNCONV is not of type IMAGE");312 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.UNCONV is not of type IMAGE"); 311 313 return false; 312 314 } … … 314 316 315 317 if (!pmFPAAddSourceFromFormat(unconvFPA, "Stack", unConv->format)) { 316 psError( PS_ERR_UNKNOWN, false, "Unable to generate output FPA.");318 psError(psErrorCodeLast(), false, "Unable to generate output FPA."); 317 319 return false; 318 320 } … … 321 323 pmFPAfile *unconvMask = pmFPAfileDefineOutput(config, unconvFPA, "PPSTACK.UNCONV.MASK"); 322 324 if (!unconvMask) { 323 psError( PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.UNCONV.MASK"));325 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.UNCONV.MASK")); 324 326 return false; 325 327 } 326 328 if (unconvMask->type != PM_FPA_FILE_MASK) { 327 psError(P S_ERR_IO, true, "PPSTACK.UNCONV.MASK is not of type MASK");329 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.UNCONV.MASK is not of type MASK"); 328 330 return false; 329 331 } … … 334 336 pmFPAfile *unconvVariance = pmFPAfileDefineOutput(config, unconvFPA, "PPSTACK.UNCONV.VARIANCE"); 335 337 if (!unconvVariance) { 336 psError( PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.UNCONV.VARIANCE"));338 psError(psErrorCodeLast(), false, "Unable to generate output file from PPSTACK.UNCONV.VARIANCE"); 337 339 return false; 338 340 } 339 341 if (unconvVariance->type != PM_FPA_FILE_VARIANCE) { 340 psError(P S_ERR_IO, true, "PPSTACK.UNCONV.VARIANCE is not of type VARIANCE");342 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.UNCONV.VARIANCE is not of type VARIANCE"); 341 343 return false; 342 344 } … … 348 350 pmFPAfile *jpeg1 = pmFPAfileDefineOutput(config, NULL, "PPSTACK.OUTPUT.JPEG1"); 349 351 if (!jpeg1) { 350 psError( PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.OUTPUT.JPEG1"));352 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT.JPEG1")); 351 353 return false; 352 354 } 353 355 if (jpeg1->type != PM_FPA_FILE_JPEG) { 354 psError(P S_ERR_IO, true, "PPSTACK.OUTPUT.JPEG1 is not of type JPEG");356 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.JPEG1 is not of type JPEG"); 355 357 return false; 356 358 } … … 358 360 pmFPAfile *jpeg2 = pmFPAfileDefineOutput(config, NULL, "PPSTACK.OUTPUT.JPEG2"); 359 361 if (!jpeg2) { 360 psError( PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.OUTPUT.JPEG2"));362 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT.JPEG2")); 361 363 return false; 362 364 } 363 365 if (jpeg2->type != PM_FPA_FILE_JPEG) { 364 psError(P S_ERR_IO, true, "PPSTACK.OUTPUT.JPEG2 is not of type JPEG");366 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.JPEG2 is not of type JPEG"); 365 367 return false; 366 368 } … … 377 379 pmFPAfile *psphotInput = pmFPAfileDefineFromFPA(config, output->fpa, 1, 1, "PSPHOT.INPUT"); 378 380 if (!psphotInput) { 379 psError( PS_ERR_IO, false, _("Unable to generate output file from PSPHOT.INPUT"));380 return false; 381 } 382 // specify the number of psphot input images383 psMetadataAddS32 (config->arguments, PS_LIST_TAIL, "PSPHOT.INPUT.NUM", PS_META_REPLACE, "number of inputs", 1);381 psError(psErrorCodeLast(), false, _("Unable to generate output file from PSPHOT.INPUT")); 382 return false; 383 } 384 // specify the number of psphot input images 385 psMetadataAddS32 (config->arguments, PS_LIST_TAIL, "PSPHOT.INPUT.NUM", PS_META_REPLACE, "number of inputs", 1); 384 386 385 387 // Define associated psphot input/output files 386 388 if (!psphotDefineFiles(config, psphotInput)) { 387 psError( PSPHOT_ERR_CONFIG, false,389 psError(psErrorCodeLast(), false, 388 390 "Trouble defining the additional input/output files for psphot"); 389 391 return false; … … 393 395 pmFPAfile *outPSF = pmFPAfileDefineOutputFromFile(config, output, "PSPHOT.PSF.SAVE"); 394 396 if (!outPSF) { 395 psError( PS_ERR_IO, false, _("Unable to generate output file from PSPHOT.PSF.SAVE"));397 psError(psErrorCodeLast(), false, _("Unable to generate output file from PSPHOT.PSF.SAVE")); 396 398 return false; 397 399 } 398 400 if (outPSF->type != PM_FPA_FILE_PSF) { 399 psError(P S_ERR_IO, true, "PSPHOT.PSF.SAVE is not of type PSF");401 psError(PPSTACK_ERR_CONFIG, true, "PSPHOT.PSF.SAVE is not of type PSF"); 400 402 return false; 401 403 } -
trunk/ppStack/src/ppStackCleanup.c
r26184 r27004 50 50 if (!pmReadoutRebin(ro1, options->outRO, maskValue, bin1, bin1) || 51 51 !pmReadoutRebin(ro2, ro1, 0, bin2, bin2)) { 52 psError(P S_ERR_UNKNOWN, false, "Unable to bin output.");52 psError(PPSTACK_ERR_DATA, false, "Unable to bin output."); 53 53 psFree(ro1); 54 54 psFree(ro2); -
trunk/ppStack/src/ppStackCombineFinal.c
r26184 r27004 31 31 if (!status) { 32 32 // Something went wrong 33 psError( PS_ERR_UNKNOWN, false, "Unable to read chunk %d", numChunk);33 psError(psErrorCodeLast(), false, "Unable to read chunk %d", numChunk); 34 34 return false; 35 35 } … … 55 55 56 56 if (!psThreadPoolWait(true)) { 57 psError( PS_ERR_UNKNOWN, false, "Unable to do final combination.");57 psError(psErrorCodeLast(), false, "Unable to do final combination."); 58 58 return false; 59 59 } … … 126 126 pmHDU *hdu = pmHDUFromCell(target->parent); 127 127 if (!hdu) { 128 psError(P S_ERR_UNKNOWN, false, "Unable to find HDU for output.");128 psError(PPSTACK_ERR_PROG, false, "Unable to find HDU for output."); 129 129 return false; 130 130 } -
trunk/ppStack/src/ppStackCombineInitial.c
r26454 r27004 20 20 if (!options->convolve) { 21 21 // No need to do initial combination when we haven't convolved 22 // XXX either allocate inspect and rejected here, or do not require them downstream22 // XXX either allocate inspect and rejected here, or do not require them downstream 23 23 return true; 24 24 } … … 37 37 if (!status) { 38 38 // Something went wrong 39 psError( PS_ERR_UNKNOWN, false, "Unable to read chunk %d", numChunk);39 psError(psErrorCodeLast(), false, "Unable to read chunk %d", numChunk); 40 40 return false; 41 41 } … … 57 57 58 58 if (!psThreadPoolWait(false)) { 59 psError( PS_ERR_UNKNOWN, false, "Unable to do initial combination.");59 psError(psErrorCodeLast(), false, "Unable to do initial combination."); 60 60 return false; 61 61 } -
trunk/ppStack/src/ppStackCombinePrepare.c
r26076 r27004 20 20 ppStackThread *thread = stack->threads->data[0]; // Representative thread 21 21 if (!pmReadoutStackSetOutputSize(&col0, &row0, &numCols, &numRows, thread->readouts)) { 22 psError(P S_ERR_UNKNOWN, false, "problem setting output readout size.");22 psError(PPSTACK_ERR_ARGUMENTS, false, "problem setting output readout size."); 23 23 return false; 24 24 } … … 45 45 46 46 if (!pmReadoutStackDefineOutput(options->outRO, col0, row0, numCols, numRows, true, true, maskBad)) { 47 psError(P S_ERR_UNKNOWN, false, "Unable to prepare output.");47 psError(PPSTACK_ERR_ARGUMENTS, false, "Unable to prepare output."); 48 48 return false; 49 49 } -
trunk/ppStack/src/ppStackConvolve.c
r26898 r27004 82 82 } else if (options->numCols != readout->image->numCols || 83 83 options->numRows != readout->image->numRows) { 84 psError(P S_ERR_UNKNOWN, true, "Sizes of input images don't match: %dx%d vs %dx%d",84 psError(PPSTACK_ERR_ARGUMENTS, true, "Sizes of input images don't match: %dx%d vs %dx%d", 85 85 readout->image->numCols, readout->image->numRows, options->numCols, options->numRows); 86 86 psFree(rng); … … 94 94 options->origCovars->data[i] = psMemIncrRefCounter(readout->covariance); 95 95 if (!ppStackMatch(readout, options, i, config)) { 96 // XXX many things can cause a failure of ppStackMatch -- should some be handled differently? 97 psErrorStackPrint(stderr, "Unable to match image %d --- ignoring.", i); 98 options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= PPSTACK_MASK_MATCH; 99 psErrorClear(); 100 continue; 96 // XXX many things can cause a failure of ppStackMatch -- should some be handled differently? 97 psErrorCode error = psErrorCodeLast(); // Error code 98 switch (error) { 99 // Fatal errors 100 case PM_ERR_CONFIG: 101 case PPSTACK_ERR_CONFIG: 102 case PPSTACK_ERR_IO: 103 psError(error, false, "Unable to match image %d due to fatal error.", i); 104 return false; 105 // Non-fatal errors 106 case PM_ERR_STAMPS: 107 case PM_ERR_SMALL_AREA: 108 case PPSTACK_ERR_DATA: 109 default: 110 psErrorStackPrint(stderr, "Unable to match image %d --- ignoring.", i); 111 options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= PPSTACK_MASK_MATCH; 112 psErrorClear(); 113 continue; 114 } 101 115 } 102 116 options->convCovars->data[i] = psMemIncrRefCounter(readout->covariance); … … 136 150 assert(hdu); 137 151 if (!ppStackWriteImage(options->convImages->data[i], hdu->header, readout->image, config)) { 138 psError(P S_ERR_IO, false, "Unable to write convolved image %d", i);152 psError(PPSTACK_ERR_IO, false, "Unable to write convolved image %d", i); 139 153 psFree(fpaList); 140 154 psFree(cellList); … … 145 159 pmConfigMaskWriteHeader(config, maskHeader); 146 160 if (!ppStackWriteImage(options->convMasks->data[i], maskHeader, readout->mask, config)) { 147 psError(P S_ERR_IO, false, "Unable to write convolved mask %d", i);161 psError(PPSTACK_ERR_IO, false, "Unable to write convolved mask %d", i); 148 162 psFree(fpaList); 149 163 psFree(cellList); … … 154 168 psFree(maskHeader); 155 169 if (!ppStackWriteImage(options->convVariances->data[i], hdu->header, readout->variance, config)) { 156 psError(P S_ERR_IO, false, "Unable to write convolved variance %d", i);170 psError(PPSTACK_ERR_IO, false, "Unable to write convolved variance %d", i); 157 171 psFree(fpaList); 158 172 psFree(cellList); … … 208 222 209 223 if (numGood == 0) { 210 psError(P S_ERR_UNKNOWN, false, "No good images to combine.");224 psError(PPSTACK_ERR_REJECTED, false, "No good images to combine."); 211 225 psFree(fpaList); 212 226 psFree(cellList); … … 257 271 assert(values->n == numGood); 258 272 if (!psVectorSortInPlace(values)) { 259 psError(P S_ERR_UNKNOWN, false, "Unable to sort vector.");273 psError(PPSTACK_ERR_PROG, false, "Unable to sort vector."); 260 274 psFree(values); 261 275 return false; … … 295 309 296 310 if (numGood == 0) { 297 psError(P S_ERR_UNKNOWN, false, "No good images to combine.");311 psError(PPSTACK_ERR_REJECTED, false, "No good images to combine."); 298 312 return false; 299 313 } -
trunk/ppStack/src/ppStackFiles.c
r26454 r27004 115 115 pmFPAview *view = pmFPAviewAlloc(0);// Pointer into FPA hierarchy 116 116 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 117 psError(PPSTACK_ERR_IO, false, "File checks failed."); 117 118 return NULL; 118 119 } 119 120 view->chip = 0; 120 121 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 122 psError(PPSTACK_ERR_IO, false, "File checks failed."); 121 123 return NULL; 122 124 } 123 125 view->cell = 0; 124 126 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 127 psError(PPSTACK_ERR_IO, false, "File checks failed."); 125 128 return NULL; 126 129 } 127 130 view->readout = 0; 128 131 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 132 psError(PPSTACK_ERR_IO, false, "File checks failed."); 129 133 return NULL; 130 134 } … … 141 145 view->chip = view->cell = view->readout = 0; 142 146 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 147 psError(PPSTACK_ERR_IO, false, "File checks failed."); 143 148 return false; 144 149 } 145 150 view->readout = -1; 146 151 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 152 psError(PPSTACK_ERR_IO, false, "File checks failed."); 147 153 return false; 148 154 } 149 155 view->cell = -1; 150 156 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 157 psError(PPSTACK_ERR_IO, false, "File checks failed."); 151 158 return false; 152 159 } 153 160 view->chip = -1; 154 161 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 162 psError(PPSTACK_ERR_IO, false, "File checks failed."); 155 163 return false; 156 164 } … … 172 180 psFits *fits = psFitsOpen(resolved, "w"); 173 181 if (!fits) { 174 psError(P S_ERR_IO, false, "Unable to open FITS file %s to write image.", resolved);182 psError(PPSTACK_ERR_IO, false, "Unable to open FITS file %s to write image.", resolved); 175 183 psFree(resolved); 176 184 return false; 177 185 } 178 186 if (!psFitsWriteImage(fits, header, image, 0, NULL)) { 179 psError(P S_ERR_IO, false, "Unable to write FITS image %s.", resolved);187 psError(PPSTACK_ERR_IO, false, "Unable to write FITS image %s.", resolved); 180 188 psFitsClose(fits); 181 189 psFree(resolved); … … 183 191 } 184 192 if (!psFitsClose(fits)) { 185 psError(P S_ERR_IO, false, "Unable to close FITS image %s.", resolved);193 psError(PPSTACK_ERR_IO, false, "Unable to close FITS image %s.", resolved); 186 194 psFree(resolved); 187 195 return false; -
trunk/ppStack/src/ppStackLoop.c
r26117 r27004 22 22 psTrace("ppStack", 1, "Setup....\n"); 23 23 if (!ppStackSetup(options, config)) { 24 psError( PS_ERR_UNKNOWN, false, "Unable to setup.");24 psError(psErrorCodeLast(), false, "Unable to setup."); 25 25 psFree(options); 26 26 return false; … … 33 33 psTrace("ppStack", 1, "Preparation for stacking: merging sources, determining target PSF....\n"); 34 34 if (!ppStackPrepare(options, config)) { 35 psError( PS_ERR_UNKNOWN, false, "Unable to prepare for stacking.");35 psError(psErrorCodeLast(), false, "Unable to prepare for stacking."); 36 36 psFree(options); 37 37 return false; … … 45 45 psTrace("ppStack", 1, "Convolving inputs to target PSF....\n"); 46 46 if (!ppStackConvolve(options, config)) { 47 psError( PS_ERR_UNKNOWN, false, "Unable to convolve images.");47 psError(psErrorCodeLast(), false, "Unable to convolve images."); 48 48 psFree(options); 49 49 return false; … … 58 58 ppStackThreadData *stack = ppStackThreadDataSetup(options, config, true); 59 59 if (!stack) { 60 psError( PS_ERR_IO, false, "Unable to initialise stack threads.");60 psError(psErrorCodeLast(), false, "Unable to initialise stack threads."); 61 61 psFree(options); 62 62 return false; … … 65 65 // Prepare for combination 66 66 if (!ppStackCombinePrepare(stack, options, config)) { 67 psError( PS_ERR_UNKNOWN, false, "Unable to prepare for combination.");67 psError(psErrorCodeLast(), false, "Unable to prepare for combination."); 68 68 psFree(stack); 69 69 psFree(options); … … 74 74 psTrace("ppStack", 1, "Initial stack of convolved images....\n"); 75 75 if (!ppStackCombineInitial(stack, options, config)) { 76 psError( PS_ERR_UNKNOWN, false, "Unable to perform initial combination.");76 psError(psErrorCodeLast(), false, "Unable to perform initial combination."); 77 77 psFree(stack); 78 78 psFree(options); … … 86 86 psTrace("ppStack", 1, "Reject pixels....\n"); 87 87 if (!ppStackReject(options, config)) { 88 psError( PS_ERR_UNKNOWN, false, "Unable to reject pixels.");88 psError(psErrorCodeLast(), false, "Unable to reject pixels."); 89 89 psFree(stack); 90 90 psFree(options); … … 98 98 psTrace("ppStack", 2, "Final stack of convolved images....\n"); 99 99 if (!ppStackCombineFinal(options->outRO, stack, options->convCovars, options, config, false, false)) { 100 psError( PS_ERR_UNKNOWN, false, "Unable to perform final combination.");100 psError(psErrorCodeLast(), false, "Unable to perform final combination."); 101 101 psFree(stack); 102 102 psFree(options); … … 109 109 psTrace("ppStack", 2, "Cleaning up after combination....\n"); 110 110 if (!ppStackCleanup(stack, options, config)) { 111 psError( PS_ERR_UNKNOWN, false, "Unable to clean up.");111 psError(psErrorCodeLast(), false, "Unable to clean up."); 112 112 psFree(stack); 113 113 psFree(options); … … 125 125 ppStackThreadData *stack = ppStackThreadDataSetup(options, config, false); 126 126 if (!stack) { 127 psError( PS_ERR_IO, false, "Unable to initialise stack threads.");127 psError(psErrorCodeLast(), false, "Unable to initialise stack threads."); 128 128 psFree(options); 129 129 return false; … … 131 131 psTrace("ppStack", 2, "Stack of unconvolved images....\n"); 132 132 if (!ppStackCombineFinal(options->unconvRO, stack, options->origCovars, options, config, false, true)) { 133 psError( PS_ERR_UNKNOWN, false, "Unable to perform unconvolved combination.");133 psError(psErrorCodeLast(), false, "Unable to perform unconvolved combination."); 134 134 psFree(stack); 135 135 psFree(options); … … 147 147 psTrace("ppStack", 1, "Photometering stacked image....\n"); 148 148 if (!ppStackPhotometry(options, config)) { 149 psError( PS_ERR_UNKNOWN, false, "Unable to perform photometry.");149 psError(psErrorCodeLast(), false, "Unable to perform photometry."); 150 150 psFree(options); 151 151 return false; … … 157 157 psTrace("ppStack", 1, "Finishing up....\n"); 158 158 if (!ppStackFinish(options, config)) { 159 psError( PS_ERR_UNKNOWN, false, "Unable to finish up.");159 psError(psErrorCodeLast(), false, "Unable to finish up."); 160 160 psFree(options); 161 161 return false; -
trunk/ppStack/src/ppStackMatch.c
r26898 r27004 31 31 psFree(resolved); 32 32 if (!fits) { 33 psError(P S_ERR_IO, false, "Unable to open previously produced image: %s", name);33 psError(PPSTACK_ERR_IO, false, "Unable to open previously produced image: %s", name); 34 34 return false; 35 35 } 36 36 psImage *image = psFitsReadImage(fits, psRegionSet(0,0,0,0), 0); // Image of interest 37 37 if (!image) { 38 psError(P S_ERR_IO, false, "Unable to read previously produced image: %s", name);38 psError(PPSTACK_ERR_IO, false, "Unable to read previously produced image: %s", name); 39 39 psFitsClose(fits); 40 40 return false; … … 150 150 psImage *unbinned = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Unbinned background model 151 151 if (!psImageUnbin(unbinned, binned, binning)) { 152 psError(P S_ERR_UNKNOWN, false, "Unable to unbin background model");152 psError(PPSTACK_ERR_DATA, false, "Unable to unbin background model"); 153 153 psFree(unbinned); 154 154 return NULL; … … 177 177 int num = psMetadataLookupS32(&mdok, recipe, "RENORM.NUM"); 178 178 if (!mdok) { 179 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "RENORM.NUM is not set in the recipe");179 psError(PPSTACK_ERR_CONFIG, true, "RENORM.NUM is not set in the recipe"); 180 180 return false; 181 181 } 182 182 float minValid = psMetadataLookupF32(&mdok, recipe, "RENORM.MIN"); 183 183 if (!mdok) { 184 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "RENORM.MIN is not set in the recipe");184 psError(PPSTACK_ERR_CONFIG, true, "RENORM.MIN is not set in the recipe"); 185 185 return false; 186 186 } 187 187 float maxValid = psMetadataLookupF32(&mdok, recipe, "RENORM.MAX"); 188 188 if (!mdok) { 189 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "RENORM.MAX is not set in the recipe");189 psError(PPSTACK_ERR_CONFIG, true, "RENORM.MAX is not set in the recipe"); 190 190 return false; 191 191 } … … 229 229 230 230 if (!pmReadoutMaskNonfinite(readout, maskVal)) { 231 psError( PS_ERR_UNKNOWN, false, "Unable to mask non-finite pixels in readout.");231 psError(psErrorCodeLast(), false, "Unable to mask non-finite pixels in readout."); 232 232 return false; 233 233 } … … 256 256 psFree(resolved); 257 257 if (!fits || !pmReadoutReadSubtractionKernels(conv, fits)) { 258 psError(P S_ERR_IO, false, "Unable to read previously produced kernel");258 psError(PPSTACK_ERR_IO, false, "Unable to read previously produced kernel"); 259 259 psFitsClose(fits); 260 260 return false; … … 265 265 !readImage(&readout->mask, options->convMasks->data[index], config) || 266 266 !readImage(&readout->variance, options->convVariances->data[index], config)) { 267 psError(P S_ERR_IO, false, "Unable to read previously produced image.");267 psError(PPSTACK_ERR_IO, false, "Unable to read previously produced image."); 268 268 return false; 269 269 } … … 326 326 float scaleMax = psMetadataLookupF32(NULL, ppsub, "SCALE.MAX"); // Maximum for scaling 327 327 if (!isfinite(scaleRef) || !isfinite(scaleMin) || !isfinite(scaleMax)) { 328 psError(P S_ERR_BAD_PARAMETER_VALUE, false,328 psError(PPSTACK_ERR_CONFIG, false, 329 329 "Scale parameters (SCALE.REF=%f, SCALE.MIN=%f, SCALE.MAX=%f) not set in PPSUB recipe.", 330 330 scaleRef, scaleMin, scaleMax); … … 346 346 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 347 347 if (!psImageBackground(bg, NULL, readout->image, readout->mask, maskVal | maskBad, rng)) { 348 psError(P S_ERR_UNKNOWN, false, "Can't measure background for image.");348 psError(PPSTACK_ERR_DATA, false, "Can't measure background for image."); 349 349 psFree(fake); 350 350 psFree(optWidths); … … 366 366 stampSources, SOURCE_MASK, NULL, NULL, options->psf, 367 367 minFlux, footprint + size, false, true)) { 368 psError(P S_ERR_UNKNOWN, false, "Unable to generate fake image with target PSF.");368 psError(PPSTACK_ERR_DATA, false, "Unable to generate fake image with target PSF."); 369 369 psFree(fake); 370 370 psFree(optWidths); … … 417 417 stride, kernelError, covarFrac, maskVal, maskBad, maskPoor, 418 418 poorFrac, badFrac)) { 419 psError( PS_ERR_UNKNOWN, false, "Unable to convolve images.");419 psError(psErrorCodeLast(), false, "Unable to convolve images."); 420 420 psFree(fake); 421 421 psFree(optWidths); … … 433 433 options->inputSeeing->data.F32[index], 434 434 options->targetSeeing, scaleRef, scaleMin, scaleMax)) { 435 psError( PS_ERR_UNKNOWN, false, "Unable to scale kernel parameters");435 psError(psErrorCodeLast(), false, "Unable to scale kernel parameters"); 436 436 psFree(fake); 437 437 psFree(optWidths); … … 451 451 sysError, skyErr, kernelError, covarFrac, maskVal, maskBad, maskPoor, 452 452 poorFrac, badFrac, PM_SUBTRACTION_MODE_2)) { 453 psError( PS_ERR_UNKNOWN, false, "Unable to match images.");453 psError(psErrorCodeLast(), false, "Unable to match images."); 454 454 psFree(fake); 455 455 psFree(optWidths); … … 464 464 psFree(widthsCopy); 465 465 } 466 466 467 467 468 #ifdef TESTING … … 628 629 // Measure the variance level for the weighting 629 630 if (!psImageBackground(bg, NULL, readout->variance, readout->mask, maskVal | maskBad, rng)) { 630 psError(P S_ERR_UNKNOWN, false, "Can't measure mean variance for image.");631 psError(PPSTACK_ERR_DATA, false, "Can't measure mean variance for image."); 631 632 psFree(rng); 632 633 psFree(bg); -
trunk/ppStack/src/ppStackPSF.c
r26898 r27004 28 28 psString maskValStr = psMetadataLookupStr(&mdok, recipe, "MASK.VAL"); // Name of bits to mask going in 29 29 if (!mdok || !maskValStr) { 30 psError(P S_ERR_UNKNOWN, false, "Unable to find MASK.VAL in recipe");30 psError(PPSTACK_ERR_CONFIG, false, "Unable to find MASK.VAL in recipe"); 31 31 return false; 32 32 } … … 43 43 pmPSF *psf = pmPSFEnvelope(numCols, numRows, psfs, psfInstances, psfRadius, psfModel, psfOrder, psfOrder, maskVal); 44 44 if (!psf) { 45 psError(P S_ERR_UNKNOWN, false, "Unable to determine output PSF.");45 psError(PPSTACK_ERR_PSF, false, "Unable to determine output PSF."); 46 46 return NULL; 47 47 } … … 50 50 pmPSF *psf = pmPSFBuildSimple("PS_MODEL_PS1_V1", 4.0, 4.0, 0.0, 1.0); 51 51 if (!psf) { 52 psError(P S_ERR_UNKNOWN, false, "Unable to build dummy PSF.");52 psError(PPSTACK_ERR_PSF, false, "Unable to build dummy PSF."); 53 53 return NULL; 54 54 } -
trunk/ppStack/src/ppStackPhotometry.c
r26928 r27004 61 61 psArray *inSources = options->sources; 62 62 if (!inSources) { 63 psError(P S_ERR_UNKNOWN, false, "Unable to find input sources");63 psError(PPSTACK_ERR_PROG, false, "Unable to find input sources"); 64 64 psFree(photView); 65 65 return false; … … 83 83 !pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL.STDEV") || 84 84 !pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND")) { 85 psError(P S_ERR_UNKNOWN, false, "Unable to drop PSPHOT internal files.");85 psError(PPSTACK_ERR_PROG, false, "Unable to drop PSPHOT internal files."); 86 86 return false; 87 87 } … … 92 92 pmReadout *photRO = pmFPAviewThisReadout(photView, photFile->fpa); // Readout with the sources 93 93 pmDetections *detections = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.DETECTIONS"); // detections 94 if (detections) { 95 psAssert (detections->allSources, "missing sources?"); 94 if (detections && detections->allSources) { 96 95 psMetadataAddS32(options->stats, PS_LIST_TAIL, "NUM_SOURCES", 0, "Number of sources detected", detections->allSources->n); 97 96 } else { -
trunk/ppStack/src/ppStackPrepare.c
r26918 r27004 26 26 float zpRadius = psMetadataLookupS32(&mdok, recipe, "PHOT.RADIUS"); // Radius for PHOT measurement 27 27 if (!mdok) { 28 psError(P S_ERR_UNKNOWN, true, "Unable to find PHOT.RADIUS in recipe");28 psError(PPSTACK_ERR_CONFIG, true, "Unable to find PHOT.RADIUS in recipe"); 29 29 return false; 30 30 } 31 31 float zpSigma = psMetadataLookupF32(&mdok, recipe, "PHOT.SIGMA"); // Gaussian sigma for photometry 32 32 if (!mdok) { 33 psError(P S_ERR_UNKNOWN, true, "Unable to find PHOT.SIGMA in recipe");33 psError(PPSTACK_ERR_CONFIG, true, "Unable to find PHOT.SIGMA in recipe"); 34 34 return false; 35 35 } 36 36 float zpFrac = psMetadataLookupF32(&mdok, recipe, "PHOT.FRAC"); // Fraction of good pixels for photometry 37 37 if (!mdok) { 38 psError(P S_ERR_UNKNOWN, true, "Unable to find PHOT.FRAC in recipe");38 psError(PPSTACK_ERR_CONFIG, true, "Unable to find PHOT.FRAC in recipe"); 39 39 return false; 40 40 } … … 42 42 psString maskValStr = psMetadataLookupStr(&mdok, recipe, "MASK.VAL"); // Name of bits to mask going in 43 43 if (!mdok || !maskValStr) { 44 psError(P S_ERR_UNKNOWN, false, "Unable to find MASK.VAL in recipe");44 psError(PPSTACK_ERR_CONFIG, false, "Unable to find MASK.VAL in recipe"); 45 45 return false; 46 46 } … … 53 53 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); // Statistics 54 54 if (!psImageBackground(stats, NULL, image, mask, maskVal, rng)) { 55 psError(P S_ERR_UNKNOWN, false, "Unable to measure background for image");55 psError(PPSTACK_ERR_DATA, false, "Unable to measure background for image"); 56 56 psFree(stats); 57 57 psFree(rng); … … 148 148 pmPSF *psf = psMetadataLookupPtr(NULL, chip->analysis, "PSPHOT.PSF"); // PSF 149 149 if (!psf) { 150 psError(P S_ERR_UNKNOWN, false, "Unable to find PSF.");150 psError(PPSTACK_ERR_PROG, false, "Unable to find PSF."); 151 151 psFree(view); 152 152 psFree(fileIter); … … 163 163 int naxis2 = psMetadataLookupS32(NULL, hdu->header, "NAXIS2"); // Number of rows 164 164 if (naxis1 <= 0 || naxis2 <= 0) { 165 psError(P S_ERR_UNKNOWN, false, "Unable to determine size of image from PSF.");165 psError(PPSTACK_ERR_PROG, false, "Unable to determine size of image from PSF."); 166 166 psFree(view); 167 167 psFree(fileIter); … … 183 183 detections = psMetadataLookupPtr(NULL, ro->analysis, "PSPHOT.DETECTIONS"); // Sources 184 184 if (!detections) { 185 psError(P S_ERR_UNEXPECTED_NULL, false, "Unable to find source detections in readout.");185 psError(PPSTACK_ERR_PROG, false, "Unable to find source detections in readout."); 186 186 return NULL; 187 187 } … … 209 209 210 210 if (!ppStackInputPhotometer(ro, detections->allSources, config)) { 211 psError( PS_ERR_UNKNOWN, false, "Unable to do photometry on input sources");211 psError(psErrorCodeLast(), false, "Unable to do photometry on input sources"); 212 212 psFree(view); 213 213 psFree(photView); … … 273 273 psFree(psfs); 274 274 if (!options->psf) { 275 psError( PS_ERR_UNKNOWN, false, "Unable to determine output PSF.");275 psError(psErrorCodeLast(), false, "Unable to determine output PSF."); 276 276 psFree(view); 277 277 return false; … … 290 290 // Zero point calibration 291 291 if (!ppStackSourcesTransparency(options, view, config)) { 292 psError(P S_ERR_UNKNOWN, false, "Unable to calculate transparency differences");292 psError(PPSTACK_ERR_DATA, false, "Unable to calculate transparency differences"); 293 293 psFree(view); 294 294 return false; -
trunk/ppStack/src/ppStackReject.c
r26076 r27004 61 61 } 62 62 if (!psThreadPoolWait(true)) { 63 psError( PS_ERR_UNKNOWN, false, "Unable to concatenate inspection lists.");63 psError(psErrorCodeLast(), false, "Unable to concatenate inspection lists."); 64 64 return false; 65 65 } … … 172 172 173 173 if (numRejected >= num - 1) { 174 psError(P S_ERR_UNKNOWN, true, "All inputs completely rejected; unable to proceed.");174 psError(PPSTACK_ERR_REJECTED, true, "All inputs completely rejected; unable to proceed."); 175 175 return false; 176 176 } -
trunk/ppStack/src/ppStackSetup.c
r26898 r27004 42 42 options->statsFile = fopen(resolved, "w"); 43 43 if (!options->statsFile) { 44 psError(P S_ERR_IO, true, "Unable to open statistics file %s for writing.\n", resolved);44 psError(PPSTACK_ERR_IO, true, "Unable to open statistics file %s for writing.\n", resolved); 45 45 psFree(resolved); 46 46 return false; … … 57 57 } 58 58 if (!tempDir) { 59 psError(P S_ERR_BAD_PARAMETER_VALUE, false, "Unable to find TEMP.DIR in site configuration");59 psError(PPSTACK_ERR_CONFIG, false, "Unable to find TEMP.DIR in site configuration"); 60 60 return false; 61 61 } … … 65 65 const char *tempName = basename(outputName); 66 66 if (!tempName) { 67 psError(P S_ERR_BAD_PARAMETER_VALUE, false, "Unable to construct basename for temporary files.");67 psError(PPSTACK_ERR_ARGUMENTS, false, "Unable to construct basename for temporary files."); 68 68 psFree(outputName); 69 69 return false; … … 74 74 const char *tempVariance = psMetadataLookupStr(NULL, recipe, "TEMP.VARIANCE"); // Suffix for var maps 75 75 if (!tempImage || !tempMask || !tempVariance) { 76 psError(P S_ERR_BAD_PARAMETER_VALUE, false,76 psError(PPSTACK_ERR_CONFIG, false, 77 77 "Unable to find TEMP.IMAGE, TEMP.MASK and TEMP.VARIANCE in recipe"); 78 78 psFree(outputName); … … 117 117 118 118 if (!pmConfigMaskSetBits(NULL, NULL, config)) { 119 psError(P S_ERR_UNKNOWN, false, "Unable to determine mask value.");119 psError(PPSTACK_ERR_CONFIG, false, "Unable to determine mask value."); 120 120 return false; 121 121 } -
trunk/ppStack/src/ppStackSources.c
r26898 r27004 116 116 psMetadata *airmassZP = psMetadataLookupMetadata(NULL, recipe, "ZP.AIRMASS"); // Airmass terms 117 117 if (!airmassZP) { 118 psError(P S_ERR_UNKNOWN, false, "Unable to find ZP.AIRMASS in recipe.");118 psError(PPSTACK_ERR_CONFIG, false, "Unable to find ZP.AIRMASS in recipe."); 119 119 return false; 120 120 } … … 152 152 if (!isfinite(exptime) || exptime == 0 || !isfinite(airmass) || airmass == 0 || 153 153 !expFilter || strlen(expFilter) == 0) { 154 psError(P S_ERR_UNEXPECTED_NULL, false,154 psError(PPSTACK_ERR_CONFIG, false, 155 155 "Unable to find exposure time (%f), airmass (%f) or filter (%s)", 156 156 exptime, airmass, expFilter); … … 163 163 airmassTerm = psMetadataLookupF32(NULL, airmassZP, filter); 164 164 if (!isfinite(airmassTerm)) { 165 psError(P S_ERR_BAD_PARAMETER_VALUE, false,165 psError(PPSTACK_ERR_CONFIG, false, 166 166 "Unable to find airmass term (ZP.AIRMASS) for filter %s", filter); 167 167 psFree(zp); … … 169 169 } 170 170 } else if (strcmp(filter, expFilter) != 0) { 171 psError(P S_ERR_BAD_PARAMETER_VALUE, false, "Filters don't match: %s vs %s", filter, expFilter);171 psError(PPSTACK_ERR_CONFIG, false, "Filters don't match: %s vs %s", filter, expFilter); 172 172 psFree(zp); 173 173 return false; … … 182 182 psArray *matches = pmSourceMatchSources(sourceLists, radius, true); // List of matches 183 183 if (!matches) { 184 psError(P S_ERR_UNKNOWN, false, "Unable to match sources");184 psError(PPSTACK_ERR_DATA, false, "Unable to match sources"); 185 185 psFree(zp); 186 186 return false; … … 196 196 transIter, transRej, transThresh); // Transparencies per image 197 197 if (!trans) { 198 psError(P S_ERR_UNKNOWN, false, "Unable to measure transparencies");198 psError(PPSTACK_ERR_DATA, false, "Unable to measure transparencies"); 199 199 return false; 200 200 } … … 241 241 psArray *matches = pmSourceMatchSources(sourceLists, radius); // List of matches 242 242 if (!matches) { 243 psError(P S_ERR_UNKNOWN, false, "Unable to match sources");243 psError(PPSTACK_ERR_DATA, false, "Unable to match sources"); 244 244 psFree(zp); 245 245 return false; … … 262 262 iter2, starRej2, starLimit); // Shifts for each image 263 263 if (!offsets) { 264 psError(P S_ERR_UNKNOWN, false, "Unable to measure offsets");264 psError(PPSTACK_ERR_DATA, false, "Unable to measure offsets"); 265 265 return false; 266 266 } -
trunk/ppStack/src/ppStackThread.c
r26076 r27004 102 102 (FITS)->data[INDEX] = psFitsOpen(resolved, "r"); \ 103 103 if (!(FITS)->data[INDEX]) { \ 104 psError(P S_ERR_IO, false, "Unable to open file %s", (char*)(NAMES)->data[INDEX]); \104 psError(PPSTACK_ERR_IO, false, "Unable to open file %s", (char*)(NAMES)->data[INDEX]); \ 105 105 psFree(resolved); \ 106 106 return NULL; \ … … 152 152 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // Recipe 153 153 if (!recipe) { 154 psError(P S_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSTACK_RECIPE);154 psError(PPSTACK_ERR_CONFIG, false, "Unable to find recipe %s", PPSTACK_RECIPE); 155 155 return NULL; 156 156 } 157 157 int rows = psMetadataLookupS32(NULL, recipe, "ROWS"); // Number of rows to read per chunk 158 158 if (rows <= 0) { 159 psError(P S_ERR_BAD_PARAMETER_VALUE, false, "ROWS is not set in the recipe.");159 psError(PPSTACK_ERR_CONFIG, false, "ROWS is not set in the recipe."); 160 160 return NULL; 161 161 } … … 204 204 keepReading = true; 205 205 if (!pmReadoutReadChunk(ro, imageFits, 0, NULL, rows, overlap, config)) { 206 psError(PS_ERR_IO, false, "Unable to read chunk %d for file PPSTACK.INPUT %d", 206 psError(PPSTACK_ERR_IO, false, 207 "Unable to read chunk %d for file PPSTACK.INPUT %d", 207 208 numChunk, i); 208 209 *status = false; … … 214 215 keepReading = true; 215 216 if (!pmReadoutReadChunkMask(ro, maskFits, 0, NULL, rows, overlap, config)) { 216 psError(PS_ERR_IO, false, "Unable to read chunk %d for file PPSTACK.INPUT.MASK %d", 217 psError(PPSTACK_ERR_IO, false, 218 "Unable to read chunk %d for file PPSTACK.INPUT.MASK %d", 217 219 numChunk, i); 218 220 *status = false; … … 224 226 keepReading = true; 225 227 if (!pmReadoutReadChunkVariance(ro, varianceFits, 0, NULL, rows, overlap, config)) { 226 psError(P S_ERR_IO, false,228 psError(PPSTACK_ERR_IO, false, 227 229 "Unable to read chunk %d for file PPSTACK.INPUT.VARIANCE %d", 228 230 numChunk, i);
Note:
See TracChangeset
for help on using the changeset viewer.
