IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 4, 2005, 11:37:01 AM (21 years ago)
Author:
Paul Price
Message:

Updated to psLib rel5alpha1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/stac/src/stacTransform.c

    r2783 r3375  
    11#include <stdio.h>
     2#include <assert.h>
    23#include "pslib.h"
    34#include "stac.h"
     
    120121
    121122    // Check input sizes
    122     if (images->n != maps->n) {
    123         psError("stac.transform", "Number of maps (%d) does not match number of images (%d).\n",
    124                 maps->n, images->n);
    125         return false;
    126     }
    127     if (errors && (images->n != errors->n)) {
    128         psError("stac.transform", "Number of error images (%d) does not match number of images (%d).\n",
    129                 errors->n, images->n);
    130         return false;
    131     }
     123    assert(images->n == maps->n);
     124    assert(!errors || (images->n == errors->n));
    132125
    133126    // Allocate the output images if required, otherwise check the number
     127    assert(!*outputs || (*outputs)->n == nImages);
    134128    if (*outputs == NULL) {
    135129        *outputs = psArrayAlloc(nImages);
     
    138132            (*outputs)->data[i] = psImageAlloc(nx, ny, PS_TYPE_F32);
    139133        }
    140     } else if ((*outputs)->n != nImages) {
    141         psError("stac.transform", "Number of output images (%d) does not match number of input images "
    142                 "(%d).\n", (*outputs)->n, nImages);
    143         return false;
    144134    }
    145135
    146136    // Allocate the output error images, if required, otherwise check the number
     137    assert(!errors || ! *outErrors || errors->n == (*outErrors)->n);
    147138    if (errors && (*outErrors == NULL)) {
    148139        *outErrors = psArrayAlloc(errors->n);
     
    151142            (*outErrors)->data[i] = psImageAlloc(nx, ny, PS_TYPE_F32);
    152143        }
    153     } else if (errors->n != (*outErrors)->n) {
    154         psError("stac.transform", "Number of error output images (%d) does not match number of input"
    155                 "images (%d).\n", (*outErrors)->n, errors->n);
    156         return false;
    157144    }
    158145
    159146    // Check the masks, if specified
     147    assert(!masks || masks->n == nImages);
    160148    if (masks != NULL) {
    161         if (masks->n != nImages) {
    162             psError("stac.transform", "Number of masks (%d) does not match number of input images (%d).\n",
    163                     masks->n, nImages);
    164             return false;
    165         }
    166149        for (int i = 0; i < nImages; i++) {
    167150            psImage *image = images->data[i];
    168151            psImage *mask = masks->data[i];
    169             if ((mask->numRows != image->numRows) || (mask->numCols != image->numCols)) {
    170                 psError ("stac.transform",
    171                          "Size of input mask (%dx%d) does not match that of input image (%dx%d).\n",
    172                          mask->numCols, mask->numRows, image->numCols, image->numRows);
    173                 return false;
    174             }
     152            assert(mask->numRows == image->numRows && mask->numCols == image->numCols);
    175153        }
    176154    }
     
    236214#ifdef TESTING
    237215        // Write error image out to check
    238         char shiftfile[MAXCHAR];        // Filename of shift image
    239         char errfile[MAXCHAR];          // Filename of error image
    240         sprintf(shiftfile,"%s.shift.%d",config->inputs->data[n],numTransforms);
    241         sprintf(errfile,"%s.shifterr.%d",config->inputs->data[n],numTransforms);
     216        char shiftName[MAXCHAR];        // Filename of shift image
     217        char errName[MAXCHAR];          // Filename of error image
     218        sprintf(shiftName,"%s.shift.%d",config->inputs->data[n],numTransforms);
     219        sprintf(errName,"%s.shifterr.%d",config->inputs->data[n],numTransforms);
    242220        psTrace("stac.transform.test", 6,
    243221                "Output files have size: %dx%d\n",outImage->numCols,outImage->numRows);
    244         psImageWriteSection(outImage,0,0,0,NULL,0,shiftfile);
    245         psImageWriteSection(outError,0,0,0,NULL,0,errfile);
     222
     223        psFits *shiftFile = psFitsAlloc(shiftName);
     224        psFits *errFile = psFitsAlloc(errName);
     225        if (!psFitsWriteImage(shiftFile, NULL, outImage, 0, NULL)) {
     226            psErrorStackPrint(stderr, "Unable to write image: %s\n", shiftName);
     227        }
     228        psTrace("stac", 1, "Shifted image written to %s\n", shiftName);
     229        if (!psFitsWriteImage(errFile, NULL, outError, 0, NULL)) {
     230            psErrorStackPrint(stderr, "Unable to write image: %s\n", errName);
     231        }
     232        psTrace("stac", 1, "Shifted error image written to %s\n", errName);
     233        psFree(shiftFile);
     234        psFree(errFile);
    246235#endif
    247236
Note: See TracChangeset for help on using the changeset viewer.