Changeset 3375 for trunk/stac/src/stacTransform.c
- Timestamp:
- Mar 4, 2005, 11:37:01 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/stac/src/stacTransform.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/stac/src/stacTransform.c
r2783 r3375 1 1 #include <stdio.h> 2 #include <assert.h> 2 3 #include "pslib.h" 3 4 #include "stac.h" … … 120 121 121 122 // 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)); 132 125 133 126 // Allocate the output images if required, otherwise check the number 127 assert(!*outputs || (*outputs)->n == nImages); 134 128 if (*outputs == NULL) { 135 129 *outputs = psArrayAlloc(nImages); … … 138 132 (*outputs)->data[i] = psImageAlloc(nx, ny, PS_TYPE_F32); 139 133 } 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;144 134 } 145 135 146 136 // Allocate the output error images, if required, otherwise check the number 137 assert(!errors || ! *outErrors || errors->n == (*outErrors)->n); 147 138 if (errors && (*outErrors == NULL)) { 148 139 *outErrors = psArrayAlloc(errors->n); … … 151 142 (*outErrors)->data[i] = psImageAlloc(nx, ny, PS_TYPE_F32); 152 143 } 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;157 144 } 158 145 159 146 // Check the masks, if specified 147 assert(!masks || masks->n == nImages); 160 148 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 }166 149 for (int i = 0; i < nImages; i++) { 167 150 psImage *image = images->data[i]; 168 151 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); 175 153 } 176 154 } … … 236 214 #ifdef TESTING 237 215 // Write error image out to check 238 char shift file[MAXCHAR]; // Filename of shift image239 char err file[MAXCHAR]; // Filename of error image240 sprintf(shift file,"%s.shift.%d",config->inputs->data[n],numTransforms);241 sprintf(err file,"%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); 242 220 psTrace("stac.transform.test", 6, 243 221 "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); 246 235 #endif 247 236
Note:
See TracChangeset
for help on using the changeset viewer.
