IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 6, 2016, 9:44:08 AM (10 years ago)
Author:
eugene
Message:

split galaxy motion model option into two options: galaxy motion model + apply proper motion; remove deprecated chunk of code; add options to skip HSC, CFH, PS1_CHIP, or PS1_STACK images (leaving them static); calculate the error based on the ordinary least squares and regular poisson weights (when doing bootstrap error analysis, choose the MAX); calculate dXpixSys,dYpixSys in arcsec based on plate scale; add option to avoid changing measurements for specific cameras; StarMap tests are now done in real arcsec using plate scales; option to fit the chips without modifying the mean objects; remove excessively verbose memory checks; add tests for HSC and CFH photcodes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20160809/Ohana/src/relastro/src/FitPMandPar.c

    r39612 r39731  
    2525  }
    2626
     27  fit->useWeight = FALSE; // Ordinary Least Squares
    2728  if (!FitPMandPar_MinChisq (fit, data, points, Npoints)) return FALSE;
    2829  if (!FitPMandPar_SetChisq (fit, data, points, Npoints)) return FALSE;
     
    4748 
    4849  // Solve OLS equation: failure here means the chisq matrix is degenerate, give up entirely
     50  fit->useWeight = FALSE; // Ordinary Least Squares
    4951  if (!FitPMandPar_MinChisq(fit, data, points, Npoints)) {
    5052    return(FALSE);
     
    9092
    9193    // Solve with the new weights
     94    fit->useWeight = TRUE; // Reweighted Least Squares
    9295    if (!FitPMandPar_MinChisq(fit, data, points, Npoints)) {
    9396
     
    157160  }
    158161
    159   // this section calculates the formal error on the weighted fit using the covariance values
    160   // NOTE EAM: in tests (fitpm.c), they seem to be too large by a factor of ~5.37
     162  // this section calculates the formal error on the regular (unweighted) fit using the covariance values
     163  // NOTE 20160929 : use only the unmasked points to calculate the error
    161164  if (data->getError) {
    162     double ax = 0.0, ay = 0.0;
    163     double bx = 0.0, by = 0.0;
    164 
    165     for (i = 0; i < Npoints; i++) {
    166       ax += dpsi_cauchy(points[i].rx / points[i].dX);
    167       ay += dpsi_cauchy(points[i].ry / points[i].dY);
    168 
    169       bx += SQ(points[i].Wx);
    170       by += SQ(points[i].Wy);
    171     }
    172     ax /= 1.0 * Npoints;  // mean(psi_dot(r))
    173     ay /= 1.0 * Npoints;
    174     bx /= 1.0 * (Npoints - data->Nterms); // mean(psi^2(r)) * (N / (N-p))
    175     by /= 1.0 * (Npoints - data->Nterms);
    176  
    177     double lambda_x = 1.0 + (data->Nterms / Npoints) * (1 - ax) / ax;
    178     double lambda_y = 1.0 + (data->Nterms / Npoints) * (1 - ay) / ay;
    179  
    180     double sigma_robust_x = lambda_x * sqrt(bx) * sigma_hat * 2.385 / ax;
    181     double sigma_robust_y = lambda_y * sqrt(by) * sigma_hat * 2.385 / ay;
    182 
    183     // This is actually sigma^2, as that's the factor in the covariance (dumouchel 4.1)
    184     double sigma_final_x  = MAX(SQ(sigma_robust_x), (2 * Npoints * SQ(sigma_robust_x) + SQ(data->Nterms * sigma_ols)) / (2 * Npoints + SQ(data->Nterms)));
    185     double sigma_final_y  = MAX(SQ(sigma_robust_y), (2 * Npoints * SQ(sigma_robust_y) + SQ(data->Nterms * sigma_ols)) / (2 * Npoints + SQ(data->Nterms)));
    186 
    187     fit[0].dRo = sqrt(data->Cov[0][0]);
    188     fit[0].duR = sqrt(data->Cov[1][1]);
    189     fit[0].dDo = sqrt(data->Cov[2][2]);
    190     fit[0].duD = sqrt(data->Cov[3][3]);
    191     fit[0].dp  = sqrt(data->Cov[4][4]);
    192 
    193     fit[0].dRo *= sigma_final_x;
    194     fit[0].duR *= sigma_final_x;
    195     fit[0].dDo *= sigma_final_y;
    196     fit[0].duD *= sigma_final_y;
    197     fit[0].dp  *= sqrt(sigma_final_x * sigma_final_y);
     165    FitAstromResult fitErrors;
     166    FitAstromResultInit (&fitErrors);
     167    fitErrors.useWeight = FALSE;
     168
     169    FitPMandPar_MinChisq(&fitErrors, data, points, Npoints);
     170
     171    // we use the errors from a simple OLS, ignoring masked points
     172    fit[0].dRo = fitErrors.dRo;
     173    fit[0].duR = fitErrors.duR;
     174    fit[0].dDo = fitErrors.dDo;
     175    fit[0].duD = fitErrors.duD;
     176    fit[0].dp  = fitErrors.dp;
    198177  }
    199178
     
    219198    Nfit ++;
    220199
    221     wx = points[i].qx;
    222     wy = points[i].qy;
     200    if (fit->useWeight) {
     201      wx = points[i].qx;
     202      wy = points[i].qy;
     203    } else {
     204      wx = points[i].Qx;
     205      wy = points[i].Qy;
     206    }
    223207
    224208    Wx += wx;
Note: See TracChangeset for help on using the changeset viewer.