Changeset 6439
- Timestamp:
- Feb 16, 2006, 4:48:25 PM (20 years ago)
- Location:
- branches/eam_rel9_p0/psModules/src/objects
- Files:
-
- 2 edited
-
pmObjects.c (modified) (6 diffs)
-
pmObjects.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_rel9_p0/psModules/src/objects/pmObjects.c
r6380 r6439 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1.5.4. 7$ $Name: not supported by cvs2svn $9 * @date $Date: 2006-02- 08 07:16:49$8 * @version $Revision: 1.5.4.8 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-02-17 02:48:25 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 786 786 return(false); 787 787 } 788 source->moments = pmMomentsAlloc(); 788 if (source->moments == NULL) { 789 source->moments = pmMomentsAlloc(); 790 } 789 791 source->moments->Sky = (psF32) tmpF64; 792 psTrace(__func__, 3, "---- %s(true) end ----\n", __func__); 793 return (true); 794 } 795 796 // A complementary function to pmSourceLocalSky: calculate the local median variance 797 bool pmSourceLocalSkyVariance( 798 pmSource *source, 799 psStatsOptions statsOptions, 800 psF32 Radius) 801 { 802 psTrace(__func__, 3, "---- %s() begin ----\n", __func__); 803 PS_ASSERT_PTR_NON_NULL(source, false); 804 PS_ASSERT_IMAGE_NON_NULL(source->weight, false); 805 PS_ASSERT_IMAGE_NON_NULL(source->mask, false); 806 PS_ASSERT_PTR_NON_NULL(source->peak, false); 807 PS_ASSERT_INT_POSITIVE(Radius, false); 808 PS_ASSERT_INT_NONNEGATIVE(Radius, false); 809 810 psImage *image = source->weight; 811 psImage *mask = source->mask; 812 pmPeak *peak = source->peak; 813 psRegion srcRegion; 814 815 srcRegion = psRegionForSquare(peak->x, peak->y, Radius); 816 srcRegion = psRegionForImage(mask, srcRegion); 817 818 psImageMaskRegion(mask, srcRegion, "OR", PSPHOT_MASK_MARKED); 819 psStats *myStats = psStatsAlloc(statsOptions); 820 myStats = psImageStats(myStats, image, mask, 0xff); 821 psImageMaskRegion(mask, srcRegion, "AND", ~PSPHOT_MASK_MARKED); 822 823 psF64 tmpF64; 824 p_psGetStatValue(myStats, &tmpF64); 825 psFree(myStats); 826 827 if (isnan(tmpF64)) { 828 psTrace(__func__, 3, "---- %s(false) end ----\n", __func__); 829 return(false); 830 } 831 if (source->moments == NULL) { 832 source->moments = pmMomentsAlloc(); 833 } 834 source->moments->dSky = (psF32) tmpF64; 790 835 psTrace(__func__, 3, "---- %s(true) end ----\n", __func__); 791 836 return (true); … … 1337 1382 PS_ASSERT_PTR_NON_NULL(source->moments, false); 1338 1383 PS_ASSERT_PTR_NON_NULL(source->peak, false); 1339 PS_ FLOAT_COMPARE(0.0, radius, false);1384 PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(radius, 0.0, false); 1340 1385 1341 1386 // … … 1671 1716 yErr->n = nPix; 1672 1717 1718 // XXX EAM : the new minimization API supplies the constraints as a struct 1673 1719 psMinimization *myMin = psMinimizationAlloc(PM_SOURCE_FIT_MODEL_NUM_ITERATIONS, 1674 1720 PM_SOURCE_FIT_MODEL_TOLERANCE); 1721 psMinConstrain *constrain = psMinConstrainAlloc(); 1675 1722 1676 1723 // PSF model only fits first 4 parameters, EXT model fits all … … 1684 1731 } 1685 1732 } 1733 constrain->paramMask = paramMask; 1686 1734 1687 1735 // Set the parameter range checks 1688 1736 pmModelLimits modelLimits = pmModelLimits_GetFunction (model->type); 1689 psVector *beta_lim = NULL; 1690 psVector *params_min = NULL; 1691 psVector *params_max = NULL; 1692 1693 // XXX EAM : in this implementation, I pass in the limits with the covar matrix. 1694 // in the SDRS, I define a new psMinimization which will take these in 1695 psImage *covar = psImageAlloc (params->n, 3, PS_TYPE_F64); 1696 modelLimits (&beta_lim, ¶ms_min, ¶ms_max); 1697 for (int i = 0; i < params->n; i++) { 1698 covar->data.F64[0][i] = beta_lim->data.F32[i]; 1699 covar->data.F64[1][i] = params_min->data.F32[i]; 1700 covar->data.F64[2][i] = params_max->data.F32[i]; 1701 } 1737 modelLimits (&constrain->paramDelta, &constrain->paramMin, &constrain->paramMax); 1738 1739 psImage *covar = psImageAlloc (params->n, params->n, PS_TYPE_F64); 1702 1740 1703 1741 psTrace (".pmObjects.pmSourceFitModel", 5, "fitting function\n"); 1704 fitStatus = psMinimizeLMChi2(myMin, covar, params, paramMask, x, y, yErr, modelFunc); 1742 1743 fitStatus = psMinimizeLMChi2(myMin, covar, params, constrain, x, y, yErr, modelFunc); 1705 1744 for (int i = 0; i < dparams->n; i++) { 1706 1745 if ((paramMask != NULL) && paramMask->data.U8[i]) … … 1749 1788 psFree(myMin); 1750 1789 psFree(covar); 1751 psFree(paramMask); 1752 psFree(params_min); 1753 psFree(params_max); 1754 psFree(beta_lim); 1790 psFree(constrain->paramMask); 1791 psFree(constrain->paramMin); 1792 psFree(constrain->paramMax); 1793 psFree(constrain->paramDelta); 1794 psFree(constrain); 1755 1795 1756 1796 rc = (onPic && fitStatus); -
branches/eam_rel9_p0/psModules/src/objects/pmObjects.h
r6380 r6439 10 10 * @author GLG, MHPCC 11 11 * 12 * @version $Revision: 1.4.4. 7$ $Name: not supported by cvs2svn $13 * @date $Date: 2006-02- 08 07:16:49$12 * @version $Revision: 1.4.4.8 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2006-02-17 02:48:23 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 88 88 typedef struct 89 89 { 90 float x; ///< X-coord of centroid.91 float y; ///< Y-coord of centroid.90 float x; ///< X-coord of centroid. 91 float y; ///< Y-coord of centroid. 92 92 float Sx; ///< x-second moment. 93 93 float Sy; ///< y-second moment. 94 float Sxy; ///< xy cross moment. 95 float Sum; ///< Pixel sum above sky (background). 96 float Peak; ///< Peak counts above sky. 97 float Sky; ///< Sky level (background). 94 float Sxy; ///< xy cross moment. 95 float Sum; ///< Pixel sum above sky (background). 96 float Peak; ///< Peak counts above sky. 97 float Sky; ///< Sky level (background). 98 float dSky; ///< local Sky variance 98 99 float SN; ///< approx signal-to-noise 99 int nPixels; ///< Number of pixels used.100 int nPixels; ///< Number of pixels used. 100 101 } 101 102 pmMoments; … … 360 361 361 362 363 // A complementary function to pmSourceLocalSky: calculate the local sky variance 364 bool pmSourceLocalSkyVariance( 365 pmSource *source, ///< The input image (float) 366 psStatsOptions statsOptions, ///< The statistic used in calculating the background sky 367 float Radius ///< The inner radius of the square annulus to exclude 368 ); 369 362 370 /** pmSourceMoments() 363 371 *
Note:
See TracChangeset
for help on using the changeset viewer.
