Changeset 27838 for branches/tap_branches/ppStack/src/ppStackCamera.c
- Timestamp:
- May 3, 2010, 8:41:49 AM (16 years ago)
- Location:
- branches/tap_branches
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
ppStack/src (modified) (1 prop)
-
ppStack/src/ppStackCamera.c (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/tap_branches
- Property svn:mergeinfo changed
-
branches/tap_branches/ppStack/src
- Property svn:ignore
-
old new 10 10 stamp-h1 11 11 ppStackVersionDefinitions.h 12 ppStackErrorCodes.c 13 ppStackErrorCodes.h
-
- Property svn:ignore
-
branches/tap_branches/ppStack/src/ppStackCamera.c
r25519 r27838 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 } … … 233 235 234 236 // Output image 235 pmFPA * fpa= pmFPAConstruct(config->camera, config->cameraName); // FPA to contain the output236 if (! fpa) {237 psError( PS_ERR_UNEXPECTED_NULL, false, "Unable to construct an FPA from camera configuration.");238 return false; 239 } 240 pmFPAfile *output = pmFPAfileDefineOutput(config, fpa, "PPSTACK.OUTPUT");241 psFree( fpa); // Drop reference237 pmFPA *outFPA = pmFPAConstruct(config->camera, config->cameraName); // FPA to contain the output 238 if (!outFPA) { 239 psError(psErrorCodeLast(), false, "Unable to construct an FPA from camera configuration."); 240 return false; 241 } 242 pmFPAfile *output = pmFPAfileDefineOutput(config, outFPA, "PPSTACK.OUTPUT"); 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 } 250 252 output->save = true; 251 253 252 if (!pmFPAAddSourceFromFormat(fpa, "Stack", output->format)) { 253 psError(PS_ERR_UNKNOWN, false, "Unable to generate output FPA."); 254 psFree(fpa); 254 if (!pmFPAAddSourceFromFormat(outFPA, "Stack", output->format)) { 255 psError(psErrorCodeLast(), false, "Unable to generate output FPA."); 255 256 return false; 256 257 } … … 259 260 pmFPAfile *outMask = pmFPAfileDefineOutput(config, output->fpa, "PPSTACK.OUTPUT.MASK"); 260 261 if (!outMask) { 261 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")); 262 263 return false; 263 264 } 264 265 if (outMask->type != PM_FPA_FILE_MASK) { 265 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"); 266 267 return false; 267 268 } … … 272 273 pmFPAfile *outVariance = pmFPAfileDefineOutput(config, output->fpa, "PPSTACK.OUTPUT.VARIANCE"); 273 274 if (!outVariance) { 274 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"); 275 276 return false; 276 277 } 277 278 if (outVariance->type != PM_FPA_FILE_VARIANCE) { 278 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"); 279 280 return false; 280 281 } … … 282 283 } 283 284 285 286 // Exposure image 287 pmFPA *expFPA = pmFPAConstruct(config->camera, config->cameraName); // FPA to contain the output 288 if (!expFPA) { 289 psError(psErrorCodeLast(), false, "Unable to construct an FPA from camera configuration."); 290 return false; 291 } 292 pmFPAfile *exp = pmFPAfileDefineOutput(config, expFPA, "PPSTACK.OUTPUT.EXP"); 293 psFree(expFPA); // Drop reference 294 if (!exp) { 295 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT.EXP")); 296 return false; 297 } 298 if (exp->type != PM_FPA_FILE_IMAGE) { 299 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.EXP is not of type IMAGE"); 300 return false; 301 } 302 exp->save = true; 303 304 if (!pmFPAAddSourceFromFormat(expFPA, "Stack", exp->format)) { 305 psError(psErrorCodeLast(), false, "Unable to generate output FPA."); 306 return false; 307 } 308 309 // Exposure numbers 310 pmFPAfile *expNum = pmFPAfileDefineOutput(config, exp->fpa, "PPSTACK.OUTPUT.EXPNUM"); 311 if (!expNum) { 312 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT.EXPNUM")); 313 return false; 314 } 315 if (expNum->type != PM_FPA_FILE_MASK) { 316 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.EXPNUM is not of type MASK"); 317 return false; 318 } 319 expNum->save = true; 320 321 // Weighted exposure 322 pmFPAfile *expWt = pmFPAfileDefineOutput(config, exp->fpa, "PPSTACK.OUTPUT.EXPWT"); 323 if (!expWt) { 324 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT.EXPWT")); 325 return false; 326 } 327 if (expWt->type != PM_FPA_FILE_VARIANCE) { 328 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.EXPWT is not of type VARIANCE"); 329 return false; 330 } 331 expWt->save = true; 332 333 284 334 if (havePSFs) { 285 pmFPAfile *targetPSF = pmFPAfileDefineOutput(config, output->fpa, "PPSTACK.TARGET.PSF"); 335 pmFPA *psfFPA = pmFPAConstruct(config->camera, config->cameraName); // FPA to contain PSF 336 if (!psfFPA) { 337 psError(psErrorCodeLast(), false, "Unable to construct an FPA from camera configuration."); 338 return false; 339 } 340 pmFPAfile *targetPSF = pmFPAfileDefineOutput(config, psfFPA, "PPSTACK.TARGET.PSF"); 286 341 if (!targetPSF) { 287 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.TARGET.PSF")); 288 return false; 289 } 342 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.TARGET.PSF")); 343 return false; 344 } 345 psFree(psfFPA); 290 346 if (targetPSF->type != PM_FPA_FILE_PSF) { 291 psError(P S_ERR_IO, true, "PPSTACK.TARGET.PSF is not of type PSF");347 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.TARGET.PSF is not of type PSF"); 292 348 return false; 293 349 } 294 350 targetPSF->save = true; 295 351 } 352 353 // Unconvolved stack 354 pmFPA *unconvFPA = pmFPAConstruct(config->camera, config->cameraName); // FPA to contain unconvolved output 355 if (!unconvFPA) { 356 psError(psErrorCodeLast(), false, "Unable to construct an FPA from camera configuration."); 357 return false; 358 } 359 pmFPAfile *unConv = pmFPAfileDefineOutput(config, unconvFPA, "PPSTACK.UNCONV"); 360 psFree(unconvFPA); // Drop reference 361 if (!unConv) { 362 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.UNCONV")); 363 return false; 364 } 365 if (unConv->type != PM_FPA_FILE_IMAGE) { 366 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.UNCONV is not of type IMAGE"); 367 return false; 368 } 369 unConv->save = true; 370 371 if (!pmFPAAddSourceFromFormat(unconvFPA, "Stack", unConv->format)) { 372 psError(psErrorCodeLast(), false, "Unable to generate output FPA."); 373 return false; 374 } 375 376 // Unconvolved mask 377 pmFPAfile *unconvMask = pmFPAfileDefineOutput(config, unconvFPA, "PPSTACK.UNCONV.MASK"); 378 if (!unconvMask) { 379 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.UNCONV.MASK")); 380 return false; 381 } 382 if (unconvMask->type != PM_FPA_FILE_MASK) { 383 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.UNCONV.MASK is not of type MASK"); 384 return false; 385 } 386 unconvMask->save = true; 387 388 // Unconvolved variance 389 if (haveVariances) { 390 pmFPAfile *unconvVariance = pmFPAfileDefineOutput(config, unconvFPA, "PPSTACK.UNCONV.VARIANCE"); 391 if (!unconvVariance) { 392 psError(psErrorCodeLast(), false, "Unable to generate output file from PPSTACK.UNCONV.VARIANCE"); 393 return false; 394 } 395 if (unconvVariance->type != PM_FPA_FILE_VARIANCE) { 396 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.UNCONV.VARIANCE is not of type VARIANCE"); 397 return false; 398 } 399 unconvVariance->save = true; 400 } 401 402 403 // Exposure image 404 pmFPA *unconvExpFPA = pmFPAConstruct(config->camera, config->cameraName); // FPA to contain the output 405 if (!unconvExpFPA) { 406 psError(psErrorCodeLast(), false, "Unable to construct an FPA from camera configuration."); 407 return false; 408 } 409 pmFPAfile *unconvExp = pmFPAfileDefineOutput(config, unconvExpFPA, "PPSTACK.UNCONV.EXP"); 410 psFree(unconvExpFPA); // Drop reference 411 if (!unconvExp) { 412 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.UNCONV.EXP")); 413 return false; 414 } 415 if (unconvExp->type != PM_FPA_FILE_IMAGE) { 416 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.UNCONV.EXP is not of type IMAGE"); 417 return false; 418 } 419 unconvExp->save = true; 420 421 if (!pmFPAAddSourceFromFormat(unconvExpFPA, "Stack", unconvExp->format)) { 422 psError(psErrorCodeLast(), false, "Unable to generate output FPA."); 423 return false; 424 } 425 426 // Exposure numbers 427 pmFPAfile *unconvExpNum = pmFPAfileDefineOutput(config, unconvExp->fpa, "PPSTACK.UNCONV.EXPNUM"); 428 if (!unconvExpNum) { 429 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.UNCONV.MASK")); 430 return false; 431 } 432 if (unconvExpNum->type != PM_FPA_FILE_MASK) { 433 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.UNCONV.EXPNUM is not of type MASK"); 434 return false; 435 } 436 unconvExpNum->save = true; 437 438 // Weighted exposure 439 pmFPAfile *unconvExpWt = pmFPAfileDefineOutput(config, unconvExp->fpa, "PPSTACK.UNCONV.EXPWT"); 440 if (!unconvExpWt) { 441 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.UNCONV.EXPWT")); 442 return false; 443 } 444 if (unconvExpWt->type != PM_FPA_FILE_VARIANCE) { 445 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.UNCONV.EXPWT is not of type VARIANCE"); 446 return false; 447 } 448 unconvExpWt->save = true; 296 449 297 450 // Output JPEGs 298 451 pmFPAfile *jpeg1 = pmFPAfileDefineOutput(config, NULL, "PPSTACK.OUTPUT.JPEG1"); 299 452 if (!jpeg1) { 300 psError( PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.OUTPUT.JPEG1"));453 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT.JPEG1")); 301 454 return false; 302 455 } 303 456 if (jpeg1->type != PM_FPA_FILE_JPEG) { 304 psError(P S_ERR_IO, true, "PPSTACK.OUTPUT.JPEG1 is not of type JPEG");457 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.JPEG1 is not of type JPEG"); 305 458 return false; 306 459 } … … 308 461 pmFPAfile *jpeg2 = pmFPAfileDefineOutput(config, NULL, "PPSTACK.OUTPUT.JPEG2"); 309 462 if (!jpeg2) { 310 psError( PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.OUTPUT.JPEG2"));463 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT.JPEG2")); 311 464 return false; 312 465 } 313 466 if (jpeg2->type != PM_FPA_FILE_JPEG) { 314 psError(P S_ERR_IO, true, "PPSTACK.OUTPUT.JPEG2 is not of type JPEG");467 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.JPEG2 is not of type JPEG"); 315 468 return false; 316 469 } … … 323 476 psMetadataLookupBool(&mdok, config->arguments, "-photometry"); // perform photometry 324 477 if (doPhotom) { 325 // This file, PSPHOT.INPUT, is just used as a carrier; output files (eg, PSPHOT.RESID) are defined by326 // psphotDefineFiles478 // This pmFPAfile, PSPHOT.INPUT, is just used as a carrier; output files (eg, 479 // PSPHOT.RESID) are defined by psphotDefineFiles 327 480 pmFPAfile *psphotInput = pmFPAfileDefineFromFPA(config, output->fpa, 1, 1, "PSPHOT.INPUT"); 328 481 if (!psphotInput) { 329 psError(PS_ERR_IO, false, _("Unable to generate output file from PSPHOT.INPUT")); 330 return false; 331 } 482 psError(psErrorCodeLast(), false, _("Unable to generate output file from PSPHOT.INPUT")); 483 return false; 484 } 485 // specify the number of psphot input images 486 psMetadataAddS32 (config->arguments, PS_LIST_TAIL, "PSPHOT.INPUT.NUM", PS_META_REPLACE, "number of inputs", 1); 332 487 333 488 // Define associated psphot input/output files 334 489 if (!psphotDefineFiles(config, psphotInput)) { 335 psError( PSPHOT_ERR_CONFIG, false,490 psError(psErrorCodeLast(), false, 336 491 "Trouble defining the additional input/output files for psphot"); 337 492 return false; … … 341 496 pmFPAfile *outPSF = pmFPAfileDefineOutputFromFile(config, output, "PSPHOT.PSF.SAVE"); 342 497 if (!outPSF) { 343 psError( PS_ERR_IO, false, _("Unable to generate output file from PSPHOT.PSF.SAVE"));498 psError(psErrorCodeLast(), false, _("Unable to generate output file from PSPHOT.PSF.SAVE")); 344 499 return false; 345 500 } 346 501 if (outPSF->type != PM_FPA_FILE_PSF) { 347 psError(P S_ERR_IO, true, "PSPHOT.PSF.SAVE is not of type PSF");502 psError(PPSTACK_ERR_CONFIG, true, "PSPHOT.PSF.SAVE is not of type PSF"); 348 503 return false; 349 504 }
Note:
See TracChangeset
for help on using the changeset viewer.
