IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7060


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

Updates for ppMerge

Location:
trunk/psModules/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPA.c

    r7017 r7060  
    1212* XXX: Should we implement non-linear cell->chip transforms?
    1313*
    14 *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2006-05-01 01:55:43 $
     14*  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2006-05-04 03:57:32 $
    1616*
    1717*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    173173}
    174174
     175void pmCellFreeData(pmCell *cell)
     176{
     177    pmCellFreeReadouts(cell);
     178    if (cell->hdu) {
     179        psFree(cell->hdu->images);
     180    }
     181}
     182
     183void pmChipFreeData(pmChip *chip)
     184{
     185    for (int i = 0; i < chip->cells->n; i++) {
     186        pmCellFreeData(chip->cells->data[i]);
     187    }
     188    if (chip->hdu) {
     189        psFree(chip->hdu->images);
     190    }
     191}
     192
     193void pmFPAFreeData(pmFPA *fpa)
     194{
     195    for (int i = 0; i < fpa->chips->n; i++) {
     196        pmChipFreeData(fpa->chips->data[i]);
     197    }
     198    if (fpa->hdu) {
     199        psFree(fpa->hdu->images);
     200    }
     201}
    175202
    176203pmReadout *pmReadoutAlloc(pmCell *cell)
  • trunk/psModules/src/camera/pmFPA.h

    r7017 r7060  
    77*  @author GLG, MHPCC
    88*
    9 *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2006-05-01 01:55:43 $
     9*  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2006-05-04 03:57:32 $
    1111*
    1212*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    151151void pmCellFreeReadouts(pmCell *cell);
    152152void pmChipFreeCells(pmChip *chip);
     153void pmCellFreeData(pmCell *cell);
     154void pmChipFreeData(pmChip *chip);
     155void pmFPAFreeData(pmFPA *fpa);
    153156
    154157/** Allocates a pmReadout
  • 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.
  • trunk/psModules/src/psmodules.h

    r7019 r7060  
    4949#include <pmFlatField.h>
    5050#include <pmFlatFieldErrors.h>
     51#include <pmFlatNormalize.h>
    5152#include <pmFringeStats.h>
    5253#include <pmMaskBadPixels.h>
Note: See TracChangeset for help on using the changeset viewer.