Changeset 27086 for trunk/psModules/src/imcombine/pmSubtractionMatch.c
- Timestamp:
- Feb 25, 2010, 12:33:42 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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);
Note:
See TracChangeset
for help on using the changeset viewer.
