Changeset 20213
- Timestamp:
- Oct 16, 2008, 3:50:31 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotSignificanceImage.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotSignificanceImage.c
r18837 r20213 15 15 // XXX we can a) choose fft to convolve if needed and b) multithread fftw 16 16 17 float minGauss = psMetadataLookupF32(NULL, recipe, "PEAKS_MIN_GAUSS"); // Minimum valid fraction of kernel 18 if (!isfinite(minGauss)) { 19 psWarning("PEAKS_MIN_GAUSS is not set in recipe; using default value"); 20 minGauss = 0.5; 21 } 22 17 23 bool status_x, status_y; 18 24 float FWHM_X = psMetadataLookupF32 (&status_x, recipe, "FWHM_X"); … … 26 32 // if we do not know the FWHM, use the guess smoothing kernel supplied. 27 33 // it is a configuration error if these are not supplied 28 SIGMA_SMTH = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_SIGMA"); 34 SIGMA_SMTH = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_SIGMA"); 29 35 PS_ASSERT (status, NULL); 30 NSIGMA_SMTH = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_NSIGMA"); 36 NSIGMA_SMTH = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_NSIGMA"); 31 37 PS_ASSERT (status, NULL); 32 38 guess = true; 33 39 } 34 40 // record the actual smoothing sigma 35 psMetadataAddF32 (recipe, PS_LIST_TAIL, "SIGMA_SMOOTH", PS_META_REPLACE, "Smoothing sigma for detections", SIGMA_SMTH); 41 psMetadataAddF32(recipe, PS_LIST_TAIL, "SIGMA_SMOOTH", PS_META_REPLACE, "Smoothing sigma for detections", 42 SIGMA_SMTH); 36 43 37 44 // smooth the image, applying the mask as we go 38 psImage *smooth_im = psImageCopy (NULL, readout->image, PS_TYPE_F32);39 psImageSmoothMask F32 (smooth_im, readout->mask, maskVal, SIGMA_SMTH, NSIGMA_SMTH);40 psLogMsg ("psphot", PS_LOG_MINUTIA, "smooth image: %f sec\n", psTimerMark("smooth"));45 psImage *smooth_im = psImageCopy(NULL, readout->image, PS_TYPE_F32); 46 psImageSmoothMask(smooth_im, smooth_im, readout->mask, maskVal, SIGMA_SMTH, NSIGMA_SMTH, minGauss); 47 psLogMsg("psphot", PS_LOG_MINUTIA, "smooth image: %f sec\n", psTimerMark("smooth")); 41 48 42 49 // Smooth the weight, applying the mask as we go. The variance is smoothed by the PSF^2, … … 47 54 // measurements based on apertures comparable to or larger than the smoothing kernel, the 48 55 // effective per-pixel variance is maintained. 49 psImage *smooth_wt = psImageCopy (NULL, readout->weight, PS_TYPE_F32); 50 psImageSmoothMaskF32 (smooth_wt, readout->mask, maskVal, SIGMA_SMTH/sqrt(2), NSIGMA_SMTH); 51 psLogMsg ("psphot", PS_LOG_MINUTIA, "smooth weight: %f sec\n", psTimerMark ("smooth")); 56 psImage *smooth_wt = psImageCopy(NULL, readout->weight, PS_TYPE_F32); 57 psImageSmoothMask(smooth_wt, smooth_wt, readout->mask, maskVal, SIGMA_SMTH * M_SQRT1_2, 58 NSIGMA_SMTH, minGauss); 59 psLogMsg("psphot", PS_LOG_MINUTIA, "smooth weight: %f sec\n", psTimerMark("smooth")); 52 60 53 61 psImage *mask = readout->mask; … … 58 66 char name[64]; 59 67 sprintf (name, "imsmooth.v%d.fits", pass); 60 psphotSaveImage (NULL, smooth_im, name);68 psphotSaveImage(NULL, smooth_im, name); 61 69 sprintf (name, "wtsmooth.v%d.fits", pass); 62 psphotSaveImage (NULL, smooth_wt, name);70 psphotSaveImage(NULL, smooth_wt, name); 63 71 } 64 72 … … 67 75 // sigma_s^2. Ideally, we are choosing sigma_s = sigma_r, in which case sigma_o^2 = 2 68 76 // sigma_s^2. If we do not know the input image PSF size (initial detection stage), then 69 // we are assuming that sigma_r = sigma_s. 77 // we are assuming that sigma_r = sigma_s. 70 78 71 79 // Build the significance image on top of smooth_im. We need to correct the ratio im/wt by … … 93 101 // record the effective area and significance scaling factor 94 102 float effArea = 8.0 * M_PI * PS_SQR(SIGMA_SMTH); 95 psMetadataAddF32 (recipe, PS_LIST_TAIL, "EFFECTIVE_AREA", PS_META_REPLACE, "Effective Area", effArea); 96 psMetadataAddF32 (recipe, PS_LIST_TAIL, "SIGNIFICANCE_SCALE_FACTOR", PS_META_REPLACE, "Signicance scale factor", factor); 103 psMetadataAddF32(recipe, PS_LIST_TAIL, "EFFECTIVE_AREA", PS_META_REPLACE, "Effective Area", effArea); 104 psMetadataAddF32(recipe, PS_LIST_TAIL, "SIGNIFICANCE_SCALE_FACTOR", PS_META_REPLACE, 105 "Signicance scale factor", factor); 97 106 98 107 // XXX multithread this if needed … … 107 116 } 108 117 } 109 psLogMsg ("psphot", PS_LOG_INFO, "built smoothed signficance image: %f sec\n", psTimerMark ("smooth"));118 psLogMsg ("psphot", PS_LOG_INFO, "built smoothed signficance image: %f sec\n", psTimerMark("smooth")); 110 119 111 120 // optionally save example images under trace … … 117 126 } 118 127 119 psFree (smooth_wt);128 psFree(smooth_wt); 120 129 return smooth_im; 121 130 }
Note:
See TracChangeset
for help on using the changeset viewer.
