Changeset 3375 for trunk/stac/src/stacCombine.c
- Timestamp:
- Mar 4, 2005, 11:37:01 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/stac/src/stacCombine.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/stac/src/stacCombine.c
r2783 r3375 1 1 #include <stdio.h> 2 #include <assert.h> 2 3 #include <math.h> 3 4 #include "pslib.h" … … 15 16 // Would like to use psVectorStats, but it doesn't have errors built in yet 16 17 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 17 (void)psVectorStats(stats, values, masks, 1);18 (void)psVectorStats(stats, values, NULL, masks, 1); 18 19 float mean = stats->sampleMean; 19 20 psFree(stats); … … 47 48 { 48 49 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN); 49 (void)psVectorStats(stats, values, masks, 1);50 (void)psVectorStats(stats, values, NULL, masks, 1); 50 51 float median = stats->sampleMedian; 51 52 psFree(stats); … … 76 77 psImage *error = (psImage *)errors->data[i]; // The error image 77 78 78 if ((image->numCols != numCols) || (image->numRows != numRows)) { 79 psError("stac.combine", 80 "Image size mismatch on error image %d\nExpected %dx%d, got %dx%d\n", 81 i, numCols, numRows, image->numCols, image->numRows); 82 return false; 83 } 84 if ((error->numCols != numCols) || (error->numRows != numRows)) { 85 psError("stac.combine", 86 "Image size mismatch on error image %d\nExpected %dx%d, got %dx%d\n", 87 i, numCols, numRows, error->numCols, error->numRows); 88 return false; 89 } 79 assert(image->numCols == numCols && image->numRows == numRows); 80 assert(error->numCols == numCols && error->numRows == numRows); 90 81 } 91 82 92 83 // Check combined image 84 assert(!*combined || ((*combined)->numRows == numRows) && ((*combined)->numCols == numCols)); 93 85 if (*combined == NULL) { 94 86 *combined = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Combined image 95 } else if (((*combined)->numRows != numRows) || ((*combined)->numCols != numCols)) {96 psError("stac.combine", "Size of combined image (%dx%d) does not match inputs (%dx%d)\n",97 (*combined)->numCols, (*combined)->numRows, numCols, numRows);98 return false;99 87 } 100 88 101 89 // Check area of interest 102 if (region && ((region->numRows != numRows) || (region->numCols != numCols))) { 103 psError("stac.combine", "Size of area of interest (%dx%d) does not match inputs (%dx%d)\n", 104 region->numCols, region->numRows, numCols, numRows); 105 return false; 106 } 90 assert(!region || (region->numRows == numRows) && (region->numCols == numCols)); 107 91 108 92 psTrace("stac.combine", 1, "Combining images....\n"); … … 117 101 // Allocate the rejection masks, if required 118 102 *rejected = psArrayAlloc(nImages); 119 } else if ((*rejected)->n != nImages) { 120 psError("stac.combine", "Number of rejection masks (%d) does not match number of input" 121 "images (%d).\n", (*rejected)->n, nImages); 122 return NULL; 103 } else { 104 assert((*rejected)->n != nImages); 123 105 } 124 106 … … 208 190 if (nReject > 0) { 209 191 for (int i = 0; i < nImages; i++) { 210 char rejfile[MAXCHAR]; // Filename of rejection image 211 sprintf(rejfile,"%s.shiftrej",config->inputs->data[i]); 212 psImageWriteSection((psImage*)((*rejected)->data[i]),0,0,0,NULL,0,rejfile); 192 char rejName[MAXCHAR]; // Filename of rejection image 193 sprintf(rejName,"%s.shiftrej",config->inputs->data[i]); 194 195 psFits *rejFile = psFitsAlloc(rejName); 196 if (!psFitsWriteImage(rejFile, NULL, (*rejected)->data[i], 0, NULL)) { 197 psErrorStackPrint(stderr, "Unable to write image: %s\n", rejName); 198 } 199 psTrace("stac", 1, "Rejection image written to %s\n", rejName); 200 psFree(rejFile); 213 201 } 214 202 } 215 203 // Write chi^2 image 216 204 iteration++; 217 char chifile[MAXCHAR]; // Filename of chi^2 image 218 sprintf(chifile,"chi2_%d.fits",iteration); 219 psImageWriteSection(chi2,0,0,0,NULL,0,chifile); 205 char chiName[MAXCHAR]; // Filename of chi^2 image 206 sprintf(chiName,"chi2_%d.fits",iteration); 207 psFits *chiFile = psFitsAlloc(chiName); 208 if (!psFitsWriteImage(chiFile, NULL, chi2 , 0, NULL)) { 209 psErrorStackPrint(stderr, "Unable to write image: %s\n", chiName); 210 } 211 psTrace("stac", 1, "Chi^2 image written to %s\n", chiName); 212 psFree(chiFile); 220 213 psFree(chi2); 221 214 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
