1 | // Part of BNC, a utility for retrieving decoding and
|
---|
2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
3 | //
|
---|
4 | // Copyright (C) 2007
|
---|
5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
6 | // http://www.bkg.bund.de
|
---|
7 | // Czech Technical University Prague, Department of Geodesy
|
---|
8 | // http://www.fsv.cvut.cz
|
---|
9 | //
|
---|
10 | // Email: euref-ip@bkg.bund.de
|
---|
11 | //
|
---|
12 | // This program is free software; you can redistribute it and/or
|
---|
13 | // modify it under the terms of the GNU General Public License
|
---|
14 | // as published by the Free Software Foundation, version 2.
|
---|
15 | //
|
---|
16 | // This program is distributed in the hope that it will be useful,
|
---|
17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
19 | // GNU General Public License for more details.
|
---|
20 | //
|
---|
21 | // You should have received a copy of the GNU General Public License
|
---|
22 | // along with this program; if not, write to the Free Software
|
---|
23 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
24 |
|
---|
25 | /* -------------------------------------------------------------------------
|
---|
26 | * BKG NTRIP Client
|
---|
27 | * -------------------------------------------------------------------------
|
---|
28 | *
|
---|
29 | * Class: t_pppParam, t_pppFilter
|
---|
30 | *
|
---|
31 | * Purpose: Model for PPP
|
---|
32 | *
|
---|
33 | * Author: L. Mervart
|
---|
34 | *
|
---|
35 | * Created: 01-Dec-2009
|
---|
36 | *
|
---|
37 | * Changes:
|
---|
38 | *
|
---|
39 | * -----------------------------------------------------------------------*/
|
---|
40 |
|
---|
41 | #include <iomanip>
|
---|
42 | #include <cmath>
|
---|
43 | #include <sstream>
|
---|
44 | #include <newmatio.h>
|
---|
45 | #include <newmatap.h>
|
---|
46 |
|
---|
47 | #include "pppFilter.h"
|
---|
48 | #include "pppClient.h"
|
---|
49 | #include "bncutils.h"
|
---|
50 | #include "bncantex.h"
|
---|
51 | #include "pppOptions.h"
|
---|
52 | #include "pppModel.h"
|
---|
53 |
|
---|
54 | using namespace BNC_PPP;
|
---|
55 | using namespace std;
|
---|
56 |
|
---|
57 | const double GLONASS_WEIGHT_FACTOR = 5.0;
|
---|
58 | const double BDS_WEIGHT_FACTOR = 2.0; // 5.0;
|
---|
59 |
|
---|
60 | #define LOG (_pppClient->log())
|
---|
61 | #define OPT (_pppClient->opt())
|
---|
62 |
|
---|
63 | // Constructor
|
---|
64 | ////////////////////////////////////////////////////////////////////////////
|
---|
65 | t_pppParam::t_pppParam(t_pppParam::parType typeIn, int indexIn,
|
---|
66 | const QString& prnIn) {
|
---|
67 | type = typeIn;
|
---|
68 | index = indexIn;
|
---|
69 | prn = prnIn;
|
---|
70 | index_old = 0;
|
---|
71 | xx = 0.0;
|
---|
72 | numEpo = 0;
|
---|
73 | }
|
---|
74 |
|
---|
75 | // Destructor
|
---|
76 | ////////////////////////////////////////////////////////////////////////////
|
---|
77 | t_pppParam::~t_pppParam() {
|
---|
78 | }
|
---|
79 |
|
---|
80 | // Partial
|
---|
81 | ////////////////////////////////////////////////////////////////////////////
|
---|
82 | double t_pppParam::partial(t_satData* satData, bool phase) {
|
---|
83 |
|
---|
84 | Tracer tracer("t_pppParam::partial");
|
---|
85 |
|
---|
86 | // Coordinates
|
---|
87 | // -----------
|
---|
88 | if (type == CRD_X) {
|
---|
89 | return (xx - satData->xx(1)) / satData->rho;
|
---|
90 | }
|
---|
91 | else if (type == CRD_Y) {
|
---|
92 | return (xx - satData->xx(2)) / satData->rho;
|
---|
93 | }
|
---|
94 | else if (type == CRD_Z) {
|
---|
95 | return (xx - satData->xx(3)) / satData->rho;
|
---|
96 | }
|
---|
97 |
|
---|
98 | // Receiver Clocks
|
---|
99 | // ---------------
|
---|
100 | else if (type == RECCLK) {
|
---|
101 | return 1.0;
|
---|
102 | }
|
---|
103 |
|
---|
104 | // Troposphere
|
---|
105 | // -----------
|
---|
106 | else if (type == TROPO) {
|
---|
107 | return 1.0 / sin(satData->eleSat);
|
---|
108 | }
|
---|
109 |
|
---|
110 | // Glonass Offset
|
---|
111 | // --------------
|
---|
112 | else if (type == GLONASS_OFFSET) {
|
---|
113 | if (satData->prn[0] == 'R') {
|
---|
114 | return 1.0;
|
---|
115 | }
|
---|
116 | else {
|
---|
117 | return 0.0;
|
---|
118 | }
|
---|
119 | }
|
---|
120 |
|
---|
121 | // Galileo Offset
|
---|
122 | // --------------
|
---|
123 | else if (type == GALILEO_OFFSET) {
|
---|
124 | if (satData->prn[0] == 'E') {
|
---|
125 | return 1.0;
|
---|
126 | }
|
---|
127 | else {
|
---|
128 | return 0.0;
|
---|
129 | }
|
---|
130 | }
|
---|
131 |
|
---|
132 | // BDS Offset
|
---|
133 | // ----------
|
---|
134 | else if (type == BDS_OFFSET) {
|
---|
135 | if (satData->prn[0] == 'C') {
|
---|
136 | return 1.0;
|
---|
137 | }
|
---|
138 | else {
|
---|
139 | return 0.0;
|
---|
140 | }
|
---|
141 | }
|
---|
142 |
|
---|
143 | // Ambiguities
|
---|
144 | // -----------
|
---|
145 | else if (type == AMB_L3) {
|
---|
146 | if (phase && satData->prn == prn) {
|
---|
147 | return 1.0;
|
---|
148 | }
|
---|
149 | else {
|
---|
150 | return 0.0;
|
---|
151 | }
|
---|
152 | }
|
---|
153 |
|
---|
154 | // Default return
|
---|
155 | // --------------
|
---|
156 | return 0.0;
|
---|
157 | }
|
---|
158 |
|
---|
159 | // Constructor
|
---|
160 | ////////////////////////////////////////////////////////////////////////////
|
---|
161 | t_pppFilter::t_pppFilter(t_pppClient* pppClient) {
|
---|
162 |
|
---|
163 | _pppClient = pppClient;
|
---|
164 | _tides = new t_tides();
|
---|
165 |
|
---|
166 | // Antenna Name, ANTEX File
|
---|
167 | // ------------------------
|
---|
168 | _antex = 0;
|
---|
169 | if (!OPT->_antexFileName.empty()) {
|
---|
170 | _antex = new bncAntex(OPT->_antexFileName.c_str());
|
---|
171 | }
|
---|
172 |
|
---|
173 | // Bancroft Coordinates
|
---|
174 | // --------------------
|
---|
175 | _xcBanc.ReSize(4); _xcBanc = 0.0;
|
---|
176 | _ellBanc.ReSize(3); _ellBanc = 0.0;
|
---|
177 |
|
---|
178 | // Save copy of data (used in outlier detection)
|
---|
179 | // ---------------------------------------------
|
---|
180 | _epoData_sav = new t_epoData();
|
---|
181 |
|
---|
182 | // Some statistics
|
---|
183 | // ---------------
|
---|
184 | _neu.ReSize(3); _neu = 0.0;
|
---|
185 | _numSat = 0;
|
---|
186 | _hDop = 0.0;
|
---|
187 | }
|
---|
188 |
|
---|
189 | // Destructor
|
---|
190 | ////////////////////////////////////////////////////////////////////////////
|
---|
191 | t_pppFilter::~t_pppFilter() {
|
---|
192 | delete _tides;
|
---|
193 | delete _antex;
|
---|
194 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
195 | delete _params[iPar-1];
|
---|
196 | }
|
---|
197 | for (int iPar = 1; iPar <= _params_sav.size(); iPar++) {
|
---|
198 | delete _params_sav[iPar-1];
|
---|
199 | }
|
---|
200 | delete _epoData_sav;
|
---|
201 | }
|
---|
202 |
|
---|
203 | // Reset Parameters and Variance-Covariance Matrix
|
---|
204 | ////////////////////////////////////////////////////////////////////////////
|
---|
205 | void t_pppFilter::reset() {
|
---|
206 |
|
---|
207 | Tracer tracer("t_pppFilter::reset");
|
---|
208 |
|
---|
209 | double lastTrp = 0.0;
|
---|
210 | for (int ii = 0; ii < _params.size(); ii++) {
|
---|
211 | t_pppParam* pp = _params[ii];
|
---|
212 | if (pp->type == t_pppParam::TROPO) {
|
---|
213 | lastTrp = pp->xx;
|
---|
214 | }
|
---|
215 | delete pp;
|
---|
216 | }
|
---|
217 | _params.clear();
|
---|
218 |
|
---|
219 | int nextPar = 0;
|
---|
220 | _params.push_back(new t_pppParam(t_pppParam::CRD_X, ++nextPar, ""));
|
---|
221 | _params.push_back(new t_pppParam(t_pppParam::CRD_Y, ++nextPar, ""));
|
---|
222 | _params.push_back(new t_pppParam(t_pppParam::CRD_Z, ++nextPar, ""));
|
---|
223 | _params.push_back(new t_pppParam(t_pppParam::RECCLK, ++nextPar, ""));
|
---|
224 | if (OPT->estTrp()) {
|
---|
225 | _params.push_back(new t_pppParam(t_pppParam::TROPO, ++nextPar, ""));
|
---|
226 | }
|
---|
227 | if (OPT->useSystem('R')) {
|
---|
228 | _params.push_back(new t_pppParam(t_pppParam::GLONASS_OFFSET, ++nextPar, ""));
|
---|
229 | }
|
---|
230 | if (OPT->useSystem('E')) {
|
---|
231 | _params.push_back(new t_pppParam(t_pppParam::GALILEO_OFFSET, ++nextPar, ""));
|
---|
232 | }
|
---|
233 | if (OPT->useSystem('C')) {
|
---|
234 | _params.push_back(new t_pppParam(t_pppParam::BDS_OFFSET, ++nextPar, ""));
|
---|
235 | }
|
---|
236 |
|
---|
237 | _QQ.ReSize(_params.size());
|
---|
238 | _QQ = 0.0;
|
---|
239 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
240 | t_pppParam* pp = _params[iPar-1];
|
---|
241 | pp->xx = 0.0;
|
---|
242 | if (pp->isCrd()) {
|
---|
243 | _QQ(iPar,iPar) = OPT->_aprSigCrd(1) * OPT->_aprSigCrd(1);
|
---|
244 | }
|
---|
245 | else if (pp->type == t_pppParam::RECCLK) {
|
---|
246 | _QQ(iPar,iPar) = OPT->_noiseClk * OPT->_noiseClk;
|
---|
247 | }
|
---|
248 | else if (pp->type == t_pppParam::TROPO) {
|
---|
249 | _QQ(iPar,iPar) = OPT->_aprSigTrp * OPT->_aprSigTrp;
|
---|
250 | pp->xx = lastTrp;
|
---|
251 | }
|
---|
252 | else if (pp->type == t_pppParam::GLONASS_OFFSET) {
|
---|
253 | _QQ(iPar,iPar) = 1000.0 * 1000.0;
|
---|
254 | }
|
---|
255 | else if (pp->type == t_pppParam::GALILEO_OFFSET) {
|
---|
256 | _QQ(iPar,iPar) = 1000.0 * 1000.0;
|
---|
257 | }
|
---|
258 | else if (pp->type == t_pppParam::BDS_OFFSET) {
|
---|
259 | _QQ(iPar,iPar) = 1000.0 * 1000.0;
|
---|
260 | }
|
---|
261 | }
|
---|
262 | }
|
---|
263 |
|
---|
264 | // Bancroft Solution
|
---|
265 | ////////////////////////////////////////////////////////////////////////////
|
---|
266 | t_irc t_pppFilter::cmpBancroft(t_epoData* epoData) {
|
---|
267 |
|
---|
268 | Tracer tracer("t_pppFilter::cmpBancroft");
|
---|
269 |
|
---|
270 | if (int(epoData->sizeSys('G')) < OPT->_minObs) {
|
---|
271 | LOG << "t_pppFilter::cmpBancroft: not enough data\n";
|
---|
272 | return failure;
|
---|
273 | }
|
---|
274 |
|
---|
275 | Matrix BB(epoData->sizeSys('G'), 4);
|
---|
276 |
|
---|
277 | QMapIterator<QString, t_satData*> it(epoData->satData);
|
---|
278 | int iObsBanc = 0;
|
---|
279 | while (it.hasNext()) {
|
---|
280 | it.next();
|
---|
281 | t_satData* satData = it.value();
|
---|
282 | if (satData->system() == 'G') {
|
---|
283 | ++iObsBanc;
|
---|
284 | QString prn = it.key();
|
---|
285 | BB(iObsBanc, 1) = satData->xx(1);
|
---|
286 | BB(iObsBanc, 2) = satData->xx(2);
|
---|
287 | BB(iObsBanc, 3) = satData->xx(3);
|
---|
288 | BB(iObsBanc, 4) = satData->P3 + satData->clk;
|
---|
289 | }
|
---|
290 | }
|
---|
291 |
|
---|
292 | bancroft(BB, _xcBanc);
|
---|
293 |
|
---|
294 | if (std::isnan(_xcBanc(1)) ||
|
---|
295 | std::isnan(_xcBanc(2)) ||
|
---|
296 | std::isnan(_xcBanc(3))) {
|
---|
297 | return failure;
|
---|
298 | }
|
---|
299 |
|
---|
300 | // Ellipsoidal Coordinates
|
---|
301 | // ------------------------
|
---|
302 | xyz2ell(_xcBanc.data(), _ellBanc.data());
|
---|
303 |
|
---|
304 | // Compute Satellite Elevations
|
---|
305 | // ----------------------------
|
---|
306 | QMutableMapIterator<QString, t_satData*> im(epoData->satData);
|
---|
307 | while (im.hasNext()) {
|
---|
308 | im.next();
|
---|
309 | t_satData* satData = im.value();
|
---|
310 | cmpEle(satData);
|
---|
311 | if (satData->eleSat < OPT->_minEle) {
|
---|
312 | delete satData;
|
---|
313 | im.remove();
|
---|
314 | }
|
---|
315 | }
|
---|
316 |
|
---|
317 | return success;
|
---|
318 | }
|
---|
319 |
|
---|
320 | // Computed Value
|
---|
321 | ////////////////////////////////////////////////////////////////////////////
|
---|
322 | double t_pppFilter::cmpValue(t_satData* satData, bool phase) {
|
---|
323 |
|
---|
324 | Tracer tracer("t_pppFilter::cmpValue");
|
---|
325 |
|
---|
326 | ColumnVector xRec(3);
|
---|
327 | xRec(1) = x();
|
---|
328 | xRec(2) = y();
|
---|
329 | xRec(3) = z();
|
---|
330 |
|
---|
331 | double rho0 = (satData->xx - xRec).norm_Frobenius();
|
---|
332 | double dPhi = t_CST::omega * rho0 / t_CST::c;
|
---|
333 |
|
---|
334 | xRec(1) = x() * cos(dPhi) - y() * sin(dPhi);
|
---|
335 | xRec(2) = y() * cos(dPhi) + x() * sin(dPhi);
|
---|
336 | xRec(3) = z();
|
---|
337 |
|
---|
338 | xRec += _tides->displacement(_time, xRec);
|
---|
339 |
|
---|
340 | satData->rho = (satData->xx - xRec).norm_Frobenius();
|
---|
341 |
|
---|
342 | double tropDelay = delay_saast(satData->eleSat) +
|
---|
343 | trp() / sin(satData->eleSat);
|
---|
344 |
|
---|
345 | double wind = 0.0;
|
---|
346 | if (phase) {
|
---|
347 | wind = windUp(satData->prn, satData->xx, xRec) * satData->lambda3;
|
---|
348 | }
|
---|
349 |
|
---|
350 | double offset = 0.0;
|
---|
351 |
|
---|
352 | t_frequency::type frqA;
|
---|
353 | t_frequency::type frqB;
|
---|
354 |
|
---|
355 | if (satData->prn[0] == 'R') {
|
---|
356 | offset = Glonass_offset();
|
---|
357 | frqA = t_frequency::R1;
|
---|
358 | frqB = t_frequency::R2;
|
---|
359 | }
|
---|
360 | else if (satData->prn[0] == 'E') {
|
---|
361 | offset = Galileo_offset();
|
---|
362 | frqA = t_frequency::E1;
|
---|
363 | frqB = t_frequency::E5;
|
---|
364 | }
|
---|
365 | else if (satData->prn[0] == 'C') {
|
---|
366 | offset = Bds_offset();
|
---|
367 | frqA = t_frequency::C2;
|
---|
368 | frqB = t_frequency::C6;
|
---|
369 | }
|
---|
370 | else {
|
---|
371 | frqA = t_frequency::G1;
|
---|
372 | frqB = t_frequency::G2;
|
---|
373 | }
|
---|
374 |
|
---|
375 | double phaseCenter = 0.0;
|
---|
376 |
|
---|
377 | if (_antex) {
|
---|
378 |
|
---|
379 | // Satellite correction
|
---|
380 | // ---------------------
|
---|
381 | double elTx,azTx;
|
---|
382 |
|
---|
383 | // LOS unit vector satellite --> receiver
|
---|
384 | ColumnVector rho = xRec - satData->xx;
|
---|
385 | rho /= rho.norm_Frobenius();
|
---|
386 |
|
---|
387 | // Sun unit vector
|
---|
388 | ColumnVector xSun = t_astro::Sun(satData->tt.mjddec());
|
---|
389 | xSun /= xSun.norm_Frobenius();
|
---|
390 |
|
---|
391 | // Satellite unit vectors sz, sy, sx
|
---|
392 | ColumnVector sz = -satData->xx / satData->xx.norm_Frobenius();
|
---|
393 | ColumnVector sy = crossproduct(sz, xSun);
|
---|
394 | ColumnVector sx = crossproduct(sy, sz);
|
---|
395 |
|
---|
396 | sx /= sx.norm_Frobenius();
|
---|
397 | sy /= sy.norm_Frobenius();
|
---|
398 |
|
---|
399 | // LOS vector in satellite frame
|
---|
400 | ColumnVector u(3);
|
---|
401 | u(1) = dotproduct(sx, rho);
|
---|
402 | u(2) = dotproduct(sy, rho);
|
---|
403 | u(3) = dotproduct(sz, rho);
|
---|
404 |
|
---|
405 | // Azimuth and elevation in satellite antenna frame
|
---|
406 | elTx = atan2(u(3),sqrt(pow(u(2),2)+pow(u(1),2)));
|
---|
407 | azTx = atan2(u(2),u(1));
|
---|
408 |
|
---|
409 | bool found;
|
---|
410 | if (OPT->_isAPC) {
|
---|
411 | phaseCenter += satData->lkB * _antex->satCorr(satData->prn, frqA, elTx, azTx, found);
|
---|
412 | }
|
---|
413 | else {
|
---|
414 | phaseCenter += satData->lkA * _antex->satCorr(satData->prn, frqA, elTx, azTx, found);
|
---|
415 | }
|
---|
416 | if (!found) {
|
---|
417 | LOG << "ANTEX: antenna >" << satData->prn.mid(0,3).toStdString() << " " << frqA << "< not found\n";
|
---|
418 | }
|
---|
419 |
|
---|
420 | phaseCenter += satData->lkB * _antex->satCorr(satData->prn, frqB, elTx, azTx, found);
|
---|
421 | if (!found) {
|
---|
422 | LOG << "ANTEX: antenna >" << satData->prn.mid(0,3).toStdString() << " " << frqB << "< not found\n";
|
---|
423 | }
|
---|
424 |
|
---|
425 | /*
|
---|
426 | LOG << "ANTEX: " << satData->prn.mid(0,3).toStdString() << " "
|
---|
427 | << fixed
|
---|
428 | << setprecision(3)
|
---|
429 | << " xyz "
|
---|
430 | << setw(7) << u(1)
|
---|
431 | << setw(7) << u(2)
|
---|
432 | << setw(7) << u(3)
|
---|
433 | << setprecision(1)
|
---|
434 | << " elTx " << setw(5) << elTx * 180.0/M_PI
|
---|
435 | << " azTx " << setw(7) << azTx * 180.0/M_PI
|
---|
436 | << " elRx " << setw(5) << satData->eleSat * 180.0/M_PI
|
---|
437 | << setprecision(3)
|
---|
438 | << " pcc " << setw(6) << phaseCenter
|
---|
439 | << endl;
|
---|
440 | */
|
---|
441 |
|
---|
442 | // Receiver correction
|
---|
443 | // -------------------
|
---|
444 |
|
---|
445 | phaseCenter += satData->lkA * _antex->rcvCorr(OPT->_antNameRover, frqA,
|
---|
446 | satData->eleSat, satData->azSat, found);
|
---|
447 | if (!found) {
|
---|
448 | phaseCenter += satData->lkA * _antex->rcvCorr(OPT->_antNameRover, t_frequency::G1,
|
---|
449 | satData->eleSat, satData->azSat, found);
|
---|
450 | }
|
---|
451 | if (!found) {
|
---|
452 | LOG << "ANTEX: antenna >" << OPT->_antNameRover << " " << frqA << "< not found\n";
|
---|
453 | }
|
---|
454 |
|
---|
455 | phaseCenter += satData->lkB * _antex->rcvCorr(OPT->_antNameRover, frqB,
|
---|
456 | satData->eleSat, satData->azSat, found);
|
---|
457 | if (!found) {
|
---|
458 | phaseCenter += satData->lkB * _antex->rcvCorr(OPT->_antNameRover, t_frequency::G2,
|
---|
459 | satData->eleSat, satData->azSat, found);
|
---|
460 | }
|
---|
461 | if (!found) {
|
---|
462 | LOG << "ANTEX: antenna >" << OPT->_antNameRover << " " << frqB << "< not found\n";
|
---|
463 | }
|
---|
464 | }
|
---|
465 |
|
---|
466 | double antennaOffset = 0.0;
|
---|
467 | double cosa = cos(satData->azSat);
|
---|
468 | double sina = sin(satData->azSat);
|
---|
469 | double cose = cos(satData->eleSat);
|
---|
470 | double sine = sin(satData->eleSat);
|
---|
471 | antennaOffset = -OPT->_neuEccRover(1) * cosa*cose
|
---|
472 | -OPT->_neuEccRover(2) * sina*cose
|
---|
473 | -OPT->_neuEccRover(3) * sine;
|
---|
474 |
|
---|
475 | return satData->rho + phaseCenter + antennaOffset + clk()
|
---|
476 | + offset - satData->clk + tropDelay + wind;
|
---|
477 | }
|
---|
478 |
|
---|
479 | // Tropospheric Model (Saastamoinen)
|
---|
480 | ////////////////////////////////////////////////////////////////////////////
|
---|
481 | double t_pppFilter::delay_saast(double Ele) {
|
---|
482 |
|
---|
483 | Tracer tracer("t_pppFilter::delay_saast");
|
---|
484 |
|
---|
485 | double xyz[3];
|
---|
486 | xyz[0] = x();
|
---|
487 | xyz[1] = y();
|
---|
488 | xyz[2] = z();
|
---|
489 | double ell[3];
|
---|
490 | xyz2ell(xyz, ell);
|
---|
491 | double height = ell[2];
|
---|
492 | // Prevent pp from causing segmentation fault (Loukis)
|
---|
493 | if (height > 40000.0 ) {
|
---|
494 | return 0.000000001;
|
---|
495 | }
|
---|
496 |
|
---|
497 | double pp = 1013.25 * pow(1.0 - 2.26e-5 * height, 5.225);
|
---|
498 | double TT = 18.0 - height * 0.0065 + 273.15;
|
---|
499 | double hh = 50.0 * exp(-6.396e-4 * height);
|
---|
500 | double ee = hh / 100.0 * exp(-37.2465 + 0.213166*TT - 0.000256908*TT*TT);
|
---|
501 |
|
---|
502 | double h_km = height / 1000.0;
|
---|
503 |
|
---|
504 | if (h_km < 0.0) h_km = 0.0;
|
---|
505 | if (h_km > 5.0) h_km = 5.0;
|
---|
506 | int ii = int(h_km + 1);
|
---|
507 | double href = ii - 1;
|
---|
508 |
|
---|
509 | double bCor[6];
|
---|
510 | bCor[0] = 1.156;
|
---|
511 | bCor[1] = 1.006;
|
---|
512 | bCor[2] = 0.874;
|
---|
513 | bCor[3] = 0.757;
|
---|
514 | bCor[4] = 0.654;
|
---|
515 | bCor[5] = 0.563;
|
---|
516 |
|
---|
517 | double BB = bCor[ii-1] + (bCor[ii]-bCor[ii-1]) * (h_km - href);
|
---|
518 |
|
---|
519 | double zen = M_PI/2.0 - Ele;
|
---|
520 |
|
---|
521 | return (0.002277/cos(zen)) * (pp + ((1255.0/TT)+0.05)*ee - BB*(tan(zen)*tan(zen)));
|
---|
522 | }
|
---|
523 |
|
---|
524 | // Prediction Step of the Filter
|
---|
525 | ////////////////////////////////////////////////////////////////////////////
|
---|
526 | void t_pppFilter::predict(int iPhase, t_epoData* epoData) {
|
---|
527 |
|
---|
528 | Tracer tracer("t_pppFilter::predict");
|
---|
529 |
|
---|
530 | if (iPhase == 0) {
|
---|
531 |
|
---|
532 | const double maxSolGap = 60.0;
|
---|
533 |
|
---|
534 | bool firstCrd = false;
|
---|
535 | if (!_lastTimeOK.valid() || (maxSolGap > 0.0 && _time - _lastTimeOK > maxSolGap)) {
|
---|
536 | firstCrd = true;
|
---|
537 | _startTime = epoData->tt;
|
---|
538 | reset();
|
---|
539 | }
|
---|
540 |
|
---|
541 | // Use different white noise for Quick-Start mode
|
---|
542 | // ----------------------------------------------
|
---|
543 | double sigCrdP_used = OPT->_noiseCrd(1);
|
---|
544 | if ( OPT->_seedingTime > 0.0 && OPT->_seedingTime > (epoData->tt - _startTime) ) {
|
---|
545 | sigCrdP_used = 0.0;
|
---|
546 | }
|
---|
547 |
|
---|
548 | // Predict Parameter values, add white noise
|
---|
549 | // -----------------------------------------
|
---|
550 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
551 | t_pppParam* pp = _params[iPar-1];
|
---|
552 |
|
---|
553 | // Coordinates
|
---|
554 | // -----------
|
---|
555 | if (pp->type == t_pppParam::CRD_X) {
|
---|
556 | if (firstCrd) {
|
---|
557 | if (OPT->xyzAprRoverSet()) {
|
---|
558 | pp->xx = OPT->_xyzAprRover[0];
|
---|
559 | }
|
---|
560 | else {
|
---|
561 | pp->xx = _xcBanc(1);
|
---|
562 | }
|
---|
563 | }
|
---|
564 | _QQ(iPar,iPar) += sigCrdP_used * sigCrdP_used;
|
---|
565 | }
|
---|
566 | else if (pp->type == t_pppParam::CRD_Y) {
|
---|
567 | if (firstCrd) {
|
---|
568 | if (OPT->xyzAprRoverSet()) {
|
---|
569 | pp->xx = OPT->_xyzAprRover[1];
|
---|
570 | }
|
---|
571 | else {
|
---|
572 | pp->xx = _xcBanc(2);
|
---|
573 | }
|
---|
574 | }
|
---|
575 | _QQ(iPar,iPar) += sigCrdP_used * sigCrdP_used;
|
---|
576 | }
|
---|
577 | else if (pp->type == t_pppParam::CRD_Z) {
|
---|
578 | if (firstCrd) {
|
---|
579 | if (OPT->xyzAprRoverSet()) {
|
---|
580 | pp->xx = OPT->_xyzAprRover[2];
|
---|
581 | }
|
---|
582 | else {
|
---|
583 | pp->xx = _xcBanc(3);
|
---|
584 | }
|
---|
585 | }
|
---|
586 | _QQ(iPar,iPar) += sigCrdP_used * sigCrdP_used;
|
---|
587 | }
|
---|
588 |
|
---|
589 | // Receiver Clocks
|
---|
590 | // ---------------
|
---|
591 | else if (pp->type == t_pppParam::RECCLK) {
|
---|
592 | pp->xx = _xcBanc(4);
|
---|
593 | for (int jj = 1; jj <= _params.size(); jj++) {
|
---|
594 | _QQ(iPar, jj) = 0.0;
|
---|
595 | }
|
---|
596 | _QQ(iPar,iPar) = OPT->_noiseClk * OPT->_noiseClk;
|
---|
597 | }
|
---|
598 |
|
---|
599 | // Tropospheric Delay
|
---|
600 | // ------------------
|
---|
601 | else if (pp->type == t_pppParam::TROPO) {
|
---|
602 | _QQ(iPar,iPar) += OPT->_noiseTrp * OPT->_noiseTrp;
|
---|
603 | }
|
---|
604 |
|
---|
605 | // Glonass Offset
|
---|
606 | // --------------
|
---|
607 | else if (pp->type == t_pppParam::GLONASS_OFFSET) {
|
---|
608 | pp->xx = 0.0;
|
---|
609 | for (int jj = 1; jj <= _params.size(); jj++) {
|
---|
610 | _QQ(iPar, jj) = 0.0;
|
---|
611 | }
|
---|
612 | _QQ(iPar,iPar) = 1000.0 * 1000.0;
|
---|
613 | }
|
---|
614 |
|
---|
615 | // Galileo Offset
|
---|
616 | // --------------
|
---|
617 | else if (pp->type == t_pppParam::GALILEO_OFFSET) {
|
---|
618 | if (_QQ(iPar,iPar)>pow(1000.0,2))
|
---|
619 | _QQ(iPar,iPar) = 1000.0 * 1000.0;
|
---|
620 | else
|
---|
621 | _QQ(iPar,iPar) += 0.1 * 0.1;
|
---|
622 | }
|
---|
623 |
|
---|
624 | // BDS Offset
|
---|
625 | // ----------
|
---|
626 | else if (pp->type == t_pppParam::BDS_OFFSET) {
|
---|
627 | if (_QQ(iPar,iPar)>pow(1000.0,2))
|
---|
628 | _QQ(iPar,iPar) = 1000.0 * 1000.0;
|
---|
629 | else
|
---|
630 | _QQ(iPar,iPar) += 0.1 * 0.1;
|
---|
631 | }
|
---|
632 | }
|
---|
633 | }
|
---|
634 |
|
---|
635 | // Add New Ambiguities if necessary
|
---|
636 | // --------------------------------
|
---|
637 | if (OPT->ambLCs('G').size() || OPT->ambLCs('R').size() ||
|
---|
638 | OPT->ambLCs('E').size() || OPT->ambLCs('C').size()) {
|
---|
639 |
|
---|
640 | // Make a copy of QQ and xx, set parameter indices
|
---|
641 | // -----------------------------------------------
|
---|
642 | SymmetricMatrix QQ_old = _QQ;
|
---|
643 |
|
---|
644 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
645 | _params[iPar-1]->index_old = _params[iPar-1]->index;
|
---|
646 | _params[iPar-1]->index = 0;
|
---|
647 | }
|
---|
648 |
|
---|
649 | // Remove Ambiguity Parameters without observations
|
---|
650 | // ------------------------------------------------
|
---|
651 | int iPar = 0;
|
---|
652 | QMutableVectorIterator<t_pppParam*> im(_params);
|
---|
653 | while (im.hasNext()) {
|
---|
654 | t_pppParam* par = im.next();
|
---|
655 | bool removed = false;
|
---|
656 | if (par->type == t_pppParam::AMB_L3) {
|
---|
657 | if (epoData->satData.find(par->prn) == epoData->satData.end()) {
|
---|
658 | removed = true;
|
---|
659 | delete par;
|
---|
660 | im.remove();
|
---|
661 | }
|
---|
662 | }
|
---|
663 | if (! removed) {
|
---|
664 | ++iPar;
|
---|
665 | par->index = iPar;
|
---|
666 | }
|
---|
667 | }
|
---|
668 |
|
---|
669 | // Add new ambiguity parameters
|
---|
670 | // ----------------------------
|
---|
671 | QMapIterator<QString, t_satData*> it(epoData->satData);
|
---|
672 | while (it.hasNext()) {
|
---|
673 | it.next();
|
---|
674 | t_satData* satData = it.value();
|
---|
675 | addAmb(satData);
|
---|
676 | }
|
---|
677 |
|
---|
678 | int nPar = _params.size();
|
---|
679 | _QQ.ReSize(nPar); _QQ = 0.0;
|
---|
680 | for (int i1 = 1; i1 <= nPar; i1++) {
|
---|
681 | t_pppParam* p1 = _params[i1-1];
|
---|
682 | if (p1->index_old != 0) {
|
---|
683 | _QQ(p1->index, p1->index) = QQ_old(p1->index_old, p1->index_old);
|
---|
684 | for (int i2 = 1; i2 <= nPar; i2++) {
|
---|
685 | t_pppParam* p2 = _params[i2-1];
|
---|
686 | if (p2->index_old != 0) {
|
---|
687 | _QQ(p1->index, p2->index) = QQ_old(p1->index_old, p2->index_old);
|
---|
688 | }
|
---|
689 | }
|
---|
690 | }
|
---|
691 | }
|
---|
692 |
|
---|
693 | for (int ii = 1; ii <= nPar; ii++) {
|
---|
694 | t_pppParam* par = _params[ii-1];
|
---|
695 | if (par->index_old == 0) {
|
---|
696 | _QQ(par->index, par->index) = OPT->_aprSigAmb * OPT->_aprSigAmb;
|
---|
697 | }
|
---|
698 | par->index_old = par->index;
|
---|
699 | }
|
---|
700 | }
|
---|
701 | }
|
---|
702 |
|
---|
703 | // Update Step of the Filter (currently just a single-epoch solution)
|
---|
704 | ////////////////////////////////////////////////////////////////////////////
|
---|
705 | t_irc t_pppFilter::update(t_epoData* epoData) {
|
---|
706 |
|
---|
707 | Tracer tracer("t_pppFilter::update");
|
---|
708 |
|
---|
709 | _time = epoData->tt; // current epoch time
|
---|
710 |
|
---|
711 | if (OPT->useOrbClkCorr()) {
|
---|
712 | LOG << "Precise Point Positioning of Epoch " << _time.datestr() << "_" << _time.timestr(3)
|
---|
713 | << "\n---------------------------------------------------------------\n";
|
---|
714 | }
|
---|
715 | else {
|
---|
716 | LOG << "Single Point Positioning of Epoch " << _time.datestr() << "_" << _time.timestr(3)
|
---|
717 | << "\n---------------------------------------------------------------\n";
|
---|
718 | }
|
---|
719 |
|
---|
720 | // Outlier Detection Loop
|
---|
721 | // ----------------------
|
---|
722 | if (update_p(epoData) != success) {
|
---|
723 | return failure;
|
---|
724 | }
|
---|
725 |
|
---|
726 | // Set Solution Vector
|
---|
727 | // -------------------
|
---|
728 | LOG.setf(ios::fixed);
|
---|
729 | QVectorIterator<t_pppParam*> itPar(_params);
|
---|
730 | while (itPar.hasNext()) {
|
---|
731 | t_pppParam* par = itPar.next();
|
---|
732 | if (par->type == t_pppParam::RECCLK) {
|
---|
733 | LOG << "\n" << _time.datestr() << "_" << _time.timestr(3)
|
---|
734 | << " CLK " << setw(10) << setprecision(3) << par->xx
|
---|
735 | << " +- " << setw(6) << setprecision(3)
|
---|
736 | << sqrt(_QQ(par->index,par->index));
|
---|
737 | }
|
---|
738 | else if (par->type == t_pppParam::AMB_L3) {
|
---|
739 | ++par->numEpo;
|
---|
740 | LOG << "\n" << _time.datestr() << "_" << _time.timestr(3)
|
---|
741 | << " AMB " << par->prn.mid(0,3).toAscii().data() << " "
|
---|
742 | << setw(10) << setprecision(3) << par->xx
|
---|
743 | << " +- " << setw(6) << setprecision(3)
|
---|
744 | << sqrt(_QQ(par->index,par->index))
|
---|
745 | << " epo = " << par->numEpo;
|
---|
746 | }
|
---|
747 | else if (par->type == t_pppParam::TROPO) {
|
---|
748 | double aprTrp = delay_saast(M_PI/2.0);
|
---|
749 | LOG << "\n" << _time.datestr() << "_" << _time.timestr(3)
|
---|
750 | << " TRP " << par->prn.mid(0,3).toAscii().data()
|
---|
751 | << setw(7) << setprecision(3) << aprTrp << " "
|
---|
752 | << setw(6) << setprecision(3) << showpos << par->xx << noshowpos
|
---|
753 | << " +- " << setw(6) << setprecision(3)
|
---|
754 | << sqrt(_QQ(par->index,par->index));
|
---|
755 | }
|
---|
756 | else if (par->type == t_pppParam::GLONASS_OFFSET) {
|
---|
757 | LOG << "\n" << _time.datestr() << "_" << _time.timestr(3)
|
---|
758 | << " OFFGLO " << setw(10) << setprecision(3) << par->xx
|
---|
759 | << " +- " << setw(6) << setprecision(3)
|
---|
760 | << sqrt(_QQ(par->index,par->index));
|
---|
761 | }
|
---|
762 | else if (par->type == t_pppParam::GALILEO_OFFSET) {
|
---|
763 | LOG << "\n" << _time.datestr() << "_" << _time.timestr(3)
|
---|
764 | << " OFFGAL " << setw(10) << setprecision(3) << par->xx
|
---|
765 | << " +- " << setw(6) << setprecision(3)
|
---|
766 | << sqrt(_QQ(par->index,par->index));
|
---|
767 | }
|
---|
768 | else if (par->type == t_pppParam::BDS_OFFSET) {
|
---|
769 | LOG << "\n" << _time.datestr() << "_" << _time.timestr(3)
|
---|
770 | << " OFFBDS " << setw(10) << setprecision(3) << par->xx
|
---|
771 | << " +- " << setw(6) << setprecision(3)
|
---|
772 | << sqrt(_QQ(par->index,par->index));
|
---|
773 | }
|
---|
774 | }
|
---|
775 |
|
---|
776 | LOG << endl << endl;
|
---|
777 |
|
---|
778 | // Compute dilution of precision
|
---|
779 | // -----------------------------
|
---|
780 | cmpDOP(epoData);
|
---|
781 |
|
---|
782 | // Final Message (both log file and screen)
|
---|
783 | // ----------------------------------------
|
---|
784 | LOG << epoData->tt.datestr() << "_" << epoData->tt.timestr(3)
|
---|
785 | << " " << OPT->_roverName
|
---|
786 | << " X = "
|
---|
787 | << setprecision(4) << x() << " +- "
|
---|
788 | << setprecision(4) << sqrt(_QQ(1,1))
|
---|
789 |
|
---|
790 | << " Y = "
|
---|
791 | << setprecision(4) << y() << " +- "
|
---|
792 | << setprecision(4) << sqrt(_QQ(2,2))
|
---|
793 |
|
---|
794 | << " Z = "
|
---|
795 | << setprecision(4) << z() << " +- "
|
---|
796 | << setprecision(4) << sqrt(_QQ(3,3));
|
---|
797 |
|
---|
798 | // NEU Output
|
---|
799 | // ----------
|
---|
800 | if (OPT->xyzAprRoverSet()) {
|
---|
801 | SymmetricMatrix QQxyz = _QQ.SymSubMatrix(1,3);
|
---|
802 |
|
---|
803 | ColumnVector xyz(3);
|
---|
804 | xyz(1) = x() - OPT->_xyzAprRover[0];
|
---|
805 | xyz(2) = y() - OPT->_xyzAprRover[1];
|
---|
806 | xyz(3) = z() - OPT->_xyzAprRover[2];
|
---|
807 |
|
---|
808 | ColumnVector ellRef(3);
|
---|
809 | xyz2ell(OPT->_xyzAprRover.data(), ellRef.data());
|
---|
810 | xyz2neu(ellRef.data(), xyz.data(), _neu.data());
|
---|
811 |
|
---|
812 | SymmetricMatrix QQneu(3);
|
---|
813 | covariXYZ_NEU(QQxyz, ellRef.data(), QQneu);
|
---|
814 |
|
---|
815 | LOG << " dN = "
|
---|
816 | << setprecision(4) << _neu[0] << " +- "
|
---|
817 | << setprecision(4) << sqrt(QQneu[0][0])
|
---|
818 |
|
---|
819 | << " dE = "
|
---|
820 | << setprecision(4) << _neu[1] << " +- "
|
---|
821 | << setprecision(4) << sqrt(QQneu[1][1])
|
---|
822 |
|
---|
823 | << " dU = "
|
---|
824 | << setprecision(4) << _neu[2] << " +- "
|
---|
825 | << setprecision(4) << sqrt(QQneu[2][2]) << endl << endl;
|
---|
826 | }
|
---|
827 | else {
|
---|
828 | LOG << endl << endl;
|
---|
829 | }
|
---|
830 |
|
---|
831 | _lastTimeOK = _time; // remember time of last successful update
|
---|
832 | return success;
|
---|
833 | }
|
---|
834 |
|
---|
835 | // Iono combi noise factor
|
---|
836 | ////////////////////////////////////////////////////////////////////////////
|
---|
837 | double ionFac(const QString prn, QMap<QString, t_satData*>& satData) {
|
---|
838 | if (satData.contains(prn))
|
---|
839 | return sqrt(pow(satData.value(prn)->lkA,2) +
|
---|
840 | pow(satData.value(prn)->lkB,2) );
|
---|
841 | else
|
---|
842 | return 0.0;
|
---|
843 | };
|
---|
844 |
|
---|
845 | // Outlier Detection
|
---|
846 | ////////////////////////////////////////////////////////////////////////////
|
---|
847 | QString t_pppFilter::outlierDetection(int iPhase, const ColumnVector& vv,
|
---|
848 | QMap<QString, t_satData*>& satData) {
|
---|
849 |
|
---|
850 | Tracer tracer("t_pppFilter::outlierDetection");
|
---|
851 |
|
---|
852 | QString prnGPS;
|
---|
853 | QString prnGlo;
|
---|
854 |
|
---|
855 | double ionFacGPS;
|
---|
856 | double ionFacGLO;
|
---|
857 |
|
---|
858 | double maxResGPS = 0.0; // GPS + Galileo
|
---|
859 | double maxResGlo = 0.0; // GLONASS + BDS
|
---|
860 |
|
---|
861 | findMaxRes(vv, satData, prnGPS, prnGlo, maxResGPS, maxResGlo);
|
---|
862 |
|
---|
863 | ionFacGLO = ionFac(prnGlo,satData);
|
---|
864 | if (iPhase == 0)
|
---|
865 | ionFacGLO *= (prnGlo[0]=='R'? GLONASS_WEIGHT_FACTOR : BDS_WEIGHT_FACTOR);
|
---|
866 | ionFacGPS = ionFac(prnGPS,satData);
|
---|
867 |
|
---|
868 | if (iPhase == 1) {
|
---|
869 | if (maxResGlo > ionFacGLO * OPT->_maxResL1) {
|
---|
870 | LOG << "Outlier Phase " << prnGlo.mid(0,3).toAscii().data() << ' ' << maxResGlo << endl;
|
---|
871 | return prnGlo;
|
---|
872 | }
|
---|
873 | else if (maxResGPS > ionFacGPS * OPT->_maxResL1) {
|
---|
874 | LOG << "Outlier Phase " << prnGPS.mid(0,3).toAscii().data() << ' ' << maxResGPS << endl;
|
---|
875 | return prnGPS;
|
---|
876 | }
|
---|
877 | }
|
---|
878 | else if (iPhase == 0) {
|
---|
879 | if (maxResGlo > ionFacGLO * OPT->_maxResC1) {
|
---|
880 | LOG << "Outlier Code " << prnGlo.mid(0,3).toLatin1().data() << ' ' << maxResGlo << endl;
|
---|
881 | return prnGlo;
|
---|
882 | }
|
---|
883 | else if (maxResGPS > ionFacGPS * OPT->_maxResC1) {
|
---|
884 | LOG << "Outlier Code " << prnGPS.mid(0,3).toLatin1().data() << ' ' << maxResGPS << endl;
|
---|
885 | return prnGPS;
|
---|
886 | }
|
---|
887 | }
|
---|
888 |
|
---|
889 | return QString();
|
---|
890 | }
|
---|
891 |
|
---|
892 | // Phase Wind-Up Correction
|
---|
893 | ///////////////////////////////////////////////////////////////////////////
|
---|
894 | double t_pppFilter::windUp(const QString& prn, const ColumnVector& rSat,
|
---|
895 | const ColumnVector& rRec) {
|
---|
896 |
|
---|
897 | Tracer tracer("t_pppFilter::windUp");
|
---|
898 |
|
---|
899 | double Mjd = _time.mjd() + _time.daysec() / 86400.0;
|
---|
900 |
|
---|
901 | // First time - initialize to zero
|
---|
902 | // -------------------------------
|
---|
903 | if (!_windUpTime.contains(prn)) {
|
---|
904 | _windUpSum[prn] = 0.0;
|
---|
905 | }
|
---|
906 |
|
---|
907 | // Compute the correction for new time
|
---|
908 | // -----------------------------------
|
---|
909 | if (!_windUpTime.contains(prn) || _windUpTime[prn] != Mjd) {
|
---|
910 | _windUpTime[prn] = Mjd;
|
---|
911 |
|
---|
912 | // Unit Vector GPS Satellite --> Receiver
|
---|
913 | // --------------------------------------
|
---|
914 | ColumnVector rho = rRec - rSat;
|
---|
915 | rho /= rho.norm_Frobenius();
|
---|
916 |
|
---|
917 | // GPS Satellite unit Vectors sz, sy, sx
|
---|
918 | // -------------------------------------
|
---|
919 | ColumnVector sz = -rSat / rSat.norm_Frobenius();
|
---|
920 |
|
---|
921 | ColumnVector xSun = t_astro::Sun(Mjd);
|
---|
922 | xSun /= xSun.norm_Frobenius();
|
---|
923 |
|
---|
924 | ColumnVector sy = crossproduct(sz, xSun);
|
---|
925 | ColumnVector sx = crossproduct(sy, sz);
|
---|
926 |
|
---|
927 | // Effective Dipole of the GPS Satellite Antenna
|
---|
928 | // ---------------------------------------------
|
---|
929 | ColumnVector dipSat = sx - rho * DotProduct(rho,sx)
|
---|
930 | - crossproduct(rho, sy);
|
---|
931 |
|
---|
932 | // Receiver unit Vectors rx, ry
|
---|
933 | // ----------------------------
|
---|
934 | ColumnVector rx(3);
|
---|
935 | ColumnVector ry(3);
|
---|
936 |
|
---|
937 | double recEll[3]; xyz2ell(rRec.data(), recEll) ;
|
---|
938 | double neu[3];
|
---|
939 |
|
---|
940 | neu[0] = 1.0;
|
---|
941 | neu[1] = 0.0;
|
---|
942 | neu[2] = 0.0;
|
---|
943 | neu2xyz(recEll, neu, rx.data());
|
---|
944 |
|
---|
945 | neu[0] = 0.0;
|
---|
946 | neu[1] = -1.0;
|
---|
947 | neu[2] = 0.0;
|
---|
948 | neu2xyz(recEll, neu, ry.data());
|
---|
949 |
|
---|
950 | // Effective Dipole of the Receiver Antenna
|
---|
951 | // ----------------------------------------
|
---|
952 | ColumnVector dipRec = rx - rho * DotProduct(rho,rx)
|
---|
953 | + crossproduct(rho, ry);
|
---|
954 |
|
---|
955 | // Resulting Effect
|
---|
956 | // ----------------
|
---|
957 | double alpha = DotProduct(dipSat,dipRec) /
|
---|
958 | (dipSat.norm_Frobenius() * dipRec.norm_Frobenius());
|
---|
959 |
|
---|
960 | if (alpha > 1.0) alpha = 1.0;
|
---|
961 | if (alpha < -1.0) alpha = -1.0;
|
---|
962 |
|
---|
963 | double dphi = acos(alpha) / 2.0 / M_PI; // in cycles
|
---|
964 |
|
---|
965 | if ( DotProduct(rho, crossproduct(dipSat, dipRec)) < 0.0 ) {
|
---|
966 | dphi = -dphi;
|
---|
967 | }
|
---|
968 |
|
---|
969 | _windUpSum[prn] = floor(_windUpSum[prn] - dphi + 0.5) + dphi;
|
---|
970 | }
|
---|
971 |
|
---|
972 | return _windUpSum[prn];
|
---|
973 | }
|
---|
974 |
|
---|
975 | //
|
---|
976 | ///////////////////////////////////////////////////////////////////////////
|
---|
977 | void t_pppFilter::cmpEle(t_satData* satData) {
|
---|
978 | Tracer tracer("t_pppFilter::cmpEle");
|
---|
979 | ColumnVector rr = satData->xx - _xcBanc.Rows(1,3);
|
---|
980 | double rho = rr.norm_Frobenius();
|
---|
981 |
|
---|
982 | double neu[3];
|
---|
983 | xyz2neu(_ellBanc.data(), rr.data(), neu);
|
---|
984 |
|
---|
985 | satData->eleSat = acos( sqrt(neu[0]*neu[0] + neu[1]*neu[1]) / rho );
|
---|
986 | if (neu[2] < 0) {
|
---|
987 | satData->eleSat *= -1.0;
|
---|
988 | }
|
---|
989 | satData->azSat = atan2(neu[1], neu[0]);
|
---|
990 | }
|
---|
991 |
|
---|
992 | //
|
---|
993 | ///////////////////////////////////////////////////////////////////////////
|
---|
994 | void t_pppFilter::addAmb(t_satData* satData) {
|
---|
995 | Tracer tracer("t_pppFilter::addAmb");
|
---|
996 | if (!OPT->ambLCs(satData->system()).size()){
|
---|
997 | return;
|
---|
998 | }
|
---|
999 | bool found = false;
|
---|
1000 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
1001 | if (_params[iPar-1]->type == t_pppParam::AMB_L3 &&
|
---|
1002 | _params[iPar-1]->prn == satData->prn) {
|
---|
1003 | found = true;
|
---|
1004 | break;
|
---|
1005 | }
|
---|
1006 | }
|
---|
1007 | if (!found) {
|
---|
1008 | t_pppParam* par = new t_pppParam(t_pppParam::AMB_L3,
|
---|
1009 | _params.size()+1, satData->prn);
|
---|
1010 | _params.push_back(par);
|
---|
1011 | par->xx = satData->L3 - cmpValue(satData, true);
|
---|
1012 | }
|
---|
1013 | }
|
---|
1014 |
|
---|
1015 | //
|
---|
1016 | ///////////////////////////////////////////////////////////////////////////
|
---|
1017 | void t_pppFilter::addObs(int iPhase, unsigned& iObs, t_satData* satData,
|
---|
1018 | Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP) {
|
---|
1019 |
|
---|
1020 | Tracer tracer("t_pppFilter::addObs");
|
---|
1021 |
|
---|
1022 | const double ELEWGHT = 20.0;
|
---|
1023 | double ellWgtCoef = 1.0;
|
---|
1024 | double eleD = satData->eleSat * 180.0 / M_PI;
|
---|
1025 | if (eleD < ELEWGHT) {
|
---|
1026 | ellWgtCoef = 1.5 - 0.5 / (ELEWGHT - 10.0) * (eleD - 10.0);
|
---|
1027 | }
|
---|
1028 |
|
---|
1029 | // Remember Observation Index
|
---|
1030 | // --------------------------
|
---|
1031 | ++iObs;
|
---|
1032 | satData->obsIndex = iObs;
|
---|
1033 |
|
---|
1034 | // Iono-free combination noise factor
|
---|
1035 | // ----------------------------------
|
---|
1036 | double ionFac = sqrt(pow(satData->lkA,2) + pow(satData->lkB,2));
|
---|
1037 |
|
---|
1038 | // Phase Observations
|
---|
1039 | // ------------------
|
---|
1040 |
|
---|
1041 | if (iPhase == 1) {
|
---|
1042 | double sigL3 = ionFac * ellWgtCoef * OPT->_sigmaL1;
|
---|
1043 | if (satData->system() == 'R') {
|
---|
1044 | sigL3 *= GLONASS_WEIGHT_FACTOR;
|
---|
1045 | }
|
---|
1046 | if (satData->system() == 'C') {
|
---|
1047 | sigL3 *= BDS_WEIGHT_FACTOR;
|
---|
1048 | }
|
---|
1049 | satData->L3sig = sigL3;
|
---|
1050 | ll(iObs) = satData->L3 - cmpValue(satData, true);
|
---|
1051 | PP(iObs,iObs) = 1.0 / (sigL3 * sigL3);
|
---|
1052 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
1053 | if (_params[iPar-1]->type == t_pppParam::AMB_L3 &&
|
---|
1054 | _params[iPar-1]->prn == satData->prn) {
|
---|
1055 | ll(iObs) -= _params[iPar-1]->xx;
|
---|
1056 | }
|
---|
1057 | AA(iObs, iPar) = _params[iPar-1]->partial(satData, true);
|
---|
1058 | }
|
---|
1059 | }
|
---|
1060 |
|
---|
1061 | // Code Observations
|
---|
1062 | // -----------------
|
---|
1063 | else {
|
---|
1064 | double sigP3 = ionFac * ellWgtCoef * OPT->_sigmaC1;
|
---|
1065 | if (satData->system() == 'R') {
|
---|
1066 | sigP3 *= GLONASS_WEIGHT_FACTOR;
|
---|
1067 | }
|
---|
1068 | if (satData->system() == 'C') {
|
---|
1069 | sigP3 *= BDS_WEIGHT_FACTOR;
|
---|
1070 | }
|
---|
1071 | satData->P3sig = sigP3;
|
---|
1072 | ll(iObs) = satData->P3 - cmpValue(satData, false);
|
---|
1073 | PP(iObs,iObs) = 1.0 / (sigP3 * sigP3);
|
---|
1074 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
1075 | AA(iObs, iPar) = _params[iPar-1]->partial(satData, false);
|
---|
1076 | }
|
---|
1077 | }
|
---|
1078 | }
|
---|
1079 |
|
---|
1080 | //
|
---|
1081 | ///////////////////////////////////////////////////////////////////////////
|
---|
1082 | QByteArray t_pppFilter::printRes(int iPhase, const ColumnVector& vv,
|
---|
1083 | const QMap<QString, t_satData*>& satDataMap) {
|
---|
1084 |
|
---|
1085 | Tracer tracer("t_pppFilter::printRes");
|
---|
1086 |
|
---|
1087 | ostringstream str;
|
---|
1088 | str.setf(ios::fixed);
|
---|
1089 | bool useObs;
|
---|
1090 | QMapIterator<QString, t_satData*> it(satDataMap);
|
---|
1091 | while (it.hasNext()) {
|
---|
1092 | it.next();
|
---|
1093 | t_satData* satData = it.value();
|
---|
1094 | (iPhase == 0) ? useObs = OPT->codeLCs(satData->system()).size() :
|
---|
1095 | useObs = OPT->ambLCs(satData->system()).size();
|
---|
1096 | if (satData->obsIndex != 0 && useObs) {
|
---|
1097 | str << _time.datestr() << "_" << _time.timestr(3)
|
---|
1098 | << " RES " << satData->prn.mid(0,3).toAscii().data()
|
---|
1099 | << (iPhase ? " L3 " : " P3 ")
|
---|
1100 | << setw(9) << setprecision(4) << vv(satData->obsIndex) << " "
|
---|
1101 | /*
|
---|
1102 | << setprecision(3)
|
---|
1103 | << setw(7) << (iPhase? satData->L3sig : satData->P3sig) << " "
|
---|
1104 | << setprecision(1)
|
---|
1105 | << setw(5) <<satData->eleSat * 180 / M_PI
|
---|
1106 | */
|
---|
1107 | << endl;
|
---|
1108 | }
|
---|
1109 | }
|
---|
1110 |
|
---|
1111 | return QByteArray(str.str().c_str());
|
---|
1112 | }
|
---|
1113 |
|
---|
1114 | //
|
---|
1115 | ///////////////////////////////////////////////////////////////////////////
|
---|
1116 | void t_pppFilter::findMaxRes(const ColumnVector& vv,
|
---|
1117 | const QMap<QString, t_satData*>& satData,
|
---|
1118 | QString& prnGPS, QString& prnGlo,
|
---|
1119 | double& maxResGPS, double& maxResGlo) {
|
---|
1120 |
|
---|
1121 | Tracer tracer("t_pppFilter::findMaxRes");
|
---|
1122 |
|
---|
1123 | maxResGPS = 0.0;
|
---|
1124 | maxResGlo = 0.0;
|
---|
1125 |
|
---|
1126 | QMapIterator<QString, t_satData*> it(satData);
|
---|
1127 | while (it.hasNext()) {
|
---|
1128 | it.next();
|
---|
1129 | t_satData* satData = it.value();
|
---|
1130 | if (satData->obsIndex != 0) {
|
---|
1131 | QString prn = satData->prn;
|
---|
1132 | if (prn[0] == 'R' || prn[0] == 'C') {
|
---|
1133 | if (fabs(vv(satData->obsIndex)) > maxResGlo) {
|
---|
1134 | maxResGlo = fabs(vv(satData->obsIndex));
|
---|
1135 | prnGlo = prn;
|
---|
1136 | }
|
---|
1137 | }
|
---|
1138 | else {
|
---|
1139 | if (fabs(vv(satData->obsIndex)) > maxResGPS) {
|
---|
1140 | maxResGPS = fabs(vv(satData->obsIndex));
|
---|
1141 | prnGPS = prn;
|
---|
1142 | }
|
---|
1143 | }
|
---|
1144 | }
|
---|
1145 | }
|
---|
1146 | }
|
---|
1147 |
|
---|
1148 | // Update Step (private - loop over outliers)
|
---|
1149 | ////////////////////////////////////////////////////////////////////////////
|
---|
1150 | t_irc t_pppFilter::update_p(t_epoData* epoData) {
|
---|
1151 |
|
---|
1152 | Tracer tracer("t_pppFilter::update_p");
|
---|
1153 |
|
---|
1154 | // Save Variance-Covariance Matrix, and Status Vector
|
---|
1155 | // --------------------------------------------------
|
---|
1156 | rememberState(epoData);
|
---|
1157 |
|
---|
1158 | QString lastOutlierPrn;
|
---|
1159 |
|
---|
1160 | // Try with all satellites, then with all minus one, etc.
|
---|
1161 | // ------------------------------------------------------
|
---|
1162 | while (selectSatellites(lastOutlierPrn, epoData->satData) == success) {
|
---|
1163 |
|
---|
1164 | QByteArray strResCode;
|
---|
1165 | QByteArray strResPhase;
|
---|
1166 |
|
---|
1167 | // Bancroft Solution
|
---|
1168 | // -----------------
|
---|
1169 | if (cmpBancroft(epoData) != success) {
|
---|
1170 | break;
|
---|
1171 | }
|
---|
1172 |
|
---|
1173 | // First update using code observations, then phase observations
|
---|
1174 | // -------------------------------------------------------------
|
---|
1175 | bool usePhase = OPT->ambLCs('G').size() || OPT->ambLCs('R').size() ||
|
---|
1176 | OPT->ambLCs('E').size() || OPT->ambLCs('C').size() ;
|
---|
1177 |
|
---|
1178 | char sys[] ={'G', 'R', 'E', 'C'};
|
---|
1179 |
|
---|
1180 | bool satnumPrinted[] = {false, false, false, false};
|
---|
1181 |
|
---|
1182 | for (int iPhase = 0; iPhase <= (usePhase ? 1 : 0); iPhase++) {
|
---|
1183 |
|
---|
1184 | // Status Prediction
|
---|
1185 | // -----------------
|
---|
1186 | predict(iPhase, epoData);
|
---|
1187 |
|
---|
1188 | // Create First-Design Matrix
|
---|
1189 | // --------------------------
|
---|
1190 | unsigned nPar = _params.size();
|
---|
1191 | unsigned nObs = 0;
|
---|
1192 | nObs = epoData->sizeAll();
|
---|
1193 | bool useObs = false;
|
---|
1194 | for (unsigned ii = 0; ii < sizeof(sys); ii++) {
|
---|
1195 | const char s = sys[ii];
|
---|
1196 | (iPhase == 0) ? useObs = OPT->codeLCs(s).size() : useObs = OPT->ambLCs(s).size();
|
---|
1197 | if (!useObs) {
|
---|
1198 | nObs -= epoData->sizeSys(s);
|
---|
1199 | }
|
---|
1200 | else {
|
---|
1201 | if (!satnumPrinted[ii]) {
|
---|
1202 | satnumPrinted[ii] = true;
|
---|
1203 | LOG << _time.datestr() << "_" << _time.timestr(3)
|
---|
1204 | << " SATNUM " << s << ' ' << right << setw(2)
|
---|
1205 | << epoData->sizeSys(s) << endl;
|
---|
1206 | }
|
---|
1207 | }
|
---|
1208 | }
|
---|
1209 |
|
---|
1210 | if (int(nObs) < OPT->_minObs) {
|
---|
1211 | restoreState(epoData);
|
---|
1212 | return failure;
|
---|
1213 | }
|
---|
1214 |
|
---|
1215 | // Prepare first-design Matrix, vector observed-computed
|
---|
1216 | // -----------------------------------------------------
|
---|
1217 | Matrix AA(nObs, nPar); // first design matrix
|
---|
1218 | ColumnVector ll(nObs); // terms observed-computed
|
---|
1219 | DiagonalMatrix PP(nObs); PP = 0.0;
|
---|
1220 |
|
---|
1221 | unsigned iObs = 0;
|
---|
1222 | QMapIterator<QString, t_satData*> it(epoData->satData);
|
---|
1223 |
|
---|
1224 | while (it.hasNext()) {
|
---|
1225 | it.next();
|
---|
1226 | t_satData* satData = it.value();
|
---|
1227 | QString prn = satData->prn;
|
---|
1228 | (iPhase == 0) ? useObs = OPT->codeLCs(satData->system()).size() :
|
---|
1229 | useObs = OPT->ambLCs(satData->system()).size();
|
---|
1230 | if (useObs) {
|
---|
1231 | addObs(iPhase, iObs, satData, AA, ll, PP);
|
---|
1232 | } else {
|
---|
1233 | satData->obsIndex = 0;
|
---|
1234 | }
|
---|
1235 | }
|
---|
1236 |
|
---|
1237 | // Compute Filter Update
|
---|
1238 | // ---------------------
|
---|
1239 | ColumnVector dx(nPar); dx = 0.0;
|
---|
1240 | kalman(AA, ll, PP, _QQ, dx);
|
---|
1241 | ColumnVector vv = ll - AA * dx;
|
---|
1242 |
|
---|
1243 | // Print Residuals
|
---|
1244 | // ---------------
|
---|
1245 | if (iPhase == 0) {
|
---|
1246 | strResCode = printRes(iPhase, vv, epoData->satData);
|
---|
1247 | }
|
---|
1248 | else {
|
---|
1249 | strResPhase = printRes(iPhase, vv, epoData->satData);
|
---|
1250 | }
|
---|
1251 |
|
---|
1252 | // Check the residuals
|
---|
1253 | // -------------------
|
---|
1254 | lastOutlierPrn = outlierDetection(iPhase, vv, epoData->satData);
|
---|
1255 |
|
---|
1256 | // No Outlier Detected
|
---|
1257 | // -------------------
|
---|
1258 | if (lastOutlierPrn.isEmpty()) {
|
---|
1259 |
|
---|
1260 | QVectorIterator<t_pppParam*> itPar(_params);
|
---|
1261 | while (itPar.hasNext()) {
|
---|
1262 | t_pppParam* par = itPar.next();
|
---|
1263 | par->xx += dx(par->index);
|
---|
1264 | }
|
---|
1265 |
|
---|
1266 | if (!usePhase || iPhase == 1) {
|
---|
1267 | if (_outlierGPS.size() > 0 || _outlierGlo.size() > 0) {
|
---|
1268 | LOG << "Neglected PRNs: ";
|
---|
1269 | if (!_outlierGPS.isEmpty()) {
|
---|
1270 | LOG << _outlierGPS.last().mid(0,3).toAscii().data() << ' ';
|
---|
1271 | }
|
---|
1272 | QStringListIterator itGlo(_outlierGlo);
|
---|
1273 | while (itGlo.hasNext()) {
|
---|
1274 | QString prn = itGlo.next();
|
---|
1275 | LOG << prn.mid(0,3).toAscii().data() << ' ';
|
---|
1276 | }
|
---|
1277 | LOG << endl;
|
---|
1278 | }
|
---|
1279 | LOG << strResCode.data() << strResPhase.data();
|
---|
1280 |
|
---|
1281 | return success;
|
---|
1282 | }
|
---|
1283 | }
|
---|
1284 |
|
---|
1285 | // Outlier Found
|
---|
1286 | // -------------
|
---|
1287 | else {
|
---|
1288 | restoreState(epoData);
|
---|
1289 | break;
|
---|
1290 | }
|
---|
1291 |
|
---|
1292 | } // for iPhase
|
---|
1293 |
|
---|
1294 | } // while selectSatellites
|
---|
1295 |
|
---|
1296 | restoreState(epoData);
|
---|
1297 | return failure;
|
---|
1298 | }
|
---|
1299 |
|
---|
1300 | // Remember Original State Vector and Variance-Covariance Matrix
|
---|
1301 | ////////////////////////////////////////////////////////////////////////////
|
---|
1302 | void t_pppFilter::rememberState(t_epoData* epoData) {
|
---|
1303 |
|
---|
1304 | _QQ_sav = _QQ;
|
---|
1305 |
|
---|
1306 | QVectorIterator<t_pppParam*> itSav(_params_sav);
|
---|
1307 | while (itSav.hasNext()) {
|
---|
1308 | t_pppParam* par = itSav.next();
|
---|
1309 | delete par;
|
---|
1310 | }
|
---|
1311 | _params_sav.clear();
|
---|
1312 |
|
---|
1313 | QVectorIterator<t_pppParam*> it(_params);
|
---|
1314 | while (it.hasNext()) {
|
---|
1315 | t_pppParam* par = it.next();
|
---|
1316 | _params_sav.push_back(new t_pppParam(*par));
|
---|
1317 | }
|
---|
1318 |
|
---|
1319 | _epoData_sav->deepCopy(epoData);
|
---|
1320 | }
|
---|
1321 |
|
---|
1322 | // Restore Original State Vector and Variance-Covariance Matrix
|
---|
1323 | ////////////////////////////////////////////////////////////////////////////
|
---|
1324 | void t_pppFilter::restoreState(t_epoData* epoData) {
|
---|
1325 |
|
---|
1326 | _QQ = _QQ_sav;
|
---|
1327 |
|
---|
1328 | QVectorIterator<t_pppParam*> it(_params);
|
---|
1329 | while (it.hasNext()) {
|
---|
1330 | t_pppParam* par = it.next();
|
---|
1331 | delete par;
|
---|
1332 | }
|
---|
1333 | _params.clear();
|
---|
1334 |
|
---|
1335 | QVectorIterator<t_pppParam*> itSav(_params_sav);
|
---|
1336 | while (itSav.hasNext()) {
|
---|
1337 | t_pppParam* par = itSav.next();
|
---|
1338 | _params.push_back(new t_pppParam(*par));
|
---|
1339 | }
|
---|
1340 |
|
---|
1341 | epoData->deepCopy(_epoData_sav);
|
---|
1342 | }
|
---|
1343 |
|
---|
1344 | //
|
---|
1345 | ////////////////////////////////////////////////////////////////////////////
|
---|
1346 | t_irc t_pppFilter::selectSatellites(const QString& lastOutlierPrn,
|
---|
1347 | QMap<QString, t_satData*>& satData) {
|
---|
1348 |
|
---|
1349 | // First Call
|
---|
1350 | // ----------
|
---|
1351 | if (lastOutlierPrn.isEmpty()) {
|
---|
1352 | _outlierGPS.clear();
|
---|
1353 | _outlierGlo.clear();
|
---|
1354 | return success;
|
---|
1355 | }
|
---|
1356 |
|
---|
1357 | // Second and next trials
|
---|
1358 | // ----------------------
|
---|
1359 | else {
|
---|
1360 |
|
---|
1361 | if (lastOutlierPrn[0] == 'R' || lastOutlierPrn[0] == 'C') {
|
---|
1362 | _outlierGlo << lastOutlierPrn;
|
---|
1363 | }
|
---|
1364 |
|
---|
1365 | // Remove all Glonass Outliers
|
---|
1366 | // ---------------------------
|
---|
1367 | QStringListIterator it(_outlierGlo);
|
---|
1368 | while (it.hasNext()) {
|
---|
1369 | QString prn = it.next();
|
---|
1370 | if (satData.contains(prn)) {
|
---|
1371 | delete satData.take(prn);
|
---|
1372 | }
|
---|
1373 | }
|
---|
1374 |
|
---|
1375 | if (lastOutlierPrn[0] == 'R' || lastOutlierPrn[0] == 'C') {
|
---|
1376 | _outlierGPS.clear();
|
---|
1377 | return success;
|
---|
1378 | }
|
---|
1379 |
|
---|
1380 | // GPS Outlier appeared for the first time - try to delete it
|
---|
1381 | // ----------------------------------------------------------
|
---|
1382 | if (_outlierGPS.indexOf(lastOutlierPrn) == -1) {
|
---|
1383 | _outlierGPS << lastOutlierPrn;
|
---|
1384 | if (satData.contains(lastOutlierPrn)) {
|
---|
1385 | delete satData.take(lastOutlierPrn);
|
---|
1386 | }
|
---|
1387 | return success;
|
---|
1388 | }
|
---|
1389 |
|
---|
1390 | }
|
---|
1391 |
|
---|
1392 | return failure;
|
---|
1393 | }
|
---|
1394 |
|
---|
1395 | //
|
---|
1396 | ////////////////////////////////////////////////////////////////////////////
|
---|
1397 | double lorentz(const ColumnVector& aa, const ColumnVector& bb) {
|
---|
1398 | return aa(1)*bb(1) + aa(2)*bb(2) + aa(3)*bb(3) - aa(4)*bb(4);
|
---|
1399 | }
|
---|
1400 |
|
---|
1401 | //
|
---|
1402 | ////////////////////////////////////////////////////////////////////////////
|
---|
1403 | void t_pppFilter::bancroft(const Matrix& BBpass, ColumnVector& pos) {
|
---|
1404 |
|
---|
1405 | if (pos.Nrows() != 4) {
|
---|
1406 | pos.ReSize(4);
|
---|
1407 | }
|
---|
1408 | pos = 0.0;
|
---|
1409 |
|
---|
1410 | for (int iter = 1; iter <= 2; iter++) {
|
---|
1411 | Matrix BB = BBpass;
|
---|
1412 | int mm = BB.Nrows();
|
---|
1413 | for (int ii = 1; ii <= mm; ii++) {
|
---|
1414 | double xx = BB(ii,1);
|
---|
1415 | double yy = BB(ii,2);
|
---|
1416 | double traveltime = 0.072;
|
---|
1417 | if (iter > 1) {
|
---|
1418 | double zz = BB(ii,3);
|
---|
1419 | double rho = sqrt( (xx-pos(1)) * (xx-pos(1)) +
|
---|
1420 | (yy-pos(2)) * (yy-pos(2)) +
|
---|
1421 | (zz-pos(3)) * (zz-pos(3)) );
|
---|
1422 | traveltime = rho / t_CST::c;
|
---|
1423 | }
|
---|
1424 | double angle = traveltime * t_CST::omega;
|
---|
1425 | double cosa = cos(angle);
|
---|
1426 | double sina = sin(angle);
|
---|
1427 | BB(ii,1) = cosa * xx + sina * yy;
|
---|
1428 | BB(ii,2) = -sina * xx + cosa * yy;
|
---|
1429 | }
|
---|
1430 |
|
---|
1431 | Matrix BBB;
|
---|
1432 | if (mm > 4) {
|
---|
1433 | SymmetricMatrix hlp; hlp << BB.t() * BB;
|
---|
1434 | BBB = hlp.i() * BB.t();
|
---|
1435 | }
|
---|
1436 | else {
|
---|
1437 | BBB = BB.i();
|
---|
1438 | }
|
---|
1439 | ColumnVector ee(mm); ee = 1.0;
|
---|
1440 | ColumnVector alpha(mm); alpha = 0.0;
|
---|
1441 | for (int ii = 1; ii <= mm; ii++) {
|
---|
1442 | alpha(ii) = lorentz(BB.Row(ii).t(),BB.Row(ii).t())/2.0;
|
---|
1443 | }
|
---|
1444 | ColumnVector BBBe = BBB * ee;
|
---|
1445 | ColumnVector BBBalpha = BBB * alpha;
|
---|
1446 | double aa = lorentz(BBBe, BBBe);
|
---|
1447 | double bb = lorentz(BBBe, BBBalpha)-1;
|
---|
1448 | double cc = lorentz(BBBalpha, BBBalpha);
|
---|
1449 | double root = sqrt(bb*bb-aa*cc);
|
---|
1450 |
|
---|
1451 | Matrix hlpPos(4,2);
|
---|
1452 | hlpPos.Column(1) = (-bb-root)/aa * BBBe + BBBalpha;
|
---|
1453 | hlpPos.Column(2) = (-bb+root)/aa * BBBe + BBBalpha;
|
---|
1454 |
|
---|
1455 | ColumnVector omc(2);
|
---|
1456 | for (int pp = 1; pp <= 2; pp++) {
|
---|
1457 | hlpPos(4,pp) = -hlpPos(4,pp);
|
---|
1458 | omc(pp) = BB(1,4) -
|
---|
1459 | sqrt( (BB(1,1)-hlpPos(1,pp)) * (BB(1,1)-hlpPos(1,pp)) +
|
---|
1460 | (BB(1,2)-hlpPos(2,pp)) * (BB(1,2)-hlpPos(2,pp)) +
|
---|
1461 | (BB(1,3)-hlpPos(3,pp)) * (BB(1,3)-hlpPos(3,pp)) ) -
|
---|
1462 | hlpPos(4,pp);
|
---|
1463 | }
|
---|
1464 | if ( fabs(omc(1)) > fabs(omc(2)) ) {
|
---|
1465 | pos = hlpPos.Column(2);
|
---|
1466 | }
|
---|
1467 | else {
|
---|
1468 | pos = hlpPos.Column(1);
|
---|
1469 | }
|
---|
1470 | }
|
---|
1471 | }
|
---|
1472 |
|
---|
1473 | //
|
---|
1474 | ////////////////////////////////////////////////////////////////////////////
|
---|
1475 | void t_pppFilter::cmpDOP(t_epoData* epoData) {
|
---|
1476 |
|
---|
1477 | Tracer tracer("t_pppFilter::cmpDOP");
|
---|
1478 |
|
---|
1479 | _numSat = 0;
|
---|
1480 | _hDop = 0.0;
|
---|
1481 |
|
---|
1482 | if (_params.size() < 4) {
|
---|
1483 | return;
|
---|
1484 | }
|
---|
1485 |
|
---|
1486 | const unsigned numPar = 4;
|
---|
1487 | Matrix AA(epoData->sizeAll(), numPar);
|
---|
1488 | QMapIterator<QString, t_satData*> it(epoData->satData);
|
---|
1489 | while (it.hasNext()) {
|
---|
1490 | it.next();
|
---|
1491 | t_satData* satData = it.value();
|
---|
1492 | _numSat += 1;
|
---|
1493 | for (unsigned iPar = 0; iPar < numPar; iPar++) {
|
---|
1494 | AA[_numSat-1][iPar] = _params[iPar]->partial(satData, false);
|
---|
1495 | }
|
---|
1496 | }
|
---|
1497 | if (_numSat < 4) {
|
---|
1498 | return;
|
---|
1499 | }
|
---|
1500 | AA = AA.Rows(1, _numSat);
|
---|
1501 | SymmetricMatrix NN; NN << AA.t() * AA;
|
---|
1502 | SymmetricMatrix QQ = NN.i();
|
---|
1503 |
|
---|
1504 | _hDop = sqrt(QQ(1,1) + QQ(2,2));
|
---|
1505 | }
|
---|