IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 3, 2006, 5:57:32 PM (20 years ago)
Author:
Paul Price
Message:

Updates for ppMerge

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

Legend:

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

    r6999 r7060  
    77
    88
    9 // Estimate the flat-field normalisation
    10 bool pmFlatNormalize(psVector *sourceFlux, // The source flux in each image; modified for return
    11                      psVector *chipGains, // Initial guess of the chip gains; modified for return
    12                      psImage *fluxLevels, // Fluxes for each integration (row) and chip (col); modified
    13                      unsigned int maxIter, // Maximum number of iterations
    14                      double tolerance   // Tolerance level before dying
    15                     )
     9// Estimate the flat-field normalisation; return the source flux in each integration
     10psVector *pmFlatNormalize(bool *converge, // Did we converge?
     11                          psVector *chipGains, // Initial guess of the chip gains; modified for return
     12                          const psImage *fluxLevels, // Fluxes for each integration (row) and chip (col)
     13                          unsigned int maxIter, // Maximum number of iterations
     14                          double tolerance   // Tolerance level before dying
     15                         )
    1616{
    17     int numSources = sourceFlux->n;     // Number of measurements made
    18     int numChips = chipGains->n;        // Number of chips with which each measurement is made
     17    int numSources = fluxLevels->numRows; // Number of integrations
     18    int numChips = fluxLevels->numCols; // Number of chips with which each integration is made
    1919
    2020    // Sanity checks
    21     assert(fluxLevels->numCols == numSources);
    22     assert(fluxLevels->numRows == numChips);
    23     assert(sourceFlux->type.type == PS_TYPE_F64);
     21    assert(chipGains->n == numChips);
    2422    assert(chipGains->type.type == PS_TYPE_F64);
    25     assert(fluxLevels->type.type == PS_TYPE_F64);
    2623    assert(maxIter >= 1);
    2724    assert(tolerance > 0);
    2825
    2926    // Take the logarithms
     27    psImage *flux = psImageCopy(NULL, fluxLevels, PS_TYPE_F64); // Copy of the input flux levels matrix
    3028    psImage *fluxMask = psImageAlloc(numSources, numChips, PS_TYPE_U8); // Mask for bad measurements
    3129    psImageInit(fluxMask, 0);
     
    4442
    4543        for (int j = 0; j < numSources; j++) {
    46             if (isfinite(fluxLevels->data.F64[j][i]) && fluxLevels->data.F64[j][i] > 0) {
    47                 fluxLevels->data.F64[j][i] = log(fluxLevels->data.F64[j][i]);
     44            if (isfinite(flux->data.F64[j][i]) && flux->data.F64[j][i] > 0) {
     45                flux->data.F64[j][i] = log(flux->data.F64[j][i]);
    4846            } else {
    4947                // Blank out this measurement
    5048                fluxMask->data.U8[j][i] = 1;
    51                 fluxLevels->data.F64[j][i] = NAN;
     49                flux->data.F64[j][i] = NAN;
    5250            }
    5351        }
    5452    }
    55     // Don't need to initialise sourceFlux, since that is changed immediately
    5653
    5754
    5855    double diff = INFINITY;             // Difference from previous iteration
     56    psVector *sourceFlux = psVectorAlloc(numSources, PS_TYPE_F64); // The flux in each integration
     57    // Don't need to initialise sourceFlux, since that is changed immediately
    5958    for (int iter = 0; iter < maxIter && diff > tolerance; iter++) {
    6059        diff = 0.0;
     
    7069            for (int j = 0; j < numChips; j++) {
    7170                if (!gainMask->data.U8[j] && !fluxMask->data.U8[i][j]) {
    72                     sum += fluxLevels->data.F64[i][j] - chipGains->data.F64[j];
     71                    sum += flux->data.F64[i][j] - chipGains->data.F64[j];
    7372                    number++;
    7473                }
     
    9392            for (int j = 0; j < numSources; j++) {
    9493                if (!fluxMask->data.U8[j][i]) {
    95                     sum += fluxLevels->data.F64[j][i] - sourceFlux->data.F64[j];
     94                    sum += flux->data.F64[j][i] - sourceFlux->data.F64[j];
    9695                    number++;
    9796                }
     
    106105        }
    107106    }
     107    psFree(flux);
    108108    psFree(fluxMask);
    109109
    110     // Un-log everything
     110    // Un-log the vectors
    111111    for (int i = 0; i < numChips; i++) {
    112112        if (!gainMask->data.U8[i]) {
     
    122122    psFree(sourceMask);
    123123
    124     return (diff <= tolerance);         // Did we converge?
     124    if (converge) {
     125        *converge = (diff < tolerance); // Did we converge?
     126    }
     127
     128    return sourceFlux;
    125129}
  • trunk/psModules/src/detrend/pmFlatNormalize.h

    r6999 r7060  
    55// Normalise the flat-field measurements (f_ij = g_i s_j where f_ij is the flux recorded for chip i and
    66// integration j, g_i is the gain for the i-th chip, s_j is the flux of the source in the j-th integration).
    7 bool pmFlatNormalize(psVector *sourceFlux, // The source flux in each image; modified for return
    8                      psVector *chipGains, // Initial guess of the chip gains; modified for return
    9                      psImage *fluxLevels, // Fluxes for each integration (row) and chip (col); modified
    10                      unsigned int maxIter, // Maximum number of iterations
    11                      double tolerance // Tolerance level before dying
    12                     );
    13 
     7// Return the source flux in each integration.
     8psVector *pmFlatNormalize(bool *converge, // Did we converge?
     9                          psVector *chipGains, // Initial guess of the chip gains; modified for return
     10                          const psImage *fluxLevels, // Fluxes for each integration (row) and chip (col)
     11                          unsigned int maxIter, // Maximum number of iterations
     12                          double tolerance   // Tolerance level before dying
     13                         );
    1414
    1515#endif
  • trunk/psModules/src/detrend/pmMaskBadPixels.h

    r6910 r7060  
    2424 *  @author Ross Harman, MHPCC
    2525 *
    26  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    27  *  @date $Date: 2006-04-19 20:37:35 $
     26 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     27 *  @date $Date: 2006-05-04 03:57:32 $
    2828 *
    2929 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3939/** Mask values */
    4040typedef enum {
    41     PM_MASK_CLEAR   = 0x00,   ///< The pixel is a charge trap.
     41    PM_MASK_CLEAR   = 0x00,   ///< The pixel is not masked
    4242    PM_MASK_TRAP    = 0x01,   ///< The pixel is a charge trap.
    4343    PM_MASK_BADCOL  = 0x02,   ///< The pixel is a bad column.
Note: See TracChangeset for help on using the changeset viewer.