IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 19, 2005, 12:26:40 PM (21 years ago)
Author:
eugene
Message:

fixing errors related to apResid and skyBias

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psPolynomials.c

    r4977 r5068  
    497497
    498498// XXX EAM : be careful here with F32 vs F64 vectors
     499psPolynomial1D* VectorClipFitPolynomial1D_EAM(psPolynomial1D* poly,
     500                                              psStats *stats,
     501                                              psVector* mask,
     502                                              psMaskType maskValue,
     503                                              const psVector* z,
     504                                              const psVector* dz,
     505                                              const psVector* x)
     506{
     507    psVector *zFit   = NULL;
     508    psVector *zResid = psVectorAlloc (x->n, PS_TYPE_F64);
     509
     510    // XXX EAM : use SAMPLE_MEAN and SAMPLE_STDEV for stats:
     511    stats->options |= (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV);
     512
     513    for (int N = 0; N < 3; N++) {
     514        int Nkeep = 0;
     515
     516        poly   = VectorFitPolynomial1D_EAM (poly, mask, maskValue, z, dz, x);
     517        zFit   = Polynomial1DEvalVector_EAM (poly, x);
     518        zResid = (psVector *) psBinaryOp (zResid, (void *) z, "-", (void *) zFit);
     519
     520        stats  = psVectorStats (stats, zResid, NULL, mask, maskValue);
     521        psTrace (".psphot.RobustFit", 4, "residual stats for robust fit:  %g +/- %g\n",
     522                 stats->sampleMedian, stats->sampleStdev);
     523
     524        // set mask if pts are not valid
     525        // we are masking out any point which is out of range
     526        // recovery is not allowed with this scheme
     527        for (int i = 0; i < zResid->n; i++) {
     528            if (mask->data.U8[i]) continue;
     529            if (fabs(zResid->data.F64[i] - stats->sampleMedian) > 2*stats->sampleStdev) {
     530                mask->data.U8[i] |= 0x01;
     531                continue;
     532            }       
     533            Nkeep ++;
     534        }
     535
     536        psTrace (".psphot.RobustFit", 4, "keeping %d of %d pts for fit\n",
     537                 Nkeep, x->n);
     538
     539        psFree (zFit);
     540    }
     541    psFree (zResid);
     542    return (poly);
     543}
     544
     545
     546// XXX EAM : be careful here with F32 vs F64 vectors
    499547psPolynomial2D* VectorClipFitPolynomial2D_EAM(psPolynomial2D* poly,
    500548                                              psStats *stats,
     
    510558
    511559    // XXX EAM : use SAMPLE_MEAN and SAMPLE_STDEV for stats:
    512     stats->options |= (PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV);
     560    stats->options |= (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV);
    513561
    514562    for (int N = 0; N < 3; N++) {
     563        int Nkeep = 0;
     564
    515565        poly   = VectorFitPolynomial2D_EAM (poly, mask, maskValue, z, dz, x, y);
    516566        zFit   = Polynomial2DEvalVectorD_EAM (poly, x, y);
     
    519569        stats  = psVectorStats (stats, zResid, NULL, mask, maskValue);
    520570        psTrace (".psphot.RobustFit", 4, "residual stats for robust fit:  %g +/- %g\n",
    521                  stats->sampleMean, stats->sampleStdev);
     571                 stats->sampleMedian, stats->sampleStdev);
    522572
    523573        // set mask if pts are not valid
     
    526576        for (int i = 0; i < zResid->n; i++) {
    527577            if (mask->data.U8[i]) continue;
    528             if (fabs(zResid->data.F64[i] - stats->sampleMean) > 3*stats->sampleStdev) {
    529                 mask->data.U8[i] &= 0x01;
     578            if (fabs(zResid->data.F64[i] - stats->sampleMedian) > 3*stats->sampleStdev) {
     579                mask->data.U8[i] |= 0x01;
    530580                continue;
    531581            }       
    532         }
     582            Nkeep ++;
     583        }
     584
     585        psTrace (".psphot.RobustFit", 4, "keeping %d of %d pts for fit\n",
     586                 Nkeep, x->n);
     587
     588//      psTrace (".psphot.RobustFit", 4, "model pars: %f %f %f %f\n",
     589//               poly->coeff[0][0], poly->coeff[1][0],
     590//               poly->coeff[0][1], poly->coeff[1][1]);
     591
     592        psTrace (".psphot.RobustFit", 4, "model pars: %f\n", poly->coeff[0][0]);
     593
    533594        psFree (zFit);
    534595    }
Note: See TracChangeset for help on using the changeset viewer.