IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 29, 2006, 8:29:59 AM (20 years ago)
Author:
magnier
Message:

plots and error checks on clip-fit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/astrom/pmAstrometryDistortion.c

    r10829 r10851  
    77*  @author EAM, IfA
    88*
    9 *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2006-12-25 01:49:49 $
     9*  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2006-12-29 18:29:59 $
    1111*
    1212*  Copyright 2006 Institute for Astronomy, University of Hawaii
     
    2929#include "pmAstrometryObjects.h"
    3030#include "pmAstrometryDistortion.h"
     31#include "pmKapaPlots.h"
    3132
    3233static void pmAstromGradientFree (pmAstromGradient *grad)
     
    117118                continue;
    118119
     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
    119130            // fit the collection of positions and offsets with a local 1st order gradient
    120131            // 3hi/3lo sigma clipping on the rflux vs metric fit
     
    131142            grad->FP.y = stats->sampleMedian;
    132143
    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            }
    134149
    135150            grad->dTPdL.x = local->coeff[1][0];
    136151            grad->dTPdM.x = local->coeff[0][1];
    137152
    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            }
    139157
    140158            grad->dTPdL.y = local->coeff[1][0];
     
    142160
    143161            psArrayAdd (gradients, 100, grad);
     162            psFree (grad);
    144163        }
    145164    }
     
    175194    }
    176195
     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
    177212    psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV);
    178213    psVector *mask = psVectorAlloc (gradients->n, PS_TYPE_MASK);
     
    182217    // determine the gradient order(s) from the fpa->toTP structure
    183218    localX = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, fpa->toTPA->x->nX-1, fpa->toTPA->x->nY);
     219
    184220    localY = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, fpa->toTPA->x->nX,   fpa->toTPA->x->nY-1);
    185221
     
    188224        for (int j = 0; j <= fpa->toTPA->x->nY; j++) {
    189225            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)) {
    191227                    localX->mask[i-1][j] = 1;
    192228                }
    193                 if ((j > 0) && (j < fpa->toTPA->y->nY)) {
     229                if ((j > 0) && (j <= fpa->toTPA->y->nY)) {
    194230                    localY->mask[i][j-1] = 1;
    195231                }
     
    199235
    200236    // 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    }
    203246
    204247    // XXX test: generate fit
Note: See TracChangeset for help on using the changeset viewer.