IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 27004


Ignore:
Timestamp:
Feb 18, 2010, 6:42:01 PM (16 years ago)
Author:
Paul Price
Message:

Reworked ppStack to be better about error codes and their translation to exit codes.

Location:
trunk
Files:
3 added
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStack/configure.ac

    r23801 r27004  
    2222PKG_CHECK_MODULES([PPSTATS],  [ppStats >= 1.0.0])
    2323
     24AC_PATH_PROG([ERRORCODES], [psParseErrorCodes], [missing])
     25if test "$ERRORCODES" = "missing" ; then
     26  AC_MSG_ERROR([psParseErrorCodes is required])
     27fi
     28
    2429IPP_STDOPTS
    2530CFLAGS="${CFLAGS=} -Wall -Werror"
  • trunk/ppStack/src

    • Property svn:ignore
      •  

        old new  
        1010stamp-h1
        1111ppStackVersionDefinitions.h
         12ppStackErrorCodes.c
         13ppStackErrorCodes.h
  • trunk/ppStack/src/Makefile.am

    r23808 r27004  
    4747        ppStackCleanup.c        \
    4848        ppStackPhotometry.c     \
    49         ppStackFinish.c
     49        ppStackFinish.c         \
     50        ppStackErrorCodes.c
    5051
    5152noinst_HEADERS =                \
     
    5354        ppStackLoop.h           \
    5455        ppStackOptions.h        \
    55         ppStackThread.h
     56        ppStackThread.h         \
     57        ppStackErrorCodes.h
     58
     59### Error codes.
     60BUILT_SOURCES = ppStackErrorCodes.h ppStackErrorCodes.c
     61CLEANFILES = ppStackErrorCodes.h ppStackErrorCodes.c
     62
     63ppStackErrorCodes.h : ppStackErrorCodes.dat ppStackErrorCodes.h.in
     64        $(ERRORCODES) --data=ppStackErrorCodes.dat --outdir=. ppStackErrorCodes.h
     65
     66ppStackErrorCodes.c : ppStackErrorCodes.dat ppStackErrorCodes.c.in ppStackErrorCodes.h
     67        $(ERRORCODES) --data=ppStackErrorCodes.dat --outdir=. ppStackErrorCodes.c
     68
    5669
    5770CLEANFILES = *~
  • trunk/ppStack/src/ppStack.c

    r23341 r27004  
    1515int main(int argc, char *argv[])
    1616{
    17     psExit exitValue = PS_EXIT_SUCCESS; // Exit value
     17    psLibInit(NULL);
    1818    psTimerStart(TIMER_NAME);
    1919    psTimerStart("PPSTACK_STEPS");
    20     psLibInit(NULL);
    2120
    2221    pmConfig *config = pmConfigRead(&argc, argv, PPSTACK_RECIPE); // Configuration
    2322    if (!config) {
    24         psErrorStackPrint(stderr, "Error reading configuration.");
    25         exitValue = PS_EXIT_CONFIG_ERROR;
    26         goto die;
    27     }
    28 
    29     (void) psTraceSetLevel("ppStack", 5);
    30 
    31     if (!ppStackArgumentsSetup(argc, argv, config)) {
    32         psErrorStackPrint(stderr, "Error reading arguments.\n");
    33         exitValue = PS_EXIT_CONFIG_ERROR;
    3423        goto die;
    3524    }
     
    3827
    3928    if (!pmModelClassInit()) {
    40         psErrorStackPrint(stderr, "Error initialising model classes.\n");
    41         exitValue = PS_EXIT_PROG_ERROR;
     29        psError(PPSTACK_ERR_PROG, false, "Unable to initialise model classes.");
    4230        goto die;
    4331    }
    4432
    4533    if (!psphotInit()) {
    46         psErrorStackPrint(stderr, "Error initialising psphot.\n");
    47         exitValue = PS_EXIT_PROG_ERROR;
     34        psError(PPSTACK_ERR_PROG, false, "Error initialising psphot.");
     35        goto die;
     36    }
     37
     38    (void)psTraceSetLevel("ppStack", 5);
     39
     40    if (!ppStackArgumentsSetup(argc, argv, config)) {
    4841        goto die;
    4942    }
    5043
    5144    if (!ppStackCamera(config)) {
    52         psErrorStackPrint(stderr, "Error setting up input files.\n");
    53         exitValue = PS_EXIT_CONFIG_ERROR;
    5445        goto die;
    5546    }
    5647
    5748    if (!ppStackArgumentsParse(config)) {
    58         psErrorStackPrint(stderr, "Error reading arguments.\n");
    59         exitValue = PS_EXIT_CONFIG_ERROR;
    6049        goto die;
    6150    }
    6251
    6352    if (!ppStackLoop(config)) {
    64         psErrorStackPrint(stderr, "Error performing combination.\n");
    65         exitValue = PS_EXIT_DATA_ERROR;
    6653        goto die;
    6754    }
     
    7865    psLibFinalize();
    7966    pmVisualClose();
     67
     68    psExit exitValue = PS_EXIT_SUCCESS;        // Exit value for program
     69    psErrorCode errorCode = psErrorCodeLast(); // Error code
     70    if (errorCode != PS_ERR_NONE) {
     71        psErrorStackPrint(stderr, "Unable to perform stack.");
     72        switch (errorCode) {
     73          case PPSTACK_ERR_UNKNOWN:
     74          case PS_ERR_UNKNOWN:
     75            exitValue = PS_EXIT_UNKNOWN_ERROR;
     76            break;
     77          case PS_ERR_IO:
     78          case PS_ERR_DB_CLIENT:
     79          case PS_ERR_DB_SERVER:
     80          case PS_ERR_BAD_FITS:
     81          case PS_ERR_OS_CALL_FAILED:
     82          case PPSTACK_ERR_IO:
     83            exitValue = PS_EXIT_SYS_ERROR;
     84            break;
     85          case PS_ERR_BAD_PARAMETER_VALUE:
     86          case PS_ERR_BAD_PARAMETER_TYPE:
     87          case PS_ERR_BAD_PARAMETER_NULL:
     88          case PS_ERR_BAD_PARAMETER_SIZE:
     89          case PPSTACK_ERR_ARGUMENTS:
     90          case PPSTACK_ERR_CONFIG:
     91            exitValue = PS_EXIT_CONFIG_ERROR;
     92            break;
     93          case PPSTACK_ERR_PSF:
     94          case PPSTACK_ERR_REJECTED:
     95          case PPSTACK_ERR_DATA:
     96            exitValue = PS_EXIT_DATA_ERROR;
     97            break;
     98          case PS_ERR_UNEXPECTED_NULL:
     99          case PS_ERR_PROGRAMMING:
     100          case PPSTACK_ERR_NOT_IMPLEMENTED:
     101          case PPSTACK_ERR_PROG:
     102          default:
     103            // It's a programming error if we're not dealing with the error correctly
     104            exitValue = PS_EXIT_PROG_ERROR;
     105            break;
     106        }
     107    }
     108
    80109    exit(exitValue);
    81110}
  • trunk/ppStack/src/ppStack.h

    r26898 r27004  
    99
    1010#include "ppStackOptions.h"
     11#include "ppStackErrorCodes.h"
    1112
    1213// Mask values for inputs
  • trunk/ppStack/src/ppStackArguments.c

    r26078 r27004  
    4343        value = psMetadataLookup##TYPE(&mdok, recipe, RECIPENAME); \
    4444        if (!mdok) { \
    45             psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to find %s in recipe %s", \
     45            psError(PPSTACK_ERR_CONFIG, true, "Unable to find %s in recipe %s", \
    4646                RECIPENAME, PPSTACK_RECIPE); \
    4747            goto ERROR; \
     
    5858        value = psMetadataLookup##TYPE(&mdok, recipe, RECIPENAME); \
    5959        if (!mdok) { \
    60             psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to find %s in recipe %s", \
     60            psError(PPSTACK_ERR_CONFIG, true, "Unable to find %s in recipe %s", \
    6161                RECIPENAME, PPSTACK_RECIPE); \
    6262            goto ERROR; \
     
    7373        name = psMetadataLookupStr(NULL, recipe, RECIPENAME); \
    7474        if (!name) { \
    75             psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to find %s in recipe %s", \
    76                 RECIPENAME, PPSTACK_RECIPE); \
     75            psError(PPSTACK_ERR_CONFIG, true, "Unable to find %s in recipe %s", \
     76                    RECIPENAME, PPSTACK_RECIPE);                        \
    7777            goto ERROR; \
    7878        } \
     
    108108        value = psMetadataLookupStr(NULL, recipe, mdName);
    109109        if (!value) {
    110             psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to find %s in recipe %s",
     110            psError(PPSTACK_ERR_CONFIG, true, "Unable to find %s in recipe %s",
    111111                    mdName, PPSTACK_RECIPE);
    112112            return false;
     
    207207        psMetadata *inputs = psMetadataConfigRead(NULL, &numBad, argv[argNum], false); // Input file info
    208208        if (!inputs || numBad > 0) {
    209             psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to cleanly read MDC file with inputs.");
     209            psError(PPSTACK_ERR_ARGUMENTS, false, "Unable to cleanly read MDC file with inputs.");
    210210            return false;
    211211        }
     
    229229    int numThreads = psMetadataLookupS32(NULL, arguments, "-threads"); // Number of threads
    230230    if (numThreads > 0 && !psThreadPoolInit(numThreads)) {
    231         psError(PS_ERR_UNKNOWN, false, "Unable to setup %d threads", numThreads);
     231        psError(PPSTACK_ERR_ARGUMENTS, false, "Unable to setup %d threads", numThreads);
    232232        return false;
    233233    }
     
    247247    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // Recipe
    248248    if (!recipe) {
    249         psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSTACK_RECIPE);
     249        psError(PPSTACK_ERR_CONFIG, false, "Unable to find recipe %s", PPSTACK_RECIPE);
    250250        goto ERROR;
    251251    }
  • trunk/ppStack/src/ppStackCamera.c

    r26898 r27004  
    3030        pmFPAfileDefineFromArgs(&found, config, name, "FILENAMES");
    3131    if (!file || !found) {
    32         psError(PS_ERR_UNKNOWN, false, "Unable to define file %s from %s", name, filename);
     32        psError(psErrorCodeLast(), false, "Unable to define file %s from %s", name, filename);
    3333        return NULL;
    3434    }
    3535    if (file->type != type) {
    36         psError(PS_ERR_IO, true, "%s is not of type %s", name, pmFPAfileStringFromType(type));
     36        psError(PS_ERR_IO, PPSTACK_ERR_CONFIG, "%s is not of type %s", name, pmFPAfileStringFromType(type));
    3737        return NULL;
    3838    }
     
    5353    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // Recipe for ppSim
    5454    if (!recipe) {
    55         psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSTACK_RECIPE);
     55        psError(PPSTACK_ERR_CONFIG, false, "Unable to find recipe %s", PPSTACK_RECIPE);
    5656        return false;
    5757    }
     
    6767                                                           "PPSTACK.INPUT.MASK"); // Input masks
    6868        if (!status) {
    69             psError(PS_ERR_UNKNOWN, false, "Unable to define input masks from RUN metadata.");
     69            psError(psErrorCodeLast(), false, "Unable to define input masks from RUN metadata.");
    7070            psFree(runImages);
    7171            return false;
     
    7676                                                          "PPSTACK.INPUT.VARIANCE"); // Input variances
    7777        if (!status) {
    78             psError(PS_ERR_UNKNOWN, false, "Unable to define input variances from RUN metadata.");
     78            psError(psErrorCodeLast(), false, "Unable to define input variances from RUN metadata.");
    7979            psFree(runImages);
    8080            return false;
     
    8888                                                         "PPSTACK.INPUT.SOURCES"); // Input sources
    8989        if (!status) {
    90             psError(PS_ERR_UNKNOWN, false, "Unable to define input sources from RUN metadata.");
     90            psError(psErrorCodeLast(), false, "Unable to define input sources from RUN metadata.");
    9191            psFree(runImages);
    9292            return false;
    9393        }
    9494        if (!runSrc) {
    95             psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to define input sources from RUN metadata.");
     95            psError(PPSTACK_ERR_CONFIG, true, "Unable to define input sources from RUN metadata.");
    9696            psFree(runImages);
    9797            return false;
     
    104104                                                         "PPSTACK.INPUT.PSF"); // Input PSFs
    105105                if (!status) {
    106                     psError(PS_ERR_UNKNOWN, false, "Unable to define input PSFs from RUN metadata.");
     106                    psError(psErrorCodeLast(), false, "Unable to define input PSFs from RUN metadata.");
    107107                    psFree(runImages);
    108108                    return false;
     
    118118                                                                    "PPSTACK.CONV.KERNEL"); // Conv'n kernels
    119119                if (!status) {
    120                     psError(PS_ERR_UNKNOWN, false, "Unable to define convolution kernels from RUN metadata.");
     120                    psError(psErrorCodeLast(), false,
     121                            "Unable to define convolution kernels from RUN metadata.");
    121122                    psFree(runImages);
    122123                    return false;
    123124                }
    124125                if (!runKernel) {
    125                     psError(PS_ERR_UNEXPECTED_NULL, true,
     126                    psError(PPSTACK_ERR_CONFIG, true,
    126127                            "Unable to define convolution kernels from RUN metadata.");
    127128                    psFree(runImages);
     
    137138        psMetadata *inputs = psMetadataLookupMetadata(NULL, config->arguments, "INPUTS"); // The inputs info
    138139        if (!inputs) {
    139             psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find inputs.");
     140            psError(PPSTACK_ERR_ARGUMENTS, false, "Unable to find inputs.");
    140141            return false;
    141142        }
     
    145146        while ((item = psMetadataGetAndIncrement(iter))) {
    146147            if (item->type != PS_DATA_METADATA) {
    147                 psError(PS_ERR_BAD_PARAMETER_TYPE, true,
     148                psError(PPSTACK_ERR_ARGUMENTS, true,
    148149                        "Component %s of the input metadata is not of type METADATA", item->name);
    149150                psFree(iter);
     
    155156            psString image = psMetadataLookupStr(NULL, input, "IMAGE"); // Name of image
    156157            if (!image || strlen(image) == 0) {
    157                 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Component %s lacks IMAGE of type STR", item->name);
     158                psError(PPSTACK_ERR_ARGUMENTS, true, "Component %s lacks IMAGE of type STR", item->name);
    158159                psFree(iter);
    159160                return false;
     
    169170                                              image, PM_FPA_FILE_IMAGE); // File for image
    170171            if (!imageFile) {
    171                 psError(PS_ERR_UNKNOWN, false, "Unable to define file from image %d (%s)", i, image);
     172                psError(psErrorCodeLast(), false, "Unable to define file from image %d (%s)", i, image);
    172173                return false;
    173174            }
     
    175176            if (mask && strlen(mask) > 0 &&
    176177                !defineFile(config, imageFile, "PPSTACK.INPUT.MASK", mask, PM_FPA_FILE_MASK)) {
    177                 psError(PS_ERR_UNKNOWN, false, "Unable to define file from mask %d (%s)", i, mask);
     178                psError(psErrorCodeLast(), false, "Unable to define file from mask %d (%s)", i, mask);
    178179                return false;
    179180            }
     
    183184                if (!defineFile(config, imageFile, "PPSTACK.INPUT.VARIANCE", variance,
    184185                                PM_FPA_FILE_VARIANCE)) {
    185                     psError(PS_ERR_UNKNOWN, false,
     186                    psError(psErrorCodeLast(), false,
    186187                            "Unable to define file from variance %d (%s)", i, variance);
    187188                    return false;
     
    195196                    havePSFs = true;
    196197                    if (!defineFile(config, imageFile, "PPSTACK.INPUT.PSF", psf, PM_FPA_FILE_PSF)) {
    197                         psError(PS_ERR_UNKNOWN, false, "Unable to define file from psf %d (%s)", i, psf);
     198                        psError(psErrorCodeLast(), false, "Unable to define file from psf %d (%s)", i, psf);
    198199                        return false;
    199200                    }
    200201                }
    201202            } else if (havePSFs) {
    202                 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find PSF %d", i);
     203                psError(PPSTACK_ERR_CONFIG, true, "Unable to find PSF %d", i);
    203204                return false;
    204205            }
    205206
    206207            if (!sources || strlen(sources) == 0) {
    207                 psError(PS_ERR_UNEXPECTED_NULL, true, "SOURCES not provided for file %d", i);
     208                psError(PPSTACK_ERR_CONFIG, true, "SOURCES not provided for file %d", i);
    208209                return false;
    209210            }
    210211            if (!defineFile(config, imageFile, "PPSTACK.INPUT.SOURCES", sources, PM_FPA_FILE_CMF)) {
    211                 psError(PS_ERR_UNKNOWN, false, "Unable to define file from sources %d (%s)",
     212                psError(psErrorCodeLast(), false, "Unable to define file from sources %d (%s)",
    212213                        i, sources);
    213214                return false;
     
    217218                pmFPAfile *kernel = pmFPAfileDefineOutput(config, imageFile->fpa, "PPSTACK.CONV.KERNEL");
    218219                if (!kernel) {
    219                     psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.CONV.KERNEL"));
     220                    psError(psErrorCodeLast(), false,
     221                            "Unable to generate output file from PPSTACK.CONV.KERNEL");
    220222                    return false;
    221223                }
     
    235237    pmFPA *outFPA = pmFPAConstruct(config->camera, config->cameraName); // FPA to contain the output
    236238    if (!outFPA) {
    237         psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to construct an FPA from camera configuration.");
     239        psError(psErrorCodeLast(), false, "Unable to construct an FPA from camera configuration.");
    238240        return false;
    239241    }
     
    241243    psFree(outFPA);                        // Drop reference
    242244    if (!output) {
    243         psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.OUTPUT"));
     245        psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT"));
    244246        return false;
    245247    }
    246248    if (output->type != PM_FPA_FILE_IMAGE) {
    247         psError(PS_ERR_IO, true, "PPSTACK.OUTPUT is not of type IMAGE");
     249        psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT is not of type IMAGE");
    248250        return false;
    249251    }
     
    251253
    252254    if (!pmFPAAddSourceFromFormat(outFPA, "Stack", output->format)) {
    253         psError(PS_ERR_UNKNOWN, false, "Unable to generate output FPA.");
     255        psError(psErrorCodeLast(), false, "Unable to generate output FPA.");
    254256        return false;
    255257    }
     
    258260    pmFPAfile *outMask = pmFPAfileDefineOutput(config, output->fpa, "PPSTACK.OUTPUT.MASK");
    259261    if (!outMask) {
    260         psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.OUTPUT.MASK"));
     262        psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT.MASK"));
    261263        return false;
    262264    }
    263265    if (outMask->type != PM_FPA_FILE_MASK) {
    264         psError(PS_ERR_IO, true, "PPSTACK.OUTPUT.MASK is not of type MASK");
     266        psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.MASK is not of type MASK");
    265267        return false;
    266268    }
     
    271273        pmFPAfile *outVariance = pmFPAfileDefineOutput(config, output->fpa, "PPSTACK.OUTPUT.VARIANCE");
    272274        if (!outVariance) {
    273             psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.OUTPUT.VARIANCE"));
     275            psError(psErrorCodeLast(), false, "Unable to generate output file from PPSTACK.OUTPUT.VARIANCE");
    274276            return false;
    275277        }
    276278        if (outVariance->type != PM_FPA_FILE_VARIANCE) {
    277             psError(PS_ERR_IO, true, "PPSTACK.OUTPUT.VARIANCE is not of type VARIANCE");
     279            psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.VARIANCE is not of type VARIANCE");
    278280            return false;
    279281        }
     
    284286        pmFPAfile *targetPSF = pmFPAfileDefineOutput(config, output->fpa, "PPSTACK.TARGET.PSF");
    285287        if (!targetPSF) {
    286             psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.TARGET.PSF"));
     288            psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.TARGET.PSF"));
    287289            return false;
    288290        }
    289291        if (targetPSF->type != PM_FPA_FILE_PSF) {
    290             psError(PS_ERR_IO, true, "PPSTACK.TARGET.PSF is not of type PSF");
     292            psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.TARGET.PSF is not of type PSF");
    291293            return false;
    292294        }
     
    298300    pmFPA *unconvFPA = pmFPAConstruct(config->camera, config->cameraName); // FPA to contain unconvolved output
    299301    if (!unconvFPA) {
    300         psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to construct an FPA from camera configuration.");
     302        psError(psErrorCodeLast(), false, "Unable to construct an FPA from camera configuration.");
    301303        return false;
    302304    }
     
    304306    psFree(unconvFPA);                  // Drop reference
    305307    if (!unConv) {
    306         psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.UNCONV"));
     308        psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.UNCONV"));
    307309        return false;
    308310    }
    309311    if (unConv->type != PM_FPA_FILE_IMAGE) {
    310         psError(PS_ERR_IO, true, "PPSTACK.UNCONV is not of type IMAGE");
     312        psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.UNCONV is not of type IMAGE");
    311313        return false;
    312314    }
     
    314316
    315317    if (!pmFPAAddSourceFromFormat(unconvFPA, "Stack", unConv->format)) {
    316         psError(PS_ERR_UNKNOWN, false, "Unable to generate output FPA.");
     318        psError(psErrorCodeLast(), false, "Unable to generate output FPA.");
    317319        return false;
    318320    }
     
    321323    pmFPAfile *unconvMask = pmFPAfileDefineOutput(config, unconvFPA, "PPSTACK.UNCONV.MASK");
    322324    if (!unconvMask) {
    323         psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.UNCONV.MASK"));
     325        psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.UNCONV.MASK"));
    324326        return false;
    325327    }
    326328    if (unconvMask->type != PM_FPA_FILE_MASK) {
    327         psError(PS_ERR_IO, true, "PPSTACK.UNCONV.MASK is not of type MASK");
     329        psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.UNCONV.MASK is not of type MASK");
    328330        return false;
    329331    }
     
    334336        pmFPAfile *unconvVariance = pmFPAfileDefineOutput(config, unconvFPA, "PPSTACK.UNCONV.VARIANCE");
    335337        if (!unconvVariance) {
    336             psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.UNCONV.VARIANCE"));
     338            psError(psErrorCodeLast(), false, "Unable to generate output file from PPSTACK.UNCONV.VARIANCE");
    337339            return false;
    338340        }
    339341        if (unconvVariance->type != PM_FPA_FILE_VARIANCE) {
    340             psError(PS_ERR_IO, true, "PPSTACK.UNCONV.VARIANCE is not of type VARIANCE");
     342            psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.UNCONV.VARIANCE is not of type VARIANCE");
    341343            return false;
    342344        }
     
    348350    pmFPAfile *jpeg1 = pmFPAfileDefineOutput(config, NULL, "PPSTACK.OUTPUT.JPEG1");
    349351    if (!jpeg1) {
    350         psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.OUTPUT.JPEG1"));
     352        psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT.JPEG1"));
    351353        return false;
    352354    }
    353355    if (jpeg1->type != PM_FPA_FILE_JPEG) {
    354         psError(PS_ERR_IO, true, "PPSTACK.OUTPUT.JPEG1 is not of type JPEG");
     356        psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.JPEG1 is not of type JPEG");
    355357        return false;
    356358    }
     
    358360    pmFPAfile *jpeg2 = pmFPAfileDefineOutput(config, NULL, "PPSTACK.OUTPUT.JPEG2");
    359361    if (!jpeg2) {
    360         psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.OUTPUT.JPEG2"));
     362        psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT.JPEG2"));
    361363        return false;
    362364    }
    363365    if (jpeg2->type != PM_FPA_FILE_JPEG) {
    364         psError(PS_ERR_IO, true, "PPSTACK.OUTPUT.JPEG2 is not of type JPEG");
     366        psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.JPEG2 is not of type JPEG");
    365367        return false;
    366368    }
     
    377379        pmFPAfile *psphotInput = pmFPAfileDefineFromFPA(config, output->fpa, 1, 1, "PSPHOT.INPUT");
    378380        if (!psphotInput) {
    379             psError(PS_ERR_IO, false, _("Unable to generate output file from PSPHOT.INPUT"));
    380             return false;
    381         }
    382         // specify the number of psphot input images
    383         psMetadataAddS32 (config->arguments, PS_LIST_TAIL, "PSPHOT.INPUT.NUM", PS_META_REPLACE, "number of inputs", 1);
     381            psError(psErrorCodeLast(), false, _("Unable to generate output file from PSPHOT.INPUT"));
     382            return false;
     383        }
     384        // specify the number of psphot input images
     385        psMetadataAddS32 (config->arguments, PS_LIST_TAIL, "PSPHOT.INPUT.NUM", PS_META_REPLACE, "number of inputs", 1);
    384386
    385387        // Define associated psphot input/output files
    386388        if (!psphotDefineFiles(config, psphotInput)) {
    387             psError(PSPHOT_ERR_CONFIG, false,
     389            psError(psErrorCodeLast(), false,
    388390                    "Trouble defining the additional input/output files for psphot");
    389391            return false;
     
    393395        pmFPAfile *outPSF = pmFPAfileDefineOutputFromFile(config, output, "PSPHOT.PSF.SAVE");
    394396        if (!outPSF) {
    395             psError(PS_ERR_IO, false, _("Unable to generate output file from PSPHOT.PSF.SAVE"));
     397            psError(psErrorCodeLast(), false, _("Unable to generate output file from PSPHOT.PSF.SAVE"));
    396398            return false;
    397399        }
    398400        if (outPSF->type != PM_FPA_FILE_PSF) {
    399             psError(PS_ERR_IO, true, "PSPHOT.PSF.SAVE is not of type PSF");
     401            psError(PPSTACK_ERR_CONFIG, true, "PSPHOT.PSF.SAVE is not of type PSF");
    400402            return false;
    401403        }
  • trunk/ppStack/src/ppStackCleanup.c

    r26184 r27004  
    5050        if (!pmReadoutRebin(ro1, options->outRO, maskValue, bin1, bin1) ||
    5151            !pmReadoutRebin(ro2, ro1, 0, bin2, bin2)) {
    52             psError(PS_ERR_UNKNOWN, false, "Unable to bin output.");
     52            psError(PPSTACK_ERR_DATA, false, "Unable to bin output.");
    5353            psFree(ro1);
    5454            psFree(ro2);
  • trunk/ppStack/src/ppStackCombineFinal.c

    r26184 r27004  
    3131        if (!status) {
    3232            // Something went wrong
    33             psError(PS_ERR_UNKNOWN, false, "Unable to read chunk %d", numChunk);
     33            psError(psErrorCodeLast(), false, "Unable to read chunk %d", numChunk);
    3434            return false;
    3535        }
     
    5555
    5656    if (!psThreadPoolWait(true)) {
    57         psError(PS_ERR_UNKNOWN, false, "Unable to do final combination.");
     57        psError(psErrorCodeLast(), false, "Unable to do final combination.");
    5858        return false;
    5959    }
     
    126126    pmHDU *hdu = pmHDUFromCell(target->parent);
    127127    if (!hdu) {
    128         psError(PS_ERR_UNKNOWN, false, "Unable to find HDU for output.");
     128        psError(PPSTACK_ERR_PROG, false, "Unable to find HDU for output.");
    129129        return false;
    130130    }
  • trunk/ppStack/src/ppStackCombineInitial.c

    r26454 r27004  
    2020    if (!options->convolve) {
    2121        // No need to do initial combination when we haven't convolved
    22         // XXX either allocate inspect and rejected here, or do not require them downstream
     22        // XXX either allocate inspect and rejected here, or do not require them downstream
    2323        return true;
    2424    }
     
    3737        if (!status) {
    3838            // Something went wrong
    39             psError(PS_ERR_UNKNOWN, false, "Unable to read chunk %d", numChunk);
     39            psError(psErrorCodeLast(), false, "Unable to read chunk %d", numChunk);
    4040            return false;
    4141        }
     
    5757
    5858    if (!psThreadPoolWait(false)) {
    59         psError(PS_ERR_UNKNOWN, false, "Unable to do initial combination.");
     59        psError(psErrorCodeLast(), false, "Unable to do initial combination.");
    6060        return false;
    6161    }
  • trunk/ppStack/src/ppStackCombinePrepare.c

    r26076 r27004  
    2020    ppStackThread *thread = stack->threads->data[0]; // Representative thread
    2121    if (!pmReadoutStackSetOutputSize(&col0, &row0, &numCols, &numRows, thread->readouts)) {
    22         psError(PS_ERR_UNKNOWN, false, "problem setting output readout size.");
     22        psError(PPSTACK_ERR_ARGUMENTS, false, "problem setting output readout size.");
    2323        return false;
    2424    }
     
    4545
    4646    if (!pmReadoutStackDefineOutput(options->outRO, col0, row0, numCols, numRows, true, true, maskBad)) {
    47         psError(PS_ERR_UNKNOWN, false, "Unable to prepare output.");
     47        psError(PPSTACK_ERR_ARGUMENTS, false, "Unable to prepare output.");
    4848        return false;
    4949    }
  • trunk/ppStack/src/ppStackConvolve.c

    r26898 r27004  
    8282        } else if (options->numCols != readout->image->numCols ||
    8383                   options->numRows != readout->image->numRows) {
    84             psError(PS_ERR_UNKNOWN, true, "Sizes of input images don't match: %dx%d vs %dx%d",
     84            psError(PPSTACK_ERR_ARGUMENTS, true, "Sizes of input images don't match: %dx%d vs %dx%d",
    8585                    readout->image->numCols, readout->image->numRows, options->numCols, options->numRows);
    8686            psFree(rng);
     
    9494        options->origCovars->data[i] = psMemIncrRefCounter(readout->covariance);
    9595        if (!ppStackMatch(readout, options, i, config)) {
    96             // XXX many things can cause a failure of ppStackMatch -- should some be handled differently?
    97             psErrorStackPrint(stderr, "Unable to match image %d --- ignoring.", i);
    98             options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= PPSTACK_MASK_MATCH;
    99             psErrorClear();
    100             continue;
     96            // XXX many things can cause a failure of ppStackMatch -- should some be handled differently?
     97            psErrorCode error = psErrorCodeLast(); // Error code
     98            switch (error) {
     99                // Fatal errors
     100              case PM_ERR_CONFIG:
     101              case PPSTACK_ERR_CONFIG:
     102              case PPSTACK_ERR_IO:
     103                psError(error, false, "Unable to match image %d due to fatal error.", i);
     104                return false;
     105                // Non-fatal errors
     106              case PM_ERR_STAMPS:
     107              case PM_ERR_SMALL_AREA:
     108              case PPSTACK_ERR_DATA:
     109              default:
     110                psErrorStackPrint(stderr, "Unable to match image %d --- ignoring.", i);
     111                options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= PPSTACK_MASK_MATCH;
     112                psErrorClear();
     113                continue;
     114            }
    101115        }
    102116        options->convCovars->data[i] = psMemIncrRefCounter(readout->covariance);
     
    136150        assert(hdu);
    137151        if (!ppStackWriteImage(options->convImages->data[i], hdu->header, readout->image, config)) {
    138             psError(PS_ERR_IO, false, "Unable to write convolved image %d", i);
     152            psError(PPSTACK_ERR_IO, false, "Unable to write convolved image %d", i);
    139153            psFree(fpaList);
    140154            psFree(cellList);
     
    145159        pmConfigMaskWriteHeader(config, maskHeader);
    146160        if (!ppStackWriteImage(options->convMasks->data[i], maskHeader, readout->mask, config)) {
    147             psError(PS_ERR_IO, false, "Unable to write convolved mask %d", i);
     161            psError(PPSTACK_ERR_IO, false, "Unable to write convolved mask %d", i);
    148162            psFree(fpaList);
    149163            psFree(cellList);
     
    154168        psFree(maskHeader);
    155169        if (!ppStackWriteImage(options->convVariances->data[i], hdu->header, readout->variance, config)) {
    156             psError(PS_ERR_IO, false, "Unable to write convolved variance %d", i);
     170            psError(PPSTACK_ERR_IO, false, "Unable to write convolved variance %d", i);
    157171            psFree(fpaList);
    158172            psFree(cellList);
     
    208222
    209223    if (numGood == 0) {
    210         psError(PS_ERR_UNKNOWN, false, "No good images to combine.");
     224        psError(PPSTACK_ERR_REJECTED, false, "No good images to combine.");
    211225        psFree(fpaList);
    212226        psFree(cellList);
     
    257271        assert(values->n == numGood);
    258272        if (!psVectorSortInPlace(values)) {
    259             psError(PS_ERR_UNKNOWN, false, "Unable to sort vector.");
     273            psError(PPSTACK_ERR_PROG, false, "Unable to sort vector.");
    260274            psFree(values);
    261275            return false;
     
    295309
    296310    if (numGood == 0) {
    297         psError(PS_ERR_UNKNOWN, false, "No good images to combine.");
     311        psError(PPSTACK_ERR_REJECTED, false, "No good images to combine.");
    298312        return false;
    299313    }
  • trunk/ppStack/src/ppStackFiles.c

    r26454 r27004  
    115115    pmFPAview *view = pmFPAviewAlloc(0);// Pointer into FPA hierarchy
    116116    if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
     117        psError(PPSTACK_ERR_IO, false, "File checks failed.");
    117118        return NULL;
    118119    }
    119120    view->chip = 0;
    120121    if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
     122        psError(PPSTACK_ERR_IO, false, "File checks failed.");
    121123        return NULL;
    122124    }
    123125    view->cell = 0;
    124126    if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
     127        psError(PPSTACK_ERR_IO, false, "File checks failed.");
    125128        return NULL;
    126129    }
    127130    view->readout = 0;
    128131    if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
     132        psError(PPSTACK_ERR_IO, false, "File checks failed.");
    129133        return NULL;
    130134    }
     
    141145    view->chip = view->cell = view->readout = 0;
    142146    if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
     147        psError(PPSTACK_ERR_IO, false, "File checks failed.");
    143148        return false;
    144149    }
    145150    view->readout = -1;
    146151    if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
     152        psError(PPSTACK_ERR_IO, false, "File checks failed.");
    147153        return false;
    148154    }
    149155    view->cell = -1;
    150156    if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
     157        psError(PPSTACK_ERR_IO, false, "File checks failed.");
    151158        return false;
    152159    }
    153160    view->chip = -1;
    154161    if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
     162        psError(PPSTACK_ERR_IO, false, "File checks failed.");
    155163        return false;
    156164    }
     
    172180    psFits *fits = psFitsOpen(resolved, "w");
    173181    if (!fits) {
    174         psError(PS_ERR_IO, false, "Unable to open FITS file %s to write image.", resolved);
     182        psError(PPSTACK_ERR_IO, false, "Unable to open FITS file %s to write image.", resolved);
    175183        psFree(resolved);
    176184        return false;
    177185    }
    178186    if (!psFitsWriteImage(fits, header, image, 0, NULL)) {
    179         psError(PS_ERR_IO, false, "Unable to write FITS image %s.", resolved);
     187        psError(PPSTACK_ERR_IO, false, "Unable to write FITS image %s.", resolved);
    180188        psFitsClose(fits);
    181189        psFree(resolved);
     
    183191    }
    184192    if (!psFitsClose(fits)) {
    185         psError(PS_ERR_IO, false, "Unable to close FITS image %s.", resolved);
     193        psError(PPSTACK_ERR_IO, false, "Unable to close FITS image %s.", resolved);
    186194        psFree(resolved);
    187195        return false;
  • trunk/ppStack/src/ppStackLoop.c

    r26117 r27004  
    2222    psTrace("ppStack", 1, "Setup....\n");
    2323    if (!ppStackSetup(options, config)) {
    24         psError(PS_ERR_UNKNOWN, false, "Unable to setup.");
     24        psError(psErrorCodeLast(), false, "Unable to setup.");
    2525        psFree(options);
    2626        return false;
     
    3333    psTrace("ppStack", 1, "Preparation for stacking: merging sources, determining target PSF....\n");
    3434    if (!ppStackPrepare(options, config)) {
    35         psError(PS_ERR_UNKNOWN, false, "Unable to prepare for stacking.");
     35        psError(psErrorCodeLast(), false, "Unable to prepare for stacking.");
    3636        psFree(options);
    3737        return false;
     
    4545    psTrace("ppStack", 1, "Convolving inputs to target PSF....\n");
    4646    if (!ppStackConvolve(options, config)) {
    47         psError(PS_ERR_UNKNOWN, false, "Unable to convolve images.");
     47        psError(psErrorCodeLast(), false, "Unable to convolve images.");
    4848        psFree(options);
    4949        return false;
     
    5858    ppStackThreadData *stack = ppStackThreadDataSetup(options, config, true);
    5959    if (!stack) {
    60         psError(PS_ERR_IO, false, "Unable to initialise stack threads.");
     60        psError(psErrorCodeLast(), false, "Unable to initialise stack threads.");
    6161        psFree(options);
    6262        return false;
     
    6565    // Prepare for combination
    6666    if (!ppStackCombinePrepare(stack, options, config)) {
    67         psError(PS_ERR_UNKNOWN, false, "Unable to prepare for combination.");
     67        psError(psErrorCodeLast(), false, "Unable to prepare for combination.");
    6868        psFree(stack);
    6969        psFree(options);
     
    7474    psTrace("ppStack", 1, "Initial stack of convolved images....\n");
    7575    if (!ppStackCombineInitial(stack, options, config)) {
    76         psError(PS_ERR_UNKNOWN, false, "Unable to perform initial combination.");
     76        psError(psErrorCodeLast(), false, "Unable to perform initial combination.");
    7777        psFree(stack);
    7878        psFree(options);
     
    8686    psTrace("ppStack", 1, "Reject pixels....\n");
    8787    if (!ppStackReject(options, config)) {
    88         psError(PS_ERR_UNKNOWN, false, "Unable to reject pixels.");
     88        psError(psErrorCodeLast(), false, "Unable to reject pixels.");
    8989        psFree(stack);
    9090        psFree(options);
     
    9898    psTrace("ppStack", 2, "Final stack of convolved images....\n");
    9999    if (!ppStackCombineFinal(options->outRO, stack, options->convCovars, options, config, false, false)) {
    100         psError(PS_ERR_UNKNOWN, false, "Unable to perform final combination.");
     100        psError(psErrorCodeLast(), false, "Unable to perform final combination.");
    101101        psFree(stack);
    102102        psFree(options);
     
    109109    psTrace("ppStack", 2, "Cleaning up after combination....\n");
    110110    if (!ppStackCleanup(stack, options, config)) {
    111         psError(PS_ERR_UNKNOWN, false, "Unable to clean up.");
     111        psError(psErrorCodeLast(), false, "Unable to clean up.");
    112112        psFree(stack);
    113113        psFree(options);
     
    125125        ppStackThreadData *stack = ppStackThreadDataSetup(options, config, false);
    126126        if (!stack) {
    127             psError(PS_ERR_IO, false, "Unable to initialise stack threads.");
     127            psError(psErrorCodeLast(), false, "Unable to initialise stack threads.");
    128128            psFree(options);
    129129            return false;
     
    131131        psTrace("ppStack", 2, "Stack of unconvolved images....\n");
    132132        if (!ppStackCombineFinal(options->unconvRO, stack, options->origCovars, options, config, false, true)) {
    133             psError(PS_ERR_UNKNOWN, false, "Unable to perform unconvolved combination.");
     133            psError(psErrorCodeLast(), false, "Unable to perform unconvolved combination.");
    134134            psFree(stack);
    135135            psFree(options);
     
    147147    psTrace("ppStack", 1, "Photometering stacked image....\n");
    148148    if (!ppStackPhotometry(options, config)) {
    149         psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry.");
     149        psError(psErrorCodeLast(), false, "Unable to perform photometry.");
    150150        psFree(options);
    151151        return false;
     
    157157    psTrace("ppStack", 1, "Finishing up....\n");
    158158    if (!ppStackFinish(options, config)) {
    159         psError(PS_ERR_UNKNOWN, false, "Unable to finish up.");
     159        psError(psErrorCodeLast(), false, "Unable to finish up.");
    160160        psFree(options);
    161161        return false;
  • trunk/ppStack/src/ppStackMatch.c

    r26898 r27004  
    3131    psFree(resolved);
    3232    if (!fits) {
    33         psError(PS_ERR_IO, false, "Unable to open previously produced image: %s", name);
     33        psError(PPSTACK_ERR_IO, false, "Unable to open previously produced image: %s", name);
    3434        return false;
    3535    }
    3636    psImage *image = psFitsReadImage(fits, psRegionSet(0,0,0,0), 0); // Image of interest
    3737    if (!image) {
    38         psError(PS_ERR_IO, false, "Unable to read previously produced image: %s", name);
     38        psError(PPSTACK_ERR_IO, false, "Unable to read previously produced image: %s", name);
    3939        psFitsClose(fits);
    4040        return false;
     
    150150    psImage *unbinned = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Unbinned background model
    151151    if (!psImageUnbin(unbinned, binned, binning)) {
    152         psError(PS_ERR_UNKNOWN, false, "Unable to unbin background model");
     152        psError(PPSTACK_ERR_DATA, false, "Unable to unbin background model");
    153153        psFree(unbinned);
    154154        return NULL;
     
    177177    int num = psMetadataLookupS32(&mdok, recipe, "RENORM.NUM");
    178178    if (!mdok) {
    179         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "RENORM.NUM is not set in the recipe");
     179        psError(PPSTACK_ERR_CONFIG, true, "RENORM.NUM is not set in the recipe");
    180180        return false;
    181181    }
    182182    float minValid = psMetadataLookupF32(&mdok, recipe, "RENORM.MIN");
    183183    if (!mdok) {
    184         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "RENORM.MIN is not set in the recipe");
     184        psError(PPSTACK_ERR_CONFIG, true, "RENORM.MIN is not set in the recipe");
    185185        return false;
    186186    }
    187187    float maxValid = psMetadataLookupF32(&mdok, recipe, "RENORM.MAX");
    188188    if (!mdok) {
    189         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "RENORM.MAX is not set in the recipe");
     189        psError(PPSTACK_ERR_CONFIG, true, "RENORM.MAX is not set in the recipe");
    190190        return false;
    191191    }
     
    229229
    230230    if (!pmReadoutMaskNonfinite(readout, maskVal)) {
    231         psError(PS_ERR_UNKNOWN, false, "Unable to mask non-finite pixels in readout.");
     231        psError(psErrorCodeLast(), false, "Unable to mask non-finite pixels in readout.");
    232232        return false;
    233233    }
     
    256256            psFree(resolved);
    257257            if (!fits || !pmReadoutReadSubtractionKernels(conv, fits)) {
    258                 psError(PS_ERR_IO, false, "Unable to read previously produced kernel");
     258                psError(PPSTACK_ERR_IO, false, "Unable to read previously produced kernel");
    259259                psFitsClose(fits);
    260260                return false;
     
    265265                !readImage(&readout->mask, options->convMasks->data[index], config) ||
    266266                !readImage(&readout->variance, options->convVariances->data[index], config)) {
    267                 psError(PS_ERR_IO, false, "Unable to read previously produced image.");
     267                psError(PPSTACK_ERR_IO, false, "Unable to read previously produced image.");
    268268                return false;
    269269            }
     
    326326            float scaleMax = psMetadataLookupF32(NULL, ppsub, "SCALE.MAX"); // Maximum for scaling
    327327            if (!isfinite(scaleRef) || !isfinite(scaleMin) || !isfinite(scaleMax)) {
    328                 psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     328                psError(PPSTACK_ERR_CONFIG, false,
    329329                        "Scale parameters (SCALE.REF=%f, SCALE.MIN=%f, SCALE.MAX=%f) not set in PPSUB recipe.",
    330330                        scaleRef, scaleMin, scaleMax);
     
    346346            psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator
    347347            if (!psImageBackground(bg, NULL, readout->image, readout->mask, maskVal | maskBad, rng)) {
    348                 psError(PS_ERR_UNKNOWN, false, "Can't measure background for image.");
     348                psError(PPSTACK_ERR_DATA, false, "Can't measure background for image.");
    349349                psFree(fake);
    350350                psFree(optWidths);
     
    366366                                          stampSources, SOURCE_MASK, NULL, NULL, options->psf,
    367367                                          minFlux, footprint + size, false, true)) {
    368                 psError(PS_ERR_UNKNOWN, false, "Unable to generate fake image with target PSF.");
     368                psError(PPSTACK_ERR_DATA, false, "Unable to generate fake image with target PSF.");
    369369                psFree(fake);
    370370                psFree(optWidths);
     
    417417                                               stride, kernelError, covarFrac, maskVal, maskBad, maskPoor,
    418418                                               poorFrac, badFrac)) {
    419                     psError(PS_ERR_UNKNOWN, false, "Unable to convolve images.");
     419                    psError(psErrorCodeLast(), false, "Unable to convolve images.");
    420420                    psFree(fake);
    421421                    psFree(optWidths);
     
    433433                                                       options->inputSeeing->data.F32[index],
    434434                                                       options->targetSeeing, scaleRef, scaleMin, scaleMax)) {
    435                     psError(PS_ERR_UNKNOWN, false, "Unable to scale kernel parameters");
     435                    psError(psErrorCodeLast(), false, "Unable to scale kernel parameters");
    436436                    psFree(fake);
    437437                    psFree(optWidths);
     
    451451                                        sysError, skyErr, kernelError, covarFrac, maskVal, maskBad, maskPoor,
    452452                                        poorFrac, badFrac, PM_SUBTRACTION_MODE_2)) {
    453                     psError(PS_ERR_UNKNOWN, false, "Unable to match images.");
     453                    psError(psErrorCodeLast(), false, "Unable to match images.");
    454454                    psFree(fake);
    455455                    psFree(optWidths);
     
    464464                psFree(widthsCopy);
    465465            }
     466
    466467
    467468#ifdef TESTING
     
    628629    // Measure the variance level for the weighting
    629630    if (!psImageBackground(bg, NULL, readout->variance, readout->mask, maskVal | maskBad, rng)) {
    630         psError(PS_ERR_UNKNOWN, false, "Can't measure mean variance for image.");
     631        psError(PPSTACK_ERR_DATA, false, "Can't measure mean variance for image.");
    631632        psFree(rng);
    632633        psFree(bg);
  • trunk/ppStack/src/ppStackPSF.c

    r26898 r27004  
    2828    psString maskValStr = psMetadataLookupStr(&mdok, recipe, "MASK.VAL"); // Name of bits to mask going in
    2929    if (!mdok || !maskValStr) {
    30         psError(PS_ERR_UNKNOWN, false, "Unable to find MASK.VAL in recipe");
     30        psError(PPSTACK_ERR_CONFIG, false, "Unable to find MASK.VAL in recipe");
    3131        return false;
    3232    }
     
    4343    pmPSF *psf = pmPSFEnvelope(numCols, numRows, psfs, psfInstances, psfRadius, psfModel, psfOrder, psfOrder, maskVal);
    4444    if (!psf) {
    45         psError(PS_ERR_UNKNOWN, false, "Unable to determine output PSF.");
     45        psError(PPSTACK_ERR_PSF, false, "Unable to determine output PSF.");
    4646        return NULL;
    4747    }
     
    5050    pmPSF *psf = pmPSFBuildSimple("PS_MODEL_PS1_V1", 4.0, 4.0, 0.0, 1.0);
    5151    if (!psf) {
    52         psError(PS_ERR_UNKNOWN, false, "Unable to build dummy PSF.");
     52        psError(PPSTACK_ERR_PSF, false, "Unable to build dummy PSF.");
    5353        return NULL;
    5454    }
  • trunk/ppStack/src/ppStackPhotometry.c

    r26928 r27004  
    6161    psArray *inSources = options->sources;
    6262    if (!inSources) {
    63         psError(PS_ERR_UNKNOWN, false, "Unable to find input sources");
     63        psError(PPSTACK_ERR_PROG, false, "Unable to find input sources");
    6464        psFree(photView);
    6565        return false;
     
    8383        !pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL.STDEV") ||
    8484        !pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND")) {
    85         psError(PS_ERR_UNKNOWN, false, "Unable to drop PSPHOT internal files.");
     85        psError(PPSTACK_ERR_PROG, false, "Unable to drop PSPHOT internal files.");
    8686        return false;
    8787    }
     
    9292        pmReadout *photRO = pmFPAviewThisReadout(photView, photFile->fpa); // Readout with the sources
    9393        pmDetections *detections = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.DETECTIONS"); // detections
    94         if (detections) {
    95             psAssert (detections->allSources, "missing sources?");
     94        if (detections && detections->allSources) {
    9695            psMetadataAddS32(options->stats, PS_LIST_TAIL, "NUM_SOURCES", 0, "Number of sources detected", detections->allSources->n);
    9796        } else {
  • trunk/ppStack/src/ppStackPrepare.c

    r26918 r27004  
    2626    float zpRadius = psMetadataLookupS32(&mdok, recipe, "PHOT.RADIUS"); // Radius for PHOT measurement
    2727    if (!mdok) {
    28         psError(PS_ERR_UNKNOWN, true, "Unable to find PHOT.RADIUS in recipe");
     28        psError(PPSTACK_ERR_CONFIG, true, "Unable to find PHOT.RADIUS in recipe");
    2929        return false;
    3030    }
    3131    float zpSigma = psMetadataLookupF32(&mdok, recipe, "PHOT.SIGMA"); // Gaussian sigma for photometry
    3232    if (!mdok) {
    33         psError(PS_ERR_UNKNOWN, true, "Unable to find PHOT.SIGMA in recipe");
     33        psError(PPSTACK_ERR_CONFIG, true, "Unable to find PHOT.SIGMA in recipe");
    3434        return false;
    3535    }
    3636    float zpFrac = psMetadataLookupF32(&mdok, recipe, "PHOT.FRAC"); // Fraction of good pixels for photometry
    3737    if (!mdok) {
    38         psError(PS_ERR_UNKNOWN, true, "Unable to find PHOT.FRAC in recipe");
     38        psError(PPSTACK_ERR_CONFIG, true, "Unable to find PHOT.FRAC in recipe");
    3939        return false;
    4040    }
     
    4242    psString maskValStr = psMetadataLookupStr(&mdok, recipe, "MASK.VAL"); // Name of bits to mask going in
    4343    if (!mdok || !maskValStr) {
    44         psError(PS_ERR_UNKNOWN, false, "Unable to find MASK.VAL in recipe");
     44        psError(PPSTACK_ERR_CONFIG, false, "Unable to find MASK.VAL in recipe");
    4545        return false;
    4646    }
     
    5353    psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); // Statistics
    5454    if (!psImageBackground(stats, NULL, image, mask, maskVal, rng)) {
    55         psError(PS_ERR_UNKNOWN, false, "Unable to measure background for image");
     55        psError(PPSTACK_ERR_DATA, false, "Unable to measure background for image");
    5656        psFree(stats);
    5757        psFree(rng);
     
    148148            pmPSF *psf = psMetadataLookupPtr(NULL, chip->analysis, "PSPHOT.PSF"); // PSF
    149149            if (!psf) {
    150                 psError(PS_ERR_UNKNOWN, false, "Unable to find PSF.");
     150                psError(PPSTACK_ERR_PROG, false, "Unable to find PSF.");
    151151                psFree(view);
    152152                psFree(fileIter);
     
    163163            int naxis2 = psMetadataLookupS32(NULL, hdu->header, "NAXIS2"); // Number of rows
    164164            if (naxis1 <= 0 || naxis2 <= 0) {
    165                 psError(PS_ERR_UNKNOWN, false, "Unable to determine size of image from PSF.");
     165                psError(PPSTACK_ERR_PROG, false, "Unable to determine size of image from PSF.");
    166166                psFree(view);
    167167                psFree(fileIter);
     
    183183            detections = psMetadataLookupPtr(NULL, ro->analysis, "PSPHOT.DETECTIONS"); // Sources
    184184            if (!detections) {
    185                 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find source detections in readout.");
     185                psError(PPSTACK_ERR_PROG, false, "Unable to find source detections in readout.");
    186186                return NULL;
    187187            }
     
    209209
    210210            if (!ppStackInputPhotometer(ro, detections->allSources, config)) {
    211                 psError(PS_ERR_UNKNOWN, false, "Unable to do photometry on input sources");
     211                psError(psErrorCodeLast(), false, "Unable to do photometry on input sources");
    212212                psFree(view);
    213213                psFree(photView);
     
    273273        psFree(psfs);
    274274        if (!options->psf) {
    275             psError(PS_ERR_UNKNOWN, false, "Unable to determine output PSF.");
     275            psError(psErrorCodeLast(), false, "Unable to determine output PSF.");
    276276            psFree(view);
    277277            return false;
     
    290290    // Zero point calibration
    291291    if (!ppStackSourcesTransparency(options, view, config)) {
    292         psError(PS_ERR_UNKNOWN, false, "Unable to calculate transparency differences");
     292        psError(PPSTACK_ERR_DATA, false, "Unable to calculate transparency differences");
    293293        psFree(view);
    294294        return false;
  • trunk/ppStack/src/ppStackReject.c

    r26076 r27004  
    6161    }
    6262    if (!psThreadPoolWait(true)) {
    63         psError(PS_ERR_UNKNOWN, false, "Unable to concatenate inspection lists.");
     63        psError(psErrorCodeLast(), false, "Unable to concatenate inspection lists.");
    6464        return false;
    6565    }
     
    172172
    173173    if (numRejected >= num - 1) {
    174         psError(PS_ERR_UNKNOWN, true, "All inputs completely rejected; unable to proceed.");
     174        psError(PPSTACK_ERR_REJECTED, true, "All inputs completely rejected; unable to proceed.");
    175175        return false;
    176176    }
  • trunk/ppStack/src/ppStackSetup.c

    r26898 r27004  
    4242        options->statsFile = fopen(resolved, "w");
    4343        if (!options->statsFile) {
    44             psError(PS_ERR_IO, true, "Unable to open statistics file %s for writing.\n", resolved);
     44            psError(PPSTACK_ERR_IO, true, "Unable to open statistics file %s for writing.\n", resolved);
    4545            psFree(resolved);
    4646            return false;
     
    5757    }
    5858    if (!tempDir) {
    59         psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to find TEMP.DIR in site configuration");
     59        psError(PPSTACK_ERR_CONFIG, false, "Unable to find TEMP.DIR in site configuration");
    6060        return false;
    6161    }
     
    6565    const char *tempName = basename(outputName);
    6666    if (!tempName) {
    67         psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to construct basename for temporary files.");
     67        psError(PPSTACK_ERR_ARGUMENTS, false, "Unable to construct basename for temporary files.");
    6868        psFree(outputName);
    6969        return false;
     
    7474    const char *tempVariance = psMetadataLookupStr(NULL, recipe, "TEMP.VARIANCE"); // Suffix for var maps
    7575    if (!tempImage || !tempMask || !tempVariance) {
    76         psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     76        psError(PPSTACK_ERR_CONFIG, false,
    7777                "Unable to find TEMP.IMAGE, TEMP.MASK and TEMP.VARIANCE in recipe");
    7878        psFree(outputName);
     
    117117
    118118    if (!pmConfigMaskSetBits(NULL, NULL, config)) {
    119         psError(PS_ERR_UNKNOWN, false, "Unable to determine mask value.");
     119        psError(PPSTACK_ERR_CONFIG, false, "Unable to determine mask value.");
    120120        return false;
    121121    }
  • trunk/ppStack/src/ppStackSources.c

    r26898 r27004  
    116116    psMetadata *airmassZP = psMetadataLookupMetadata(NULL, recipe, "ZP.AIRMASS"); // Airmass terms
    117117    if (!airmassZP) {
    118         psError(PS_ERR_UNKNOWN, false, "Unable to find ZP.AIRMASS in recipe.");
     118        psError(PPSTACK_ERR_CONFIG, false, "Unable to find ZP.AIRMASS in recipe.");
    119119        return false;
    120120    }
     
    152152        if (!isfinite(exptime) || exptime == 0 || !isfinite(airmass) || airmass == 0 ||
    153153            !expFilter || strlen(expFilter) == 0) {
    154             psError(PS_ERR_UNEXPECTED_NULL, false,
     154            psError(PPSTACK_ERR_CONFIG, false,
    155155                    "Unable to find exposure time (%f), airmass (%f) or filter (%s)",
    156156                    exptime, airmass, expFilter);
     
    163163            airmassTerm = psMetadataLookupF32(NULL, airmassZP, filter);
    164164            if (!isfinite(airmassTerm)) {
    165                 psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     165                psError(PPSTACK_ERR_CONFIG, false,
    166166                        "Unable to find airmass term (ZP.AIRMASS) for filter %s", filter);
    167167                psFree(zp);
     
    169169            }
    170170        } else if (strcmp(filter, expFilter) != 0) {
    171             psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Filters don't match: %s vs %s", filter, expFilter);
     171            psError(PPSTACK_ERR_CONFIG, false, "Filters don't match: %s vs %s", filter, expFilter);
    172172            psFree(zp);
    173173            return false;
     
    182182    psArray *matches = pmSourceMatchSources(sourceLists, radius, true); // List of matches
    183183    if (!matches) {
    184         psError(PS_ERR_UNKNOWN, false, "Unable to match sources");
     184        psError(PPSTACK_ERR_DATA, false, "Unable to match sources");
    185185        psFree(zp);
    186186        return false;
     
    196196                                               transIter, transRej, transThresh); // Transparencies per image
    197197        if (!trans) {
    198             psError(PS_ERR_UNKNOWN, false, "Unable to measure transparencies");
     198            psError(PPSTACK_ERR_DATA, false, "Unable to measure transparencies");
    199199            return false;
    200200        }
     
    241241            psArray *matches = pmSourceMatchSources(sourceLists, radius); // List of matches
    242242            if (!matches) {
    243                 psError(PS_ERR_UNKNOWN, false, "Unable to match sources");
     243                psError(PPSTACK_ERR_DATA, false, "Unable to match sources");
    244244                psFree(zp);
    245245                return false;
     
    262262                                                  iter2, starRej2, starLimit); // Shifts for each image
    263263        if (!offsets) {
    264             psError(PS_ERR_UNKNOWN, false, "Unable to measure offsets");
     264            psError(PPSTACK_ERR_DATA, false, "Unable to measure offsets");
    265265            return false;
    266266        }
  • trunk/ppStack/src/ppStackThread.c

    r26076 r27004  
    102102            (FITS)->data[INDEX] = psFitsOpen(resolved, "r");                            \
    103103            if (!(FITS)->data[INDEX]) { \
    104                 psError(PS_ERR_IO, false, "Unable to open file %s", (char*)(NAMES)->data[INDEX]); \
     104                psError(PPSTACK_ERR_IO, false, "Unable to open file %s", (char*)(NAMES)->data[INDEX]); \
    105105                psFree(resolved); \
    106106                return NULL; \
     
    152152    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // Recipe
    153153    if (!recipe) {
    154         psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSTACK_RECIPE);
     154        psError(PPSTACK_ERR_CONFIG, false, "Unable to find recipe %s", PPSTACK_RECIPE);
    155155        return NULL;
    156156    }
    157157    int rows = psMetadataLookupS32(NULL, recipe, "ROWS"); // Number of rows to read per chunk
    158158    if (rows <= 0) {
    159         psError(PS_ERR_BAD_PARAMETER_VALUE, false, "ROWS is not set in the recipe.");
     159        psError(PPSTACK_ERR_CONFIG, false, "ROWS is not set in the recipe.");
    160160        return NULL;
    161161    }
     
    204204                    keepReading = true;
    205205                    if (!pmReadoutReadChunk(ro, imageFits, 0, NULL, rows, overlap, config)) {
    206                         psError(PS_ERR_IO, false, "Unable to read chunk %d for file PPSTACK.INPUT %d",
     206                        psError(PPSTACK_ERR_IO, false,
     207                                "Unable to read chunk %d for file PPSTACK.INPUT %d",
    207208                                numChunk, i);
    208209                        *status = false;
     
    214215                    keepReading = true;
    215216                    if (!pmReadoutReadChunkMask(ro, maskFits, 0, NULL, rows, overlap, config)) {
    216                         psError(PS_ERR_IO, false, "Unable to read chunk %d for file PPSTACK.INPUT.MASK %d",
     217                        psError(PPSTACK_ERR_IO, false,
     218                                "Unable to read chunk %d for file PPSTACK.INPUT.MASK %d",
    217219                                numChunk, i);
    218220                        *status = false;
     
    224226                    keepReading = true;
    225227                    if (!pmReadoutReadChunkVariance(ro, varianceFits, 0, NULL, rows, overlap, config)) {
    226                         psError(PS_ERR_IO, false,
     228                        psError(PPSTACK_ERR_IO, false,
    227229                                "Unable to read chunk %d for file PPSTACK.INPUT.VARIANCE %d",
    228230                                numChunk, i);
  • trunk/psModules/src/imcombine/pmStack.c

    r26260 r27004  
    10081008    if (!pmReadoutStackValidate(&minInputCols, &maxInputCols, &minInputRows, &maxInputRows, &xSize, &ySize,
    10091009                                stack)) {
    1010         psError(PS_ERR_UNKNOWN, false, "Input stack is not valid.");
     1010        psError(psErrorCodeLast(), false, "Input stack is not valid.");
    10111011        psFree(stack);
    10121012        return false;
  • trunk/psModules/src/imcombine/pmStackReject.c

    r26893 r27004  
    158158        if (!pmSubtractionConvolve(NULL, convRO, NULL, inRO, NULL, stride, 0, 0, 1.0, 0.0, 0.0,
    159159                                   region, kernels, false, true)) {
    160             psError(PS_ERR_UNKNOWN, false, "Unable to convolve mask image in region %d.", i);
     160            psError(psErrorCodeLast(), false, "Unable to convolve mask image in region %d.", i);
    161161            psFree(convRO);
    162162            psFree(inRO);
     
    170170        psImage *kernel = pmSubtractionKernelImage(kernels, 0.5, 0.5, false);
    171171        if (!kernel) {
    172             psError(PS_ERR_UNKNOWN, false, "Unable to generate kernel image.");
     172            psError(psErrorCodeLast(), false, "Unable to generate kernel image.");
    173173            psFree(convRO);
    174174            psFree(inRO);
     
    283283                } else if (!stackRejectGrow(target, source, kernels, numCols, numRows,
    284284                                            i, xSubMax, j, ySubMax, poorFrac)) {
    285                     psError(PS_ERR_UNKNOWN, false, "Unable to grow bad pixels.");
     285                    psError(psErrorCodeLast(), false, "Unable to grow bad pixels.");
    286286                    psFree(source);
    287287                    psFree(target);
     
    293293
    294294    if (!psThreadPoolWait(false)) {
    295         psError(PS_ERR_UNKNOWN, false, "Unable to grow bad pixels.");
     295        psError(psErrorCodeLast(), false, "Unable to grow bad pixels.");
    296296        psFree(source);
    297297        psFree(target);
Note: See TracChangeset for help on using the changeset viewer.