Changeset 23960 for trunk/psModules/src/imcombine/pmPSFEnvelope.c
- Timestamp:
- Apr 23, 2009, 5:48:09 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/imcombine/pmPSFEnvelope.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmPSFEnvelope.c
r23956 r23960 40 40 #define PSF_STATS PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV // Statistics options for measuring PSF 41 41 #define SOURCE_FIT_ITERATIONS 100 // Number of iterations for source fitting 42 #define MODEL_MASK (PM_MODEL_STATUS_NONCONVERGE | PM_MODEL_STATUS_OFFIMAGE | \ 43 PM_MODEL_STATUS_BADARGS | PM_MODEL_STATUS_LIMITS) // Mask to apply to models 42 44 43 45 … … 112 114 psImageInit(envelope, SKY_VALUE); 113 115 pmReadout *fakeRO = pmReadoutAlloc(NULL); // Fake readout 114 float maxRadius = 0.0; // Maximum radius of sources115 116 psVector *numbers = psVectorAlloc(numFakes, PS_TYPE_S32); // Number of detections for each source 116 117 psVectorInit(numbers, 0); … … 143 144 144 145 double flux = fakeRO->image->data.F32[(int)y][(int)x]; 145 if (flux > 0) { 146 // The source is present 147 numbers->data.S32[j]++; 146 if (!isfinite(flux) || flux < 0) { 147 continue; 148 148 } 149 149 float norm = PEAK_FLUX / flux; // Normalisation for source … … 156 156 psFree(subEnv); 157 157 158 // Get the radius 159 pmModel *model = pmModelFromPSFforXY(psf, x, y, PEAK_FLUX); // Model for source 160 psAssert (model, "failed to generate model: should this be an error or not?"); 161 float srcRadius = model->modelRadius(model->params, PS_SQR(VARIANCE_VAL)); // Radius for source 162 if (srcRadius > maxRadius) { 163 maxRadius = srcRadius; 164 } 165 psFree(model); 158 // If we got this far, the source is decent 159 numbers->data.S32[j]++; 166 160 } 167 161 … … 182 176 psFree(fakeRO); 183 177 184 if (maxRadius > radius) {185 maxRadius = radius;186 }187 188 178 #ifdef TESTING 189 179 { … … 261 251 262 252 // Reset the sources to point to the new pixels, and measure the moments in preparation for PSF fitting 253 int numMoments = 0; // Number of moments measured 263 254 for (int i = 0; i < numFakes; i++) { 264 255 pmSource *source = fakes->data[i]; // Fake source … … 275 266 source->maskObj = NULL; 276 267 277 if (!pmSourceDefinePixels(source, readout, x, y, maxRadius)) {268 if (!pmSourceDefinePixels(source, readout, x, y, radius)) { 278 269 psError(PS_ERR_UNKNOWN, false, "Unable to define pixels for source."); 279 270 psFree(readout); … … 282 273 } 283 274 284 if (!pmSourceMoments(source, maxRadius)) { 285 psError(PS_ERR_UNKNOWN, false, "Unable to measure moments for source."); 286 psFree(readout); 287 psFree(fakes); 288 return NULL; 289 } 275 if (!pmSourceMoments(source, radius)) { 276 // Can't do anything about it; limp along as best we can 277 psErrorClear(); 278 continue; 279 } 280 numMoments++; 281 } 282 283 if (numMoments == 0) { 284 psError(PS_ERR_UNKNOWN, true, "Unable to measure moments for sources."); 285 psFree(fakes); 286 psFree(readout); 287 return NULL; 290 288 } 291 289 … … 296 294 options->poissonErrorsParams = true; 297 295 options->stats = psStatsAlloc(PSF_STATS); 298 options->radius = maxRadius;296 options->radius = radius; 299 297 options->psfTrendMode = PM_TREND_MAP; 300 298 options->psfTrendNx = xOrder;
Note:
See TracChangeset
for help on using the changeset viewer.
