Changeset 4116 for trunk/psphot/src/psPolynomials.c
- Timestamp:
- Jun 5, 2005, 8:41:28 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psPolynomials.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psPolynomials.c
r4115 r4116 453 453 const psVector* dz) 454 454 { 455 PS_VECTOR_CHECK_NULL(mask, NULL); 456 PS_VECTOR_CHECK_NULL(x, NULL); 457 PS_VECTOR_CHECK_NULL(y, NULL); 458 PS_VECTOR_CHECK_NULL(z, NULL); 459 PS_VECTOR_CHECK_NULL(dz, NULL); 460 455 461 psVector *zFit = NULL; 456 psVector *zResid = NULL;457 psStats *stats = NULL;462 psVector *zResid = psVectorAlloc (x->n, PS_TYPE_F64); 463 psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV); 458 464 459 465 for (int N = 0; N < 3; N++) { 460 466 poly = VectorFitPolynomial2DOrd_EAM (poly, mask, x, y, z, dz); 461 467 zFit = Polynomial2DEvalVectorD (poly, x, y); 462 zResid = (psVector *) psBinaryOp (NULL, (void *) z, "-", (void *) zFit); 463 464 stats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV); 468 zResid = (psVector *) psBinaryOp (zResid, (void *) z, "-", (void *) zFit); 469 465 470 stats = psVectorStats (stats, zResid, NULL, mask, 1); 466 psTrace (".psphot.RobustFit", 4, "residual stats for robust fit: %g +/- %g (%d pts)\n",467 stats-> clippedMean, stats->clippedStdev, stats->clippedNvalues);471 psTrace (".psphot.RobustFit", 4, "residual stats for robust fit: %g +/- %g\n", 472 stats->sampleMean, stats->sampleStdev); 468 473 469 474 // set mask if pts are not valid 470 int n = 0; 475 // we are masking out any point which is out of range 476 // recovery is not allowed with this scheme 471 477 for (int i = 0; i < zResid->n; i++) { 472 if (fabs(zResid->data.F64[i] - stats->clippedMean) > 3*stats->clippedStdev) { 473 mask->data.U8[i] = 1; 474 continue; 475 } else { 476 mask->data.U8[i] = 0; 477 } 478 n++; 479 } 480 } 478 if (mask->data.U8[i]) continue; 479 if (fabs(zResid->data.F64[i] - stats->sampleMean) > 3*stats->sampleStdev) { 480 mask->data.U8[i] = 1; 481 continue; 482 } 483 } 484 psFree (zFit); 485 } 486 psFree (zResid); 487 psFree (stats); 481 488 return (poly); 482 489 }
Note:
See TracChangeset
for help on using the changeset viewer.
