Changeset 2661 for trunk/stac/src/stacCombine.c
- Timestamp:
- Dec 7, 2004, 3:38:05 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/stac/src/stacCombine.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/stac/src/stacCombine.c
r2500 r2661 16 16 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV); 17 17 (void)psVectorStats(stats, values, masks, 1); 18 float mean = stats->sampleMean; 18 19 psFree(stats); 19 return stats->sampleMean;20 return mean; 20 21 #else 21 22 // Instead, do it ourselves … … 45 46 { 46 47 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN); 47 (void)psVectorStats(stats, values, masks, 1); 48 (void)psVectorStats(stats, values, masks, 0); 49 float median = stats->sampleMedian; 48 50 psFree(stats); 49 return stats->sampleMedian;51 return median; 50 52 } 51 53 … … 113 115 } 114 116 } 115 117 118 #ifdef TESTING 119 // chi^2 image 120 psImage *chi2 = psImageAlloc(numCols, numRows, PS_TYPE_F32); 121 static int iteration = 0; // Number of times function has been called 122 #endif 116 123 117 124 for (int y = 0; y < numRows; y++) { … … 131 138 } 132 139 133 float average = stacCombineMean(pixels, deltas, mask); // Combined value 140 float average = stacCombineMedian(pixels, deltas, mask); // Combined value 141 142 #ifdef TESTING 143 // Calculate chi^2 144 chi2->data.F32[y][x] = 0.0; 145 int numGoodPix = 0; 146 for (int i = 0; i < nImages; i++) { 147 if (mask->data.U8[i]) { 148 chi2->data.F32[y][x] += SQUARE((pixels->data.F32[i] - average) / deltas->data.F32[i]); 149 numGoodPix++; 150 } 151 } 152 chi2->data.F32[y][x] /= (float)numGoodPix; 153 #endif 134 154 135 155 // Rejection iterations 136 156 for (int rejNum = 0; rejNum < nReject; rejNum++) { 137 157 float max = 0.0; 138 int maxIndex = 0;158 int maxIndex = -1; 139 159 for (int i = 0; i < nImages; i++) { 140 if (mask->data.U8[i] && ( ABS(pixels->data.F32[i] - average) / deltas->data.F32[i] > max)) {141 max = ABS(pixels->data.F32[i] - average) / deltas->data.F32[i];160 if (mask->data.U8[i] && ((pixels->data.F32[i] - average) / deltas->data.F32[i] > max)) { 161 max = (pixels->data.F32[i] - average) / deltas->data.F32[i]; 142 162 maxIndex = i; 143 163 } … … 152 172 } // Rejection iterations 153 173 154 combined->data.F32[y][x] = average;174 combined->data.F32[y][x] = stacCombineMean(pixels, deltas, mask); 155 175 } 156 176 } // Iterating over output pixels … … 160 180 if (nReject > 0) { 161 181 for (int i = 0; i < nImages; i++) { 162 char rejfile[MAXCHAR]; // Filename of rejection image182 char rejfile[MAXCHAR]; // Filename of rejection image 163 183 sprintf(rejfile,"%s.shiftrej",config->inputs->data[i]); 164 184 psImageWriteSection((psImage*)((*rejected)->data[i]),0,0,0,NULL,0,rejfile); 165 185 } 166 186 } 187 // Write chi^2 image 188 iteration++; 189 char chifile[MAXCHAR]; // Filename of chi^2 image 190 sprintf(chifile,"chi2_%d.fits",iteration); 191 psImageWriteSection(chi2,0,0,0,NULL,0,chifile); 192 psFree(chi2); 167 193 #endif 168 194
Note:
See TracChangeset
for help on using the changeset viewer.
