- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 4 edited
-
. (modified) (1 prop)
-
psphot (modified) (1 prop)
-
psphot/src (modified) (1 prop)
-
psphot/src/psphotRadiusChecks.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/psphot
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/psphot merged eligible /branches/eam_branches/stackphot.20100406/psphot 27622-27655 /branches/pap_delete/psphot 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/simtest_nebulous_branches/psphot/src
- Property svn:ignore
-
old new 18 18 psphotVersionDefinitions.h 19 19 psphotMomentsStudy 20 psphotPetrosianStudy 21 psphotForced 22 psphotMakePSF 23 psphotStack
-
- Property svn:ignore
-
branches/simtest_nebulous_branches/psphot/src/psphotRadiusChecks.c
r21183 r27840 4 4 static float PSF_FIT_NSIGMA; 5 5 static float PSF_FIT_PADDING; 6 static float PSF_APERTURE = 0; // radius to use in PSF aperture mags 6 7 static float PSF_FIT_RADIUS = 0; // radius to use in fitting (ignored if <= 0, 7 8 // and a per-object radius is calculated) 8 9 9 bool psphotInitRadiusPSF(const psMetadata *recipe, const p mModelType type) {10 bool psphotInitRadiusPSF(const psMetadata *recipe, const psMetadata *analysis, const pmModelType type) { 10 11 11 12 bool status = true; 12 13 13 PSF_FIT_NSIGMA = psMetadataLookupF32(&status, recipe, "PSF_FIT_NSIGMA");14 PSF_FIT_NSIGMA = psMetadataLookupF32(&status, recipe, "PSF_FIT_NSIGMA"); 14 15 PSF_FIT_PADDING = psMetadataLookupF32(&status, recipe, "PSF_FIT_PADDING"); 15 PSF_FIT_RADIUS = psMetadataLookupF32(&status, recipe, "PSF_FIT_RADIUS"); 16 17 PSF_FIT_RADIUS = psMetadataLookupF32(&status, analysis, "PSF_FIT_RADIUS"); 18 if (!status) { 19 PSF_FIT_RADIUS = psMetadataLookupF32(&status, recipe, "PSF_FIT_RADIUS"); 20 } 21 22 PSF_APERTURE = psMetadataLookupF32(&status, analysis, "PSF_APERTURE"); 23 if (!status) { 24 PSF_APERTURE = psMetadataLookupF32(&status, recipe, "PSF_APERTURE"); 25 } 16 26 17 27 return true; … … 34 44 radiusFit = model->modelRadius(model->params, 1.0); 35 45 } 46 model->fitRadius = (RADIUS_TYPE)(radiusFit + PSF_FIT_PADDING); 47 } else { 48 model->fitRadius = radiusFit; 36 49 } 37 model->radiusFit = (RADIUS_TYPE)(radiusFit + PSF_FIT_PADDING); 38 39 if (isnan(model->radiusFit)) psAbort("error in radius"); 50 if (isnan(model->fitRadius)) psAbort("error in radius"); 40 51 41 52 if (source->mode & PM_SOURCE_MODE_SATSTAR) { 42 model-> radiusFit*= 2;53 model->fitRadius *= 2; 43 54 } 44 55 45 bool status = pmSourceRedefinePixels (source, readout, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit); 56 // radius used to measure aperture photometry 57 source->apRadius = PSF_APERTURE; 58 59 bool status = pmSourceRedefinePixels (source, readout, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->fitRadius); 46 60 47 61 // set the mask to flag the excluded pixels 48 psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model-> radiusFit, "OR", markVal);62 psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->fitRadius, "OR", markVal); 49 63 return status; 50 64 } … … 58 72 59 73 // set the fit radius based on the object flux limit and the model 60 model->radiusFit = (RADIUS_TYPE) (model->modelRadius (model->params, PSF_FIT_NSIGMA*moments->dSky) + dR + PSF_FIT_PADDING); 61 if (isnan(model->radiusFit)) psAbort("error in radius"); 62 74 float radiusFit = PSF_FIT_RADIUS; 75 if (radiusFit <= 0) { // use fixed radius 76 if (moments == NULL) { 77 radiusFit = model->modelRadius(model->params, PSF_FIT_NSIGMA*moments->dSky); 78 } else { 79 radiusFit = model->modelRadius(model->params, 1.0); 80 } 81 model->fitRadius = (RADIUS_TYPE)(radiusFit + PSF_FIT_PADDING); 82 } else { 83 model->fitRadius = radiusFit; 84 } 85 if (isnan(model->fitRadius)) psAbort("error in radius"); 86 87 // above sets a radius for a single star, bump by blend separation 88 model->fitRadius += dR; 89 63 90 if (source->mode & PM_SOURCE_MODE_SATSTAR) { 64 model-> radiusFit*= 2;91 model->fitRadius *= 2; 65 92 } 66 93 67 bool status = pmSourceRedefinePixels (source, readout, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit); 94 // radius used to measure aperture photometry 95 source->apRadius = PSF_APERTURE; 96 97 bool status = pmSourceRedefinePixels (source, readout, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->fitRadius); 68 98 69 99 // set the mask to flag the excluded pixels 70 psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model-> radiusFit, "OR", markVal);100 psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->fitRadius, "OR", markVal); 71 101 return status; 72 102 } … … 74 104 static float EXT_FIT_NSIGMA; 75 105 static float EXT_FIT_PADDING; 106 static float EXT_FIT_MAX_RADIUS; 76 107 77 108 bool psphotInitRadiusEXT (psMetadata *recipe, pmModelType type) { … … 79 110 bool status; 80 111 81 EXT_FIT_NSIGMA = psMetadataLookupF32 (&status, recipe, "EXT_FIT_NSIGMA"); 82 EXT_FIT_PADDING = psMetadataLookupF32 (&status, recipe, "EXT_FIT_PADDING"); 112 EXT_FIT_NSIGMA = psMetadataLookupF32 (&status, recipe, "EXT_FIT_NSIGMA"); 113 EXT_FIT_PADDING = psMetadataLookupF32 (&status, recipe, "EXT_FIT_PADDING"); 114 EXT_FIT_MAX_RADIUS = psMetadataLookupF32 (&status, recipe, "EXT_FIT_MAX_RADIUS"); 83 115 84 116 return true; … … 86 118 87 119 // call this function whenever you (re)-define the EXT model 120 float psphotSetRadiusEXT (pmReadout *readout, pmSource *source, psImageMaskType markVal) { 121 122 psAssert (source, "source not defined??"); 123 psAssert (source->peak, "peak not defined??"); 124 125 pmPeak *peak = source->peak; 126 127 // set the radius based on the footprint: 128 if (!peak->footprint) goto escape; 129 pmFootprint *footprint = peak->footprint; 130 if (!footprint->spans) goto escape; 131 if (footprint->spans->n < 1) goto escape; 132 133 // find the max radius 134 float radius = 0.0; 135 for (int j = 0; j < footprint->spans->n; j++) { 136 pmSpan *span = footprint->spans->data[j]; 137 138 float dY = span->y - peak->yf; 139 float dX0 = span->x0 - peak->xf; 140 float dX1 = span->x1 - peak->xf; 141 142 radius = PS_MAX (radius, hypot(dY, dX0)); 143 radius = PS_MAX (radius, hypot(dY, dX1)); 144 } 145 146 radius += EXT_FIT_PADDING; 147 if (isnan(radius)) psAbort("error in radius"); 148 149 radius = PS_MIN (radius, EXT_FIT_MAX_RADIUS); 150 151 // redefine the pixels if needed 152 pmSourceRedefinePixels (source, readout, peak->xf, peak->yf, radius); 153 154 // set the mask to flag the excluded pixels 155 psImageKeepCircle (source->maskObj, peak->xf, peak->yf, radius, "OR", markVal); 156 return radius; 157 158 escape: 159 return NAN; 160 // bool result = psphotCheckRadiusEXT (readout, source, model, markVal); 161 // return result; 162 } 163 164 // alternative EXT radius based on model guess (for use without footprints) 88 165 bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model, psImageMaskType markVal) { 166 167 psAbort ("do not use this function"); 89 168 90 169 psF32 *PAR = model->params->data.F32; … … 96 175 float rawRadius = model->modelRadius (model->params, EXT_FIT_NSIGMA*moments->dSky); 97 176 98 model-> radiusFit= rawRadius + EXT_FIT_PADDING;99 if (isnan(model-> radiusFit)) psAbort("error in radius");177 model->fitRadius = rawRadius + EXT_FIT_PADDING; 178 if (isnan(model->fitRadius)) psAbort("error in radius"); 100 179 101 180 // redefine the pixels if needed 102 bool status = pmSourceRedefinePixels (source, readout, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model-> radiusFit);181 bool status = pmSourceRedefinePixels (source, readout, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->fitRadius); 103 182 104 183 // set the mask to flag the excluded pixels 105 psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model-> radiusFit, "OR", markVal);184 psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->fitRadius, "OR", markVal); 106 185 return status; 107 186 }
Note:
See TracChangeset
for help on using the changeset viewer.
