Changeset 10851 for trunk/psModules/src/astrom/pmAstrometryDistortion.c
- Timestamp:
- Dec 29, 2006, 8:29:59 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/astrom/pmAstrometryDistortion.c
r10829 r10851 7 7 * @author EAM, IfA 8 8 * 9 * @version $Revision: 1. 9$ $Name: not supported by cvs2svn $10 * @date $Date: 2006-12-2 5 01:49:49 $9 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2006-12-29 18:29:59 $ 11 11 * 12 12 * Copyright 2006 Institute for Astronomy, University of Hawaii … … 29 29 #include "pmAstrometryObjects.h" 30 30 #include "pmAstrometryDistortion.h" 31 #include "pmKapaPlots.h" 31 32 32 33 static void pmAstromGradientFree (pmAstromGradient *grad) … … 117 118 continue; 118 119 120 char key; 121 pmKapaPlotVectorPair (L, M); 122 fscanf (stdin, "%c", &key); 123 124 pmKapaPlotVectorPair (L, dP); 125 fscanf (stdin, "%c", &key); 126 127 pmKapaPlotVectorPair (L, dQ); 128 fscanf (stdin, "%c", &key); 129 119 130 // fit the collection of positions and offsets with a local 1st order gradient 120 131 // 3hi/3lo sigma clipping on the rflux vs metric fit … … 131 142 grad->FP.y = stats->sampleMedian; 132 143 133 psVectorClipFitPolynomial2D (local, stats, mask, 0xff, dP, NULL, L, M); 144 // test how many survive and include / exclude points on that basis 145 if (!psVectorClipFitPolynomial2D (local, stats, mask, 0xff, dP, NULL, L, M)) { 146 psFree (grad); 147 continue; 148 } 134 149 135 150 grad->dTPdL.x = local->coeff[1][0]; 136 151 grad->dTPdM.x = local->coeff[0][1]; 137 152 138 psVectorClipFitPolynomial2D (local, stats, mask, 0xff, dQ, NULL, L, M); 153 if (!psVectorClipFitPolynomial2D (local, stats, mask, 0xff, dQ, NULL, L, M)) { 154 psFree (grad); 155 continue; 156 } 139 157 140 158 grad->dTPdL.y = local->coeff[1][0]; … … 142 160 143 161 psArrayAdd (gradients, 100, grad); 162 psFree (grad); 144 163 } 145 164 } … … 175 194 } 176 195 196 char key; 197 pmKapaPlotVectorPair (L, M); 198 fscanf (stdin, "%c", &key); 199 200 pmKapaPlotVectorPair (L, dPdL); 201 fscanf (stdin, "%c", &key); 202 203 pmKapaPlotVectorPair (L, dPdM); 204 fscanf (stdin, "%c", &key); 205 206 pmKapaPlotVectorPair (L, dQdL); 207 fscanf (stdin, "%c", &key); 208 209 pmKapaPlotVectorPair (L, dQdM); 210 fscanf (stdin, "%c", &key); 211 177 212 psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV); 178 213 psVector *mask = psVectorAlloc (gradients->n, PS_TYPE_MASK); … … 182 217 // determine the gradient order(s) from the fpa->toTP structure 183 218 localX = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, fpa->toTPA->x->nX-1, fpa->toTPA->x->nY); 219 184 220 localY = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, fpa->toTPA->x->nX, fpa->toTPA->x->nY-1); 185 221 … … 188 224 for (int j = 0; j <= fpa->toTPA->x->nY; j++) { 189 225 if (fpa->toTPA->x->mask[i][j]) { 190 if ((i > 0) && (i < fpa->toTPA->x->nX)) {226 if ((i > 0) && (i <= fpa->toTPA->x->nX)) { 191 227 localX->mask[i-1][j] = 1; 192 228 } 193 if ((j > 0) && (j < fpa->toTPA->y->nY)) {229 if ((j > 0) && (j <= fpa->toTPA->y->nY)) { 194 230 localY->mask[i][j-1] = 1; 195 231 } … … 199 235 200 236 // fit the local gradients in each direction 201 psVectorClipFitPolynomial2D (localX, stats, mask, 0xff, dPdL, NULL, L, M); 202 psVectorClipFitPolynomial2D (localY, stats, mask, 0xff, dPdM, NULL, L, M); 237 if (!psVectorClipFitPolynomial2D (localX, stats, mask, 0xff, dPdL, NULL, L, M)) { 238 psLogMsg ("psastro", 3, "failed to fit x-dir gradient\n"); 239 return false; 240 } 241 242 if (!psVectorClipFitPolynomial2D (localY, stats, mask, 0xff, dPdM, NULL, L, M)) { 243 psLogMsg ("psastro", 3, "failed to fit y-dir gradient\n"); 244 return false; 245 } 203 246 204 247 // XXX test: generate fit
Note:
See TracChangeset
for help on using the changeset viewer.
