IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7179


Ignore:
Timestamp:
May 22, 2006, 5:19:26 PM (20 years ago)
Author:
Paul Price
Message:

Converting from F64 to F32

Location:
trunk/psModules/src/detrend
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/detrend/pmFlatNormalize.c

    r7178 r7179  
    1212                          const psImage *fluxLevels, // Fluxes for each integration (row) and chip (col)
    1313                          unsigned int maxIter, // Maximum number of iterations
    14                           double tolerance   // Tolerance level before dying
     14                          float tolerance   // Tolerance level before dying
    1515                         )
    1616{
     
    2020    // Sanity checks
    2121    assert(chipGains->n == numChips);
    22     assert(chipGains->type.type == PS_TYPE_F64);
     22    assert(chipGains->type.type == PS_TYPE_F32);
    2323    assert(maxIter >= 1);
    2424    assert(tolerance > 0);
    2525
    2626    // Take the logarithms
    27     psImage *flux = psImageCopy(NULL, fluxLevels, PS_TYPE_F64); // Copy of the input flux levels matrix
     27    psImage *flux = psImageCopy(NULL, fluxLevels, PS_TYPE_F32); // Copy of the input flux levels matrix
    2828    psImage *fluxMask = psImageAlloc(numChips, numSources, PS_TYPE_U8); // Mask for bad measurements
    2929    psImageInit(fluxMask, 0);
     
    3535    psVectorInit(sourceMask, 0);
    3636    for (int i = 0; i < numChips; i++) {
    37         if (isfinite(chipGains->data.F64[i]) && chipGains->data.F64[i] > 0) {
    38             chipGains->data.F64[i] = log(chipGains->data.F64[i]);
     37        if (isfinite(chipGains->data.F32[i]) && chipGains->data.F32[i] > 0) {
     38            chipGains->data.F32[i] = log(chipGains->data.F32[i]);
    3939        } else {
    40             chipGains->data.F64[i] = 0.0; // Take a wild guess
     40            chipGains->data.F32[i] = 0.0; // Take a wild guess
    4141            #if 0
    4242            // Blank out this chip
    4343            gainMask->data.U8[i] = 1;
    44             chipGains->data.F64[i] = NAN;
     44            chipGains->data.F32[i] = NAN;
    4545            #endif
    4646
     
    4848
    4949        for (int j = 0; j < numSources; j++) {
    50             if (isfinite(flux->data.F64[j][i]) && flux->data.F64[j][i] > 0) {
    51                 flux->data.F64[j][i] = log(flux->data.F64[j][i]);
     50            if (isfinite(flux->data.F32[j][i]) && flux->data.F32[j][i] > 0) {
     51                flux->data.F32[j][i] = log(flux->data.F32[j][i]);
    5252            } else {
    5353                // Blank out this measurement
    5454                fluxMask->data.U8[j][i] = 1;
    55                 flux->data.F64[j][i] = NAN;
     55                flux->data.F32[j][i] = NAN;
    5656            }
    5757        }
    5858    }
    5959
    60     double diff = INFINITY;             // Difference from previous iteration
    61     psVector *sourceFlux = psVectorAlloc(numSources, PS_TYPE_F64); // The flux in each integration
     60    float diff = INFINITY;             // Difference from previous iteration
     61    psVector *sourceFlux = psVectorAlloc(numSources, PS_TYPE_F32); // The flux in each integration
    6262    sourceFlux->n = numSources;
    63     psVector *oldSourceFlux = psVectorAlloc(numSources, PS_TYPE_F64); // The fluxes in the previous iteration
     63    psVector *oldSourceFlux = psVectorAlloc(numSources, PS_TYPE_F32); // The fluxes in the previous iteration
    6464    oldSourceFlux->n = numSources;
    6565    psVectorInit(oldSourceFlux, 0.0);
     
    6969
    7070        // Improve on the fluxes
    71         double sumFlux = 0.0;           // Total fluxes
     71        float sumFlux = 0.0;           // Total fluxes
    7272        long numFluxes = 0;             // Number of fluxes
    7373        for (int i = 0; i < numSources; i++) {
     
    7777            }
    7878            numFluxes++;
    79             double sum = 0.0;           // Sum of F_ij - G_j
     79            float sum = 0.0;           // Sum of F_ij - G_j
    8080            int number = 0;             // Number of chips contributing
    8181            for (int j = 0; j < numChips; j++) {
    8282                if (!gainMask->data.U8[j] && !fluxMask->data.U8[i][j]) {
    83                     sum += flux->data.F64[i][j] - chipGains->data.F64[j];
     83                    sum += flux->data.F32[i][j] - chipGains->data.F32[j];
    8484                    number++;
    8585                }
    8686            }
    8787            if (number > 0) {
    88                 sourceFlux->data.F64[i] = sum / (double)number;
     88                sourceFlux->data.F32[i] = sum / (float)number;
    8989            } else {
    9090                sourceMask->data.U8[i] = 1;
    91                 sourceFlux->data.F64[i] = NAN;
     91                sourceFlux->data.F32[i] = NAN;
    9292            }
    93             sumFlux += exp(sourceFlux->data.F64[i]);
    94             psTrace(__func__, 7, "Flux for exposure %d is %f\n", i, exp(sourceFlux->data.F64[i]));
     93            sumFlux += exp(sourceFlux->data.F32[i]);
     94            psTrace(__func__, 7, "Flux for exposure %d is %f\n", i, exp(sourceFlux->data.F32[i]));
    9595        }
    9696        // Normalise the mean to unity
    97         sumFlux /= (double)numFluxes;
     97        sumFlux /= (float)numFluxes;
    9898        sumFlux = log(sumFlux);
    9999        for (int i = 0; i < numSources; i++) {
     
    101101                continue;
    102102            }
    103             sourceFlux->data.F64[i] -= sumFlux;
    104             diff += abs((sourceFlux->data.F64[i] - oldSourceFlux->data.F64[i]) / sourceFlux->data.F64[i]);
     103            sourceFlux->data.F32[i] -= sumFlux;
     104            diff += abs((sourceFlux->data.F32[i] - oldSourceFlux->data.F32[i]) / sourceFlux->data.F32[i]);
    105105        }
    106106
     
    110110                continue;
    111111            }
    112             double sum = 0.0;           // Sum of F_ji - S_j
     112            float sum = 0.0;           // Sum of F_ji - S_j
    113113            int number = 0;             // Numer of sources contributing
    114114            for (int j = 0; j < numSources; j++) {
    115115                if (!fluxMask->data.U8[j][i]) {
    116                     sum += flux->data.F64[j][i] - sourceFlux->data.F64[j];
     116                    sum += flux->data.F32[j][i] - sourceFlux->data.F32[j];
    117117                    number++;
    118118                }
    119119            }
    120120            if (number > 0) {
    121                 chipGains->data.F64[i] = sum / (double)number;
     121                chipGains->data.F32[i] = sum / (float)number;
    122122            } else {
    123123                gainMask->data.U8[i] = 1;
    124                 chipGains->data.F64[i] = NAN;
     124                chipGains->data.F32[i] = NAN;
    125125            }
    126             psTrace(__func__, 7, "Gain for chip %d is %f\n", i, exp(chipGains->data.F64[i]));
     126            psTrace(__func__, 7, "Gain for chip %d is %f\n", i, exp(chipGains->data.F32[i]));
    127127        }
    128128
     
    141141    for (int i = 0; i < numChips; i++) {
    142142        if (!gainMask->data.U8[i]) {
    143             chipGains->data.F64[i] = exp(chipGains->data.F64[i]);
     143            chipGains->data.F32[i] = exp(chipGains->data.F32[i]);
    144144        }
    145145    }
    146146    for (int i = 0; i < numSources; i++) {
    147147        if (!sourceMask->data.U8[i]) {
    148             sourceFlux->data.F64[i] = exp(sourceFlux->data.F64[i]);
     148            sourceFlux->data.F32[i] = exp(sourceFlux->data.F32[i]);
    149149        }
    150150    }
  • trunk/psModules/src/detrend/pmFlatNormalize.h

    r7060 r7179  
    22#define PM_FLAT_NORMALIZE_H
    33
     4#include "pslib.h"
    45
    56// Normalise the flat-field measurements (f_ij = g_i s_j where f_ij is the flux recorded for chip i and
     
    1011                          const psImage *fluxLevels, // Fluxes for each integration (row) and chip (col)
    1112                          unsigned int maxIter, // Maximum number of iterations
    12                           double tolerance  // Tolerance level before dying
     13                          float tolerance // Tolerance level before dying
    1314                         );
    1415
Note: See TracChangeset for help on using the changeset viewer.