IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 24, 2016, 5:07:24 PM (10 years ago)
Author:
eugene
Message:

modify irls fitting to apply the multiply the modified weight by the error-based weight

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.astro/fitplx_irls.c

    r39596 r39610  
    119119                         fitdata.t, fitdata.pX, fitdata.pY,
    120120                         fitdata.Wx, fitdata.Wy,
     121                         fitdata.Qx, fitdata.Qy,
     122                         fitdata.qx, fitdata.qy,
    121123                         fitdata.Npts, max_iterations, outlier_limit, binning_step, VERBOSE)) {
    122124    return FALSE;
     
    204206    }
    205207
    206     // now calculate median and sigma for each vector
    207     VectorRobustStats (pvec,  &fit.p,  &fit.dp);
    208     VectorRobustStats (uRvec, &fit.uR, &fit.duR);
    209     VectorRobustStats (uDvec, &fit.uD, &fit.duD);
    210     VectorRobustStats (Rvec,  &fit.Ro, &fit.dRo);
    211     VectorRobustStats (Dvec,  &fit.Do, &fit.dDo);
     208    // now calculate robust sigma for each vector
     209    VectorRobustStats (pvec,  NULL, &fit.dp);
     210    VectorRobustStats (uRvec, NULL, &fit.duR);
     211    VectorRobustStats (uDvec, NULL, &fit.duD);
     212    VectorRobustStats (Rvec,  NULL, &fit.dRo);
     213    VectorRobustStats (Dvec,  NULL, &fit.dDo);
     214
     215    PlxFitDataFree (&sample);   
    212216  }
    213217
     
    250254  set_variable ("Nfit",  fit.Nfit);
    251255
    252 
     256  PlxFitDataFree (&fitdata);
    253257 
    254258  return (TRUE);
     
    257261/* do we want an init function which does the alloc and a clear function to free? */
    258262int FitPMandPar_IRLS (PlxFit *fit, double *X, double *dX, double *Y, double *dY, double *T, double *pR, double *pD,
    259                       double *Wx, double *Wy,
     263                      double *Wx, double *Wy, double *Qx, double *Qy, double *qx, double *qy,
    260264                      int Npts, int max_iterations, double outlier_limit, double binning_step, int VERBOSE) {
    261265
     
    270274
    271275  double sigma_ols, sigma_hat; // Sigma estimates.
    272   //  double *Wx, *Wy;             // Weight vectors.  Not errors.
    273276  double *rx, *ry;             // Deviation from model
    274277  double *u;                   // Deviation magnitude
     
    305308  // Convert the measurement errors into the initial weights.
    306309  for (i = 0; i < Npts; i++) {
    307     Wx[i] = (fabs(dX[i]) < 0.0001) ? 1.0 : 1.0 / SQ(dX[i]);
    308     Wy[i] = (fabs(dY[i]) < 0.0001) ? 1.0 : 1.0 / SQ(dY[i]);
     310    Qx[i] = (fabs(dX[i]) < 0.0001) ? 1.0 : 1.0 / SQ(dX[i]);
     311    Qy[i] = (fabs(dY[i]) < 0.0001) ? 1.0 : 1.0 / SQ(dY[i]);
    309312  }
    310313 
     
    313316  // Solve OLS equation
    314317  if (binning_step == 0.0) {
    315     if (!weighted_LS_PLX(T,pR,pD,X,Wx,Y,Wy,Npts,
    316                          A,B,VERBOSE)) {
     318    if (!weighted_LS_PLX(T,pR,pD,X,Qx,Y,Qy,Npts,A,B,VERBOSE)) {
    317319      // Handle fail case
    318320      return(FALSE);
     
    329331    double *WYbin = NULL;
    330332
    331     if (!bin_points_PLX(T, pR, pD, X, Wx, Y, Wy, Npts,
     333    if (!bin_points_PLX(T, pR, pD, X, Qx, Y, Qy, Npts,
    332334                        &Tbin, &pRbin, &pDbin, &Xbin, &WXbin, &Ybin, &WYbin, &Nbins,  binning_step) ) {
    333335      return(FALSE);
     
    396398      Wx[i] = weight_cauchy(rx[i] / dX[i]);
    397399      Wy[i] = weight_cauchy(ry[i] / dY[i]);
     400      qx[i] = Qx[i] * Wx[i];
     401      qy[i] = Qy[i] * Wy[i];
    398402    }
    399403
    400404    // Solve
    401     if (!weighted_LS_PLX(T,pR,pD,X,Wx,Y,Wy,Npts,A,B,VERBOSE)) {
     405    if (!weighted_LS_PLX(T,pR,pD,X,qx,Y,qy,Npts,A,B,VERBOSE)) {
    402406      // Handle fail case
    403407      return(FALSE);
Note: See TracChangeset for help on using the changeset viewer.