IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 27086


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

Fixing error codes for PSF-matching.

Location:
trunk/psModules/src/imcombine
Files:
8 edited

Legend:

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

    r26893 r27086  
    1717#include <pslib.h>
    1818
     19#include "pmErrorCodes.h"
    1920#include "pmHDU.h"                      // Required for pmFPA.h
    2021#include "pmFPA.h"
     
    752753
    753754    if (stamp->status != PM_SUBTRACTION_STAMP_CALCULATE) {
    754         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Stamp not marked for calculation.");
     755        psError(PM_ERR_PROG, true, "Stamp not marked for calculation.");
    755756        return false;
    756757    }
     
    808809
    809810    if (numStamps == 0) {
    810         psError(PS_ERR_UNKNOWN, true, "No good stamps found.");
     811        psError(PM_ERR_STAMPS, true, "No good stamps found.");
    811812        psFree(mask);
    812813        return -1;
     
    816817                                  PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_QUARTILE); // Statistics for deviatns
    817818    if (!psVectorStats(stats, deviations, NULL, mask, 0xff)) {
    818         psError(PS_ERR_UNKNOWN, false, "Unable to measure statistics for deviations.");
     819        psError(PM_ERR_DATA, false, "Unable to measure statistics for deviations.");
    819820        psFree(stats);
    820821        psFree(mask);
     
    11991200    if (region && psRegionIsNaN(*region)) {
    12001201        psString string = psRegionToString(*region);
    1201         psError(PS_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);
    12021203        psFree(string);
    12031204        return false;
     
    13031304
    13041305    if (!psThreadPoolWait(false)) {
    1305         psError(PS_ERR_UNKNOWN, false, "Error waiting for threads.");
     1306        psError(psErrorCodeLast(), false, "Error waiting for threads.");
    13061307        return false;
    13071308    }
  • trunk/psModules/src/imcombine/pmSubtractionAnalysis.c

    r26893 r27086  
    7474                                                           false); // Image of the kernel
    7575                if (!kernel) {
    76                     psError(PS_ERR_UNKNOWN, false, "Unable to generate kernel image.");
     76                    psError(psErrorCodeLast(), false, "Unable to generate kernel image.");
    7777                    psFree(convKernels);
    7878                    return false;
     
    8181                if (psImageOverlaySection(convKernels, kernel, (i + KERNEL_MOSAIC) * fullSize,
    8282                                          (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.");
    8484                    psFree(kernel);
    8585                    psFree(convKernels);
     
    9393                                                      true); // Image of the kernel
    9494                    if (!kernel) {
    95                         psError(PS_ERR_UNKNOWN, false, "Unable to generate kernel image.");
     95                        psError(psErrorCodeLast(), false, "Unable to generate kernel image.");
    9696                        psFree(convKernels);
    9797                        return false;
     
    101101                                              (2 * KERNEL_MOSAIC + 1 + i + KERNEL_MOSAIC) * fullSize + 4,
    102102                                              (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.");
    104104                        psFree(kernel);
    105105                        psFree(convKernels);
     
    161161        psImage *image = pmSubtractionKernelImage(kernels, 0.5, 0.5, false); // Image of the kernel
    162162        if (!image) {
    163             psError(PS_ERR_UNKNOWN, false, "Unable to generate image of kernel.");
     163            psError(psErrorCodeLast(), false, "Unable to generate image of kernel.");
    164164            return false;
    165165        }
     
    216216        psImage *image = pmSubtractionKernelImage(kernels, 0.5, 0.5, false); // Image of the kernel
    217217        if (!image) {
    218             psError(PS_ERR_UNKNOWN, false, "Unable to generate image of kernel.");
     218            psError(psErrorCodeLast(), false, "Unable to generate image of kernel.");
    219219            return false;
    220220        }
  • trunk/psModules/src/imcombine/pmSubtractionEquation.c

    r26893 r27086  
    77#include <pslib.h>
    88
     9#include "pmErrorCodes.h"
    910#include "pmSubtraction.h"
    1011#include "pmSubtractionKernels.h"
     
    718719    // Generate convolutions: these are generated once and saved
    719720    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);
    721722        return NULL;
    722723    }
     
    869870
    870871    if (!psThreadPoolWait(true)) {
    871         psError(PS_ERR_UNKNOWN, false, "Error waiting for threads.");
     872        psError(psErrorCodeLast(), false, "Error waiting for threads.");
    872873        return false;
    873874    }
     
    989990            psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); // Statistics for norm
    990991            if (!psVectorStats(stats, norms, NULL, NULL, 0)) {
    991                 psError(PS_ERR_UNKNOWN, false, "Unable to determine median normalisation");
     992                psError(PM_ERR_DATA, false, "Unable to determine median normalisation");
    992993                psFree(stats);
    993994                psFree(sumMatrix);
     
    11341135            psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); // Statistics for norm
    11351136            if (!psVectorStats(stats, norms, NULL, NULL, 0)) {
    1136                 psError(PS_ERR_UNKNOWN, false, "Unable to determine median normalisation");
     1137                psError(PM_ERR_DATA, false, "Unable to determine median normalisation");
    11371138                psFree(stats);
    11381139                psFree(sumMatrix);
     
    13711372                                                          false); // Kernel image
    13721373                if (!image) {
    1373                     psError(PS_ERR_UNKNOWN, false, "Unable to generate image of kernel.");
     1374                    psError(psErrorCodeLast(), false, "Unable to generate image of kernel.");
    13741375                    return false;
    13751376                }
     
    19471948            psVector *w = NULL;
    19481949            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");
    19501951                return NULL;
    19511952            }
     
    20872088            psImage *luMatrix = psMatrixLUDecomposition(NULL, &permutation, sumMatrix);
    20882089            if (!luMatrix) {
    2089                 psError(PS_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");
    20902091                psFree(solution);
    20912092                psFree(sumVector);
     
    21002101            psFree(permutation);
    21012102            if (!solution) {
    2102                 psError(PS_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");
    21032104                psFree(solution);
    21042105                psFree(sumVector);
  • trunk/psModules/src/imcombine/pmSubtractionIO.c

    r26893 r27086  
    33#include <string.h>
    44
     5#include "pmErrorCodes.h"
    56#include "pmHDU.h"
    67#include "pmHDUUtils.h"
     
    6667    }
    6768    if (regions->n == 0) {
    68         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "No subtraction regions found.");
     69        psError(PM_ERR_PROG, true, "No subtraction regions found.");
    6970        psFree(regions);
    7071        return false;
     
    8788
    8889    if (regions->n != kernels->n) {
    89         psError(PS_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",
    9091                regions->n, kernels->n);
    9192        psFree(regions);
     
    165166
    166167    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.");
    168169        psFree(header);
    169170        psFree(rows);
     
    175176
    176177    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.");
    178179        psFree(header);
    179180        psFree(rows);
     
    201202        thisView->readout = i;
    202203        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);
    204205            psFree(thisView);
    205206            return false;
     
    224225        thisView->cell = i;
    225226        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);
    227228            psFree(thisView);
    228229            return false;
     
    247248        thisView->chip = i;
    248249        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);
    250251            psFree(thisView);
    251252            return false;
     
    265266
    266267    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.");
    268269        return false;
    269270    }
     
    271272    psArray *table = psFitsReadTable(fits); // Table of interest
    272273    if (!table) {
    273         psError(PS_ERR_IO, false, "Unable to read FITS table");
     274        psError(psErrorCodeLast(), false, "Unable to read FITS table");
    274275        return false;
    275276    }
     
    282283        TARGET = psMetadataLookup##SUFFIX(&mdok, row, NAME); \
    283284        if (!mdok) { \
    284             psError(PS_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); \
    285286            psFree(table); \
    286287            return false; \
     
    325326            kernels->solution1 = psMemIncrRefCounter(psMetadataLookupPtr(&mdok, row, NAME_SOL1));
    326327            if (!mdok) {
    327                 psError(PS_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.",
    328329                        NAME_SOL1);
    329330                psFree(kernels);
     
    335336            kernels->solution1 = psMemIncrRefCounter(psMetadataLookupPtr(&mdok, row, NAME_SOL1));
    336337            if (!mdok) {
    337                 psError(PS_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.",
    338339                        NAME_SOL1);
    339340                psFree(kernels);
     
    343344            kernels->solution2 = psMemIncrRefCounter(psMetadataLookupPtr(&mdok, row, NAME_SOL2));
    344345            if (!mdok) {
    345                 psError(PS_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.",
    346347                        NAME_SOL2);
    347348                psFree(kernels);
     
    379380        pmReadout *readout = cell->readouts->data[i];
    380381        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        }
    382387        if (!readout->data_exists) {
    383388            continue;
     
    410415        pmCell *cell = chip->cells->data[i];
    411416        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) {
    414423            continue;
    415424        }
     
    419428
    420429    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");
    422431        return false;
    423432    }
     
    440449        pmChip *chip = fpa->chips->data[i];
    441450        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        }
    443456    }
    444457    psFree(thisView);
    445458
    446459    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");
    448461        return false;
    449462    }
     
    464477    if (view->chip == -1) {
    465478        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");
    467480            psFree(fpa);
    468481            return false;
     
    473486
    474487    if (view->chip >= fpa->chips->n) {
    475         psError(PS_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);
    476489        psFree(fpa);
    477490        return false;
     
    481494    if (view->cell == -1) {
    482495        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");
    484497            psFree(fpa);
    485498            return false;
     
    490503
    491504    if (view->cell >= chip->cells->n) {
    492         psError(PS_ERR_UNKNOWN, false, "Writing cell == %d (>= cells->n == %ld)",
     505        psError(PM_ERR_PROG, true, "Writing cell == %d (>= cells->n == %ld)",
    493506                view->cell, chip->cells->n);
    494507        psFree(fpa);
     
    499512    if (view->readout == -1) {
    500513        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");
    502515            psFree(fpa);
    503516            return false;
     
    508521
    509522    if (view->readout >= cell->readouts->n) {
    510         psError(PS_ERR_UNKNOWN, false, "Writing readout == %d (>= readouts->n == %ld)",
     523        psError(PM_ERR_PROG, true, "Writing readout == %d (>= readouts->n == %ld)",
    511524                view->readout, cell->readouts->n);
    512525        psFree(fpa);
     
    516529
    517530    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);
    519532        psFree(fpa);
    520533        return false;
  • trunk/psModules/src/imcombine/pmSubtractionMask.c

    r26893 r27086  
    146146    if (!psImageConvolveMask(mask, mask, PM_SUBTRACTION_MASK_BAD_1, PM_SUBTRACTION_MASK_CONVOLVE_1,
    147147                             -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.");
    149149        psFree(mask);
    150150        return NULL;
     
    152152    if (!psImageConvolveMask(mask, mask, PM_SUBTRACTION_MASK_BAD_2, PM_SUBTRACTION_MASK_CONVOLVE_2,
    153153                             -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.");
    155155        psFree(mask);
    156156        return NULL;
     
    176176    if (!psImageConvolveMask(mask, mask, maskRej, PM_SUBTRACTION_MASK_REJ,
    177177                             -footprint, footprint, -footprint, footprint)) {
    178         psError(PS_ERR_UNKNOWN, false, "Unable to convolve bad pixels.");
     178        psError(psErrorCodeLast(), false, "Unable to convolve bad pixels.");
    179179        psFree(mask);
    180180        return NULL;
  • 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);
  • trunk/psModules/src/imcombine/pmSubtractionParams.c

    r26893 r27086  
    88#include <pslib.h>
    99
     10#include "pmErrorCodes.h"
    1011#include "pmSubtractionStamps.h"
    1112#include "pmSubtraction.h"
     
    281282        }
    282283        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);
    284285            psFree(targets);
    285286            psFree(kernels);
     
    297298        }
    298299        if (!isfinite(sum1)) {
    299             psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     300            psError(PM_ERR_DATA, true,
    300301                    "Sum of 1/sigma^2 is non-finite for stamp %d (%d,%d)\n",
    301302                    i, (int)stamp->x, (int)stamp->y);
     
    369370
    370371        if (bestIndex == -1) {
    371             psError(PS_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);
    372373            psFree(targets);
    373374            psFree(sumC);
     
    408409
    409410    if (cutIndex < 0) {
    410         psError(PS_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);
    411412        psFree(ranking);
    412413        psFree(kernels);
  • trunk/psModules/src/imcombine/pmSubtractionStamps.c

    r26980 r27086  
    369369        if (psRegionIsNaN(*region)) {
    370370            psString string = psRegionToString(*region);
    371             psError(PS_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);
    372372            psFree(string);
    373373            return false;
     
    376376            region->y0 < 0 || region->y1 > numRows) {
    377377            psString string = psRegionToString(*region);
    378             psError(PS_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)",
    379379                    string, numCols, numRows);
    380380            psFree(string);
     
    785785
    786786        if (x < bounds.x0 + size || x > bounds.x1 - size || y < bounds.y0 + size || y > bounds.y1 - size) {
    787             psError(PS_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);
    788788            return false;
    789789        }
     
    881881
    882882    if (!stamps) {
    883         psError(PS_ERR_UNKNOWN, false, "Unable to set stamps from sources.");
     883        psError(psErrorCodeLast(), false, "Unable to set stamps from sources.");
    884884    }
    885885
     
    898898    psArray *data = psVectorsReadFromFile(filename, "%f %f");
    899899    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);
    901901        return NULL;
    902902    }
Note: See TracChangeset for help on using the changeset viewer.