- Timestamp:
- Aug 26, 2010, 9:18:39 AM (16 years ago)
- Location:
- branches/sc_branches/trunkTest
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/sc_branches/trunkTest
- Property svn:mergeinfo changed
-
branches/sc_branches/trunkTest/psphot
- Property svn:mergeinfo deleted
-
branches/sc_branches/trunkTest/psphot/src/psphotRadiusChecks.c
r28418 r29060 8 8 // and a per-object radius is calculated) 9 9 10 bool psphotInitRadiusPSF( const psMetadata *recipe, const psMetadata *analysis, const pmModelType type) {10 bool psphotInitRadiusPSF(psMetadata *recipe, pmReadout *readout) { 11 11 12 12 bool status = true; … … 15 15 PSF_FIT_PADDING = psMetadataLookupF32(&status, recipe, "PSF_FIT_PADDING"); 16 16 17 PSF_FIT_RADIUS = psMetadataLookupF32(&status, analysis, "PSF_FIT_RADIUS");17 PSF_FIT_RADIUS = psMetadataLookupF32(&status, readout->analysis, "PSF_FIT_RADIUS"); 18 18 if (!status) { 19 19 PSF_FIT_RADIUS = psMetadataLookupF32(&status, recipe, "PSF_FIT_RADIUS"); 20 20 } 21 21 22 PSF_APERTURE = psMetadataLookupF32(&status, analysis, "PSF_APERTURE");22 PSF_APERTURE = psMetadataLookupF32(&status, readout->analysis, "PSF_APERTURE"); 23 23 if (!status) { 24 24 PSF_APERTURE = psMetadataLookupF32(&status, recipe, "PSF_APERTURE"); … … 28 28 29 29 if (PSF_FIT_RADIUS == 0.0) { 30 float gaussSigma = psMetadataLookupF32(&status, analysis, "MOMENTS_GAUSS_SIGMA");30 float gaussSigma = psMetadataLookupF32(&status, readout->analysis, "MOMENTS_GAUSS_SIGMA"); 31 31 if (!status) { 32 32 gaussSigma = psMetadataLookupF32(&status, recipe, "MOMENTS_GAUSS_SIGMA"); … … 37 37 38 38 if (PSF_APERTURE == 0.0) { 39 float gaussSigma = psMetadataLookupF32(&status, analysis, "MOMENTS_GAUSS_SIGMA");39 float gaussSigma = psMetadataLookupF32(&status, readout->analysis, "MOMENTS_GAUSS_SIGMA"); 40 40 if (!status) { 41 41 gaussSigma = psMetadataLookupF32(&status, recipe, "MOMENTS_GAUSS_SIGMA"); … … 122 122 } 123 123 124 static float EXT_FIT_SKY_SIG; 124 125 static float EXT_FIT_NSIGMA; 125 126 static float EXT_FIT_PADDING; 126 127 static float EXT_FIT_MAX_RADIUS; 127 128 128 bool psphotInitRadiusEXT (psMetadata *recipe, pm ModelType type) {129 bool psphotInitRadiusEXT (psMetadata *recipe, pmReadout *readout) { 129 130 130 131 bool status; … … 134 135 EXT_FIT_MAX_RADIUS = psMetadataLookupF32 (&status, recipe, "EXT_FIT_MAX_RADIUS"); 135 136 137 float skyMean = psMetadataLookupF32 (&status, readout->analysis, "SKY_MEAN"); 138 float skyStdev = psMetadataLookupF32 (&status, readout->analysis, "SKY_STDEV"); 139 140 fprintf (stderr, "sky: %f +/- %f\n", skyMean, skyStdev); 141 142 EXT_FIT_SKY_SIG = skyStdev; 143 136 144 return true; 137 145 } 138 146 139 147 // call this function whenever you (re)-define the EXT model 140 float psphotSetRadiusEXT (pmReadout *readout, pmSource *source, psImageMaskType markVal) {148 bool psphotSetRadiusFootprint (float *radius, pmReadout *readout, pmSource *source, psImageMaskType markVal, float factor) { 141 149 142 150 psAssert (source, "source not defined??"); … … 146 154 147 155 // set the radius based on the footprint: 148 if (!peak->footprint) goto escape;156 if (!peak->footprint) return false; 149 157 pmFootprint *footprint = peak->footprint; 150 if (!footprint->spans) goto escape;151 if (footprint->spans->n < 1) goto escape;158 if (!footprint->spans) return false; 159 if (footprint->spans->n < 1) return false; 152 160 153 161 // find the max radius 154 float ra dius = 0.0;162 float rawRadius = 0.0; 155 163 for (int j = 0; j < footprint->spans->n; j++) { 156 164 pmSpan *span = footprint->spans->data[j]; … … 160 168 float dX1 = span->x1 - peak->xf; 161 169 162 radius = PS_MAX (radius, hypot(dY, dX0)); 163 radius = PS_MAX (radius, hypot(dY, dX1)); 164 } 165 166 radius += EXT_FIT_PADDING; 167 if (isnan(radius)) psAbort("error in radius"); 168 169 radius = PS_MIN (radius, EXT_FIT_MAX_RADIUS); 170 rawRadius = PS_MAX (rawRadius, hypot(dY, dX0)); 171 rawRadius = PS_MAX (rawRadius, hypot(dY, dX1)); 172 } 173 if (isnan(rawRadius)) return false; 174 rawRadius = PS_MIN (factor*rawRadius + EXT_FIT_PADDING, EXT_FIT_MAX_RADIUS); 170 175 171 176 // redefine the pixels if needed 172 pmSourceRedefinePixels (source, readout, peak->xf, peak->yf, radius); 173 174 // set the mask to flag the excluded pixels 175 psImageKeepCircle (source->maskObj, peak->xf, peak->yf, radius, "OR", markVal); 176 return radius; 177 178 escape: 179 return NAN; 180 // bool result = psphotCheckRadiusEXT (readout, source, model, markVal); 181 // return result; 177 pmSourceRedefinePixels (source, readout, peak->xf, peak->yf, rawRadius); 178 179 // set the mask to flag the excluded pixels 180 psImageKeepCircle (source->maskObj, peak->xf, peak->yf, rawRadius, "OR", markVal); 181 182 *radius = rawRadius; 183 return true; 182 184 } 183 185 184 186 // alternative EXT radius based on model guess (for use without footprints) 185 bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model, psImageMaskType markVal) { 186 187 psAbort ("do not use this function"); 187 bool psphotSetRadiusModel (pmModel *model, pmReadout *readout, pmSource *source, psImageMaskType markVal, bool deep) { 188 188 189 189 psF32 *PAR = model->params->data.F32; … … 193 193 194 194 // set the fit radius based on the object flux limit and the model 195 float rawRadius = model->modelRadius (model->params, EXT_FIT_NSIGMA*moments->dSky); 196 197 model->fitRadius = rawRadius + EXT_FIT_PADDING; 198 if (isnan(model->fitRadius)) psAbort("error in radius"); 195 float flux = deep ? EXT_FIT_NSIGMA*EXT_FIT_SKY_SIG : 0.1 * model->params->data.F32[PM_PAR_I0]; 196 197 float rawRadius = model->modelRadius (model->params, flux); 198 if (isnan(rawRadius)) return false; 199 200 rawRadius = PS_MIN (rawRadius + EXT_FIT_PADDING, EXT_FIT_MAX_RADIUS); 201 model->fitRadius = rawRadius; 199 202 200 203 // redefine the pixels if needed 201 bool status =pmSourceRedefinePixels (source, readout, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->fitRadius);204 pmSourceRedefinePixels (source, readout, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->fitRadius); 202 205 203 206 // set the mask to flag the excluded pixels 204 207 psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->fitRadius, "OR", markVal); 205 return status;206 } 208 return true; 209 }
Note:
See TracChangeset
for help on using the changeset viewer.
