Changeset 12951
- Timestamp:
- Apr 21, 2007, 11:30:21 AM (19 years ago)
- Location:
- branches/eam_02_branch/psModules
- Files:
-
- 7 edited
-
src/objects/pmModel.c (modified) (8 diffs)
-
src/objects/pmModel.h (modified) (4 diffs)
-
src/objects/pmPSF.c (modified) (2 diffs)
-
src/objects/pmSource.h (modified) (2 diffs)
-
src/objects/pmSourcePhotometry.c (modified) (3 diffs)
-
test/objects/tap_pmSourceFitModel.c (modified) (1 diff)
-
test/objects/tap_pmSourceFitModel_Delta.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_02_branch/psModules/src/objects/pmModel.c
r12941 r12951 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.9.6. 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-04-21 00:02:35$8 * @version $Revision: 1.9.6.2 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-04-21 21:30:21 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 135 135 psImage *mask, 136 136 pmModel *model, 137 bool center, 138 bool sky, 137 pmModelAddMode mode, 139 138 bool add 140 139 ) … … 151 150 psS32 imageCol; 152 151 psS32 imageRow; 153 psF32 skyValue = params->data.F32[0];154 152 psF32 pixelValue; 155 153 156 float xCenter = model->params->data.F32[PM_PAR_XPOS]; 157 float yCenter = model->params->data.F32[PM_PAR_YPOS]; 158 float Io = model->params->data.F32[PM_PAR_I0]; 154 // save original values; restore before returning 155 // use the true source position for the residual model 156 // the PSF model has presumably already been set for this coordinate 157 float xPos = params->data.F32[PM_PAR_XPOS]; 158 float yPos = params->data.F32[PM_PAR_YPOS]; 159 float IoSave = params->data.F32[PM_PAR_I0]; 160 float skySave = params->data.F32[PM_PAR_SKY]; 161 162 if (mode & PM_MODEL_ADD_NORM) { 163 params->data.F32[PM_PAR_I0] = 1.0; 164 } 165 if (!(mode & PM_MODEL_ADD_SKY)) { 166 params->data.F32[PM_PAR_SKY] = 0.0; 167 } 168 if (mode & PM_MODEL_ADD_CENTER) { 169 params->data.F32[PM_PAR_XPOS] = image->col0 + 0.5*image->numCols; 170 params->data.F32[PM_PAR_YPOS] = image->row0 + 0.5*image->numRows; 171 } 172 173 // use these values for this realization 174 float xCenter = params->data.F32[PM_PAR_XPOS]; 175 float yCenter = params->data.F32[PM_PAR_YPOS]; 176 float Io = params->data.F32[PM_PAR_I0]; 159 177 160 178 int xBin = 1; … … 166 184 psImageInterpolateOptions *Rx = NULL; 167 185 psImageInterpolateOptions *Ry = NULL; 168 if (model->residuals ) {186 if (model->residuals && (mode & (PM_MODEL_ADD_RES0 | PM_MODEL_ADD_RES1))) { 169 187 Ro = psImageInterpolateOptionsAlloc( 170 188 PS_INTERPOLATE_BILINEAR, … … 189 207 190 208 // Convert i/j to image coord space: 191 // 'center' option changes meaning of i,j: 192 if (center) { 193 imageCol = ix - 0.5*image->numCols + xCenter; 194 imageRow = iy - 0.5*image->numRows + yCenter; 195 } else { 196 imageCol = ix + image->col0; 197 imageRow = iy + image->row0; 198 } 209 // XXX should we use using 0.5 pixel offset? 210 imageCol = ix + image->col0; 211 imageRow = iy + image->row0; 199 212 200 213 x->data.F32[0] = (float) imageCol; 201 214 x->data.F32[1] = (float) imageRow; 202 215 203 // set the appropriate pixel value for this coordinate 204 if (sky) { 205 pixelValue = modelFunc (NULL, params, x);206 } else{207 pixelValue = modelFunc (NULL, params, x) - skyValue;208 } 216 pixelValue = 0.0; 217 218 // add in the desired components for this coordinate 219 if (mode & PM_MODEL_ADD_FUNC) { 220 pixelValue += modelFunc (NULL, params, x); 221 } 209 222 210 223 // get the contribution from the residual model 211 // XXX for a test, do this for all sources and all pixels212 224 if (Ro) { 213 225 // fractional image position 214 // this is wrong for the 'center' case 215 float ox = xBin*(ix + 0.5 + image->col0 - xCenter) + xResidCenter; 216 float oy = yBin*(iy + 0.5 + image->row0 - yCenter) + yResidCenter; 217 218 psU8 mflux = 0; 219 double Fo = 0.0; 220 double Fx = 0.0; 221 double Fy = 0.0; 222 psImageInterpolate (&Fo, NULL, &mflux, ox, oy, Ro); 223 psImageInterpolate (&Fx, NULL, &mflux, ox, oy, Rx); 224 psImageInterpolate (&Fy, NULL, &mflux, ox, oy, Ry); 225 226 if (!mflux && isfinite(Fo) && isfinite(Fx) && isfinite(Fy)) { 227 double flux = Fo + xCenter*Fx + yCenter*Fy; 228 pixelValue += Io*flux; 226 float ox = xBin*(imageCol + 0.5 - xCenter) + xResidCenter; 227 float oy = yBin*(imageRow + 0.5 - yCenter) + yResidCenter; 228 229 if (mode & PM_MODEL_ADD_RES0) { 230 psU8 mflux = 0; 231 double Fo = 0.0; 232 psImageInterpolate (&Fo, NULL, &mflux, ox, oy, Ro); 233 if (!mflux && isfinite(Fo)) { 234 pixelValue += Io*Fo; 235 } 236 } 237 if (mode & PM_MODEL_ADD_RES1) { 238 psU8 mflux = 0; 239 double Fx = 0.0; 240 double Fy = 0.0; 241 psImageInterpolate (&Fx, NULL, &mflux, ox, oy, Rx); 242 psImageInterpolate (&Fy, NULL, &mflux, ox, oy, Ry); 243 if (!mflux && isfinite(Fx) && isfinite(Fy)) { 244 pixelValue += Io*(xPos*Fx + yPos*Fy); 245 } 229 246 } 230 247 } … … 238 255 } 239 256 } 257 258 // restore original values 259 params->data.F32[PM_PAR_I0] = IoSave; 260 params->data.F32[PM_PAR_SKY] = skySave; 261 params->data.F32[PM_PAR_XPOS] = xPos; 262 params->data.F32[PM_PAR_YPOS] = yPos; 263 240 264 psFree(x); 241 265 psFree(Ro); … … 251 275 psImage *mask, 252 276 pmModel *model, 253 bool center, 254 bool sky) 255 { 256 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); 257 psBool rc = AddOrSubModel(image, mask, model, center, sky, true); 277 pmModelAddMode mode) 278 { 279 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); 280 psBool rc = AddOrSubModel(image, mask, model, mode, true); 258 281 psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc); 259 282 return(rc); … … 265 288 psImage *mask, 266 289 pmModel *model, 267 bool center, 268 bool sky) 269 { 270 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); 271 psBool rc = AddOrSubModel(image, mask, model, center, sky, false); 290 pmModelAddMode mode) 291 { 292 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); 293 psBool rc = AddOrSubModel(image, mask, model, mode, false); 272 294 psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc); 273 295 return(rc); -
branches/eam_02_branch/psModules/src/objects/pmModel.h
r12942 r12951 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1.6.6. 1$ $Name: not supported by cvs2svn $8 * @date $Date: 2007-04-21 00:03:11 $7 * @version $Revision: 1.6.6.2 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-04-21 21:30:21 $ 9 9 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 10 10 */ … … 26 26 PM_MODEL_BADARGS ///< model fit called with invalid args 27 27 } pmModelStatus; 28 29 typedef enum { 30 PM_MODEL_ADD_NONE = 0x00, 31 PM_MODEL_ADD_FUNC = 0x01, 32 PM_MODEL_ADD_RES0 = 0x02, 33 PM_MODEL_ADD_RES1 = 0x04, 34 PM_MODEL_ADD_FULL = 0x07, 35 PM_MODEL_ADD_SKY = 0x08, 36 PM_MODEL_ADD_CENTER = 0x10, 37 PM_MODEL_ADD_NORM = 0x20, 38 } pmModelAddMode; 28 39 29 40 /** pmModel data structure … … 91 102 */ 92 103 bool pmModelAdd( 93 psImage *image, ///< The output image (float) 94 psImage *mask, ///< The image pixel mask (valid == 0) 95 pmModel *model, ///< The input pmModel 96 bool center, ///< A boolean flag that determines whether pixels are centered 97 bool sky ///< A boolean flag that determines if the sky is subtracted 104 psImage *image, ///< The output image (float) 105 psImage *mask, ///< The image pixel mask (valid == 0) 106 pmModel *model, ///< The input pmModel 107 pmModelAddMode mode ///< mode to control how the model is added into the image 98 108 ); 99 100 109 101 110 /** pmModelSub() … … 110 119 */ 111 120 bool pmModelSub( 112 psImage *image, ///< The output image (float) 113 psImage *mask, ///< The image pixel mask (valid == 0) 114 pmModel *model, ///< The input pmModel 115 bool center, ///< A boolean flag that determines whether pixels are centered 116 bool sky ///< A boolean flag that determines if the sky is subtracted 121 psImage *image, ///< The output image (float) 122 psImage *mask, ///< The image pixel mask (valid == 0) 123 pmModel *model, ///< The input pmModel 124 pmModelAddMode mode ///< mode to control how the model is added into the image 117 125 ); 118 126 -
branches/eam_02_branch/psModules/src/objects/pmPSF.c
r12943 r12951 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.19.2. 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-04-21 00:03:31 $8 * @version $Revision: 1.19.2.3 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-04-21 21:30:21 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 424 424 // place the reference object in the image center 425 425 // no need to mask the source here 426 pmModelAdd (image, NULL, model, false, false); 426 // XXX should we measure this for the analytical model only or the full model? 427 pmModelAdd (image, NULL, model, PM_MODEL_ADD_FULL); 427 428 428 429 // loop over a range of source fluxes -
branches/eam_02_branch/psModules/src/objects/pmSource.h
r11253 r12951 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $6 * @date $Date: 2007-0 1-24 02:54:15$5 * @version $Revision: 1.10.6.1 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-04-21 21:30:21 $ 7 7 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 8 8 */ … … 13 13 /// @addtogroup Objects Object Detection / Analysis Functions 14 14 /// @{ 15 16 /**17 * In the object analysis process, we will use specific mask values to mark the18 * image pixels. The following structure defines the relevant mask values.19 *20 * XXX: This is probably a bad solution: we will want to set mask values21 * outside of the PSPHOT code. Perhaps we can set up a registered set of mask22 * values with specific meanings that other functions can add to or define?23 24 * XXX We will only use the PM_MASK_xxx mask values25 typedef enum {26 PM_SOURCE_MASK_CLEAR = 0x00,27 PM_SOURCE_MASK_INVALID = 0x01,28 PM_SOURCE_MASK_SATURATED = 0x02,29 PM_SOURCE_MASK_MARKED = 0x08,30 } psphotMaskValues;31 */32 15 33 16 /** pmSourceType enumeration -
branches/eam_02_branch/psModules/src/objects/pmSourcePhotometry.c
r12943 r12951 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1.22.4. 2$ $Name: not supported by cvs2svn $6 * @date $Date: 2007-04-21 00:03:31 $5 * @version $Revision: 1.22.4.3 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-04-21 21:30:21 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 106 106 // replace source flux 107 107 // XXX need to be certain which model and size of mask for prior subtraction 108 // XXX full model or just analytical? 109 // XXX use pmSourceAdd instead? 108 110 if (source->mode & PM_SOURCE_MODE_SUBTRACTED) { 109 pmModelAdd (source->pixels, source->mask, model, false, false);111 pmModelAdd (source->pixels, source->mask, model, PM_MODEL_ADD_FULL); 110 112 } 111 113 … … 210 212 // if source was originally subtracted, re-subtract object, leave local sky 211 213 if (source->mode & PM_SOURCE_MODE_SUBTRACTED) { 212 pmModelSub (source->pixels, source->mask, model, false, false);214 pmModelSub (source->pixels, source->mask, model, PM_MODEL_ADD_FULL); 213 215 } 214 216 -
branches/eam_02_branch/psModules/test/objects/tap_pmSourceFitModel.c
r10263 r12951 136 136 137 137 // create an image with the model, and add noise: gain is 1, subtracted sky is 100, readnoise is 5 138 pmModelAdd (source->pixels, source->mask, source->modelEXT, false, false);138 pmModelAdd (source->pixels, source->mask, source->modelEXT, PM_MODEL_ADD_FULL); 139 139 int npix = 0; 140 140 for (int j = 0; j < source->pixels->numRows; j++) { -
branches/eam_02_branch/psModules/test/objects/tap_pmSourceFitModel_Delta.c
r10194 r12951 54 54 55 55 // create an image with the model, and add noise: gain is 1, subtracted sky is 100, readnoise is 5 56 pmModelAdd (source->pixels, source->mask, source->modelEXT, false, false);56 pmModelAdd (source->pixels, source->mask, source->modelEXT, PM_MODEL_ADD_FULL); 57 57 int npix = 0; 58 58 for (int j = 0; j < source->pixels->numRows; j++) {
Note:
See TracChangeset
for help on using the changeset viewer.
