IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 25, 2010, 12:33:42 PM (16 years ago)
Author:
Paul Price
Message:

Fixing error codes for PSF-matching.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/imcombine/pmSubtractionMatch.c

    r27040 r27086  
    104104    psTrace("psModules.imcombine", 3, "Extracting stamps...\n");
    105105    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.");
    107107        return false;
    108108    }
     
    318318        while ((item = psMetadataGetAndIncrement(iter))) {
    319319            if (item->type != PS_DATA_UNKNOWN) {
    320                 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unexpected type for kernel.");
     320                psError(PM_ERR_PROG, true, "Unexpected type for kernel.");
    321321                psFree(iter);
    322322                psFree(kernelList);
     
    338338    }
    339339    if (psListLength(kernelList) == 0) {
    340         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to find kernels");
     340        psError(PM_ERR_PROG, true, "Unable to find kernels");
    341341        psFree(kernelList);
    342342        return false;
     
    353353        while ((item = psMetadataGetAndIncrement(iter))) {
    354354            if (item->type != PS_DATA_REGION) {
    355                 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unexpected type for region.");
     355                psError(PM_ERR_PROG, true, "Unexpected type for region.");
    356356                psFree(iter);
    357357                psFree(kernels);
     
    365365    }
    366366    if (regions->n != kernels->n) {
    367         psError(PS_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)",
    368368                kernels->n, regions->n);
    369369        psFree(regions);
     
    406406        if (!pmSubtractionAnalysis(outAnalysis, outHeader, kernel, region,
    407407                                   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");
    409409            psFree(outAnalysis);
    410410            psFree(outHeader);
     
    417417        if (!pmSubtractionConvolve(conv1, conv2, ro1, ro2, subMask, stride, maskBad, maskPoor, poorFrac,
    418418                                   kernelError, covarFrac, region, kernel, true, useFFT)) {
    419             psError(PS_ERR_UNKNOWN, false, "Unable to convolve image.");
     419            psError(psErrorCodeLast(), false, "Unable to convolve image.");
    420420            psFree(outAnalysis);
    421421            psFree(outHeader);
     
    555555            psStatsInit(bg);
    556556            if (!psImageBackground(bg, NULL, ro1->image, ro1->mask, maskVal, rng)) {
    557                 psError(PS_ERR_UNKNOWN, false, "Unable to measure background statistics.");
     557                psError(PM_ERR_DATA, false, "Unable to measure background statistics.");
    558558                psFree(bg);
    559559                goto MATCH_ERROR;
     
    565565            psStatsInit(bg);
    566566            if (!psImageBackground(bg, NULL, ro2->image, ro2->mask, maskVal, rng)) {
    567                 psError(PS_ERR_UNKNOWN, false, "Unable to measure background statistics.");
     567                psError(PM_ERR_DATA, false, "Unable to measure background statistics.");
    568568                psFree(bg);
    569569                goto MATCH_ERROR;
     
    640640                psVector *buffer = NULL;// Buffer for stats
    641641                if (!psImageBackground(bgStats, &buffer, ro1->image, ro1->mask, maskVal, rng)) {
    642                     psError(PS_ERR_UNKNOWN, false, "Unable to measure background of image 1.");
     642                    psError(PM_ERR_DATA, false, "Unable to measure background of image 1.");
    643643                    psFree(bgStats);
    644644                    psFree(buffer);
     
    647647                float bg1 = psStatsGetValue(bgStats, BG_STAT); // Background for image 1
    648648                if (!psImageBackground(bgStats, &buffer, ro2->image, ro2->mask, maskVal, rng)) {
    649                     psError(PS_ERR_UNKNOWN, false, "Unable to measure background of image 2.");
     649                    psError(PM_ERR_DATA, false, "Unable to measure background of image 2.");
    650650                    psFree(bgStats);
    651651                    psFree(buffer);
     
    667667                    break;
    668668                  default:
    669                     psError(PS_ERR_UNKNOWN, false, "Unable to determine subtraction order.");
     669                    psError(psErrorCodeLast(), false, "Unable to determine subtraction order.");
    670670                    goto MATCH_ERROR;
    671671                }
     
    685685                // generate the window function from the set of stamps
    686686                if (!pmSubtractionStampsGetWindow(stamps, size)) {
    687                     psError(PS_ERR_UNKNOWN, false, "Unable to get stamps window.");
     687                    psError(psErrorCodeLast(), false, "Unable to get stamps window.");
    688688                    goto MATCH_ERROR;
    689689                }
     
    692692                psTrace("psModules.imcombine", 3, "Calculating equation for normalization...\n");
    693693                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.");
    695695                    goto MATCH_ERROR;
    696696                }
     
    698698                psTrace("psModules.imcombine", 3, "Solving equation for normalization...\n");
    699699                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.");
    701701                    goto MATCH_ERROR;
    702702                }
     
    710710                psTrace("psModules.imcombine", 3, "Calculating equation for kernels...\n");
    711711                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.");
    713713                    goto MATCH_ERROR;
    714714                }
     
    717717                psTrace("psModules.imcombine", 3, "Solving equation for kernels...\n");
    718718                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.");
    720720                    goto MATCH_ERROR;
    721721                }
     
    724724                psVector *deviations = pmSubtractionCalculateDeviations(stamps, kernels); // Stamp deviations
    725725                if (!deviations) {
    726                     psError(PS_ERR_UNKNOWN, false, "Unable to calculate deviations.");
     726                    psError(psErrorCodeLast(), false, "Unable to calculate deviations.");
    727727                    goto MATCH_ERROR;
    728728                }
     
    733733                numRejected = pmSubtractionRejectStamps(kernels, stamps, deviations, subMask, rej);
    734734                if (numRejected < 0) {
    735                     psError(PS_ERR_UNKNOWN, false, "Unable to reject stamps.");
     735                    psError(psErrorCodeLast(), false, "Unable to reject stamps.");
    736736                    psFree(deviations);
    737737                    goto MATCH_ERROR;
     
    747747                psTrace("psModules.imcombine", 3, "Calculating equation for normalization...\n");
    748748                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.");
    750750                    goto MATCH_ERROR;
    751751                }
     
    754754                psTrace("psModules.imcombine", 3, "Solving equation for kernels...\n");
    755755                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.");
    757757                    goto MATCH_ERROR;
    758758                }
     
    765765                psTrace("psModules.imcombine", 3, "Calculating equation for normalization...\n");
    766766                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.");
    768768                    goto MATCH_ERROR;
    769769                }
     
    772772                psTrace("psModules.imcombine", 3, "Solving equation for kernels...\n");
    773773                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.");
    775775                    goto MATCH_ERROR;
    776776                }
     
    779779                psVector *deviations = pmSubtractionCalculateDeviations(stamps, kernels); // Stamp deviations
    780780                if (!deviations) {
    781                     psError(PS_ERR_UNKNOWN, false, "Unable to calculate deviations.");
     781                    psError(psErrorCodeLast(), false, "Unable to calculate deviations.");
    782782                    goto MATCH_ERROR;
    783783                }
     
    791791
    792792            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");
    794794                goto MATCH_ERROR;
    795795            }
     
    800800            if (!pmSubtractionConvolve(conv1, conv2, ro1, ro2, subMask, stride, maskBad, maskPoor, poorFrac,
    801801                                       kernelError, covarFrac, region, kernels, true, useFFT)) {
    802                 psError(PS_ERR_UNKNOWN, false, "Unable to convolve image.");
     802                psError(psErrorCodeLast(), false, "Unable to convolve image.");
    803803                goto MATCH_ERROR;
    804804            }
     
    820820
    821821    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.");
    823823        goto MATCH_ERROR;
    824824    }
    825825    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.");
    827827        goto MATCH_ERROR;
    828828    }
     
    10231023        } else {
    10241024            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);
    10261026                psFree(models);
    10271027                psFree(modelSums);
     
    10341034
    10351035    if (!psThreadPoolWait(true)) {
    1036         psError(PS_ERR_UNKNOWN, false, "Error waiting for threads.");
     1036        psError(psErrorCodeLast(), false, "Error waiting for threads.");
    10371037        psFree(models);
    10381038        psFree(modelSums);
     
    10471047    psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN);
    10481048    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.");
    10501050        psFree(mask);
    10511051        psFree(ratios);
     
    10831083    psTrace("psModules.imcombine", 3, "Calculating %s normalization equation...\n", description);
    10841084    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.");
    10861086        return false;
    10871087    }
     
    10891089    psTrace("psModules.imcombine", 3, "Solving %s normalization equation...\n", description);
    10901090    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.");
    10921092        return false;
    10931093    }
     
    10991099    psTrace("psModules.imcombine", 3, "Calculating %s kernel coeffs equation...\n", description);
    11001100    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.");
    11021102        return false;
    11031103    }
     
    11051105    psTrace("psModules.imcombine", 3, "Solving %s kernel coeffs equation...\n", description);
    11061106    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.");
    11081108        return false;
    11091109    }
     
    11131113    psVector *deviations = pmSubtractionCalculateDeviations(stamps, kernels); // Stamp deviations
    11141114    if (!deviations) {
    1115         psError(PS_ERR_UNKNOWN, false, "Unable to calculate deviations.");
     1115        psError(psErrorCodeLast(), false, "Unable to calculate deviations.");
    11161116        return false;
    11171117    }
     
    11201120    long numRejected = pmSubtractionRejectStamps(kernels, stamps, deviations, subMask, rej);
    11211121    if (numRejected < 0) {
    1122         psError(PS_ERR_UNKNOWN, false, "Unable to reject stamps.");
     1122        psError(psErrorCodeLast(), false, "Unable to reject stamps.");
    11231123        psFree(deviations);
    11241124        return false;
     
    11301130        psTrace("psModules.imcombine", 3, "Calculating %s normalization equation...\n", description);
    11311131        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.");
    11331133            return false;
    11341134        }
     
    11361136        psTrace("psModules.imcombine", 3, "Resolving %s equation...\n", description);
    11371137        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.");
    11391139            return false;
    11401140        }
     
    11471147        psTrace("psModules.imcombine", 3, "Calculating %s normalization equation...\n", description);
    11481148        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.");
    11501150            return false;
    11511151        }
     
    11531153        psTrace("psModules.imcombine", 3, "Resolving %s equation...\n", description);
    11541154        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.");
    11561156            return false;
    11571157        }
     
    11611161        psVector *deviations = pmSubtractionCalculateDeviations(stamps, kernels); // Stamp deviations
    11621162        if (!deviations) {
    1163             psError(PS_ERR_UNKNOWN, false, "Unable to calculate deviations.");
     1163            psError(psErrorCodeLast(), false, "Unable to calculate deviations.");
    11641164            return false;
    11651165        }
     
    11671167        long numRejected = pmSubtractionRejectStamps(kernels, stamps, deviations, subMask, NAN);
    11681168        if (numRejected < 0) {
    1169             psError(PS_ERR_UNKNOWN, false, "Unable to reject stamps.");
     1169            psError(psErrorCodeLast(), false, "Unable to reject stamps.");
    11701170            psFree(deviations);
    11711171            return false;
     
    11911191
    11921192    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");
    11941194        psFree(stamps1);
    11951195        psFree(kernels1);
     
    12061206
    12071207    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");
    12091209        psFree(stamps2);
    12101210        psFree(kernels2);
Note: See TracChangeset for help on using the changeset viewer.