- Timestamp:
- Apr 25, 2018, 10:29:37 AM (8 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/cmd.astro/fitplx_irls.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.astro/fitplx_irls.c
r40291 r40406 12 12 if ((mvec = SelectVector (argv[N], ANYVECTOR, TRUE)) == NULL) return (FALSE); 13 13 remove_argument (N, &argc, argv); 14 CastVector (mvec, OPIHI_INT);15 14 } 16 15 … … 81 80 double *dD = dDvec->elements.Flt; 82 81 83 opihi_int *mask = NULL;84 if (mvec) {85 mask = mvec->elements.Int;86 }87 88 82 // Ntotal : all points supplied by user 89 83 // Nsubset : unmasked points 90 84 int Ntotal = tvec->Nelements; // XXX check other lengths 91 85 86 if (rvec->Nelements != Ntotal) ESCAPE ("mis-match in vector lengths (mjd vs ra) = (%d vs %d)\n", rvec->Nelements, Ntotal); 87 if (dvec->Nelements != Ntotal) ESCAPE ("mis-match in vector lengths (mjd vs dec) = (%d vs %d)\n", dvec->Nelements, Ntotal); 88 if (dRvec->Nelements != Ntotal) ESCAPE ("mis-match in vector lengths (mjd vs dR) = (%d vs %d)\n", dRvec->Nelements, Ntotal); 89 if (dDvec->Nelements != Ntotal) ESCAPE ("mis-match in vector lengths (mjd vs dD) = (%d vs %d)\n", dDvec->Nelements, Ntotal); 90 91 opihi_int *mask = NULL; 92 if (mvec) { 93 ResetVector (mvec, OPIHI_INT, Ntotal); 94 mask = mvec->elements.Int; 95 for (i = 0; i < Ntotal; i++) { mask[i] = 1; } 96 } 97 98 92 99 double Rmean, Dmean, Tmean; 93 100 PlxSetMeanEpoch (R, D, T, &Rmean, &Dmean, &Tmean, mask, Ntotal); … … 135 142 136 143 // update the mask based on the input mask and the outlier limits. 137 double Sum_Wx = 0; 138 double Sum_Wy = 0; 139 mask = mvec->elements.Int; 140 for (i = 0; i < fitdata.Npts; i++) { 141 Sum_Wx += fitdata.Wx[i]; 142 Sum_Wy += fitdata.Wy[i]; 143 } 144 for (i = 0; i < fitdata.Npts; i++) { 145 // fitdata only includes the previously unmasked points 146 if ((fitdata.Wx[i] < outlier_limit * Sum_Wx / (1.0 * fitdata.Npts))|| 147 (fitdata.Wy[i] < outlier_limit * Sum_Wy / (1.0 * fitdata.Npts))) { 148 int n = fitdata.index[i]; 149 mask[n] = 0; 144 if (mask) { 145 double Sum_Wx = 0; 146 double Sum_Wy = 0; 147 148 // calculate the total weight 149 for (i = 0; i < fitdata.Npts; i++) { 150 Sum_Wx += fitdata.Wx[i]; 151 Sum_Wy += fitdata.Wy[i]; 152 } 153 for (i = 0; i < fitdata.Npts; i++) { 154 // fitdata only includes the previously unmasked points 155 if ((fitdata.Wx[i] < outlier_limit * Sum_Wx / (1.0 * fitdata.Npts))|| 156 (fitdata.Wy[i] < outlier_limit * Sum_Wy / (1.0 * fitdata.Npts))) { 157 int n = fitdata.index[i]; 158 mask[n] = 0; 150 159 151 if (VERBOSE == 2) {160 if (VERBOSE == 2) { 152 161 fprintf (stderr, "%f %f : %f "OPIHI_INT_FMT" : %f %f %f : %f %f %f %f\n", R[n], D[n], T[n], mask[n], fitdata.t[i], fitdata.X[i], fitdata.Y[i], fitdata.Wx[i], fitdata.Wy[i], Sum_Wx, Sum_Wy); 153 } 154 } 155 } 156 157 if (Nresample){ 158 // now that the mask has been updated, we need to recalculate mean epoch and positions 159 // XXX make this conditional on actually masking unmasked points above 160 // PlxSetMeanEpoch (R, D, T, &Rmean, &Dmean, &Tmean, mask, Ntotal); 161 // PlxSetEpochPosition (&fitdata, R, D, dR, dD, T, mask, Ntotal, &coords, Tmean); 162 } 163 } 164 } 165 } 166 167 if (Nresample) { 168 // if the mask has been updated, we need to recalculate mean epoch and positions 169 if (mask) { 170 PlxSetMeanEpoch (R, D, T, &Rmean, &Dmean, &Tmean, mask, Ntotal); 171 PlxSetEpochPosition (&fitdata, R, D, dR, dD, T, mask, Ntotal, &coords, Tmean); 172 } 162 173 163 174 PlxFitData sample; … … 218 229 // fprintf (stderr, "%f +/- %f | %f %f\n", fit.p, fit.dp, fit.uR, fit.uD); 219 230 220 Vector *dRresP MP, *dDresPMP, *dRresPLX, *dDresPLX;231 Vector *dRresPOS, *dDresPOS, *dRresPMP, *dDresPMP, *dRresPLX, *dDresPLX; 221 232 222 233 // save fit residuals (with only pm removed, and pm and plx removed) 234 if ((dRresPOS = SelectVector ("dRresPOS", ANYVECTOR, TRUE)) == NULL) ESCAPE ("cannot generate vector %s\n", "dRresPOS"); 235 if ((dDresPOS = SelectVector ("dDresPOS", ANYVECTOR, TRUE)) == NULL) ESCAPE ("cannot generate vector %s\n", "dDresPOS"); 223 236 if ((dRresPMP = SelectVector ("dRresPMP", ANYVECTOR, TRUE)) == NULL) ESCAPE ("cannot generate vector %s\n", "dRresPMP"); 224 237 if ((dDresPMP = SelectVector ("dDresPMP", ANYVECTOR, TRUE)) == NULL) ESCAPE ("cannot generate vector %s\n", "dDresPMP"); … … 226 239 if ((dDresPLX = SelectVector ("dDresPLX", ANYVECTOR, TRUE)) == NULL) ESCAPE ("cannot generate vector %s\n", "dDresPLX"); 227 240 241 ResetVector (dRresPOS, OPIHI_FLT, Ntotal); 242 ResetVector (dDresPOS, OPIHI_FLT, Ntotal); 228 243 ResetVector (dRresPMP, OPIHI_FLT, Ntotal); 229 244 ResetVector (dDresPMP, OPIHI_FLT, Ntotal); … … 246 261 double Yplx = fit.Do + fit.uD*t0; 247 262 263 dRresPOS->elements.Flt[i] = x0; 264 dDresPOS->elements.Flt[i] = y0; 248 265 dRresPMP->elements.Flt[i] = x0 - Xpmp; 249 266 dDresPMP->elements.Flt[i] = y0 - Ypmp;
Note:
See TracChangeset
for help on using the changeset viewer.
