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/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;
Note: See TracChangeset for help on using the changeset viewer.