Changeset 12956
- Timestamp:
- Apr 22, 2007, 5:26:23 PM (19 years ago)
- Location:
- branches/eam_02_branch/psModules
- Files:
-
- 8 edited
-
src/objects/pmModel.c (modified) (6 diffs)
-
src/objects/pmModel.h (modified) (2 diffs)
-
src/objects/pmPSF.c (modified) (2 diffs)
-
src/objects/pmSource.c (modified) (14 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
r12951 r12956 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.9.6. 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-04-2 1 21:30:21$8 * @version $Revision: 1.9.6.3 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-04-23 03:26:23 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 160 160 float skySave = params->data.F32[PM_PAR_SKY]; 161 161 162 if (mode & PM_MODEL_ ADD_NORM) {162 if (mode & PM_MODEL_OP_NORM) { 163 163 params->data.F32[PM_PAR_I0] = 1.0; 164 164 } 165 if (!(mode & PM_MODEL_ ADD_SKY)) {165 if (!(mode & PM_MODEL_OP_SKY)) { 166 166 params->data.F32[PM_PAR_SKY] = 0.0; 167 167 } 168 if (mode & PM_MODEL_ ADD_CENTER) {168 if (mode & PM_MODEL_OP_CENTER) { 169 169 params->data.F32[PM_PAR_XPOS] = image->col0 + 0.5*image->numCols; 170 170 params->data.F32[PM_PAR_YPOS] = image->row0 + 0.5*image->numRows; … … 184 184 psImageInterpolateOptions *Rx = NULL; 185 185 psImageInterpolateOptions *Ry = NULL; 186 if (model->residuals && (mode & (PM_MODEL_ ADD_RES0 | PM_MODEL_ADD_RES1))) {186 if (model->residuals && (mode & (PM_MODEL_OP_RES0 | PM_MODEL_OP_RES1))) { 187 187 Ro = psImageInterpolateOptionsAlloc( 188 188 PS_INTERPOLATE_BILINEAR, … … 217 217 218 218 // add in the desired components for this coordinate 219 if (mode & PM_MODEL_ ADD_FUNC) {219 if (mode & PM_MODEL_OP_FUNC) { 220 220 pixelValue += modelFunc (NULL, params, x); 221 221 } … … 227 227 float oy = yBin*(imageRow + 0.5 - yCenter) + yResidCenter; 228 228 229 if (mode & PM_MODEL_ ADD_RES0) {229 if (mode & PM_MODEL_OP_RES0) { 230 230 psU8 mflux = 0; 231 231 double Fo = 0.0; … … 235 235 } 236 236 } 237 if (mode & PM_MODEL_ ADD_RES1) {237 if (mode & PM_MODEL_OP_RES1) { 238 238 psU8 mflux = 0; 239 239 double Fx = 0.0; -
branches/eam_02_branch/psModules/src/objects/pmModel.h
r12951 r12956 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1.6.6. 2$ $Name: not supported by cvs2svn $8 * @date $Date: 2007-04-2 1 21:30:21$7 * @version $Revision: 1.6.6.3 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-04-23 03:26:23 $ 9 9 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 10 10 */ … … 28 28 29 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 } pmModel AddMode;30 PM_MODEL_OP_NONE = 0x00, 31 PM_MODEL_OP_FUNC = 0x01, 32 PM_MODEL_OP_RES0 = 0x02, 33 PM_MODEL_OP_RES1 = 0x04, 34 PM_MODEL_OP_FULL = 0x07, 35 PM_MODEL_OP_SKY = 0x08, 36 PM_MODEL_OP_CENTER = 0x10, 37 PM_MODEL_OP_NORM = 0x20, 38 } pmModelOpMode; 39 39 40 40 /** pmModel data structure -
branches/eam_02_branch/psModules/src/objects/pmPSF.c
r12951 r12956 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.19.2. 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-04-2 1 21:30:21$8 * @version $Revision: 1.19.2.4 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-04-23 03:26:23 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 425 425 // no need to mask the source here 426 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 pmModelAdd (image, NULL, model, PM_MODEL_OP_FULL); 428 428 429 429 // loop over a range of source fluxes -
branches/eam_02_branch/psModules/src/objects/pmSource.c
r12954 r12956 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1.25.4. 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-04-2 2 22:23:20$8 * @version $Revision: 1.25.4.3 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-04-23 03:26:23 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 39 39 psFree(tmp->pixels); 40 40 psFree(tmp->weight); 41 psFree(tmp->mask); 41 psFree(tmp->maskObj); 42 psFree(tmp->maskView); 43 psFree(tmp->modelFlux); 42 44 psFree(tmp->moments); 43 45 psFree(tmp->modelPSF); … … 47 49 } 48 50 51 // free only the pixel data associated with this source 49 52 void pmSourceFreePixels(pmSource *source) 50 53 { … … 55 58 psFree (source->pixels); 56 59 psFree (source->weight); 57 psFree (source->mask); 60 psFree (source->maskObj); 61 psFree (source->maskView); 62 psFree (source->modelFlux); 58 63 59 64 source->pixels = NULL; 60 65 source->weight = NULL; 61 source->mask = NULL; 66 source->maskObj = NULL; 67 source->maskView = NULL; 68 source->modelFlux = NULL; 62 69 return; 63 70 } … … 76 83 source->pixels = NULL; 77 84 source->weight = NULL; 78 source->mask = NULL; 85 source->maskObj = NULL; 86 source->maskView = NULL; 87 source->modelFlux = NULL; 79 88 source->moments = NULL; 80 89 source->blends = NULL; … … 117 126 source->pixels = psMemIncrRefCounter (in->pixels); 118 127 source->weight = psMemIncrRefCounter (in->weight); 119 source->mask = psMemIncrRefCounter (in->mask); 128 source->maskObj = psMemIncrRefCounter (in->maskObj); 129 source->maskView = psMemIncrRefCounter (in->maskView); 120 130 source->moments = psMemIncrRefCounter (in->moments); 121 131 source->blends = NULL; 122 132 source->modelPSF = NULL; 123 133 source->modelEXT = NULL; 134 source->modelFlux = NULL; 124 135 source->type = in->type; 125 136 source->mode = in->mode; … … 151 162 srcRegion = psRegionForImage (readout->image, srcRegion); 152 163 153 mySource->pixels = psMemIncrRefCounter(psImageSubset(readout->image, srcRegion)); 154 mySource->weight = psMemIncrRefCounter(psImageSubset(readout->weight, srcRegion)); 155 mySource->mask = psMemIncrRefCounter(psImageSubset(readout->mask, srcRegion)); 156 mySource->region = srcRegion; 164 // these images are subset images of the equivalent parents 165 mySource->pixels = psMemIncrRefCounter(psImageSubset(readout->image, srcRegion)); 166 mySource->weight = psMemIncrRefCounter(psImageSubset(readout->weight, srcRegion)); 167 mySource->maskView = psMemIncrRefCounter(psImageSubset(readout->mask, srcRegion)); 168 mySource->region = srcRegion; 169 170 // the object mask is a copy, and used to define the source pixels 171 mySource->maskObj = psImageCopy (NULL, mySource->maskView, PS_TYPE_MASK); 157 172 158 173 return true; … … 183 198 extend |= (mySource->pixels == NULL); 184 199 extend |= (mySource->weight == NULL); 185 extend |= (mySource->mask == NULL); 200 extend |= (mySource->maskObj == NULL); 201 extend |= (mySource->maskView == NULL); 186 202 187 203 // extend = true; … … 190 206 psFree (mySource->pixels); 191 207 psFree (mySource->weight); 192 psFree (mySource->mask); 193 194 mySource->pixels = psMemIncrRefCounter(psImageSubset(readout->image, newRegion)); 195 mySource->weight = psMemIncrRefCounter(psImageSubset(readout->weight, newRegion)); 196 mySource->mask = psMemIncrRefCounter(psImageSubset(readout->mask, newRegion)); 197 mySource->region = newRegion; 198 } 199 208 psFree (mySource->maskView); 209 210 mySource->pixels = psMemIncrRefCounter(psImageSubset(readout->image, newRegion)); 211 mySource->weight = psMemIncrRefCounter(psImageSubset(readout->weight, newRegion)); 212 mySource->maskView = psMemIncrRefCounter(psImageSubset(readout->mask, newRegion)); 213 mySource->region = newRegion; 214 215 // XXX how do we extend the mask? do we need to keep the old masked pixels? 216 // the object mask is a copy, and used to define the source pixels 217 psFree (mySource->maskObj); 218 mySource->maskObj = psImageCopy (NULL, mySource->maskView, PS_TYPE_MASK); 219 220 // XXX what about the modelFlux image? 221 } 200 222 return extend; 201 223 } … … 207 229 208 230 // XXX EAM include a S/N cutoff in selecting the sources? 231 // XXX this function should probably accept the values, not a recipe. wrap with a 232 // psphot-specific function which applies the recipe values 209 233 pmPSFClump pmSourcePSFClump(psArray *sources, psMetadata *recipe) 210 234 { … … 458 482 // XXX EAM : can we use the value of SATURATE if mask is NULL? 459 483 inner = psRegionForSquare (source->peak->x, source->peak->y, 2); 460 inner = psRegionForImage (source->mask , inner);461 int Nsatpix = psImageCountPixelMask (source->mask , inner, PM_MASK_SAT);484 inner = psRegionForImage (source->maskView, inner); 485 int Nsatpix = psImageCountPixelMask (source->maskView, inner, PM_MASK_SAT); 462 486 463 487 // saturated star (size consistent with PSF or larger) … … 572 596 PS_ASSERT_PTR_NON_NULL(source->peak, false); 573 597 PS_ASSERT_PTR_NON_NULL(source->pixels, false); 574 PS_ASSERT_PTR_NON_NULL(source->mask , false);598 PS_ASSERT_PTR_NON_NULL(source->maskObj, false); 575 599 PS_ASSERT_FLOAT_LARGER_THAN(radius, 0.0, false); 576 600 … … 622 646 psF32 *vPix = source->pixels->data.F32[row]; 623 647 psF32 *vWgt = source->weight->data.F32[row]; 624 psU8 *vMsk = (source->mask == NULL) ? NULL : source->mask->data.U8[row];648 psU8 *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.U8[row]; 625 649 626 650 for (psS32 col = 0; col < source->pixels->numCols ; col++, vPix++, vWgt++) { … … 751 775 // in some places (psphotEnsemble), we need a normalized version 752 776 // in others, we just want the model. which is more commonly used? 753 pmModelAdd (source->modelFlux, source->mask , model, PM_MODEL_ADD_FULL | PM_MODEL_ADD_NORM);777 pmModelAdd (source->modelFlux, source->maskObj, model, PM_MODEL_OP_FULL | PM_MODEL_OP_NORM); 754 778 return true; 755 779 } 756 780 757 // XXX should this API take an operator (+/-)? 758 // XXX should we specify norm, etc? 759 bool pmSourceAdd (pmSource *source) { 781 // should we call pmSourceCacheModel if it does not exist? 782 bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add) { 783 784 pmModel *model = pmSourceGetModel (NULL, source); 785 if (model == NULL) continue; // model must be defined 760 786 761 787 if (source->modelFlux) { 762 788 // add in the pixels from the modelFlux image 763 psImageSubsetAdd (source->pixels, source->modelFlux); 789 int dX = source->modelFlux->col0 - source->pixels->col0; 790 int dY = source->modelFlux->row0 - source->pixels->row0; 791 assert (dX >= 0); 792 assert (dY >= 0); 793 assert (dX + source->modelFlux->numCols < source->pixels->numCols); 794 assert (dY + source->modelFlux->numRows < source->pixels->numRows); 795 796 float Io = 1.0; 797 if (mode & PM_MODEL_OP_NORM) { 798 Io = 1.0 / model->params->data.F32[PM_PAR_I0]; 799 } 800 801 // XXX need to respect the source and model masks? 802 for (int iy = 0; iy < source->modelFlux->numRows; iy++) { 803 oy = iy + dY; 804 for (int ix = 0; ix < source->modelFlux->numCols; ix++) { 805 ox = ix + dX; 806 float value = Io*source->modelFlux->data.F32[iy][ix]; 807 if (add) { 808 source->pixels->data.F32[oy][ox] -= value; 809 } else { 810 source->pixels->data.F32[oy][ox] += value; 811 } 812 } 813 } 764 814 } else { 765 pmModel *model = pmSourceGetModel (NULL, source); 766 if (model == NULL) continue; // model must be defined 767 pmModelAdd (source->pixels, source->mask, model, PM_MODEL_ADD_FULL); 815 if (add) { 816 pmModelAdd (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL); 817 } else { 818 pmModelSub (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL); 819 } 768 820 } 769 821 770 // we would need to save X,Y somehow (or use the peak?) 771 // psTrace ("psphot", 3, "replacing object at %f,%f\n", 772 // model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS]); 822 if (add) { 823 psTrace ("psphot", 3, "replacing object at %f,%f\n", source->peak->xf, source->peak->yf); 824 } else { 825 psTrace ("psphot", 3, "removing object at %f,%f\n", source->peak->xf, source->peak->yf); 826 } 773 827 return true; 774 828 } 775 829 776 bool pmSourceSub (pmSource *source) { 777 778 if (source->modelFlux) { 779 // add in the pixels from the modelFlux image 780 psImageSubsetSub (source->pixels, source->modelFlux); 781 } else { 782 pmModel *model = pmSourceGetModel (NULL, source); 783 if (model == NULL) continue; // model must be defined 784 pmModelSub (source->pixels, source->mask, model, PM_MODEL_ADD_FULL); 785 } 786 return true; 787 } 788 789 // XXX merge this function with psImageOverlay, which is probably mid-defined 790 bool psImageSubsetAdd (psImage *input, psImage *subset) { 791 792 // col0,row0 in both images refer to parent coordinates 793 794 int dX = subset->col0 - input->col0; 795 int dY = subset->row0 - input->row0; 796 assert (dX >= 0); 797 assert (dY >= 0); 798 assert (dX + subset->numCols < input->numCols); 799 assert (dY + subset->numRows < input->numRows); 800 assert (input->type.type == PS_TYPE_F32); 801 assert (subset->type.type == PS_TYPE_F32); 802 803 for (int iy = 0; iy < subset->numRows; iy++) { 804 oy = iy + dY; 805 for (int ix = 0; ix < subset->numCols; ix++) { 806 ox = ix + dX; 807 input->data.F32[oy][ox] += subset->data.F32[iy][ix]; 808 } 809 } 810 return true; 811 } 812 813 // XXX merge this function with psImageOverlay, which is probably mid-defined 814 bool psImageSubsetSub (psImage *input, psImage *subset) { 815 816 // col0,row0 in both images refer to parent coordinates 817 818 int dX = subset->col0 - input->col0; 819 int dY = subset->row0 - input->row0; 820 assert (dX >= 0); 821 assert (dY >= 0); 822 assert (dX + subset->numCols < input->numCols); 823 assert (dY + subset->numRows < input->numRows); 824 assert (input->type.type == PS_TYPE_F32); 825 assert (subset->type.type == PS_TYPE_F32); 826 827 for (int iy = 0; iy < subset->numRows; iy++) { 828 oy = iy + dY; 829 for (int ix = 0; ix < subset->numCols; ix++) { 830 ox = ix + dX; 831 input->data.F32[oy][ox] -= subset->data.F32[iy][ix]; 832 } 833 } 834 return true; 835 } 830 bool pmSourceAdd (pmSource *source, pmSourceOpMode mode) { 831 pmSourceOp (source, mode, true); 832 } 833 834 bool pmSourceSub (pmSource *source, pmSourceOpMode mode) { 835 pmSourceOp (source, mode, false); 836 } -
branches/eam_02_branch/psModules/src/objects/pmSource.h
r12951 r12956 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1.10.6. 1$ $Name: not supported by cvs2svn $6 * @date $Date: 2007-04-2 1 21:30:21$5 * @version $Revision: 1.10.6.2 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-04-23 03:26:23 $ 7 7 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 8 8 */ … … 58 58 typedef struct 59 59 { 60 const int id; ///< Unique ID for object 61 pmPeak *peak; ///< Description of peak pixel. 62 psImage *pixels; ///< Rectangular region including object pixels. 63 psImage *weight; ///< Image variance. 64 psImage *mask; ///< Mask which marks pixels associated with objects. 65 pmMoments *moments; ///< Basic moments measure for the object. 66 pmModel *modelPSF; ///< PSF Model fit (parameters and type) 67 pmModel *modelEXT; ///< EXT (floating) Model fit (parameters and type). 68 pmSourceType type; ///< Best identification of object. 69 pmSourceMode mode; ///< Best identification of object. 60 const int id; ///< Unique ID for object 61 pmPeak *peak; ///< Description of peak pixel. 62 psImage *pixels; ///< Rectangular region including object pixels. 63 psImage *weight; ///< Image variance. 64 psImage *modelFlux; ///< cached copy of the model for this source 65 psImage *maskObj; ///< unique mask for this object which marks included pixels associated with objects. 66 psImage *maskView; ///< view into global image mask for this object region 67 pmMoments *moments; ///< Basic moments measure for the object. 68 pmModel *modelPSF; ///< PSF Model fit (parameters and type) 69 pmModel *modelEXT; ///< EXT (floating) Model fit (parameters and type). 70 pmSourceType type; ///< Best identification of object. 71 pmSourceMode mode; ///< Best identification of object. 70 72 psArray *blends; 71 float psfMag; ///< calculated from flux in modelPsf72 float extMag; ///< calculated from flux in modelEXT73 float errMag; ///< error in psfMag OR extMag (depending on type)74 float apMag; ///< apMag corresponding to psfMag or extMag (depending on type)75 float pixWeight; // model-weighted coverage of valid pixels76 psRegion region; // area on image covered by selected pixels77 float sky, skyErr; //?< The sky and its error at the center of the object73 float psfMag; ///< calculated from flux in modelPsf 74 float extMag; ///< calculated from flux in modelEXT 75 float errMag; ///< error in psfMag OR extMag (depending on type) 76 float apMag; ///< apMag corresponding to psfMag or extMag (depending on type) 77 float pixWeight; // model-weighted coverage of valid pixels 78 psRegion region; // area on image covered by selected pixels 79 float sky, skyErr; //?< The sky and its error at the center of the object 78 80 } 79 81 pmSource; -
branches/eam_02_branch/psModules/src/objects/pmSourcePhotometry.c
r12951 r12956 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1.22.4. 3$ $Name: not supported by cvs2svn $6 * @date $Date: 2007-04-2 1 21:30:21$5 * @version $Revision: 1.22.4.4 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-04-23 03:26:23 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 109 109 // XXX use pmSourceAdd instead? 110 110 if (source->mode & PM_SOURCE_MODE_SUBTRACTED) { 111 pmModelAdd (source->pixels, source->mask, model, PM_MODEL_ ADD_FULL);111 pmModelAdd (source->pixels, source->mask, model, PM_MODEL_OP_FULL); 112 112 } 113 113 … … 212 212 // if source was originally subtracted, re-subtract object, leave local sky 213 213 if (source->mode & PM_SOURCE_MODE_SUBTRACTED) { 214 pmModelSub (source->pixels, source->mask, model, PM_MODEL_ ADD_FULL);214 pmModelSub (source->pixels, source->mask, model, PM_MODEL_OP_FULL); 215 215 } 216 216 -
branches/eam_02_branch/psModules/test/objects/tap_pmSourceFitModel.c
r12951 r12956 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, PM_MODEL_ ADD_FULL);138 pmModelAdd (source->pixels, source->mask, source->modelEXT, PM_MODEL_OP_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
r12951 r12956 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, PM_MODEL_ ADD_FULL);56 pmModelAdd (source->pixels, source->mask, source->modelEXT, PM_MODEL_OP_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.
