Changeset 27086
- Timestamp:
- Feb 25, 2010, 12:33:42 PM (16 years ago)
- Location:
- trunk/psModules/src/imcombine
- Files:
-
- 8 edited
-
pmSubtraction.c (modified) (6 diffs)
-
pmSubtractionAnalysis.c (modified) (6 diffs)
-
pmSubtractionEquation.c (modified) (9 diffs)
-
pmSubtractionIO.c (modified) (25 diffs)
-
pmSubtractionMask.c (modified) (3 diffs)
-
pmSubtractionMatch.c (modified) (44 diffs)
-
pmSubtractionParams.c (modified) (5 diffs)
-
pmSubtractionStamps.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtraction.c
r26893 r27086 17 17 #include <pslib.h> 18 18 19 #include "pmErrorCodes.h" 19 20 #include "pmHDU.h" // Required for pmFPA.h 20 21 #include "pmFPA.h" … … 752 753 753 754 if (stamp->status != PM_SUBTRACTION_STAMP_CALCULATE) { 754 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "Stamp not marked for calculation.");755 psError(PM_ERR_PROG, true, "Stamp not marked for calculation."); 755 756 return false; 756 757 } … … 808 809 809 810 if (numStamps == 0) { 810 psError(P S_ERR_UNKNOWN, true, "No good stamps found.");811 psError(PM_ERR_STAMPS, true, "No good stamps found."); 811 812 psFree(mask); 812 813 return -1; … … 816 817 PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_QUARTILE); // Statistics for deviatns 817 818 if (!psVectorStats(stats, deviations, NULL, mask, 0xff)) { 818 psError(P S_ERR_UNKNOWN, false, "Unable to measure statistics for deviations.");819 psError(PM_ERR_DATA, false, "Unable to measure statistics for deviations."); 819 820 psFree(stats); 820 821 psFree(mask); … … 1199 1200 if (region && psRegionIsNaN(*region)) { 1200 1201 psString string = psRegionToString(*region); 1201 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "Input region (%s) contains NAN values", string);1202 psError(PM_ERR_PROG, true, "Input region (%s) contains NAN values", string); 1202 1203 psFree(string); 1203 1204 return false; … … 1303 1304 1304 1305 if (!psThreadPoolWait(false)) { 1305 psError( PS_ERR_UNKNOWN, false, "Error waiting for threads.");1306 psError(psErrorCodeLast(), false, "Error waiting for threads."); 1306 1307 return false; 1307 1308 } -
trunk/psModules/src/imcombine/pmSubtractionAnalysis.c
r26893 r27086 74 74 false); // Image of the kernel 75 75 if (!kernel) { 76 psError( PS_ERR_UNKNOWN, false, "Unable to generate kernel image.");76 psError(psErrorCodeLast(), false, "Unable to generate kernel image."); 77 77 psFree(convKernels); 78 78 return false; … … 81 81 if (psImageOverlaySection(convKernels, kernel, (i + KERNEL_MOSAIC) * fullSize, 82 82 (j + KERNEL_MOSAIC) * fullSize, "=") == 0) { 83 psError( PS_ERR_UNKNOWN, false, "Unable to overlay kernel image.");83 psError(psErrorCodeLast(), false, "Unable to overlay kernel image."); 84 84 psFree(kernel); 85 85 psFree(convKernels); … … 93 93 true); // Image of the kernel 94 94 if (!kernel) { 95 psError( PS_ERR_UNKNOWN, false, "Unable to generate kernel image.");95 psError(psErrorCodeLast(), false, "Unable to generate kernel image."); 96 96 psFree(convKernels); 97 97 return false; … … 101 101 (2 * KERNEL_MOSAIC + 1 + i + KERNEL_MOSAIC) * fullSize + 4, 102 102 (j + KERNEL_MOSAIC) * fullSize, "=") == 0) { 103 psError( PS_ERR_UNKNOWN, false, "Unable to overlay kernel image.");103 psError(psErrorCodeLast(), false, "Unable to overlay kernel image."); 104 104 psFree(kernel); 105 105 psFree(convKernels); … … 161 161 psImage *image = pmSubtractionKernelImage(kernels, 0.5, 0.5, false); // Image of the kernel 162 162 if (!image) { 163 psError( PS_ERR_UNKNOWN, false, "Unable to generate image of kernel.");163 psError(psErrorCodeLast(), false, "Unable to generate image of kernel."); 164 164 return false; 165 165 } … … 216 216 psImage *image = pmSubtractionKernelImage(kernels, 0.5, 0.5, false); // Image of the kernel 217 217 if (!image) { 218 psError( PS_ERR_UNKNOWN, false, "Unable to generate image of kernel.");218 psError(psErrorCodeLast(), false, "Unable to generate image of kernel."); 219 219 return false; 220 220 } -
trunk/psModules/src/imcombine/pmSubtractionEquation.c
r26893 r27086 7 7 #include <pslib.h> 8 8 9 #include "pmErrorCodes.h" 9 10 #include "pmSubtraction.h" 10 11 #include "pmSubtractionKernels.h" … … 718 719 // Generate convolutions: these are generated once and saved 719 720 if (!pmSubtractionConvolveStamp(stamp, kernels, footprint)) { 720 psError( PS_ERR_UNKNOWN, false, "Unable to convolve stamp %d.", index);721 psError(psErrorCodeLast(), false, "Unable to convolve stamp %d.", index); 721 722 return NULL; 722 723 } … … 869 870 870 871 if (!psThreadPoolWait(true)) { 871 psError( PS_ERR_UNKNOWN, false, "Error waiting for threads.");872 psError(psErrorCodeLast(), false, "Error waiting for threads."); 872 873 return false; 873 874 } … … 989 990 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); // Statistics for norm 990 991 if (!psVectorStats(stats, norms, NULL, NULL, 0)) { 991 psError(P S_ERR_UNKNOWN, false, "Unable to determine median normalisation");992 psError(PM_ERR_DATA, false, "Unable to determine median normalisation"); 992 993 psFree(stats); 993 994 psFree(sumMatrix); … … 1134 1135 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); // Statistics for norm 1135 1136 if (!psVectorStats(stats, norms, NULL, NULL, 0)) { 1136 psError(P S_ERR_UNKNOWN, false, "Unable to determine median normalisation");1137 psError(PM_ERR_DATA, false, "Unable to determine median normalisation"); 1137 1138 psFree(stats); 1138 1139 psFree(sumMatrix); … … 1371 1372 false); // Kernel image 1372 1373 if (!image) { 1373 psError( PS_ERR_UNKNOWN, false, "Unable to generate image of kernel.");1374 psError(psErrorCodeLast(), false, "Unable to generate image of kernel."); 1374 1375 return false; 1375 1376 } … … 1947 1948 psVector *w = NULL; 1948 1949 if (!psMatrixSVD (&U, &w, &V, kernelMatrix)) { 1949 psError( PS_ERR_UNKNOWN, false, "failed to perform SVD on sumMatrix\n");1950 psError(psErrorCodeLast(), false, "failed to perform SVD on sumMatrix\n"); 1950 1951 return NULL; 1951 1952 } … … 2087 2088 psImage *luMatrix = psMatrixLUDecomposition(NULL, &permutation, sumMatrix); 2088 2089 if (!luMatrix) { 2089 psError(P S_ERR_UNKNOWN, true, "LU Decomposition of least-squares matrix failed.\n");2090 psError(PM_ERR_DATA, true, "LU Decomposition of least-squares matrix failed.\n"); 2090 2091 psFree(solution); 2091 2092 psFree(sumVector); … … 2100 2101 psFree(permutation); 2101 2102 if (!solution) { 2102 psError(P S_ERR_UNKNOWN, true, "Failed to solve the least-squares system.\n");2103 psError(PM_ERR_DATA, true, "Failed to solve the least-squares system.\n"); 2103 2104 psFree(solution); 2104 2105 psFree(sumVector); -
trunk/psModules/src/imcombine/pmSubtractionIO.c
r26893 r27086 3 3 #include <string.h> 4 4 5 #include "pmErrorCodes.h" 5 6 #include "pmHDU.h" 6 7 #include "pmHDUUtils.h" … … 66 67 } 67 68 if (regions->n == 0) { 68 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "No subtraction regions found.");69 psError(PM_ERR_PROG, true, "No subtraction regions found."); 69 70 psFree(regions); 70 71 return false; … … 87 88 88 89 if (regions->n != kernels->n) { 89 psError(P S_ERR_BAD_PARAMETER_SIZE, true, "Number of regions (%ld) and kernels (%ld) don't match.\n",90 psError(PM_ERR_PROG, true, "Number of regions (%ld) and kernels (%ld) don't match.\n", 90 91 regions->n, kernels->n); 91 92 psFree(regions); … … 165 166 166 167 if (!psFitsWriteTable(fits, header, rows, EXTNAME_KERNEL)) { 167 psError( PS_ERR_IO, false, "Unable to write subtraction kernel to FITS table.");168 psError(psErrorCodeLast(), false, "Unable to write subtraction kernel to FITS table."); 168 169 psFree(header); 169 170 psFree(rows); … … 175 176 176 177 if (image && !psFitsWriteImage(fits, header, image, 0, EXTNAME_IMAGE)) { 177 psError( PS_ERR_IO, false, "Unable to write subtraction kernel image.");178 psError(psErrorCodeLast(), false, "Unable to write subtraction kernel image."); 178 179 psFree(header); 179 180 psFree(rows); … … 201 202 thisView->readout = i; 202 203 if (!pmReadoutWriteSubtractionKernels(readout, file->fits)) { 203 psError( PS_ERR_IO, false, "Failed to write %dth readout", i);204 psError(psErrorCodeLast(), false, "Failed to write %dth readout", i); 204 205 psFree(thisView); 205 206 return false; … … 224 225 thisView->cell = i; 225 226 if (!pmCellWriteSubtractionKernels(cell, thisView, file, config)) { 226 psError( PS_ERR_IO, false, "Failed to write %dth cell", i);227 psError(psErrorCodeLast(), false, "Failed to write %dth cell", i); 227 228 psFree(thisView); 228 229 return false; … … 247 248 thisView->chip = i; 248 249 if (!pmChipWriteSubtractionKernels(chip, thisView, file, config)) { 249 psError( PS_ERR_IO, false, "Failed to write %dth chip", i);250 psError(psErrorCodeLast(), false, "Failed to write %dth chip", i); 250 251 psFree(thisView); 251 252 return false; … … 265 266 266 267 if (!psFitsMoveExtName(fits, EXTNAME_KERNEL)) { 267 psError( PS_ERR_IO, false, "Unable to move to subtraction kernel table.");268 psError(psErrorCodeLast(), false, "Unable to move to subtraction kernel table."); 268 269 return false; 269 270 } … … 271 272 psArray *table = psFitsReadTable(fits); // Table of interest 272 273 if (!table) { 273 psError( PS_ERR_IO, false, "Unable to read FITS table");274 psError(psErrorCodeLast(), false, "Unable to read FITS table"); 274 275 return false; 275 276 } … … 282 283 TARGET = psMetadataLookup##SUFFIX(&mdok, row, NAME); \ 283 284 if (!mdok) { \ 284 psError(P S_ERR_UNKNOWN, false, "Unable to find column %s in subtraction kernel table.", NAME); \285 psError(PM_ERR_PROG, false, "Unable to find column %s in subtraction kernel table.", NAME); \ 285 286 psFree(table); \ 286 287 return false; \ … … 325 326 kernels->solution1 = psMemIncrRefCounter(psMetadataLookupPtr(&mdok, row, NAME_SOL1)); 326 327 if (!mdok) { 327 psError(P S_ERR_UNKNOWN, false, "Unable to find column %s in subtraction kernel table.",328 psError(PM_ERR_PROG, false, "Unable to find column %s in subtraction kernel table.", 328 329 NAME_SOL1); 329 330 psFree(kernels); … … 335 336 kernels->solution1 = psMemIncrRefCounter(psMetadataLookupPtr(&mdok, row, NAME_SOL1)); 336 337 if (!mdok) { 337 psError(P S_ERR_UNKNOWN, false, "Unable to find column %s in subtraction kernel table.",338 psError(PM_ERR_PROG, false, "Unable to find column %s in subtraction kernel table.", 338 339 NAME_SOL1); 339 340 psFree(kernels); … … 343 344 kernels->solution2 = psMemIncrRefCounter(psMetadataLookupPtr(&mdok, row, NAME_SOL2)); 344 345 if (!mdok) { 345 psError(P S_ERR_UNKNOWN, false, "Unable to find column %s in subtraction kernel table.",346 psError(PM_ERR_PROG, false, "Unable to find column %s in subtraction kernel table.", 346 347 NAME_SOL2); 347 348 psFree(kernels); … … 379 380 pmReadout *readout = cell->readouts->data[i]; 380 381 thisView->readout = i; 381 pmReadoutReadSubtractionKernels(readout, file->fits); 382 if (!pmReadoutReadSubtractionKernels(readout, file->fits)) { 383 psError(psErrorCodeLast(), false, "Unable to read subtraction kernels from cell"); 384 psFree(thisView); 385 return false; 386 } 382 387 if (!readout->data_exists) { 383 388 continue; … … 410 415 pmCell *cell = chip->cells->data[i]; 411 416 thisView->cell = i; 412 pmCellReadSubtractionKernels(cell, thisView, file, config); 413 if (!cell->data_exists) { 417 if (!pmCellReadSubtractionKernels(cell, thisView, file, config)) { 418 psError(psErrorCodeLast(), false, "Unable to read subtraction kernels from cell"); 419 psFree(thisView); 420 return false; 421 } 422 if (!cell->data_exists) { 414 423 continue; 415 424 } … … 419 428 420 429 if (!pmConceptsReadChip(chip, PM_CONCEPT_SOURCE_HEADER, true, true, NULL)) { 421 psError( PS_ERR_IO, false, "Failed to read concepts for chip.\n");430 psError(psErrorCodeLast(), false, "Failed to read concepts for chip.\n"); 422 431 return false; 423 432 } … … 440 449 pmChip *chip = fpa->chips->data[i]; 441 450 thisView->chip = i; 442 pmChipReadSubtractionKernels(chip, thisView, file, config); 451 if (!pmChipReadSubtractionKernels(chip, thisView, file, config)) { 452 psError(psErrorCodeLast(), false, "Unable to read subtraction kernels from chip"); 453 psFree(thisView); 454 return false; 455 } 443 456 } 444 457 psFree(thisView); 445 458 446 459 if (!pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER, true, NULL)) { 447 psError( PS_ERR_IO, false, "Failed to read concepts for fpa.\n");460 psError(psErrorCodeLast(), false, "Failed to read concepts for fpa.\n"); 448 461 return false; 449 462 } … … 464 477 if (view->chip == -1) { 465 478 if (!pmFPAWriteSubtractionKernels(fpa, view, file, config)) { 466 psError( PS_ERR_IO, false, "Failed to write subtraction kernels from fpa");479 psError(psErrorCodeLast(), false, "Failed to write subtraction kernels from fpa"); 467 480 psFree(fpa); 468 481 return false; … … 473 486 474 487 if (view->chip >= fpa->chips->n) { 475 psError(P S_ERR_UNKNOWN, false, "Writing chip == %d (>= chips->n == %ld)", view->chip, fpa->chips->n);488 psError(PM_ERR_PROG, true, "Writing chip == %d (>= chips->n == %ld)", view->chip, fpa->chips->n); 476 489 psFree(fpa); 477 490 return false; … … 481 494 if (view->cell == -1) { 482 495 if (!pmChipWriteSubtractionKernels(chip, view, file, config)) { 483 psError( PS_ERR_IO, false, "Failed to write objects from chip");496 psError(psErrorCodeLast(), false, "Failed to write objects from chip"); 484 497 psFree(fpa); 485 498 return false; … … 490 503 491 504 if (view->cell >= chip->cells->n) { 492 psError(P S_ERR_UNKNOWN, false, "Writing cell == %d (>= cells->n == %ld)",505 psError(PM_ERR_PROG, true, "Writing cell == %d (>= cells->n == %ld)", 493 506 view->cell, chip->cells->n); 494 507 psFree(fpa); … … 499 512 if (view->readout == -1) { 500 513 if (!pmCellWriteSubtractionKernels(cell, view, file, config)) { 501 psError( PS_ERR_IO, false, "Failed to write objects from cell");514 psError(psErrorCodeLast(), false, "Failed to write objects from cell"); 502 515 psFree(fpa); 503 516 return false; … … 508 521 509 522 if (view->readout >= cell->readouts->n) { 510 psError(P S_ERR_UNKNOWN, false, "Writing readout == %d (>= readouts->n == %ld)",523 psError(PM_ERR_PROG, true, "Writing readout == %d (>= readouts->n == %ld)", 511 524 view->readout, cell->readouts->n); 512 525 psFree(fpa); … … 516 529 517 530 if (!pmReadoutWriteSubtractionKernels(readout, file->fits)) { 518 psError( PS_ERR_IO, false, "Failed to write objects from readout %d", view->readout);531 psError(psErrorCodeLast(), false, "Failed to write objects from readout %d", view->readout); 519 532 psFree(fpa); 520 533 return false; -
trunk/psModules/src/imcombine/pmSubtractionMask.c
r26893 r27086 146 146 if (!psImageConvolveMask(mask, mask, PM_SUBTRACTION_MASK_BAD_1, PM_SUBTRACTION_MASK_CONVOLVE_1, 147 147 -size, size, -size, size)) { 148 psError( PS_ERR_UNKNOWN, false, "Unable to convolve bad pixels from mask 1.");148 psError(psErrorCodeLast(), false, "Unable to convolve bad pixels from mask 1."); 149 149 psFree(mask); 150 150 return NULL; … … 152 152 if (!psImageConvolveMask(mask, mask, PM_SUBTRACTION_MASK_BAD_2, PM_SUBTRACTION_MASK_CONVOLVE_2, 153 153 -size, size, -size, size)) { 154 psError( PS_ERR_UNKNOWN, false, "Unable to convolve bad pixels from mask 2.");154 psError(psErrorCodeLast(), false, "Unable to convolve bad pixels from mask 2."); 155 155 psFree(mask); 156 156 return NULL; … … 176 176 if (!psImageConvolveMask(mask, mask, maskRej, PM_SUBTRACTION_MASK_REJ, 177 177 -footprint, footprint, -footprint, footprint)) { 178 psError( PS_ERR_UNKNOWN, false, "Unable to convolve bad pixels.");178 psError(psErrorCodeLast(), false, "Unable to convolve bad pixels."); 179 179 psFree(mask); 180 180 return NULL; -
trunk/psModules/src/imcombine/pmSubtractionMatch.c
r27040 r27086 104 104 psTrace("psModules.imcombine", 3, "Extracting stamps...\n"); 105 105 if (!pmSubtractionStampsExtract(*stamps, ro1->image, ro2->image, variance, size, *region)) { 106 psError( PS_ERR_UNKNOWN, false, "Unable to extract stamps.");106 psError(psErrorCodeLast(), false, "Unable to extract stamps."); 107 107 return false; 108 108 } … … 318 318 while ((item = psMetadataGetAndIncrement(iter))) { 319 319 if (item->type != PS_DATA_UNKNOWN) { 320 psError(P S_ERR_BAD_PARAMETER_TYPE, true, "Unexpected type for kernel.");320 psError(PM_ERR_PROG, true, "Unexpected type for kernel."); 321 321 psFree(iter); 322 322 psFree(kernelList); … … 338 338 } 339 339 if (psListLength(kernelList) == 0) { 340 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "Unable to find kernels");340 psError(PM_ERR_PROG, true, "Unable to find kernels"); 341 341 psFree(kernelList); 342 342 return false; … … 353 353 while ((item = psMetadataGetAndIncrement(iter))) { 354 354 if (item->type != PS_DATA_REGION) { 355 psError(P S_ERR_BAD_PARAMETER_TYPE, true, "Unexpected type for region.");355 psError(PM_ERR_PROG, true, "Unexpected type for region."); 356 356 psFree(iter); 357 357 psFree(kernels); … … 365 365 } 366 366 if (regions->n != kernels->n) { 367 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "Differing number of kernels (%ld) and regions (%ld)",367 psError(PM_ERR_PROG, true, "Differing number of kernels (%ld) and regions (%ld)", 368 368 kernels->n, regions->n); 369 369 psFree(regions); … … 406 406 if (!pmSubtractionAnalysis(outAnalysis, outHeader, kernel, region, 407 407 ro1->image->numCols, ro1->image->numRows)) { 408 psError( PS_ERR_UNKNOWN, false, "Unable to generate QA data");408 psError(psErrorCodeLast(), false, "Unable to generate QA data"); 409 409 psFree(outAnalysis); 410 410 psFree(outHeader); … … 417 417 if (!pmSubtractionConvolve(conv1, conv2, ro1, ro2, subMask, stride, maskBad, maskPoor, poorFrac, 418 418 kernelError, covarFrac, region, kernel, true, useFFT)) { 419 psError( PS_ERR_UNKNOWN, false, "Unable to convolve image.");419 psError(psErrorCodeLast(), false, "Unable to convolve image."); 420 420 psFree(outAnalysis); 421 421 psFree(outHeader); … … 555 555 psStatsInit(bg); 556 556 if (!psImageBackground(bg, NULL, ro1->image, ro1->mask, maskVal, rng)) { 557 psError(P S_ERR_UNKNOWN, false, "Unable to measure background statistics.");557 psError(PM_ERR_DATA, false, "Unable to measure background statistics."); 558 558 psFree(bg); 559 559 goto MATCH_ERROR; … … 565 565 psStatsInit(bg); 566 566 if (!psImageBackground(bg, NULL, ro2->image, ro2->mask, maskVal, rng)) { 567 psError(P S_ERR_UNKNOWN, false, "Unable to measure background statistics.");567 psError(PM_ERR_DATA, false, "Unable to measure background statistics."); 568 568 psFree(bg); 569 569 goto MATCH_ERROR; … … 640 640 psVector *buffer = NULL;// Buffer for stats 641 641 if (!psImageBackground(bgStats, &buffer, ro1->image, ro1->mask, maskVal, rng)) { 642 psError(P S_ERR_UNKNOWN, false, "Unable to measure background of image 1.");642 psError(PM_ERR_DATA, false, "Unable to measure background of image 1."); 643 643 psFree(bgStats); 644 644 psFree(buffer); … … 647 647 float bg1 = psStatsGetValue(bgStats, BG_STAT); // Background for image 1 648 648 if (!psImageBackground(bgStats, &buffer, ro2->image, ro2->mask, maskVal, rng)) { 649 psError(P S_ERR_UNKNOWN, false, "Unable to measure background of image 2.");649 psError(PM_ERR_DATA, false, "Unable to measure background of image 2."); 650 650 psFree(bgStats); 651 651 psFree(buffer); … … 667 667 break; 668 668 default: 669 psError( PS_ERR_UNKNOWN, false, "Unable to determine subtraction order.");669 psError(psErrorCodeLast(), false, "Unable to determine subtraction order."); 670 670 goto MATCH_ERROR; 671 671 } … … 685 685 // generate the window function from the set of stamps 686 686 if (!pmSubtractionStampsGetWindow(stamps, size)) { 687 psError( PS_ERR_UNKNOWN, false, "Unable to get stamps window.");687 psError(psErrorCodeLast(), false, "Unable to get stamps window."); 688 688 goto MATCH_ERROR; 689 689 } … … 692 692 psTrace("psModules.imcombine", 3, "Calculating equation for normalization...\n"); 693 693 if (!pmSubtractionCalculateEquation(stamps, kernels, SUBMODE)) { 694 psError( PS_ERR_UNKNOWN, false, "Unable to calculate least-squares equation.");694 psError(psErrorCodeLast(), false, "Unable to calculate least-squares equation."); 695 695 goto MATCH_ERROR; 696 696 } … … 698 698 psTrace("psModules.imcombine", 3, "Solving equation for normalization...\n"); 699 699 if (!pmSubtractionSolveEquation(kernels, stamps, SUBMODE)) { 700 psError( PS_ERR_UNKNOWN, false, "Unable to calculate least-squares equation.");700 psError(psErrorCodeLast(), false, "Unable to calculate least-squares equation."); 701 701 goto MATCH_ERROR; 702 702 } … … 710 710 psTrace("psModules.imcombine", 3, "Calculating equation for kernels...\n"); 711 711 if (!pmSubtractionCalculateEquation(stamps, kernels, PM_SUBTRACTION_EQUATION_KERNELS)) { 712 psError( PS_ERR_UNKNOWN, false, "Unable to calculate least-squares equation.");712 psError(psErrorCodeLast(), false, "Unable to calculate least-squares equation."); 713 713 goto MATCH_ERROR; 714 714 } … … 717 717 psTrace("psModules.imcombine", 3, "Solving equation for kernels...\n"); 718 718 if (!pmSubtractionSolveEquation(kernels, stamps, PM_SUBTRACTION_EQUATION_KERNELS)) { 719 psError( PS_ERR_UNKNOWN, false, "Unable to calculate least-squares equation.");719 psError(psErrorCodeLast(), false, "Unable to calculate least-squares equation."); 720 720 goto MATCH_ERROR; 721 721 } … … 724 724 psVector *deviations = pmSubtractionCalculateDeviations(stamps, kernels); // Stamp deviations 725 725 if (!deviations) { 726 psError( PS_ERR_UNKNOWN, false, "Unable to calculate deviations.");726 psError(psErrorCodeLast(), false, "Unable to calculate deviations."); 727 727 goto MATCH_ERROR; 728 728 } … … 733 733 numRejected = pmSubtractionRejectStamps(kernels, stamps, deviations, subMask, rej); 734 734 if (numRejected < 0) { 735 psError( PS_ERR_UNKNOWN, false, "Unable to reject stamps.");735 psError(psErrorCodeLast(), false, "Unable to reject stamps."); 736 736 psFree(deviations); 737 737 goto MATCH_ERROR; … … 747 747 psTrace("psModules.imcombine", 3, "Calculating equation for normalization...\n"); 748 748 if (!pmSubtractionCalculateEquation(stamps, kernels, SUBMODE)) { 749 psError( PS_ERR_UNKNOWN, false, "Unable to calculate least-squares equation.");749 psError(psErrorCodeLast(), false, "Unable to calculate least-squares equation."); 750 750 goto MATCH_ERROR; 751 751 } … … 754 754 psTrace("psModules.imcombine", 3, "Solving equation for kernels...\n"); 755 755 if (!pmSubtractionSolveEquation(kernels, stamps, SUBMODE)) { 756 psError( PS_ERR_UNKNOWN, false, "Unable to calculate least-squares equation.");756 psError(psErrorCodeLast(), false, "Unable to calculate least-squares equation."); 757 757 goto MATCH_ERROR; 758 758 } … … 765 765 psTrace("psModules.imcombine", 3, "Calculating equation for normalization...\n"); 766 766 if (!pmSubtractionCalculateEquation(stamps, kernels, PM_SUBTRACTION_EQUATION_KERNELS)) { 767 psError( PS_ERR_UNKNOWN, false, "Unable to calculate least-squares equation.");767 psError(psErrorCodeLast(), false, "Unable to calculate least-squares equation."); 768 768 goto MATCH_ERROR; 769 769 } … … 772 772 psTrace("psModules.imcombine", 3, "Solving equation for kernels...\n"); 773 773 if (!pmSubtractionSolveEquation(kernels, stamps, PM_SUBTRACTION_EQUATION_KERNELS)) { 774 psError( PS_ERR_UNKNOWN, false, "Unable to calculate least-squares equation.");774 psError(psErrorCodeLast(), false, "Unable to calculate least-squares equation."); 775 775 goto MATCH_ERROR; 776 776 } … … 779 779 psVector *deviations = pmSubtractionCalculateDeviations(stamps, kernels); // Stamp deviations 780 780 if (!deviations) { 781 psError( PS_ERR_UNKNOWN, false, "Unable to calculate deviations.");781 psError(psErrorCodeLast(), false, "Unable to calculate deviations."); 782 782 goto MATCH_ERROR; 783 783 } … … 791 791 792 792 if (!pmSubtractionAnalysis(analysis, header, kernels, region, numCols, numRows)) { 793 psError( PS_ERR_UNKNOWN, false, "Unable to generate QA data");793 psError(psErrorCodeLast(), false, "Unable to generate QA data"); 794 794 goto MATCH_ERROR; 795 795 } … … 800 800 if (!pmSubtractionConvolve(conv1, conv2, ro1, ro2, subMask, stride, maskBad, maskPoor, poorFrac, 801 801 kernelError, covarFrac, region, kernels, true, useFFT)) { 802 psError( PS_ERR_UNKNOWN, false, "Unable to convolve image.");802 psError(psErrorCodeLast(), false, "Unable to convolve image."); 803 803 goto MATCH_ERROR; 804 804 } … … 820 820 821 821 if (conv1 && !pmSubtractionBorder(conv1->image, conv1->variance, conv1->mask, size, maskBad)) { 822 psError( PS_ERR_UNKNOWN, false, "Unable to set border of convolved image.");822 psError(psErrorCodeLast(), false, "Unable to set border of convolved image."); 823 823 goto MATCH_ERROR; 824 824 } 825 825 if (conv2 && !pmSubtractionBorder(conv2->image, conv2->variance, conv2->mask, size, maskBad)) { 826 psError( PS_ERR_UNKNOWN, false, "Unable to set border of convolved image.");826 psError(psErrorCodeLast(), false, "Unable to set border of convolved image."); 827 827 goto MATCH_ERROR; 828 828 } … … 1023 1023 } else { 1024 1024 if (!pmSubtractionOrderStamp(ratios, mask, stamps, models, modelSums, i, bg1, bg2)) { 1025 psError( PS_ERR_UNKNOWN, false, "Unable to measure PSF width for stamp %d", i);1025 psError(psErrorCodeLast(), false, "Unable to measure PSF width for stamp %d", i); 1026 1026 psFree(models); 1027 1027 psFree(modelSums); … … 1034 1034 1035 1035 if (!psThreadPoolWait(true)) { 1036 psError( PS_ERR_UNKNOWN, false, "Error waiting for threads.");1036 psError(psErrorCodeLast(), false, "Error waiting for threads."); 1037 1037 psFree(models); 1038 1038 psFree(modelSums); … … 1047 1047 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); 1048 1048 if (!psVectorStats(stats, ratios, NULL, mask, 0xff)) { 1049 psError( PS_ERR_UNKNOWN, false, "Unable to calculate statistics for moments ratio.");1049 psError(psErrorCodeLast(), false, "Unable to calculate statistics for moments ratio."); 1050 1050 psFree(mask); 1051 1051 psFree(ratios); … … 1083 1083 psTrace("psModules.imcombine", 3, "Calculating %s normalization equation...\n", description); 1084 1084 if (!pmSubtractionCalculateEquation(stamps, kernels, SUBMODE)) { 1085 psError( PS_ERR_UNKNOWN, false, "Unable to calculate least-squares equation.");1085 psError(psErrorCodeLast(), false, "Unable to calculate least-squares equation."); 1086 1086 return false; 1087 1087 } … … 1089 1089 psTrace("psModules.imcombine", 3, "Solving %s normalization equation...\n", description); 1090 1090 if (!pmSubtractionSolveEquation(kernels, stamps, SUBMODE)) { 1091 psError( PS_ERR_UNKNOWN, false, "Unable to calculate least-squares equation.");1091 psError(psErrorCodeLast(), false, "Unable to calculate least-squares equation."); 1092 1092 return false; 1093 1093 } … … 1099 1099 psTrace("psModules.imcombine", 3, "Calculating %s kernel coeffs equation...\n", description); 1100 1100 if (!pmSubtractionCalculateEquation(stamps, kernels, PM_SUBTRACTION_EQUATION_KERNELS)) { 1101 psError( PS_ERR_UNKNOWN, false, "Unable to calculate least-squares equation.");1101 psError(psErrorCodeLast(), false, "Unable to calculate least-squares equation."); 1102 1102 return false; 1103 1103 } … … 1105 1105 psTrace("psModules.imcombine", 3, "Solving %s kernel coeffs equation...\n", description); 1106 1106 if (!pmSubtractionSolveEquation(kernels, stamps, PM_SUBTRACTION_EQUATION_KERNELS)) { 1107 psError( PS_ERR_UNKNOWN, false, "Unable to calculate least-squares equation.");1107 psError(psErrorCodeLast(), false, "Unable to calculate least-squares equation."); 1108 1108 return false; 1109 1109 } … … 1113 1113 psVector *deviations = pmSubtractionCalculateDeviations(stamps, kernels); // Stamp deviations 1114 1114 if (!deviations) { 1115 psError( PS_ERR_UNKNOWN, false, "Unable to calculate deviations.");1115 psError(psErrorCodeLast(), false, "Unable to calculate deviations."); 1116 1116 return false; 1117 1117 } … … 1120 1120 long numRejected = pmSubtractionRejectStamps(kernels, stamps, deviations, subMask, rej); 1121 1121 if (numRejected < 0) { 1122 psError( PS_ERR_UNKNOWN, false, "Unable to reject stamps.");1122 psError(psErrorCodeLast(), false, "Unable to reject stamps."); 1123 1123 psFree(deviations); 1124 1124 return false; … … 1130 1130 psTrace("psModules.imcombine", 3, "Calculating %s normalization equation...\n", description); 1131 1131 if (!pmSubtractionCalculateEquation(stamps, kernels, PM_SUBTRACTION_EQUATION_ALL)) { 1132 psError( PS_ERR_UNKNOWN, false, "Unable to calculate least-squares equation.");1132 psError(psErrorCodeLast(), false, "Unable to calculate least-squares equation."); 1133 1133 return false; 1134 1134 } … … 1136 1136 psTrace("psModules.imcombine", 3, "Resolving %s equation...\n", description); 1137 1137 if (!pmSubtractionSolveEquation(kernels, stamps, PM_SUBTRACTION_EQUATION_ALL)) { 1138 psError( PS_ERR_UNKNOWN, false, "Unable to calculate least-squares equation.");1138 psError(psErrorCodeLast(), false, "Unable to calculate least-squares equation."); 1139 1139 return false; 1140 1140 } … … 1147 1147 psTrace("psModules.imcombine", 3, "Calculating %s normalization equation...\n", description); 1148 1148 if (!pmSubtractionCalculateEquation(stamps, kernels, PM_SUBTRACTION_EQUATION_KERNELS)) { 1149 psError( PS_ERR_UNKNOWN, false, "Unable to calculate least-squares equation.");1149 psError(psErrorCodeLast(), false, "Unable to calculate least-squares equation."); 1150 1150 return false; 1151 1151 } … … 1153 1153 psTrace("psModules.imcombine", 3, "Resolving %s equation...\n", description); 1154 1154 if (!pmSubtractionSolveEquation(kernels, stamps, PM_SUBTRACTION_EQUATION_KERNELS)) { 1155 psError( PS_ERR_UNKNOWN, false, "Unable to calculate least-squares equation.");1155 psError(psErrorCodeLast(), false, "Unable to calculate least-squares equation."); 1156 1156 return false; 1157 1157 } … … 1161 1161 psVector *deviations = pmSubtractionCalculateDeviations(stamps, kernels); // Stamp deviations 1162 1162 if (!deviations) { 1163 psError( PS_ERR_UNKNOWN, false, "Unable to calculate deviations.");1163 psError(psErrorCodeLast(), false, "Unable to calculate deviations."); 1164 1164 return false; 1165 1165 } … … 1167 1167 long numRejected = pmSubtractionRejectStamps(kernels, stamps, deviations, subMask, NAN); 1168 1168 if (numRejected < 0) { 1169 psError( PS_ERR_UNKNOWN, false, "Unable to reject stamps.");1169 psError(psErrorCodeLast(), false, "Unable to reject stamps."); 1170 1170 psFree(deviations); 1171 1171 return false; … … 1191 1191 1192 1192 if (!subtractionModeTest(stamps1, kernels1, "convolve 1", subMask1, rej)) { 1193 psError( PS_ERR_UNKNOWN, false, "Unable to test subtraction with convolution of image 1");1193 psError(psErrorCodeLast(), false, "Unable to test subtraction with convolution of image 1"); 1194 1194 psFree(stamps1); 1195 1195 psFree(kernels1); … … 1206 1206 1207 1207 if (!subtractionModeTest(stamps2, kernels2, "convolve 2", subMask2, rej)) { 1208 psError( PS_ERR_UNKNOWN, false, "Unable to test subtraction with convolution of image 2");1208 psError(psErrorCodeLast(), false, "Unable to test subtraction with convolution of image 2"); 1209 1209 psFree(stamps2); 1210 1210 psFree(kernels2); -
trunk/psModules/src/imcombine/pmSubtractionParams.c
r26893 r27086 8 8 #include <pslib.h> 9 9 10 #include "pmErrorCodes.h" 10 11 #include "pmSubtractionStamps.h" 11 12 #include "pmSubtraction.h" … … 281 282 } 282 283 if (!pmSubtractionConvolveStamp(stamp, kernels, footprint)) { 283 psError( PS_ERR_UNKNOWN, false, "Unable to convolve stamp %d.", i);284 psError(psErrorCodeLast(), false, "Unable to convolve stamp %d.", i); 284 285 psFree(targets); 285 286 psFree(kernels); … … 297 298 } 298 299 if (!isfinite(sum1)) { 299 psError(P S_ERR_BAD_PARAMETER_VALUE, true,300 psError(PM_ERR_DATA, true, 300 301 "Sum of 1/sigma^2 is non-finite for stamp %d (%d,%d)\n", 301 302 i, (int)stamp->x, (int)stamp->y); … … 369 370 370 371 if (bestIndex == -1) { 371 psError(P S_ERR_UNKNOWN, false, "Unable to find best kernel component in round %d.", iter);372 psError(PM_ERR_DATA, true, "Unable to find best kernel component in round %d.", iter); 372 373 psFree(targets); 373 374 psFree(sumC); … … 408 409 409 410 if (cutIndex < 0) { 410 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "Unable to converge to tolerance %g\n", tolerance);411 psError(PM_ERR_DATA, true, "Unable to converge to tolerance %g\n", tolerance); 411 412 psFree(ranking); 412 413 psFree(kernels); -
trunk/psModules/src/imcombine/pmSubtractionStamps.c
r26980 r27086 369 369 if (psRegionIsNaN(*region)) { 370 370 psString string = psRegionToString(*region); 371 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "Input region (%s) contains NAN values", string);371 psError(PM_ERR_PROG, true, "Input region (%s) contains NAN values", string); 372 372 psFree(string); 373 373 return false; … … 376 376 region->y0 < 0 || region->y1 > numRows) { 377 377 psString string = psRegionToString(*region); 378 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "Input region (%s) does not fit in image (%dx%d)",378 psError(PM_ERR_PROG, true, "Input region (%s) does not fit in image (%dx%d)", 379 379 string, numCols, numRows); 380 380 psFree(string); … … 785 785 786 786 if (x < bounds.x0 + size || x > bounds.x1 - size || y < bounds.y0 + size || y > bounds.y1 - size) { 787 psError(P S_ERR_UNKNOWN, false, "Stamp %d (%d,%d) is within the region border.\n", i, x, y);787 psError(PM_ERR_PROG, false, "Stamp %d (%d,%d) is within the region border.\n", i, x, y); 788 788 return false; 789 789 } … … 881 881 882 882 if (!stamps) { 883 psError( PS_ERR_UNKNOWN, false, "Unable to set stamps from sources.");883 psError(psErrorCodeLast(), false, "Unable to set stamps from sources."); 884 884 } 885 885 … … 898 898 psArray *data = psVectorsReadFromFile(filename, "%f %f"); 899 899 if (!data) { 900 psError( PS_ERR_IO, false, "Unable to read stamps file %s", filename);900 psError(psErrorCodeLast(), false, "Unable to read stamps file %s", filename); 901 901 return NULL; 902 902 }
Note:
See TracChangeset
for help on using the changeset viewer.
