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