IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 17, 2006, 12:03:32 PM (20 years ago)
Author:
Paul Price
Message:

Documenting pmFringeStats. Adding mask to pmFringeRegions{Read,Write}Fits.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/detrend/pmFringeStats.h

    r7875 r9615  
    1 /** @file  pmFringeStats.h
    2  *
    3  *  @brief Measure Fringe statistics and apply correction
    4  *
    5  *  @author Eugene Magnier, IfA
    6  *
    7  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2006-07-12 04:44:01 $
    9  *
    10  *  Copyright 2004 IfA, University of Hawaii
    11  */
     1/// @file pmFringeStats.h
     2///
     3/// @brief Measure fringe statistics, and apply correction
     4///
     5/// @ingroup Detrend
     6///
     7/// @author Eugene Magnier, IfA
     8/// @author Paul Price, IfA
     9///
     10/// @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     11/// @date $Date: 2006-10-17 22:03:32 $
     12///
     13/// Copyright 2004-2006 Institute for Astronomy, University of Hawaii
     14///
    1215
    13 # ifndef PM_FRINGE_STATS
    14 # define PM_FRINGE_STATS
     16#ifndef PM_FRINGE_STATS
     17#define PM_FRINGE_STATS
    1518
    1619//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    1821//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    1922
    20 /** Structure to hold the fringe measurement regions.
    21  */
     23/// Fringe measurement regions.
     24///
     25/// Fringes are measured within a box of size dX,dY.  A large scale smoothing is performed by subtracting the
     26/// background within large divisions of the image.  The coordinates of the fringe points and the mask may be
     27/// NULL, which means that they will be generated when required.
    2228typedef struct
    2329{
    24     psU32 nRequested;   // number of fringe points selected
    25     psU32 nAccepted;   // number of fringe points not masked
    26     psU32 dX;    // median box half-width
    27     psU32 dY;    // median box half-height
    28     psU32 nX;    // large-scale smoothing in x (col)
    29     psU32 nY;    // large-scale smoothing in y (row)
    30     psVector *x;    // fringe point coordinates (col)
    31     psVector *y;    // fringe point coordinates (row)
    32     psVector *mask;   // fringe point on/off mask
     30    psU32 nRequested;                   // Number of fringe points selected
     31    psU32 nAccepted;                    // Number of fringe points not masked
     32    psU32 dX;                           // Median box half-width
     33    psU32 dY;                           // Median box half-height
     34    psU32 nX;                           // Number of large-scale smoothing divisions in x (col)
     35    psU32 nY;                           // Number of large-scale smoothing divisions in y (row)
     36    psVector *x;                        // Fringe point coordinates (col), or NULL
     37    psVector *y;                        // Fringe point coordinates (row), or NULL
     38    psVector *mask;                     // Fringe point on/off mask, or NULL
    3339}
    3440pmFringeRegions;
    3541
    3642/// Allocate fringe regions
    37 pmFringeRegions *pmFringeRegionsAlloc (
    38     int nPts,     // number of points to create
    39     int dX,     // half-width of fringe boxes
    40     int dY,     // half-height of fringe boxes
    41     int nX,     // smoothing scale in x
    42     int nY    // smoothing scale in y
    43 );
     43pmFringeRegions *pmFringeRegionsAlloc (int nPts, ///< Number of fringe points to create
     44                                       int dX, ///< Half-width of fringe boxes
     45                                       int dY, ///< Half-height of fringe boxes
     46                                       int nX, ///< Smoothing scale in x
     47                                       int nY ///< Smoothing scale in y
     48                                      );
    4449
    45 // Generate the fringe points
    46 bool pmFringeRegionsCreatePoints(pmFringeRegions *fringe, // Fringe regions
    47                                  const psImage *image, // Image for the regions (defines the size)
    48                                  psRandom *random // Random number generator
     50/// Generate the fringe points
     51///
     52/// Fringe points are generated randomly over the image.  No effort is made to avoid masked regions (indeed,
     53/// the function knows nothing about masks).  If the random number generator is NULL, then a new one will be
     54/// used.
     55bool pmFringeRegionsCreatePoints(pmFringeRegions *fringe, ///< Fringe regions to generate
     56                                 const psImage *image, ///< Image for the regions (defines the size)
     57                                 psRandom *random ///< Random number generator, or NULL
    4958                                );
    5059
    51 // Write the regions to a FITS file
    52 bool pmFringeRegionsWriteFits(psFits *fits, // Output FITS file
    53                               psMetadata *header, // Header to write, or NULL
    54                               const pmFringeRegions *regions, // Regions to write
    55                               const char *extname // Extension name, or NULL
     60/// Write the regions to a FITS file
     61///
     62/// The fringe regions are written to the FITS file, with the given extension name.  The header is
     63/// supplemented with scalar values dX, dY, nX and nY (as PSFRNGDX, PSFRNGDY, PSFRNGNX, PSFRNGNY) from the
     64/// fringe regions, while the fringe coordinates and mask are written as a FITS table (as x, y, mask).
     65bool pmFringeRegionsWriteFits(psFits *fits, ///< Output FITS file
     66                              psMetadata *header, ///< Additional headers to write, or NULL
     67                              const pmFringeRegions *regions, ///< Regions to write
     68                              const char *extname ///< Extension name, or NULL
    5669                             );
    5770
    58 // Read the regions from a FITS file
    59 pmFringeRegions *pmFringeRegionsReadFits(psMetadata *header, // Header to read, or NULL
    60         const psFits *fits, // Input FITS file
    61         const char *extname // Extension name, or NULL
     71/// Read the regions from a FITS file
     72///
     73/// The fringe regions are read from the FITS file, at the given extension name.  The scalars are retrieved
     74/// from the header, while the table provides the fringe coordinates and mask.
     75pmFringeRegions *pmFringeRegionsReadFits(psMetadata *header, ///< Header to read, or NULL
     76        const psFits *fits, ///< Input FITS file
     77        const char *extname ///< Extension name, or NULL
    6278                                        );
    6379
     
    6884//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    6985
    70 /** Structure to hold the fringe measurements for a particular image
    71  */
     86/// Fringe measurements for a particular image
     87///
     88/// Measurements of the median and stdev are made at each of the fringe regions.
    7289typedef struct
    7390{
    74     pmFringeRegions *regions;           // Fringe regions
    75     psVector *f;    // fringe point median
    76     psVector *df;   // fringe point stdev
     91    pmFringeRegions *regions;           ///< Fringe regions
     92    psVector *f;                        ///< Fringe point median
     93    psVector *df;                       ///< Fringe point stdev
    7794}
    7895pmFringeStats;
     
    8299                                 );
    83100
    84 /** Measure the fringe stats for an image
    85  *
    86  *  Given an input image and a fringe stats structure, measure the statistics for each of the fringe points on
    87  *  the image.  If the fringe vectors are NULL, new vectors are created.
    88  *
    89  *  XXX should the structure carry the image dimensions for validation?
    90  *
    91  *  @return  bool: True or false for success or failure
    92  */
    93 pmFringeStats *pmFringeStatsMeasure(
    94     pmFringeRegions *fringe,            ///< fringe regions
    95     pmReadout *readout,                 ///< measure fringes on this readout
    96     psMaskType maskVal                  ///< Mask value for statistics
    97 );
     101/// Measure the fringe statistics for an image
     102///
     103/// Given an input image and fringe regions at which to measure, measures the median and stdev at each of the
     104/// fringe points.  If the fringe points are undefined, they are generated.
     105pmFringeStats *pmFringeStatsMeasure(pmFringeRegions *fringe, ///< Fringe regions at which to measure
     106                                    const pmReadout *readout, ///< Readout for which to measure
     107                                    psMaskType maskVal ///< Mask value for image
     108                                   );
    98109
    99 // Write the fringe stats for an image to a FITS table
    100 bool pmFringeStatsWriteFits(psFits *fits, // FITS file to which to write
    101                             psMetadata *header, // Header to write, or NULL
    102                             const pmFringeStats *fringe, // Fringe statistics to be written
    103                             const char *extname // Extension name for table
     110/// Write the fringe stats for an image to a FITS table
     111///
     112/// The fringe measurements are written to the FITS file with the given extension name.  The median and stdev
     113/// measurements are written as a FITS table (as f and df).
     114bool pmFringeStatsWriteFits(psFits *fits, ///< FITS file to which to write
     115                            psMetadata *header, ///< Additional headers to write, or NULL
     116                            const pmFringeStats *fringe, ///< Fringe statistics to be written
     117                            const char *extname ///< Extension name for table
    104118                           );
    105119
    106 // Read the fringe stats for an image from a FITS table
    107 pmFringeStats *pmFringeStatsReadFits(psMetadata *header, // Header to read, or NULL
    108                                      const psFits *fits, // FITS file from which to read
    109                                      const char *extname, // Extension name to read
    110                                      pmFringeRegions *regions // Corresponding regions for fringe measurements
     120/// Read the fringe stats for an image from a FITS table
     121///
     122/// The fringe measurements are read from the FITS file, at the given extension name.  The table provides the
     123/// median and stdev measurements.  It is assumed that the fringe measurements correspond to the regions
     124/// provided.
     125pmFringeStats *pmFringeStatsReadFits(psMetadata *header, ///< Header to read, or NULL
     126                                     const psFits *fits, ///< FITS file from which to read
     127                                     const char *extname, ///< Extension name to read
     128                                     pmFringeRegions *regions ///< Corresponding regions
    111129                                    );
    112130
    113 // Concatenate the fringe stats for several readouts into a single fringe stats.  The idea is that each
    114 // readout of each chip should be measured separately (so as to avoid any gaps, as in the case for GPC), but
    115 // then perform the fit to all the readouts belonging to a chip.  To do so, we need to concatenate.
    116 pmFringeStats *pmFringeStatsConcatenate(const psArray *fringes, // Array of pmFringeStats for the readouts
    117                                         const psVector *x0, // Offset in x for the readout
    118                                         const psVector *y0 // Offset in y for the readout
     131/// Concatenate the fringe stats for several readouts into a single fringe stats.
     132///
     133/// Each readout of each chip must be measured separately (so as to avoid any gaps between the cells, as in
     134/// the case for GPC).  But the fit must be performed with all the readouts belonging to a chip (in order to
     135/// get a secure measurement of the fringe amplitudes).  To do so, we need to concatenate the fringe
     136/// measurements for each of the chip components.  This function generates a new pmFringeStats from
     137/// concatenating those in the array.  The corresponding pmFringeRegions is also generated.
     138pmFringeStats *pmFringeStatsConcatenate(const psArray *fringes, ///< Array of pmFringeStats for the readouts
     139                                        const psVector *x0, ///< Offset in x for the readout
     140                                        const psVector *y0 ///< Offset in y for the readout
    119141                                       );
    120142
     
    123145//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    124146
    125 /** the pmFringeScale structure defines the relationship between two fringe measurements
    126  */
     147/// The fringe correction solution
    127148typedef struct
    128149{
    129     int nFringeFrames;
    130     psVector *coeff;
    131     psVector *coeffErr;
     150    int nFringeFrames;                  ///< Number of fringe frames
     151    psVector *coeff;                    ///< Fringe coefficients; size = nFringeFrames
     152    psVector *coeffErr;                 ///< Error in fringe coefficients; size = nFringeFrames
    132153}
    133154pmFringeScale;
    134155
    135 /** Determine the scales for the fringe correction
    136  *
    137  * Given an input fringe measurement, and an array of template fringe measurements, measure the contribution
    138  * of each of the templates to the input.  Rejection is performed on the fringe regions, to weed out stars
    139  * etc.
    140  *
    141  * @return pmFringeScale*
    142  */
    143 pmFringeScale *pmFringeScaleMeasure(pmFringeStats *science, // Fringe measurements from science image
    144                                     psArray *fringes, // Array of fringe measurements from templates
    145                                     float rej, // Rejection threshold (in standard deviations)
    146                                     unsigned int nIter, // Maximum number of iterations
    147                                     float keepFrac // Minimum fraction of regions to keep
     156/// Measure the scales for the fringe correction
     157///
     158/// Given a fringe measurement for a science image, and an array of template fringe measurements, this
     159/// function measures the contribution of each of the templates to the input.  Rejection is performed on the
     160/// fringe regions, to weed out stars etc.
     161pmFringeScale *pmFringeScaleMeasure(pmFringeStats *science, ///< Fringe measurements from science image
     162                                    psArray *fringes, ///< Array of fringe measurements from templates
     163                                    float rej, ///< Rejection threshold (in standard deviations)
     164                                    unsigned int nIter, ///< Maximum number of iterations
     165                                    float keepFrac ///< Minimum fraction of regions to keep
    148166                                   );
    149167
    150168/// Allocate fringe scales
    151 pmFringeScale *pmFringeScaleAlloc(int nFringeFrames // Number of fringe frames
     169pmFringeScale *pmFringeScaleAlloc(int nFringeFrames ///< Number of fringe frames
    152170                                 );
    153171
     
    157175//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    158176
    159 /** Fringe correct the science image
    160  *
    161  *  Given a science image, a set of fringe stats and a matched set of fringe images, correct the science image
    162  *  for the fringe images.
    163  *
    164  *  @return  psImage: summed fringe image
    165  */
    166 psImage *pmFringeCorrect(pmReadout *in, // place info about results here
    167                          pmFringeRegions *fringes, // The fringe regions used
    168                          psArray *fringeImages, // fringe images to use in correction
    169                          psArray *fringeStats, // fringe stats to use in correction
    170                          psMaskType maskVal, // Value to mask
    171                          float rej,     // Rejection threshold, for pmFringeScaleMeasure
    172                          unsigned int nIter, // Maximum number of iterations, for pmFringeScaleMeasure
    173                          float keepFrac // Minimum fraction of regions to keep, for pmFringeScaleMeasure
     177/// Solve for and apply the fringe correction
     178///
     179/// This is a wrapper around each of the fringe correction components to measure the fringe points, solve for
     180/// the fringe correction, and apply the fringe correction.  The input fringe images are modified (scaled by
     181/// the solution coefficients in order to correct the science image).  Returns the summed fringe image.
     182psImage *pmFringeCorrect(pmReadout *in, ///< Input science image
     183                         pmFringeRegions *fringes, ///< The fringe regions used
     184                         psArray *fringeImages, ///< Fringe template images to use in correction
     185                         psArray *fringeStats, ///< Fringe stats (for templates) to use in correction
     186                         psMaskType maskVal, ///< Value to mask for science image
     187                         float rej,     ///< Rejection threshold, for pmFringeScaleMeasure
     188                         unsigned int nIter, ///< Maximum number of iterations, for pmFringeScaleMeasure
     189                         float keepFrac ///< Minimum fraction of regions to keep, for pmFringeScaleMeasure
    174190                        );
    175191
    176192
    177 # endif
     193#endif
Note: See TracChangeset for help on using the changeset viewer.