00001 /** @file pmSource.h 00002 * 00003 * @author EAM, IfA; GLG, MHPCC 00004 * 00005 * @version $Revision: 1.5 $ $Name: rel12 $ 00006 * @date $Date: 2006/06/22 20:04:13 $ 00007 * 00008 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 00009 * 00010 */ 00011 00012 # ifndef PM_SOURCE_H 00013 # define PM_SOURCE_H 00014 00015 /** 00016 * In the object analysis process, we will use specific mask values to mark the 00017 * image pixels. The following structure defines the relevant mask values. 00018 * 00019 * XXX: This is probably a bad solution: we will want to set mask values 00020 * outside of the PSPHOT code. Perhaps we can set up a registered set of mask 00021 * values with specific meanings that other functions can add to or define? 00022 00023 * XXX We will only use the PM_MASK_xxx mask values 00024 typedef enum { 00025 PM_SOURCE_MASK_CLEAR = 0x00, 00026 PM_SOURCE_MASK_INVALID = 0x01, 00027 PM_SOURCE_MASK_SATURATED = 0x02, 00028 PM_SOURCE_MASK_MARKED = 0x08, 00029 } psphotMaskValues; 00030 */ 00031 00032 /** pmSourceType enumeration 00033 * 00034 * A given source may be identified as most-likely to be one of several source 00035 * types. The pmSource entry pmSourceType defines the current best-guess for this 00036 * source. 00037 * 00038 * XXX: The values given below are currently illustrative and will require 00039 * some modification as the source classification code is developed. (TBD) 00040 * 00041 */ 00042 typedef enum { 00043 PM_SOURCE_TYPE_UNKNOWN, ///< a cosmic-ray 00044 PM_SOURCE_TYPE_DEFECT, ///< a cosmic-ray 00045 PM_SOURCE_TYPE_SATURATED, ///< random saturated pixels 00046 PM_SOURCE_TYPE_STAR, ///< a good-quality star 00047 PM_SOURCE_TYPE_EXTENDED, ///< an extended object (eg, galaxy) 00048 } pmSourceType; 00049 00050 typedef enum { 00051 PM_SOURCE_MODE_DEFAULT = 0x0000, ///< 00052 PM_SOURCE_MODE_PSFMODEL = 0x0001, ///< 00053 PM_SOURCE_MODE_EXTMODEL = 0x0002, ///< 00054 PM_SOURCE_MODE_SUBTRACTED = 0x0004, ///< 00055 PM_SOURCE_MODE_FITTED = 0x0008, ///< 00056 PM_SOURCE_MODE_FAIL = 0x0010, ///< 00057 PM_SOURCE_MODE_POOR = 0x0020, ///< 00058 PM_SOURCE_MODE_PAIR = 0x0040, ///< 00059 PM_SOURCE_MODE_PSFSTAR = 0x0080, ///< 00060 PM_SOURCE_MODE_SATSTAR = 0x0100, ///< 00061 PM_SOURCE_MODE_BLEND = 0x0200, ///< 00062 PM_SOURCE_MODE_LINEAR = 0x0400, ///< 00063 PM_SOURCE_MODE_TEMPSUB = 0x0800, ///< XXX get me a better name! 00064 } pmSourceMode; 00065 00066 /** pmSource data structure 00067 * 00068 * This source has the capacity for several types of measurements. The 00069 * simplest measurement of a source is the location and flux of the peak pixel 00070 * associated with the source: 00071 * 00072 */ 00073 typedef struct 00074 { 00075 const int id; ///< Unique ID for object 00076 pmPeak *peak; ///< Description of peak pixel. 00077 psImage *pixels; ///< Rectangular region including object pixels. 00078 psImage *weight; ///< Image variance. 00079 psImage *mask; ///< Mask which marks pixels associated with objects. 00080 pmMoments *moments; ///< Basic moments measure for the object. 00081 pmModel *modelPSF; ///< PSF Model fit (parameters and type) 00082 pmModel *modelEXT; ///< EXT (floating) Model fit (parameters and type). 00083 pmSourceType type; ///< Best identification of object. 00084 pmSourceMode mode; ///< Best identification of object. 00085 psArray *blends; 00086 float psfMag; 00087 float extMag; 00088 float errMag; 00089 float apMag; 00090 float pixWeight; // model-weighted coverage of valid pixels 00091 psRegion region; // area on image covered by selected pixels 00092 } 00093 pmSource; 00094 00095 /** pmPSFClump data structure 00096 * 00097 * A collection of object moment measurements can be used to determine 00098 * approximate object classes. The key to this analysis is the location and 00099 * statistics (in the second-moment plane, 00100 * 00101 */ 00102 typedef struct 00103 { 00104 float X; 00105 float dX; 00106 float Y; 00107 float dY; 00108 } 00109 pmPSFClump; 00110 00111 00112 /** pmSourceAlloc() 00113 * 00114 */ 00115 pmSource *pmSourceAlloc(); 00116 00117 // free just the pixels for a source, keeping derived data 00118 void pmSourceFreePixels(pmSource *source); 00119 00120 bool pmIsSource(const psPtr ptr); 00121 00122 /** pmSourceDefinePixels() 00123 * 00124 * Define psImage subarrays for the source located at coordinates x,y on the 00125 * image set defined by readout. The pixels defined by this operation consist of 00126 * a square window (of full width 2Radius+1) centered on the pixel which contains 00127 * the given coordinate, in the frame of the readout. The window is defined to 00128 * have limits which are valid within the boundary of the readout image, thus if 00129 * the radius would fall outside the image pixels, the subimage is truncated to 00130 * only consist of valid pixels. If readout->mask or readout->weight are not 00131 * NULL, matching subimages are defined for those images as well. This function 00132 * fails if no valid pixels can be defined (x or y less than Radius, for 00133 * example). This function should be used to define a region of interest around a 00134 * source, including both source and sky pixels. 00135 * 00136 */ 00137 bool pmSourceDefinePixels( 00138 pmSource *mySource, ///< source to be re-defined 00139 const pmReadout *readout, ///< base the source on this readout 00140 psF32 x, ///< center coords of source 00141 psF32 y, ///< center coords of source 00142 psF32 Radius ///< size of box on source 00143 ); 00144 00145 bool pmSourceRedefinePixels ( 00146 pmSource *mySource, ///< source to be re-defined 00147 const pmReadout *readout, ///< base the source on this readout 00148 psF32 x, ///< center coords of source 00149 psF32 y, ///< center coords of source 00150 psF32 Radius ///< size of box on source 00151 ); 00152 00153 /** pmSourcePSFClump() 00154 * 00155 * We use the source moments to make an initial, approximate source 00156 * classification, and as part of the information needed to build a PSF model for 00157 * the image. As long as the PSF shape does not vary excessively across the 00158 * image, the sources which are represented by a PSF (the start) will have very 00159 * similar second moments. The function pmSourcePSFClump searches a collection of 00160 * sources with measured moments for a group with moments which are all very 00161 * similar. The function returns a pmPSFClump structure, representing the 00162 * centroid and size of the clump in the sigma_x, sigma_y second-moment plane. 00163 * 00164 * The goal is to identify and characterize the stellar clump within the 00165 * sigma_x, sigma_y second-moment plane. To do this, an image is constructed to 00166 * represent this plane. The units of sigma_x and sigma_y are in image pixels. A 00167 * pixel in this analysis image represents 0.1 pixels in the input image. The 00168 * dimensions of the image need only be 10 pixels. The peak pixel in this image 00169 * (above a threshold of half of the image maximum) is found. The coordinates of 00170 * this peak pixel represent the 2D mode of the sigma_x, sigma_y distribution. 00171 * The sources with sigma_x, sigma_y within 0.2 pixels of this value are then 00172 * * used to calculate the median and standard deviation of the sigma_x, sigma_y 00173 * values. These resulting values are returned via the pmPSFClump structure. 00174 * 00175 * The return value indicates the success (TRUE) of the operation. 00176 * 00177 * XXX: Limit the S/N of the candidate sources (part of Metadata)? (TBD). 00178 * XXX: Save the clump parameters on the Metadata (TBD) 00179 * 00180 */ 00181 pmPSFClump pmSourcePSFClump( 00182 psArray *source, ///< The input pmSource 00183 psMetadata *metadata ///< Contains classification parameters 00184 ); 00185 00186 00187 /** pmSourceRoughClass() 00188 * 00189 * Based on the specified data values, make a guess at the source 00190 * classification. The sources are provides as a psArray of pmSource entries. 00191 * Definable parameters needed to make the classification are provided to the 00192 * routine with the psMetadata structure. The rules (in SDRS) refer to values which 00193 * can be extracted from the metadata using the given keywords. Except as noted, 00194 * the data type for these parameters are psF32. 00195 * 00196 */ 00197 bool pmSourceRoughClass( 00198 psArray *source, ///< The input pmSource 00199 psMetadata *metadata, ///< Contains classification parameters 00200 pmPSFClump clump ///< Statistics about the PSF clump 00201 ); 00202 00203 00204 /** pmSourceMoments() 00205 * 00206 * Measure source moments for the given source, using the value of 00207 * source.moments.sky provided as the local background value and the peak 00208 * coordinates as the initial source location. The resulting moment values are 00209 * applied to the source.moments entry, and the source is returned. The moments 00210 * are measured within the given circular radius of the source.peak coordinates. 00211 * The return value indicates the success (TRUE) of the operation. 00212 * 00213 */ 00214 bool pmSourceMoments( 00215 pmSource *source, ///< The input pmSource for which moments will be computed 00216 float radius ///< Use a circle of pixels around the peak 00217 ); 00218 00219 00220 // select the model used for this source 00221 pmModel *pmSourceSelectModel (pmSource *source); 00222 00223 # endif /* PM_SOURCE_H */
1.4.4