Changeset 14778
- Timestamp:
- Sep 7, 2007, 10:24:34 AM (19 years ago)
- Location:
- branches/eam_branch_20070830/psModules/src/objects
- Files:
-
- 2 edited
-
pmTrend2D.c (modified) (6 diffs)
-
pmTrend2D.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20070830/psModules/src/objects/pmTrend2D.c
r14731 r14778 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.1.2. 1$ $Name: not supported by cvs2svn $6 * @date $Date: 2007-09-0 4 18:35:51$5 * @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-09-07 20:24:34 $ 7 7 * 8 8 * Copyright 2004 Institute for Astronomy, University of Hawaii … … 22 22 return; 23 23 24 psFree (trend->stats); 24 25 psFree (trend->poly); 25 26 psFree (trend->map); … … 27 28 } 28 29 29 pmTrend2D *pmTrend2DAlloc (pmTrend2DMode mode, int nXout, int nYout, int nXtrend, int nYtrend, psStats *stats)30 pmTrend2D *pmTrend2DAlloc (pmTrend2DMode mode, psImage *image, int nXtrend, int nYtrend, psStats *stats) 30 31 { 31 32 pmTrend2D *trend = (pmTrend2D *) psAlloc(sizeof(pmTrend2D)); … … 35 36 trend->poly = NULL; 36 37 trend->stats = psMemIncrRefCounter (stats); 38 trend->mode = mode; 37 39 38 40 switch (mode) { … … 45 47 break; 46 48 47 case PM_TREND_MAP: 48 // XXX *** I need the output image dimensions here! 49 case PM_TREND_MAP: { 50 // binning defines the map scale relationship 51 psImageBinning *binning = psImageBinningAlloc(); 52 binning->nXfine = image->numCols; 53 binning->nYfine = image->numRows; 54 binning->nXruff = nXtrend; 55 binning->nYruff = nYtrend; 49 56 50 // function is defined over the range 0-1000, 0-1000 51 psImageBinning *binning = psImageBinningAlloc(); 52 binning->nXfine = nXout; 53 binning->nYfine = nYout; 54 binning->nXruff = nXtrend; 55 binning->nYruff = nYtrend; 56 57 trend->map = psImageMapAlloc (NULL, binning, stats); 58 psFree (binning); 59 break; 57 trend->map = psImageMapAlloc (image, binning, stats); 58 psFree (binning); 59 break; 60 } 60 61 61 62 default: … … 64 65 return (trend); 65 66 } 67 68 pmTrend2D *pmTrend2DFieldAlloc (pmTrend2DMode mode, int nXfield, int nYfield, int nXtrend, int nYtrend, psStats *stats) 69 { 70 pmTrend2D *trend = (pmTrend2D *) psAlloc(sizeof(pmTrend2D)); 71 psMemSetDeallocator(trend, (psFreeFunc) pmTrend2DFree); 72 73 trend->map = NULL; 74 trend->poly = NULL; 75 trend->stats = psMemIncrRefCounter (stats); 76 trend->mode = mode; 77 78 switch (mode) { 79 case PM_TREND_POLY_ORD: 80 trend->poly = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, nXtrend, nYtrend); 81 break; 82 83 case PM_TREND_POLY_CHEB: 84 trend->poly = psPolynomial2DAlloc (PS_POLYNOMIAL_CHEB, nXtrend, nYtrend); 85 break; 86 87 case PM_TREND_MAP: { 88 // binning defines the map scale relationship 89 psImageBinning *binning = psImageBinningAlloc(); 90 binning->nXfine = nXfield; 91 binning->nYfine = nYfield; 92 binning->nXruff = nXtrend; 93 binning->nYruff = nYtrend; 94 95 trend->map = psImageMapAlloc (NULL, binning, stats); 96 psFree (binning); 97 break; 98 } 99 100 default: 101 psAbort ("error"); 102 } 103 return (trend); 104 } 105 106 bool pmTrend2DFit (pmTrend2D *trend, psVector *x, psVector *y, psVector *f, psVector *df) { 107 108 bool status; 109 110 psVector *mask = psVectorAlloc (x->n, PS_TYPE_MASK); 111 112 switch (trend->mode) { 113 case PM_TREND_POLY_ORD: 114 case PM_TREND_POLY_CHEB: 115 status = psVectorClipFitPolynomial2D (trend->poly, trend->stats, mask, 0xff, f, df, x, y); 116 // we can use the API here which adjusts the polynomial order based on the number 117 // of points in the image, and potentially based on the fractional range of the 118 // data? 119 break; 120 121 case PM_TREND_MAP: 122 // XXX supply fraction from trend elements 123 status = psImageMapGenerateScale (trend->map, x, y, f, df, 0.1); 124 break; 125 126 default: 127 psAbort ("error"); 128 } 129 psFree (mask); 130 return status; 131 } 132 133 double pmTrend2DEval (pmTrend2D *trend, float x, float y) { 134 135 double result; 136 137 if (!trend) return 0.0; 138 139 switch (trend->mode) { 140 case PM_TREND_POLY_ORD: 141 case PM_TREND_POLY_CHEB: 142 result = psPolynomial2DEval (trend->poly, x, y); 143 break; 144 145 case PM_TREND_MAP: 146 result = psImageMapEval (trend->map, x, y); 147 break; 148 149 default: 150 psAbort ("error"); 151 } 152 return result; 153 } 154 155 psVector *pmTrend2DEvalVector (pmTrend2D *trend, psVector *x, psVector *y) { 156 157 psVector *result; 158 159 switch (trend->mode) { 160 case PM_TREND_POLY_ORD: 161 case PM_TREND_POLY_CHEB: 162 result = psPolynomial2DEvalVector (trend->poly, x, y); 163 break; 164 165 case PM_TREND_MAP: 166 result = psImageMapEvalVector (trend->map, x, y); 167 break; 168 169 default: 170 psAbort ("error"); 171 } 172 return result; 173 } -
branches/eam_branch_20070830/psModules/src/objects/pmTrend2D.h
r14731 r14778 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1.1.2. 1$ $Name: not supported by cvs2svn $8 * @date $Date: 2007-09-0 4 18:35:51$7 * @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-09-07 20:24:34 $ 9 9 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 10 10 */ … … 17 17 18 18 typedef enum { 19 PM_TREND_POLY_ORD,20 PM_TREND_POLY_CHEB,21 PM_TREND_MAP,19 PM_TREND_POLY_ORD, 20 PM_TREND_POLY_CHEB, 21 PM_TREND_MAP, 22 22 } pmTrend2DMode; 23 23 24 24 typedef struct { 25 psPolynomial2D *poly; 26 psImageMap *map; 27 pmTrend2DMode mode; // POLY_ORD, POLY_CHEB, MAP 25 psPolynomial2D *poly; 26 psImageMap *map; 27 psStats *stats; 28 pmTrend2DMode mode; // POLY_ORD, POLY_CHEB, MAP 28 29 } pmTrend2D; 29 30 30 // allocate a pmTrend2D structure . nX,nY isorder for the polynomials, max number of grid cells for31 // allocate a pmTrend2D structure tied to an image dimensions. nXtrend,nYtrend is the order for the polynomials, max number of grid cells for 31 32 // psImageMap 32 pmTrend2D *pmTrend2DAlloc (pmTrend2DMode mode, int nXout, int nYout, int nXtrend, int nYtrend, psStats *stats); 33 pmTrend2D *pmTrend2DAlloc (pmTrend2DMode mode, psImage *image, int nXtrend, int nYtrend, psStats *stats); 34 35 // allocate a pmTrend2D tied to an abstract field with size nXfield,nYfield 36 pmTrend2D *pmTrend2DFieldAlloc (pmTrend2DMode mode, int nXfield, int nYfield, int nXtrend, int nYtrend, psStats *stats); 33 37 34 38 bool pmTrend2DFit (pmTrend2D *trend, psVector *x, psVector *y, psVector *f, psVector *df); 35 39 40 double pmTrend2DEval (pmTrend2D *trend, float x, float y); 41 psVector *pmTrend2DEvalVector (pmTrend2D *trend, psVector *x, psVector *y); 42 36 43 /// @} 37 44 # endif
Note:
See TracChangeset
for help on using the changeset viewer.
