00001 /** @file pmFringeStats.h 00002 * 00003 * @brief Measure Fringe statistics and apply correction 00004 * 00005 * @author Eugene Magnier, IfA 00006 * 00007 * @version $Revision: 1.5 $ $Name: rel12 $ 00008 * @date $Date: 2006/06/14 22:04:40 $ 00009 * 00010 * Copyright 2004 IfA, University of Hawaii 00011 */ 00012 00013 # ifndef PM_FRINGE_STATS 00014 # define PM_FRINGE_STATS 00015 00016 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00017 // pmFringeRegions 00018 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00019 00020 /** Structure to hold the fringe measurement regions. 00021 */ 00022 typedef struct 00023 { 00024 psU32 nRequested; // number of fringe points selected 00025 psU32 nAccepted; // number of fringe points not masked 00026 psU32 dX; // median box half-width 00027 psU32 dY; // median box half-height 00028 psU32 nX; // large-scale smoothing in x (col) 00029 psU32 nY; // large-scale smoothing in y (row) 00030 psVector *x; // fringe point coordinates (col) 00031 psVector *y; // fringe point coordinates (row) 00032 psVector *mask; // fringe point on/off mask 00033 } 00034 pmFringeRegions; 00035 00036 /// Allocate fringe regions 00037 pmFringeRegions *pmFringeRegionsAlloc ( 00038 int nPts, // number of points to create 00039 int dX, // half-width of fringe boxes 00040 int dY, // half-height of fringe boxes 00041 int nX, // smoothing scale in x 00042 int nY // smoothing scale in y 00043 ); 00044 00045 // Generate the fringe points 00046 bool pmFringeRegionsCreatePoints(pmFringeRegions *fringe, // Fringe regions 00047 const psImage *image // Image for the regions (defines the size) 00048 ); 00049 00050 00051 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00052 // pmFringeStats 00053 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00054 00055 /** Structure to hold the fringe measurements for a particular image 00056 */ 00057 typedef struct 00058 { 00059 pmFringeRegions *regions; // Fringe regions 00060 psVector *f; // fringe point median 00061 psVector *df; // fringe point stdev 00062 } 00063 pmFringeStats; 00064 00065 /// Allocate fringe statistics 00066 pmFringeStats *pmFringeStatsAlloc(pmFringeRegions *regions // The fringe regions which will be measured 00067 ); 00068 00069 /** Measure the fringe stats for an image 00070 * 00071 * Given an input image and a fringe stats structure, measure the statistics for each of the fringe points on 00072 * the image. If the fringe vectors are NULL, new vectors are created. 00073 * 00074 * XXX should the structure carry the image dimensions for validation? 00075 * 00076 * @return bool: True or false for success or failure 00077 */ 00078 pmFringeStats *pmFringeStatsMeasure( 00079 pmFringeRegions *fringe, ///< fringe regions 00080 pmReadout *readout, ///< measure fringes on this readout 00081 psMaskType maskVal ///< Mask value for statistics 00082 ); 00083 00084 // Write the fringe stats for an image to a FITS table 00085 bool pmFringeStatsWriteFits(psFits *fits, // FITS file to which to write 00086 const pmFringeStats *fringe, // Fringe statistics to be written 00087 const char *extname // Extension name for table 00088 ); 00089 00090 // Read the fringe stats for an image from a FITS table 00091 pmFringeStats *pmFringeStatsReadFits(const psFits *fits, // FITS file from which to read 00092 const char *extname // Extension name to read 00093 ); 00094 00095 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00096 // pmFringeScale 00097 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00098 00099 /** the pmFringeScale structure defines the relationship between two fringe measurements 00100 */ 00101 typedef struct 00102 { 00103 int nFringeFrames; 00104 psVector *coeff; 00105 psVector *coeffErr; 00106 } 00107 pmFringeScale; 00108 00109 /** Determine the scales for the fringe correction 00110 * 00111 * Given an input fringe measurement, and an array of template fringe measurements, measure the contribution 00112 * of each of the templates to the input. Rejection is performed on the fringe regions, to weed out stars 00113 * etc. 00114 * 00115 * @return pmFringeScale* 00116 */ 00117 pmFringeScale *pmFringeScaleMeasure(pmFringeStats *science, // Fringe measurements from science image 00118 psArray *fringes, // Array of fringe measurements from templates 00119 float rej, // Rejection threshold (in standard deviations) 00120 unsigned int nIter, // Maximum number of iterations 00121 float keepFrac // Minimum fraction of regions to keep 00122 ); 00123 00124 /// Allocate fringe scales 00125 pmFringeScale *pmFringeScaleAlloc(int nFringeFrames // Number of fringe frames 00126 ); 00127 00128 00129 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00130 // Fringe correction 00131 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00132 00133 /** Fringe correct the science image 00134 * 00135 * Given a science image, a set of fringe stats and a matched set of fringe images, correct the science image 00136 * for the fringe images. 00137 * 00138 * @return psImage: summed fringe image 00139 */ 00140 psImage *pmFringeCorrect(pmReadout *in, // place info about results here 00141 pmFringeRegions *fringes, // The fringe regions used 00142 psArray *fringeImages, // fringe images to use in correction 00143 psArray *fringeStats, // fringe stats to use in correction 00144 psMaskType maskVal, // Value to mask 00145 float rej, // Rejection threshold, for pmFringeScaleMeasure 00146 unsigned int nIter, // Maximum number of iterations, for pmFringeScaleMeasure 00147 float keepFrac // Minimum fraction of regions to keep, for pmFringeScaleMeasure 00148 ); 00149 00150 00151 # endif
1.4.4