Changeset 6761
- Timestamp:
- Apr 4, 2006, 8:41:38 AM (20 years ago)
- Location:
- branches/rel10_ifa/psModules/src/detrend
- Files:
-
- 2 edited
-
pmFringeStats.c (modified) (3 diffs)
-
pmFringeStats.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/rel10_ifa/psModules/src/detrend/pmFringeStats.c
r6758 r6761 3 3 * @author Eugene Magnier, IfA 4 4 * 5 * @version $Revision: 1.1.2. 1$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-04-0 3 06:12:10$5 * @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-04-04 18:41:38 $ 7 7 * 8 8 * Copyright 2004 IfA … … 44 44 } 45 45 46 static pmFringeScaleFree (pmFringeScale *scale) 47 { 48 psFree (scale->coeff); 49 psFree (scale->coeffErr); 50 return; 51 } 52 53 pmFringeScale *pmFringeScaleAlloc (int nFringeFrames) 54 { 55 pmFringeScale *scale = psAlloc(sizeof(pmFringeScale)); 56 (void)psMemSetDeallocator(scale, (psFreeFunc)pmFringeScaleFree); 57 58 scale->nFringeFrames = nFringeFrames; 59 scale->coeff = psVectorAlloc (nFringeFrames + 1, PS_TYPE_F32); 60 scale->coeffErr = psVectorAlloc (nFringeFrames + 1, PS_TYPE_F32); 61 62 return scale; 63 } 64 46 65 bool pmFringeStatsCreatePoints (pmFringeStats *fringe, psImage *image) 47 66 { … … 117 136 return true; 118 137 } 119 psImage *pmFringeCorrect( 120 psImage *out, 121 psMetadata *info, 122 psImage *science, 123 psArray *fringeImage, 124 psArray *fringeStats 125 ); 126 138 139 // XXX include the fringe error (fringe->df) in the fit? 140 pmFringeScale *pmFringeScaleMeasure (pmFringeStats *science, psArray *fringes) 141 { 142 143 double sum; 144 psVector *v1; 145 psVector *v2; 146 147 pmFringeScale *scale = pmFringeScaleAlloc (fringes->n); 148 149 int nCof = fringes->n + 1; 150 int nPts = science->f->n; 151 152 psImage *A = psImageAlloc (nCof, nCof, PS_TYPE_F64); 153 psVector *B = psVectorAlloc (nCod, PS_TYPE_F64); 154 155 for (int i = 0; i < nCof; i++) { 156 if (i == 0) { 157 p1 = NULL; 158 } else { 159 v1 = fringes->data[i - 1]; 160 p1 = v1->data.F32; 161 } 162 for (int j = 0; j < nCof; j++) { 163 if (j == 0) { 164 p2 = NULL; 165 } else { 166 v2 = fringes->data[j - 1]; 167 p2 = v2->data.F32; 168 } 169 170 sum = 0; 171 for (int I = 0; I < nPts; I++) { 172 f1 = (p1 == NULL) ? 1.0 : p1[I]; 173 f2 = (p2 == NULL) ? 1.0 : p2[I]; 174 sum += f1*f2; 175 } 176 A->data.F32[i][j] = sum; 177 } 178 179 sum = 0; 180 p2 = science->f->data.F32; 181 for (int I = 0; I < nPts; I++) { 182 f1 = (p1 == NULL) ? 1.0 : p1[I]; 183 f2 = p2[I]; 184 sum += f1*f2; 185 } 186 B->data.F32[i] = sum; 187 } 188 189 if (! psGaussJordan(A, B)) { 190 psError(PS_ERR_UNKNOWN, false, "Could not solve linear equations. Returning NULL.\n"); 191 } 192 193 194 for (int i = 0; i < nCof; i++) { 195 scale->coeff->data.F32[i] = B->data.F32[i]; 196 scale->coeffErr->data.F32[i] = sqrt(A->data.F32[i][i]); 197 } 198 199 return scale; 200 } 201 202 // XXX note that this modifies the input fringe images 203 psImage *pmFringeCorrect(psImage *out, psMetadata *info, psImage *science, psArray *fringeImage, psArray *fringeStats) 204 { 205 206 // measure the fringe stats 207 pmFringeScale *scale = pmFringeScaleMeasure (science, fringeStats); 208 209 if (out != NULL) { 210 psImageInit (out, 0.0); 211 } 212 213 // build the fringe correction image 214 // XXX we could save data space by making the first image the output image 215 for (int i = 0; i < fringeImage->n; i++) { 216 217 // rescale the fringe image 218 psBinaryOp (fringeImage->data[i], fringeImage->data[i], "*", psScalarAlloc (scale->coeff->data.F32[i+1])); 219 220 // sum together 221 out = psBinaryOp (out, out, "+", fringeImage->data[i]); 222 } 223 224 // subtract the resulting fringe frame 225 out = psBinaryOp (out, science, "-", out); 226 227 return out; 228 } 229 -
branches/rel10_ifa/psModules/src/detrend/pmFringeStats.h
r6758 r6761 5 5 * @author Eugene Magnier, IfA 6 6 * 7 * @version $Revision: 1.1.2. 1$ $Name: not supported by cvs2svn $8 * @date $Date: 2006-04-0 3 06:12:10$7 * @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2006-04-04 18:41:38 $ 9 9 * 10 10 * Copyright 2004 IfA, University of Hawaii … … 41 41 ); 42 42 43 /** the pmFringeScale structure defines the relationship between two fringe measurements 44 */ 45 typedef struct 46 { 47 int nFringeFrames; 48 psVector *coeff; 49 psVector *coeffErr; 50 } 51 pmFringeScale; 52 43 53 /** Measure the fringe stats for an image 44 54 *
Note:
See TracChangeset
for help on using the changeset viewer.
