IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 31, 2008, 12:39:06 PM (18 years ago)
Author:
Paul Price
Message:

Adding assertion macros for readouts (about time too!). Adding function to renormalise the weight map to correspond to the measured image stdev.

File:
1 edited

Legend:

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

    r16396 r17249  
    66 * @author Eugene Magnier, IfA
    77 *
    8  * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
    9  * @date $Date: 2008-02-12 01:52:56 $
     8 * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
     9 * @date $Date: 2008-03-31 22:39:06 $
    1010 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    1111 */
     
    178178bool pmFPACheckParents(pmFPA *fpa);     ///< FPA to check
    179179
     180
     181/// Assertions
     182
     183/// Check that the fundamentals of a readout are set
     184#define PM_ASSERT_READOUT_NON_NULL(READOUT, RETVAL) { \
     185    if (!(READOUT) || !(READOUT)->bias || !(READOUT)->analysis) { \
     186        psError(PS_ERR_UNEXPECTED_NULL, true, "Readout %s or one of its components is NULL.", #READOUT); \
     187        return RETVAL; \
     188    } \
     189    int numCols = 0, numRows = 0; /* Size of readout images */ \
     190    psImage *image = (READOUT)->image; /* Image pixels */ \
     191    if (image) { \
     192        PS_ASSERT_IMAGE_TYPE((READOUT)->image, PS_TYPE_F32, RETVAL); \
     193        numCols = image->numCols; \
     194        numRows = image->numRows; \
     195    } \
     196    psImage *mask = (READOUT)->mask; /* Mask pixels */ \
     197    if (mask) { \
     198        PS_ASSERT_IMAGE_NON_NULL((READOUT)->mask, RETVAL); \
     199        if ((numCols != 0 || numRows != 0) && (mask->numCols != numCols || mask->numRows != numRows)) { \
     200            psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Mask in readout %s has wrong size (%dx%d vs %dx%d)", \
     201                    #READOUT, mask->numCols, mask->numRows, numCols, numRows); \
     202            return RETVAL; \
     203        } else { \
     204            numCols = mask->numCols; \
     205            numRows = mask->numRows; \
     206        } \
     207    } \
     208    psImage *weight = (READOUT)->weight; /* Weight map pixels */ \
     209    if (weight) { \
     210        PS_ASSERT_IMAGE_NON_NULL((READOUT)->weight, RETVAL); \
     211        if ((numCols != 0 || numRows != 0) && (weight->numCols != numCols || weight->numRows != numRows)) { \
     212            psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Weight in readout %s has wrong size (%dx%d vs %dx%d)", \
     213                    #READOUT, weight->numCols, weight->numRows, numCols, numRows); \
     214            return RETVAL; \
     215        } \
     216    } \
     217}
     218
     219/// Assert that a readout contains an image
     220#define PM_ASSERT_READOUT_IMAGE(READOUT, RETVAL) \
     221    PS_ASSERT_IMAGE_NON_NULL((READOUT)->image, RETVAL);
     222
     223/// Assert that a readout contains a mask
     224#define PM_ASSERT_READOUT_MASK(READOUT, RETVAL) \
     225    PS_ASSERT_IMAGE_NON_NULL((READOUT)->mask, RETVAL);
     226
     227/// Assert that a readout contains a weight map
     228#define PM_ASSERT_READOUT_WEIGHT(READOUT, RETVAL) \
     229    PS_ASSERT_IMAGE_NON_NULL((READOUT)->weight, RETVAL);
     230
    180231/// @}
    181232#endif // #ifndef PM_FPA_H
Note: See TracChangeset for help on using the changeset viewer.