Changeset 7860
- Timestamp:
- Jul 10, 2006, 3:48:50 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/detrend/pmFlatNormalize.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmFlatNormalize.c
r7278 r7860 38 38 psVectorInit(sourceMask, 0); 39 39 for (int i = 0; i < numChips; i++) { 40 // Note: the input gains are in e/ADU; we want to work with ADU/e (bg [ADU] = g [ADU/e] * f [e]) 40 41 if (isfinite(chipGains->data.F32[i]) && chipGains->data.F32[i] > 0) { 41 chipGains->data.F32[i] = log(chipGains->data.F32[i]);42 chipGains->data.F32[i] = -log(chipGains->data.F32[i]); 42 43 } else { 43 44 chipGains->data.F32[i] = 0.0; // Take a wild guess 44 #if 045 // Blank out this chip46 gainMask->data.U8[i] = 1;47 chipGains->data.F32[i] = NAN;48 #endif49 50 45 } 51 46 … … 61 56 } 62 57 58 // Not really sure that we need to iterate, but here we go anyway... 59 63 60 float diff = INFINITY; // Difference from previous iteration 64 61 psVector *sourceFlux = psVectorAlloc(numSources, PS_TYPE_F32); // The flux in each integration … … 70 67 diff = 0.0; 71 68 72 73 69 // Improve on the fluxes 74 float sumFlux = 0.0; // Total fluxes75 70 long numFluxes = 0; // Number of fluxes 76 71 for (int i = 0; i < numSources; i++) { … … 94 89 sourceFlux->data.F32[i] = NAN; 95 90 } 96 sumFlux += exp(sourceFlux->data.F32[i]); 97 psTrace(__func__, 7, "Flux for exposure %d is %f\n", i, exp(sourceFlux->data.F32[i])); 91 psTrace(__func__, 7, "Flux for exposure %d is %lf\n", i, exp(sourceFlux->data.F32[i])); 98 92 } 99 // Normalise the mean to unity 100 sumFlux /= (float)numFluxes; 101 sumFlux = log(sumFlux); 93 102 94 for (int i = 0; i < numSources; i++) { 103 if ( sourceMask->data.U8[i]) {104 continue;95 if (!sourceMask->data.U8[i]) { 96 diff += abs((sourceFlux->data.F32[i] - oldSourceFlux->data.F32[i]) / sourceFlux->data.F32[i]); 105 97 } 106 sourceFlux->data.F32[i] -= sumFlux;107 diff += abs((sourceFlux->data.F32[i] - oldSourceFlux->data.F32[i]) / sourceFlux->data.F32[i]);108 98 } 109 99 … … 127 117 chipGains->data.F32[i] = NAN; 128 118 } 129 psTrace(__func__, 7, "Gain for chip %d is % f\n", i, exp(chipGains->data.F32[i]));119 psTrace(__func__, 7, "Gain for chip %d is %lf\n", i, exp(-chipGains->data.F32[i])); 130 120 } 131 121 132 psTrace(__func__, 2, "Iteration %d: difference is % f\n", iter, diff);122 psTrace(__func__, 2, "Iteration %d: difference is %e\n", iter, diff); 133 123 134 124 // Switch the old and new
Note:
See TracChangeset
for help on using the changeset viewer.
