Changeset 21183 for trunk/psModules/src/detrend/pmFlatNormalize.c
- Timestamp:
- Jan 26, 2009, 8:40:07 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/detrend/pmFlatNormalize.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmFlatNormalize.c
r9730 r21183 9 9 10 10 #include "pmFlatNormalize.h" 11 12 // XXX this function should take the abstract mask names and set bad values in a more precise way 11 13 12 14 // I'm not sure that many many iterations are required, but rather suspect that the system converges within a … … 55 57 // Take the logarithms 56 58 psImage *flux = psImageCopy(NULL, bgMatrix, PS_TYPE_F32); // Copy of the input flux levels matrix 57 psImage *fluxMask = psImageAlloc(numChips, numExps, PS_TYPE_ U8); // Mask for bad measurements59 psImage *fluxMask = psImageAlloc(numChips, numExps, PS_TYPE_IMAGE_MASK); // Mask for bad measurements 58 60 psImageInit(fluxMask, 0); 59 psVector *gainMask = psVectorAlloc(numChips, PS_TYPE_ U8); // Mask for bad gains61 psVector *gainMask = psVectorAlloc(numChips, PS_TYPE_VECTOR_MASK); // Mask for bad gains 60 62 psVectorInit(gainMask, 0); 61 psVector *expMask = psVectorAlloc(numExps, PS_TYPE_ U8); // Mask for bad exposures63 psVector *expMask = psVectorAlloc(numExps, PS_TYPE_VECTOR_MASK); // Mask for bad exposures 62 64 psVectorInit(expMask, 0); 63 65 for (int i = 0; i < numChips; i++) { … … 75 77 } else { 76 78 // Blank out this measurement 77 fluxMask->data. U8[j][i] = 1;79 fluxMask->data.PS_TYPE_IMAGE_MASK_DATA[j][i] = 1; 78 80 flux->data.F32[j][i] = NAN; 79 81 } … … 90 92 int numFluxes = 0; // Number of fluxes 91 93 for (int i = 0; i < numExps; i++) { 92 if (expMask->data. U8[i]) {94 if (expMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 93 95 psTrace("psModules.detrend", 7, "Flux for exposure %d is masked.\n", i); 94 96 continue; … … 98 100 int number = 0; // Number of chips contributing 99 101 for (int j = 0; j < numChips; j++) { 100 if (!gainMask->data. U8[j] && !fluxMask->data.U8[i][j]) {102 if (!gainMask->data.PS_TYPE_VECTOR_MASK_DATA[j] && !fluxMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j]) { 101 103 sum += flux->data.F32[i][j] - chipGains->data.F32[j]; 102 104 number++; … … 106 108 expFluxes->data.F32[i] = sum / (float)number; 107 109 } else { 108 expMask->data. U8[i] = 1;110 expMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1; 109 111 expFluxes->data.F32[i] = NAN; 110 112 } … … 116 118 int numGains = 0; // Number of gains 117 119 for (int i = 0; i < numChips; i++) { 118 if (gainMask->data. U8[i]) {120 if (gainMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 119 121 continue; 120 122 } … … 122 124 int number = 0; // Numer of sources contributing 123 125 for (int j = 0; j < numExps; j++) { 124 if (!fluxMask->data. U8[j][i]) {126 if (!fluxMask->data.PS_TYPE_IMAGE_MASK_DATA[j][i]) { 125 127 sum += flux->data.F32[j][i] - expFluxes->data.F32[j]; 126 128 number++; … … 130 132 chipGains->data.F32[i] = sum / (float)number; 131 133 } else { 132 gainMask->data. U8[i] = 1;134 gainMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1; 133 135 chipGains->data.F32[i] = NAN; 134 136 } … … 144 146 diff = 0.0; 145 147 for (int i = 0; i < numChips; i++) { 146 if (gainMask->data. U8[i]) {148 if (gainMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 147 149 continue; 148 150 } … … 151 153 } 152 154 for (int i = 0; i < numExps; i++) { 153 if (expMask->data. U8[i]) {155 if (expMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 154 156 continue; 155 157 } … … 171 173 // Un-log the vectors 172 174 for (int i = 0; i < numChips; i++) { 173 if (!gainMask->data. U8[i]) {175 if (!gainMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 174 176 chipGains->data.F32[i] = expf(chipGains->data.F32[i]); 175 177 } 176 178 } 177 179 for (int i = 0; i < numExps; i++) { 178 if (!expMask->data. U8[i]) {180 if (!expMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 179 181 expFluxes->data.F32[i] = expf(expFluxes->data.F32[i]); 180 182 }
Note:
See TracChangeset
for help on using the changeset viewer.
