1 | /* -------------------------------------------------------------------------
|
---|
2 | * BKG NTRIP Client
|
---|
3 | * -------------------------------------------------------------------------
|
---|
4 | *
|
---|
5 | * Class: bncComb
|
---|
6 | *
|
---|
7 | * Purpose: Combinations of Orbit/Clock Corrections
|
---|
8 | *
|
---|
9 | * Author: L. Mervart
|
---|
10 | *
|
---|
11 | * Created: 22-Jan-2011
|
---|
12 | *
|
---|
13 | * Changes:
|
---|
14 | *
|
---|
15 | * -----------------------------------------------------------------------*/
|
---|
16 |
|
---|
17 | #include <newmatio.h>
|
---|
18 | #include <iomanip>
|
---|
19 | #include <sstream>
|
---|
20 | #include <map>
|
---|
21 |
|
---|
22 | #include "bnccomb.h"
|
---|
23 | #include <combination/bncbiassnx.h>
|
---|
24 | #include "bnccore.h"
|
---|
25 | #include "upload/bncrtnetdecoder.h"
|
---|
26 | #include "bncsettings.h"
|
---|
27 | #include "bncutils.h"
|
---|
28 | #include "bncantex.h"
|
---|
29 | #include "t_prn.h"
|
---|
30 |
|
---|
31 | const double sig0_offAC = 1000.0;
|
---|
32 | const double sig0_offACSat = 100.0;
|
---|
33 | const double sigP_offACSat = 0.01;
|
---|
34 | const double sig0_clkSat = 100.0;
|
---|
35 |
|
---|
36 | const double sigObs = 0.05;
|
---|
37 |
|
---|
38 | using namespace std;
|
---|
39 |
|
---|
40 | // Constructor
|
---|
41 | ////////////////////////////////////////////////////////////////////////////
|
---|
42 | bncComb::cmbParam::cmbParam(parType type_, int index_, const QString& ac_, const QString& prn_) {
|
---|
43 |
|
---|
44 | type = type_;
|
---|
45 | index = index_;
|
---|
46 | AC = ac_;
|
---|
47 | prn = prn_;
|
---|
48 | xx = 0.0;
|
---|
49 | eph = 0;
|
---|
50 |
|
---|
51 | if (type == offACgnss) {
|
---|
52 | epoSpec = true;
|
---|
53 | sig0 = sig0_offAC;
|
---|
54 | sigP = sig0;
|
---|
55 | }
|
---|
56 | else if (type == offACSat) {
|
---|
57 | epoSpec = false;
|
---|
58 | sig0 = sig0_offACSat;
|
---|
59 | sigP = sigP_offACSat;
|
---|
60 | }
|
---|
61 | else if (type == clkSat) {
|
---|
62 | epoSpec = true;
|
---|
63 | sig0 = sig0_clkSat;
|
---|
64 | sigP = sig0;
|
---|
65 | }
|
---|
66 | }
|
---|
67 |
|
---|
68 | // Destructor
|
---|
69 | ////////////////////////////////////////////////////////////////////////////
|
---|
70 | bncComb::cmbParam::~cmbParam() {
|
---|
71 | }
|
---|
72 |
|
---|
73 | // Partial
|
---|
74 | ////////////////////////////////////////////////////////////////////////////
|
---|
75 | double bncComb::cmbParam::partial(char sys, const QString& AC_, const QString& prn_) {
|
---|
76 |
|
---|
77 | if (type == offACgnss) {
|
---|
78 | if (AC == AC_ && prn_[0].toLatin1() == sys) {
|
---|
79 | return 1.0;
|
---|
80 | }
|
---|
81 | }
|
---|
82 | else if (type == offACSat) {
|
---|
83 | if (AC == AC_ && prn == prn_) {
|
---|
84 | return 1.0;
|
---|
85 | }
|
---|
86 | }
|
---|
87 | else if (type == clkSat) {
|
---|
88 | if (prn == prn_) {
|
---|
89 | return 1.0;
|
---|
90 | }
|
---|
91 | }
|
---|
92 |
|
---|
93 | return 0.0;
|
---|
94 | }
|
---|
95 |
|
---|
96 | //
|
---|
97 | ////////////////////////////////////////////////////////////////////////////
|
---|
98 | QString bncComb::cmbParam::toString(char sys) const {
|
---|
99 |
|
---|
100 | QString outStr;
|
---|
101 |
|
---|
102 | if (type == offACgnss) {
|
---|
103 | outStr = "AC Offset " + AC + " " + sys + " ";
|
---|
104 | }
|
---|
105 | else if (type == offACSat) {
|
---|
106 | outStr = "Sat Offset " + AC + " " + prn.mid(0,3);
|
---|
107 | }
|
---|
108 | else if (type == clkSat) {
|
---|
109 | outStr = "Clk Corr " + prn.mid(0,3);
|
---|
110 | }
|
---|
111 |
|
---|
112 | return outStr;
|
---|
113 | }
|
---|
114 |
|
---|
115 | // Singleton: definition class variable
|
---|
116 | ////////////////////////////////////////////////////////////////////////////
|
---|
117 | bncComb* bncComb::instance = nullptr;
|
---|
118 |
|
---|
119 |
|
---|
120 | // Constructor
|
---|
121 | ////////////////////////////////////////////////////////////////////////////
|
---|
122 | bncComb::bncComb() : _ephUser(true) {
|
---|
123 |
|
---|
124 | bncSettings settings;
|
---|
125 |
|
---|
126 | QStringList cmbStreams = settings.value("cmbStreams").toStringList();
|
---|
127 |
|
---|
128 | _cmbSampl = settings.value("cmbSampl").toInt();
|
---|
129 | if (_cmbSampl <= 0) {
|
---|
130 | _cmbSampl = 5;
|
---|
131 | }
|
---|
132 | _useGps = (Qt::CheckState(settings.value("cmbGps").toInt()) == Qt::Checked) ? true : false;
|
---|
133 | if (_useGps) {
|
---|
134 | _cmbSysPrn['G'] = t_prn::MAXPRN_GPS;
|
---|
135 | _masterMissingEpochs['G'] = 0;
|
---|
136 | }
|
---|
137 | _useGlo = (Qt::CheckState(settings.value("cmbGlo").toInt()) == Qt::Checked) ? true : false;
|
---|
138 | if (_useGlo) {
|
---|
139 | _cmbSysPrn['R'] = t_prn::MAXPRN_GLONASS;
|
---|
140 | _masterMissingEpochs['R'] = 0;
|
---|
141 | }
|
---|
142 | _useGal = (Qt::CheckState(settings.value("cmbGal").toInt()) == Qt::Checked) ? true : false;
|
---|
143 | if (_useGal) {
|
---|
144 | _cmbSysPrn['E'] = t_prn::MAXPRN_GALILEO;
|
---|
145 | _masterMissingEpochs['E'] = 0;
|
---|
146 | }
|
---|
147 | _useBds = (Qt::CheckState(settings.value("cmbBds").toInt()) == Qt::Checked) ? true : false;
|
---|
148 | if (_useBds) {
|
---|
149 | _cmbSysPrn['C'] = t_prn::MAXPRN_BDS;
|
---|
150 | _masterMissingEpochs['C'] = 0;
|
---|
151 | }
|
---|
152 | _useQzss = (Qt::CheckState(settings.value("cmbQzss").toInt()) == Qt::Checked) ? true : false;
|
---|
153 | if (_useQzss) {
|
---|
154 | _cmbSysPrn['J'] = t_prn::MAXPRN_QZSS;
|
---|
155 | _masterMissingEpochs['J'] = 0;
|
---|
156 | }
|
---|
157 | _useSbas = (Qt::CheckState(settings.value("cmbSbas").toInt()) == Qt::Checked) ? true : false;
|
---|
158 | if (_useSbas) {
|
---|
159 | _cmbSysPrn['S'] = t_prn::MAXPRN_SBAS;
|
---|
160 | _masterMissingEpochs['S'] = 0;
|
---|
161 | }
|
---|
162 | _useIrnss = (Qt::CheckState(settings.value("cmbIrnss").toInt()) == Qt::Checked) ? true : false;
|
---|
163 | if (_useIrnss) {
|
---|
164 | _cmbSysPrn['I'] = t_prn::MAXPRN_IRNSS;
|
---|
165 | _masterMissingEpochs['I'] = 0;
|
---|
166 | }
|
---|
167 |
|
---|
168 | if (cmbStreams.size() >= 1 && !cmbStreams[0].isEmpty()) {
|
---|
169 | QListIterator<QString> it(cmbStreams);
|
---|
170 | while (it.hasNext()) {
|
---|
171 | QStringList hlp = it.next().split(" ");
|
---|
172 | cmbAC* newAC = new cmbAC();
|
---|
173 | newAC->mountPoint = hlp[0];
|
---|
174 | newAC->name = hlp[1];
|
---|
175 | newAC->weightFactor = hlp[2].toDouble();
|
---|
176 | newAC->isAPC = (newAC->mountPoint.mid(0,4) =="SSRA");
|
---|
177 | QMapIterator<char, unsigned> itSys(_cmbSysPrn);
|
---|
178 | // init
|
---|
179 | while (itSys.hasNext()) {
|
---|
180 | itSys.next();
|
---|
181 | char sys = itSys.key();
|
---|
182 | if (!_masterOrbitAC.contains(sys)) {
|
---|
183 | _masterOrbitAC[sys] = newAC->name;
|
---|
184 | _masterIsAPC[sys] = newAC->isAPC;
|
---|
185 | }
|
---|
186 | }
|
---|
187 | _ACs.append(newAC);
|
---|
188 | }
|
---|
189 | }
|
---|
190 |
|
---|
191 | QString ssrFormat;
|
---|
192 | _ssrCorr = 0;
|
---|
193 | QListIterator<QString> it(settings.value("uploadMountpointsOut").toStringList());
|
---|
194 | while (it.hasNext()) {
|
---|
195 | QStringList hlp = it.next().split(",");
|
---|
196 | if (hlp.size() > 7) {
|
---|
197 | ssrFormat = hlp[7];
|
---|
198 | }
|
---|
199 | }
|
---|
200 | if (ssrFormat == "IGS-SSR") {
|
---|
201 | _ssrCorr = new SsrCorrIgs();
|
---|
202 | }
|
---|
203 | else if (ssrFormat == "RTCM-SSR") {
|
---|
204 | _ssrCorr = new SsrCorrRtcm();
|
---|
205 | }
|
---|
206 | else { // default
|
---|
207 | _ssrCorr = new SsrCorrIgs();
|
---|
208 | }
|
---|
209 |
|
---|
210 | _rtnetDecoder = 0;
|
---|
211 |
|
---|
212 | connect(this, SIGNAL(newMessage(QByteArray,bool)), BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
|
---|
213 | connect(BNC_CORE, SIGNAL(providerIDChanged(QString)), this, SLOT(slotProviderIDChanged(QString)));
|
---|
214 | connect(BNC_CORE, SIGNAL(newOrbCorrections(QList<t_orbCorr>)), this, SLOT(slotNewOrbCorrections(QList<t_orbCorr>)));
|
---|
215 | connect(BNC_CORE, SIGNAL(newClkCorrections(QList<t_clkCorr>)), this, SLOT(slotNewClkCorrections(QList<t_clkCorr>)));
|
---|
216 | connect(BNC_CORE, SIGNAL(newCodeBiases(QList<t_satCodeBias>)), this, SLOT(slotNewCodeBiases(QList<t_satCodeBias>)));
|
---|
217 |
|
---|
218 | // Combination Method
|
---|
219 | // ------------------
|
---|
220 | if (settings.value("cmbMethod").toString() == "Single-Epoch") {
|
---|
221 | _method = singleEpoch;
|
---|
222 | }
|
---|
223 | else {
|
---|
224 | _method = filter;
|
---|
225 | }
|
---|
226 |
|
---|
227 | // Initialize Parameters (model: Clk_Corr = AC_Offset + Sat_Offset + Clk)
|
---|
228 | // ----------------------------------------------------------------------
|
---|
229 | if (_method == filter) {
|
---|
230 | // SYSTEM
|
---|
231 | QMapIterator<char, unsigned> itSys(_cmbSysPrn);
|
---|
232 | while (itSys.hasNext()) {
|
---|
233 | itSys.next();
|
---|
234 | int nextPar = 0;
|
---|
235 | char sys = itSys.key();
|
---|
236 | unsigned maxPrn = itSys.value();
|
---|
237 | unsigned flag = 0;
|
---|
238 | if (sys == 'E') {
|
---|
239 | flag = 1;
|
---|
240 | }
|
---|
241 | // AC
|
---|
242 | QListIterator<cmbAC*> itAc(_ACs);
|
---|
243 | while (itAc.hasNext()) {
|
---|
244 | cmbAC* AC = itAc.next();
|
---|
245 | _params[sys].push_back(new cmbParam(cmbParam::offACgnss, ++nextPar, AC->name, ""));
|
---|
246 | for (unsigned iGnss = 1; iGnss <= maxPrn; iGnss++) {
|
---|
247 | QString prn = QString("%1%2_%3").arg(sys).arg(iGnss, 2, 10, QChar('0')).arg(flag);
|
---|
248 | _params[sys].push_back(new cmbParam(cmbParam::offACSat, ++nextPar, AC->name, prn));
|
---|
249 | }
|
---|
250 | }
|
---|
251 | for (unsigned iGnss = 1; iGnss <= maxPrn; iGnss++) {
|
---|
252 | QString prn = QString("%1%2_%3").arg(sys).arg(iGnss, 2, 10, QChar('0')).arg(flag);
|
---|
253 | _params[sys].push_back(new cmbParam(cmbParam::clkSat, ++nextPar, "", prn));
|
---|
254 | }
|
---|
255 | // Initialize Variance-Covariance Matrix
|
---|
256 | // -------------------------------------
|
---|
257 | _QQ[sys].ReSize(_params[sys].size());
|
---|
258 | _QQ[sys] = 0.0;
|
---|
259 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
260 | cmbParam* pp = _params[sys][iPar-1];
|
---|
261 | _QQ[sys](iPar,iPar) = pp->sig0 * pp->sig0;
|
---|
262 | }
|
---|
263 | }
|
---|
264 | }
|
---|
265 |
|
---|
266 | // ANTEX File
|
---|
267 | // ----------
|
---|
268 | _antex = 0;
|
---|
269 | QString antexFileName = settings.value("uploadAntexFile").toString();
|
---|
270 | if (!antexFileName.isEmpty()) {
|
---|
271 | _antex = new bncAntex();
|
---|
272 | if (_antex->readFile(antexFileName) != success) {
|
---|
273 | emit newMessage("bncCmb: wrong ANTEX file", true);
|
---|
274 | delete _antex;
|
---|
275 | _antex = 0;
|
---|
276 | }
|
---|
277 | }
|
---|
278 |
|
---|
279 |
|
---|
280 | // Bias SINEX File
|
---|
281 | // ---------------
|
---|
282 | _bsx = 0;
|
---|
283 | QString bsxFileName = settings.value("cmbBsxFile").toString();
|
---|
284 | if (!bsxFileName.isEmpty()) {
|
---|
285 | _bsx = new bncBiasSnx();
|
---|
286 | if (_bsx->readFile(bsxFileName) != success) {
|
---|
287 | emit newMessage("bncComb: wrong Bias SINEX file", true);
|
---|
288 | delete _bsx;
|
---|
289 | _bsx = 0;
|
---|
290 | }
|
---|
291 | }
|
---|
292 | if (_bsx) {
|
---|
293 | _ms = 6.0 * 3600 * 1000.0;
|
---|
294 | QTimer::singleShot(_ms, this, SLOT(slotReadBiasSnxFile()));
|
---|
295 | }
|
---|
296 |
|
---|
297 |
|
---|
298 | // Maximal Residuum
|
---|
299 | // ----------------
|
---|
300 | _MAXRES = settings.value("cmbMaxres").toDouble();
|
---|
301 | if (_MAXRES <= 0.0) {
|
---|
302 | _MAXRES = 999.0;
|
---|
303 | }
|
---|
304 | }
|
---|
305 |
|
---|
306 | // Destructor
|
---|
307 | ////////////////////////////////////////////////////////////////////////////
|
---|
308 | bncComb::~bncComb() {
|
---|
309 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
310 | while (icAC.hasNext()) {
|
---|
311 | delete icAC.next();
|
---|
312 | }
|
---|
313 | delete _rtnetDecoder;
|
---|
314 | if (_ssrCorr) {
|
---|
315 | delete _ssrCorr;
|
---|
316 | }
|
---|
317 | delete _antex;
|
---|
318 | delete _bsx;
|
---|
319 |
|
---|
320 | QMapIterator<char, unsigned> itSys(_cmbSysPrn);
|
---|
321 | while (itSys.hasNext()) {
|
---|
322 | itSys.next();
|
---|
323 | char sys = itSys.key();
|
---|
324 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
325 | delete _params[sys][iPar-1];
|
---|
326 | }
|
---|
327 | _buffer.remove(sys);
|
---|
328 | }
|
---|
329 | while (!_epoClkData.empty()) {
|
---|
330 | delete _epoClkData.front();
|
---|
331 | _epoClkData.pop_front();
|
---|
332 | }
|
---|
333 | }
|
---|
334 |
|
---|
335 | void bncComb::slotReadBiasSnxFile() {
|
---|
336 | bncSettings settings;
|
---|
337 | QString bsxFileName = settings.value("cmbBsxFile").toString();
|
---|
338 |
|
---|
339 | if (bsxFileName.isEmpty()) {
|
---|
340 | emit newMessage("bncComb: no Bias SINEX file specified", true);
|
---|
341 | return;
|
---|
342 | }
|
---|
343 | if (!_bsx) {
|
---|
344 | _bsx = new bncBiasSnx();
|
---|
345 | }
|
---|
346 | if (_bsx->readFile(bsxFileName) != success) {
|
---|
347 | emit newMessage("bncComb: wrong Bias SINEX file", true);
|
---|
348 | delete _bsx;
|
---|
349 | _bsx = 0;
|
---|
350 | }
|
---|
351 | else {
|
---|
352 | emit newMessage("bncComb: successfully read Bias SINEX file", true);
|
---|
353 | }
|
---|
354 |
|
---|
355 | QTimer::singleShot(_ms, this, SLOT(slotReadBiasSnxFile()));
|
---|
356 | }
|
---|
357 |
|
---|
358 |
|
---|
359 | // Remember orbit corrections
|
---|
360 | ////////////////////////////////////////////////////////////////////////////
|
---|
361 | void bncComb::slotNewOrbCorrections(QList<t_orbCorr> orbCorrections) {
|
---|
362 | QMutexLocker locker(&_mutex);
|
---|
363 |
|
---|
364 | for (int ii = 0; ii < orbCorrections.size(); ii++) {
|
---|
365 | t_orbCorr& orbCorr = orbCorrections[ii];
|
---|
366 | QString staID(orbCorr._staID.c_str());
|
---|
367 | char sys = orbCorr._prn.system();
|
---|
368 |
|
---|
369 | if (!_cmbSysPrn.contains(sys)){
|
---|
370 | continue;
|
---|
371 | }
|
---|
372 |
|
---|
373 | // Find/Check the AC Name
|
---|
374 | // ----------------------
|
---|
375 | QString acName;
|
---|
376 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
377 | while (icAC.hasNext()) {
|
---|
378 | cmbAC* AC = icAC.next();
|
---|
379 | if (AC->mountPoint == staID) {
|
---|
380 | acName = AC->name;
|
---|
381 | break;
|
---|
382 | }
|
---|
383 | }
|
---|
384 | if (acName.isEmpty()) {
|
---|
385 | continue;
|
---|
386 | }
|
---|
387 |
|
---|
388 | // Store the correction
|
---|
389 | // --------------------
|
---|
390 | QMap<t_prn, t_orbCorr*>& storage = _orbCorrections[acName];
|
---|
391 | if (storage[orbCorr._prn]) {
|
---|
392 | delete storage[orbCorr._prn];
|
---|
393 | }
|
---|
394 | storage[orbCorr._prn] = new t_orbCorr(orbCorr);
|
---|
395 | }
|
---|
396 | }
|
---|
397 |
|
---|
398 | // Remember Satellite Code Biases
|
---|
399 | ////////////////////////////////////////////////////////////////////////////
|
---|
400 | void bncComb::slotNewCodeBiases(QList<t_satCodeBias> satCodeBiases) {
|
---|
401 | QMutexLocker locker(&_mutex);
|
---|
402 |
|
---|
403 | for (int ii = 0; ii < satCodeBiases.size(); ii++) {
|
---|
404 | t_satCodeBias& satCodeBias = satCodeBiases[ii];
|
---|
405 | QString staID(satCodeBias._staID.c_str());
|
---|
406 | char sys = satCodeBias._prn.system();
|
---|
407 |
|
---|
408 | if (!_cmbSysPrn.contains(sys)){
|
---|
409 | continue;
|
---|
410 | }
|
---|
411 |
|
---|
412 | // Find/Check the AC Name
|
---|
413 | // ----------------------
|
---|
414 | QString acName;
|
---|
415 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
416 | while (icAC.hasNext()) {
|
---|
417 | cmbAC* AC = icAC.next();
|
---|
418 | if (AC->mountPoint == staID) {
|
---|
419 | acName = AC->name;
|
---|
420 | break;
|
---|
421 | }
|
---|
422 | }
|
---|
423 | if (acName.isEmpty()) {
|
---|
424 | continue;
|
---|
425 | }
|
---|
426 |
|
---|
427 | // Store the correction
|
---|
428 | // --------------------
|
---|
429 | QMap<t_prn, t_satCodeBias*>& storage = _satCodeBiases[acName];
|
---|
430 | if (storage[satCodeBias._prn]) {
|
---|
431 | delete storage[satCodeBias._prn];
|
---|
432 | }
|
---|
433 | storage[satCodeBias._prn] = new t_satCodeBias(satCodeBias);
|
---|
434 | }
|
---|
435 | }
|
---|
436 |
|
---|
437 | // Process clock corrections
|
---|
438 | ////////////////////////////////////////////////////////////////////////////
|
---|
439 | void bncComb::slotNewClkCorrections(QList<t_clkCorr> clkCorrections) {
|
---|
440 | QMutexLocker locker(&_mutex);
|
---|
441 | const double outWait = 1.0 * _cmbSampl;
|
---|
442 | int currentWeek = 0;
|
---|
443 | double currentSec = 0.0;
|
---|
444 | currentGPSWeeks(currentWeek, currentSec);
|
---|
445 | bncTime currentTime(currentWeek, currentSec);
|
---|
446 |
|
---|
447 | // Loop over all observations (possible different epochs)
|
---|
448 | // -----------------------------------------------------
|
---|
449 | for (int ii = 0; ii < clkCorrections.size(); ii++) {
|
---|
450 | t_clkCorr* newClk = new t_clkCorr(clkCorrections[ii]);
|
---|
451 |
|
---|
452 | char sys = newClk->_prn.system();
|
---|
453 | if (!_cmbSysPrn.contains(sys)){
|
---|
454 | delete newClk;
|
---|
455 | continue;
|
---|
456 | }
|
---|
457 |
|
---|
458 | // Check Modulo Time
|
---|
459 | // -----------------
|
---|
460 | int sec = int(nint(newClk->_time.gpssec()*10));
|
---|
461 | if (sec % (_cmbSampl*10) != 0.0) {
|
---|
462 | delete newClk;
|
---|
463 | continue;
|
---|
464 | }
|
---|
465 |
|
---|
466 | // Find/Check the AC Name
|
---|
467 | // ----------------------
|
---|
468 | QString acName;
|
---|
469 | bool isAPC;
|
---|
470 | QString staID(newClk->_staID.c_str());
|
---|
471 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
472 | while (icAC.hasNext()) {
|
---|
473 | cmbAC* AC = icAC.next();
|
---|
474 | if (AC->mountPoint == staID) {
|
---|
475 | acName = AC->name;
|
---|
476 | isAPC = AC->isAPC;
|
---|
477 | break;
|
---|
478 | }
|
---|
479 | }
|
---|
480 | if (acName.isEmpty() || isAPC != _masterIsAPC[sys]) {
|
---|
481 | delete newClk;
|
---|
482 | continue;
|
---|
483 | }
|
---|
484 |
|
---|
485 | // Check regarding current time
|
---|
486 | // ----------------------------
|
---|
487 | if (BNC_CORE->mode() != t_bncCore::batchPostProcessing) {
|
---|
488 | if ((newClk->_time >= currentTime) || // future time stamp
|
---|
489 | (currentTime - newClk->_time) > 60.0) { // very old data sets
|
---|
490 | #ifdef BNC_DEBUG_CMB
|
---|
491 | emit newMessage("bncComb: very old data sets: " + acName.toLatin1() + " " + newClk->_prn.toString().c_str() +
|
---|
492 | QString(" %1 ").arg(newClk->_time.timestr().c_str()).toLatin1() + "vs. current time" +
|
---|
493 | QString(" %1 ").arg(currentTime.timestr().c_str()).toLatin1(), true);
|
---|
494 | #endif
|
---|
495 | delete newClk;
|
---|
496 | continue;
|
---|
497 | }
|
---|
498 | }
|
---|
499 |
|
---|
500 | // Check Correction Age
|
---|
501 | // --------------------
|
---|
502 | if (_resTime.valid() && newClk->_time <= _resTime) {
|
---|
503 | #ifdef BNC_DEBUG_CMB
|
---|
504 | emit newMessage("bncComb: old correction: " + acName.toLatin1() + " " + newClk->_prn.toString().c_str() +
|
---|
505 | QString(" %1 ").arg(newClk->_time.timestr().c_str()).toLatin1() + "vs. last processing Epoch" +
|
---|
506 | QString(" %1 ").arg(_resTime.timestr().c_str()).toLatin1(), true);
|
---|
507 | #endif
|
---|
508 | delete newClk;
|
---|
509 | continue;
|
---|
510 | }
|
---|
511 |
|
---|
512 | // Set the last time
|
---|
513 | // -----------------
|
---|
514 | if (_lastClkCorrTime.undef() || newClk->_time > _lastClkCorrTime) {
|
---|
515 | _lastClkCorrTime = newClk->_time;
|
---|
516 | }
|
---|
517 |
|
---|
518 | // Find the corresponding data epoch or create a new one
|
---|
519 | // -----------------------------------------------------
|
---|
520 | epoClkData* epoch = 0;
|
---|
521 | deque<epoClkData*>::const_iterator it;
|
---|
522 | for (it = _epoClkData.begin(); it != _epoClkData.end(); it++) {
|
---|
523 | if (newClk->_time == (*it)->_time) {
|
---|
524 | epoch = *it;
|
---|
525 | break;
|
---|
526 | }
|
---|
527 | }
|
---|
528 | if (epoch == 0) {
|
---|
529 | if (_epoClkData.empty() || newClk->_time > _epoClkData.back()->_time) {
|
---|
530 | epoch = new epoClkData;
|
---|
531 | epoch->_time = newClk->_time;
|
---|
532 | _epoClkData.push_back(epoch);
|
---|
533 | }
|
---|
534 | }
|
---|
535 |
|
---|
536 | // Put data into the epoch
|
---|
537 | // -----------------------
|
---|
538 | if (epoch != 0) {
|
---|
539 | epoch->_clkCorr.push_back(newClk);
|
---|
540 | }
|
---|
541 | else {
|
---|
542 | delete newClk;
|
---|
543 | }
|
---|
544 | }
|
---|
545 |
|
---|
546 | // Make sure the buffer does not grow beyond any limit
|
---|
547 | // ---------------------------------------------------
|
---|
548 | const unsigned MAX_EPODATA_SIZE = 12;
|
---|
549 | if (_epoClkData.size() > MAX_EPODATA_SIZE) {
|
---|
550 | delete _epoClkData.front();
|
---|
551 | _epoClkData.pop_front();
|
---|
552 | }
|
---|
553 |
|
---|
554 | // Process the oldest epochs
|
---|
555 | // ------------------------
|
---|
556 | while (_epoClkData.size()) {
|
---|
557 |
|
---|
558 | if (!_lastClkCorrTime.valid()) {
|
---|
559 | return;
|
---|
560 | }
|
---|
561 |
|
---|
562 | const vector<t_clkCorr*>& clkCorrVec = _epoClkData.front()->_clkCorr;
|
---|
563 |
|
---|
564 | bncTime epoTime = _epoClkData.front()->_time;
|
---|
565 |
|
---|
566 | if ((currentTime - epoTime) > 60.0) {
|
---|
567 | delete _epoClkData.front();
|
---|
568 | _epoClkData.pop_front();
|
---|
569 | continue;
|
---|
570 | }
|
---|
571 |
|
---|
572 | // Process the front epoch
|
---|
573 | // -----------------------
|
---|
574 | if (epoTime < (_lastClkCorrTime - outWait)) {
|
---|
575 | _resTime = epoTime;
|
---|
576 | processEpoch(_resTime, clkCorrVec);
|
---|
577 | delete _epoClkData.front();
|
---|
578 | _epoClkData.pop_front();
|
---|
579 | }
|
---|
580 | else {
|
---|
581 | return;
|
---|
582 | }
|
---|
583 | }
|
---|
584 | }
|
---|
585 |
|
---|
586 | // Change the correction so that it refers to last received ephemeris
|
---|
587 | ////////////////////////////////////////////////////////////////////////////
|
---|
588 | void bncComb::switchToLastEph(t_eph* lastEph, cmbCorr* corr) {
|
---|
589 |
|
---|
590 | if (corr->_eph == lastEph) {
|
---|
591 | return;
|
---|
592 | }
|
---|
593 |
|
---|
594 | ColumnVector oldXC(6);
|
---|
595 | ColumnVector oldVV(3);
|
---|
596 | if (corr->_eph->getCrd(corr->_time, oldXC, oldVV, false) != success) {
|
---|
597 | return;
|
---|
598 | }
|
---|
599 |
|
---|
600 | ColumnVector newXC(6);
|
---|
601 | ColumnVector newVV(3);
|
---|
602 | if (lastEph->getCrd(corr->_time, newXC, newVV, false) != success) {
|
---|
603 | return;
|
---|
604 | }
|
---|
605 |
|
---|
606 | ColumnVector dX = newXC.Rows(1,3) - oldXC.Rows(1,3);
|
---|
607 | ColumnVector dV = newVV - oldVV;
|
---|
608 | double dC = newXC(4) - oldXC(4);
|
---|
609 |
|
---|
610 | ColumnVector dRAO(3);
|
---|
611 | XYZ_to_RSW(newXC.Rows(1,3), newVV, dX, dRAO);
|
---|
612 |
|
---|
613 | ColumnVector dDotRAO(3);
|
---|
614 | XYZ_to_RSW(newXC.Rows(1,3), newVV, dV, dDotRAO);
|
---|
615 |
|
---|
616 | QString msg = "switch corr " + corr->_prn.mid(0,3)
|
---|
617 | + QString(" %1 -> %2 %3").arg(corr->_iod,3).arg(lastEph->IOD(),3).arg(dC*t_CST::c, 8, 'f', 4);
|
---|
618 |
|
---|
619 | emit newMessage(msg.toLatin1(), false);
|
---|
620 |
|
---|
621 | corr->_iod = lastEph->IOD();
|
---|
622 | corr->_eph = lastEph;
|
---|
623 |
|
---|
624 | corr->_orbCorr->_xr += dRAO;
|
---|
625 | corr->_orbCorr->_dotXr += dDotRAO;
|
---|
626 | corr->_clkCorr->_dClk -= dC;
|
---|
627 | }
|
---|
628 |
|
---|
629 | // Process Epoch
|
---|
630 | ////////////////////////////////////////////////////////////////////////////
|
---|
631 | void bncComb::processEpoch(bncTime epoTime, const vector<t_clkCorr*>& clkCorrVec) {
|
---|
632 |
|
---|
633 | for (unsigned ii = 0; ii < clkCorrVec.size(); ii++) {
|
---|
634 | const t_clkCorr* clkCorr = clkCorrVec.at(ii);
|
---|
635 | QString staID(clkCorr->_staID.c_str());
|
---|
636 | QString prn(clkCorr->_prn.toInternalString().c_str());
|
---|
637 | char sys = clkCorr->_prn.system();
|
---|
638 |
|
---|
639 | // Find/Check the AC Name
|
---|
640 | // ----------------------
|
---|
641 | QString acName;
|
---|
642 | double weigthFactor;
|
---|
643 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
644 | while (icAC.hasNext()) {
|
---|
645 | cmbAC* AC = icAC.next();
|
---|
646 | if (AC->mountPoint == staID) {
|
---|
647 | acName = AC->name;
|
---|
648 | weigthFactor = AC->weightFactor;
|
---|
649 | break;
|
---|
650 | }
|
---|
651 | }
|
---|
652 |
|
---|
653 | // Create new correction
|
---|
654 | // ---------------------
|
---|
655 | cmbCorr* newCorr = new cmbCorr();
|
---|
656 | newCorr->_prn = prn;
|
---|
657 | newCorr->_time = clkCorr->_time;
|
---|
658 | newCorr->_iod = clkCorr->_iod;
|
---|
659 | newCorr->_acName = acName;
|
---|
660 | newCorr->_weightFactor = weigthFactor;
|
---|
661 | newCorr->_clkCorr = new t_clkCorr(*clkCorrVec[ii]);
|
---|
662 |
|
---|
663 | // Check orbit correction
|
---|
664 | // ----------------------
|
---|
665 | if (!_orbCorrections.contains(acName)) {
|
---|
666 | delete newCorr;
|
---|
667 | continue;
|
---|
668 | }
|
---|
669 | else {
|
---|
670 | QMap<t_prn, t_orbCorr*>& storage = _orbCorrections[acName];
|
---|
671 | if (!storage.contains(clkCorr->_prn) ||
|
---|
672 | storage[clkCorr->_prn]->_iod != newCorr->_iod) {
|
---|
673 | delete newCorr;
|
---|
674 | continue;
|
---|
675 | }
|
---|
676 | else {
|
---|
677 | newCorr->_orbCorr = storage[clkCorr->_prn];
|
---|
678 | }
|
---|
679 | }
|
---|
680 |
|
---|
681 | // Check the Ephemeris
|
---|
682 | //--------------------
|
---|
683 | t_eph* ephLast = _ephUser.ephLast(prn);
|
---|
684 | t_eph* ephPrev = _ephUser.ephPrev(prn);
|
---|
685 | if (ephLast == 0) {
|
---|
686 | #ifdef BNC_DEBUG_CMB
|
---|
687 | emit newMessage("bncComb: eph not found for " + prn.mid(0,3).toLatin1(), true);
|
---|
688 | #endif
|
---|
689 | delete newCorr;
|
---|
690 | continue;
|
---|
691 | }
|
---|
692 | else if (ephLast->checkState() == t_eph::bad ||
|
---|
693 | ephLast->checkState() == t_eph::outdated ||
|
---|
694 | ephLast->checkState() == t_eph::unhealthy) {
|
---|
695 | #ifdef BNC_DEBUG_CMB
|
---|
696 | emit newMessage("bncComb: ephLast not ok (checkState: " + ephLast->checkStateToString().toLatin1() + ") for " + prn.mid(0,3).toLatin1(), true);
|
---|
697 | #endif
|
---|
698 | delete newCorr;
|
---|
699 | continue;
|
---|
700 | }
|
---|
701 | else {
|
---|
702 | if (ephLast->IOD() == newCorr->_iod) {
|
---|
703 | newCorr->_eph = ephLast;
|
---|
704 | }
|
---|
705 | else if (ephPrev && ephPrev->checkState() == t_eph::ok &&
|
---|
706 | ephPrev->IOD() == newCorr->_iod) {
|
---|
707 | newCorr->_eph = ephPrev;
|
---|
708 | switchToLastEph(ephLast, newCorr);
|
---|
709 | }
|
---|
710 | else {
|
---|
711 | #ifdef BNC_DEBUG_CMB
|
---|
712 | emit newMessage("bncComb: eph not found for " + prn.mid(0,3).toLatin1() +
|
---|
713 | QString(" with IOD %1").arg(newCorr->_iod).toLatin1(), true);
|
---|
714 | #endif
|
---|
715 | delete newCorr;
|
---|
716 | continue;
|
---|
717 | }
|
---|
718 | }
|
---|
719 |
|
---|
720 | // Check satellite code biases
|
---|
721 | // ----------------------------
|
---|
722 | if (_satCodeBiases.contains(acName)) {
|
---|
723 | QMap<t_prn, t_satCodeBias*>& storage = _satCodeBiases[acName];
|
---|
724 | if (storage.contains(clkCorr->_prn)) {
|
---|
725 | newCorr->_satCodeBias = storage[clkCorr->_prn];
|
---|
726 | QMap<t_frequency::type, double> codeBiasesRefSig;
|
---|
727 | for (unsigned ii = 1; ii < cmbRefSig::cIF; ii++) {
|
---|
728 | t_frequency::type frqType = cmbRefSig::toFreq(sys, static_cast<cmbRefSig::type>(ii));
|
---|
729 | char frqNum = t_frequency::toString(frqType)[1];
|
---|
730 | char attrib = cmbRefSig::toAttrib(sys, static_cast<cmbRefSig::type>(ii));
|
---|
731 | QString rnxType2ch = QString("%1%2").arg(frqNum).arg(attrib);
|
---|
732 | for (unsigned ii = 0; ii < newCorr->_satCodeBias->_bias.size(); ii++) {
|
---|
733 | const t_frqCodeBias& bias = newCorr->_satCodeBias->_bias[ii];
|
---|
734 | if (rnxType2ch.toStdString() == bias._rnxType2ch) {
|
---|
735 | codeBiasesRefSig[frqType] = bias._value;
|
---|
736 | }
|
---|
737 | }
|
---|
738 | }
|
---|
739 | if (codeBiasesRefSig.size() == 2) {
|
---|
740 | map<t_frequency::type, double> codeCoeff;
|
---|
741 | double channel = double(newCorr->_eph->slotNum());
|
---|
742 | cmbRefSig::coeff(sys, cmbRefSig::cIF, channel, codeCoeff);
|
---|
743 | map<t_frequency::type, double>::const_iterator it;
|
---|
744 | for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {
|
---|
745 | t_frequency::type frqType = it->first;
|
---|
746 | newCorr->_satCodeBiasIF += it->second * codeBiasesRefSig[frqType];
|
---|
747 | }
|
---|
748 | }
|
---|
749 | newCorr->_satCodeBias->_bias.clear();
|
---|
750 | }
|
---|
751 | }
|
---|
752 |
|
---|
753 | // Store correction into the buffer
|
---|
754 | // --------------------------------
|
---|
755 | QVector<cmbCorr*>& corrs = _buffer[sys].corrs;
|
---|
756 |
|
---|
757 | QVectorIterator<cmbCorr*> itCorr(corrs);
|
---|
758 | bool available = false;
|
---|
759 | while (itCorr.hasNext()) {
|
---|
760 | cmbCorr* corr = itCorr.next();
|
---|
761 | QString prn = corr->_prn;
|
---|
762 | QString acName = corr->_acName;
|
---|
763 | if (newCorr->_acName == acName && newCorr->_prn == prn) {
|
---|
764 | available = true;
|
---|
765 | }
|
---|
766 | }
|
---|
767 | if (!available) {
|
---|
768 | corrs.push_back(newCorr);
|
---|
769 | }
|
---|
770 | else {
|
---|
771 | delete newCorr;
|
---|
772 | continue;
|
---|
773 | }
|
---|
774 | }
|
---|
775 |
|
---|
776 | // Process Systems of this Epoch
|
---|
777 | // ------------------------------
|
---|
778 | QMapIterator<char, unsigned> itSys(_cmbSysPrn);
|
---|
779 | while (itSys.hasNext()) {
|
---|
780 | itSys.next();
|
---|
781 | char sys = itSys.key();
|
---|
782 | _log.clear();
|
---|
783 | QTextStream out(&_log, QIODevice::WriteOnly);
|
---|
784 | processSystem(epoTime, sys, out);
|
---|
785 | emit newMessage(_log, false);
|
---|
786 | }
|
---|
787 | }
|
---|
788 |
|
---|
789 | void bncComb::processSystem(bncTime epoTime, char sys, QTextStream& out) {
|
---|
790 |
|
---|
791 | out << "\n" << "Combination: " << sys << "\n"
|
---|
792 | << "--------------------------------" << "\n";
|
---|
793 |
|
---|
794 | // Observation Statistics
|
---|
795 | // ----------------------
|
---|
796 | bool masterPresent = false;
|
---|
797 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
798 | while (icAC.hasNext()) {
|
---|
799 | cmbAC* AC = icAC.next();
|
---|
800 | AC->numObs[sys] = 0;
|
---|
801 | QVectorIterator<cmbCorr*> itCorr(corrs(sys));
|
---|
802 | while (itCorr.hasNext()) {
|
---|
803 | cmbCorr* corr = itCorr.next();
|
---|
804 | if (corr->_acName == AC->name) {
|
---|
805 | AC->numObs[sys] += 1;
|
---|
806 | if (AC->name == _masterOrbitAC[sys]) {
|
---|
807 | masterPresent = true;
|
---|
808 | }
|
---|
809 | }
|
---|
810 | }
|
---|
811 | out << AC->name.toLatin1().data() << ": " << AC->numObs[sys] << "\n";
|
---|
812 | }
|
---|
813 |
|
---|
814 | // If Master not present, switch to another one
|
---|
815 | // --------------------------------------------
|
---|
816 | const unsigned switchMasterAfterGap = 1;
|
---|
817 | if (masterPresent) {
|
---|
818 | _masterMissingEpochs[sys] = 0;
|
---|
819 | }
|
---|
820 | else {
|
---|
821 | ++_masterMissingEpochs[sys];
|
---|
822 | if (_masterMissingEpochs[sys] < switchMasterAfterGap) {
|
---|
823 | out << "Missing Master, Epoch skipped" << "\n";
|
---|
824 | _buffer.remove(sys);
|
---|
825 | emit newMessage(_log, false);
|
---|
826 | return;
|
---|
827 | }
|
---|
828 | else {
|
---|
829 | _masterMissingEpochs[sys] = 0;
|
---|
830 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
831 | while (icAC.hasNext()) {
|
---|
832 | cmbAC* AC = icAC.next();
|
---|
833 | if (AC->numObs[sys] > 0) {
|
---|
834 | out << "Switching Master AC "
|
---|
835 | << _masterOrbitAC[sys].toLatin1().data() << " --> "
|
---|
836 | << AC->name.toLatin1().data() << " "
|
---|
837 | << epoTime.datestr().c_str() << " "
|
---|
838 | << epoTime.timestr().c_str() << "\n";
|
---|
839 | _masterOrbitAC[sys] = AC->name;
|
---|
840 | _masterIsAPC[sys] = AC->isAPC;
|
---|
841 | break;
|
---|
842 | }
|
---|
843 | }
|
---|
844 | }
|
---|
845 | }
|
---|
846 |
|
---|
847 | QMap<QString, cmbCorr*> resCorr;
|
---|
848 |
|
---|
849 | // Perform the actual Combination using selected Method
|
---|
850 | // ----------------------------------------------------
|
---|
851 | t_irc irc;
|
---|
852 | ColumnVector dx;
|
---|
853 | if (_method == filter) {
|
---|
854 | irc = processEpoch_filter(epoTime, sys, out, resCorr, dx);
|
---|
855 | }
|
---|
856 | else {
|
---|
857 | irc = processEpoch_singleEpoch(epoTime, sys, out, resCorr, dx);
|
---|
858 | }
|
---|
859 |
|
---|
860 | // Update Parameter Values, Print Results
|
---|
861 | // --------------------------------------
|
---|
862 | if (irc == success) {
|
---|
863 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
864 | cmbParam* pp = _params[sys][iPar-1];
|
---|
865 | pp->xx += dx(iPar);
|
---|
866 | if (pp->type == cmbParam::clkSat) {
|
---|
867 | if (resCorr.find(pp->prn) != resCorr.end()) {
|
---|
868 | // set clock result
|
---|
869 | resCorr[pp->prn]->_dClkResult = pp->xx / t_CST::c;
|
---|
870 | // Add Code Biases from SINEX File
|
---|
871 | if (_bsx) {
|
---|
872 | map<t_frequency::type, double> codeCoeff;
|
---|
873 | double channel = double(resCorr[pp->prn]->_eph->slotNum());
|
---|
874 | cmbRefSig::coeff(sys, cmbRefSig::cIF, channel, codeCoeff);
|
---|
875 | t_frequency::type fType1 = cmbRefSig::toFreq(sys, cmbRefSig::c1);
|
---|
876 | t_frequency::type fType2 = cmbRefSig::toFreq(sys, cmbRefSig::c2);
|
---|
877 | if (resCorr[pp->prn]->_satCodeBias == 0) {
|
---|
878 | resCorr[pp->prn]->_satCodeBias = new t_satCodeBias();
|
---|
879 | }
|
---|
880 | _bsx->determineSsrSatCodeBiases(pp->prn.mid(0,3), codeCoeff[fType1], codeCoeff[fType2], resCorr[pp->prn]->_satCodeBias);
|
---|
881 | }
|
---|
882 | }
|
---|
883 | }
|
---|
884 | out << epoTime.datestr().c_str() << " "
|
---|
885 | << epoTime.timestr().c_str() << " ";
|
---|
886 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
887 | out.setFieldWidth(8);
|
---|
888 | out.setRealNumberPrecision(4);
|
---|
889 | out << pp->toString(sys) << " "
|
---|
890 | << pp->xx << " +- " << sqrt(_QQ[sys](pp->index,pp->index)) << "\n";
|
---|
891 | out.setFieldWidth(0);
|
---|
892 | }
|
---|
893 | printResults(epoTime, out, resCorr);
|
---|
894 | dumpResults(epoTime, resCorr);
|
---|
895 | }
|
---|
896 | // Delete Data
|
---|
897 | // -----------
|
---|
898 | _buffer.remove(sys);
|
---|
899 | }
|
---|
900 |
|
---|
901 | // Process Epoch - Filter Method
|
---|
902 | ////////////////////////////////////////////////////////////////////////////
|
---|
903 | t_irc bncComb::processEpoch_filter(bncTime epoTime, char sys, QTextStream& out,
|
---|
904 | QMap<QString, cmbCorr*>& resCorr,
|
---|
905 | ColumnVector& dx) {
|
---|
906 |
|
---|
907 | // Prediction Step
|
---|
908 | // ---------------
|
---|
909 | int nPar = _params[sys].size();
|
---|
910 | ColumnVector x0(nPar);
|
---|
911 | for (int iPar = 1; iPar <= nPar; iPar++) {
|
---|
912 | cmbParam* pp = _params[sys][iPar-1];
|
---|
913 | if (pp->epoSpec) {
|
---|
914 | pp->xx = 0.0;
|
---|
915 | _QQ[sys].Row(iPar) = 0.0;
|
---|
916 | _QQ[sys].Column(iPar) = 0.0;
|
---|
917 | _QQ[sys](iPar,iPar) = pp->sig0 * pp->sig0;
|
---|
918 | }
|
---|
919 | else {
|
---|
920 | _QQ[sys](iPar,iPar) += pp->sigP * pp->sigP;
|
---|
921 | }
|
---|
922 | x0(iPar) = pp->xx;
|
---|
923 | }
|
---|
924 |
|
---|
925 | // Check Satellite Positions for Outliers
|
---|
926 | // --------------------------------------
|
---|
927 | if (checkOrbits(epoTime, sys, out) != success) {
|
---|
928 | return failure;
|
---|
929 | }
|
---|
930 |
|
---|
931 | // Update and outlier detection loop
|
---|
932 | // ---------------------------------
|
---|
933 | SymmetricMatrix QQ_sav = _QQ[sys];
|
---|
934 | while (true) {
|
---|
935 |
|
---|
936 | Matrix AA;
|
---|
937 | ColumnVector ll;
|
---|
938 | DiagonalMatrix PP;
|
---|
939 |
|
---|
940 | if (createAmat(sys, AA, ll, PP, x0, resCorr) != success) {
|
---|
941 | return failure;
|
---|
942 | }
|
---|
943 |
|
---|
944 | dx.ReSize(nPar); dx = 0.0;
|
---|
945 | kalman(AA, ll, PP, _QQ[sys], dx);
|
---|
946 |
|
---|
947 | ColumnVector vv = ll - AA * dx;
|
---|
948 |
|
---|
949 | int maxResIndex;
|
---|
950 | double maxRes = vv.maximum_absolute_value1(maxResIndex);
|
---|
951 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
952 | out.setRealNumberPrecision(3);
|
---|
953 | out << epoTime.datestr().c_str() << " " << epoTime.timestr().c_str()
|
---|
954 | << " Maximum Residuum " << maxRes << ' '
|
---|
955 | << corrs(sys)[maxResIndex-1]->_acName << ' ' << corrs(sys)[maxResIndex-1]->_prn.mid(0,3);
|
---|
956 | if (maxRes > _MAXRES) {
|
---|
957 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
958 | cmbParam* pp = _params[sys][iPar-1];
|
---|
959 | if (pp->type == cmbParam::offACSat &&
|
---|
960 | pp->AC == corrs(sys)[maxResIndex-1]->_acName &&
|
---|
961 | pp->prn == corrs(sys)[maxResIndex-1]->_prn.mid(0,3)) {
|
---|
962 | QQ_sav.Row(iPar) = 0.0;
|
---|
963 | QQ_sav.Column(iPar) = 0.0;
|
---|
964 | QQ_sav(iPar,iPar) = pp->sig0 * pp->sig0;
|
---|
965 | }
|
---|
966 | }
|
---|
967 |
|
---|
968 | out << " Outlier" << "\n";
|
---|
969 | _QQ[sys] = QQ_sav;
|
---|
970 | corrs(sys).remove(maxResIndex-1);
|
---|
971 | }
|
---|
972 | else {
|
---|
973 | out << " OK" << "\n";
|
---|
974 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
975 | out.setRealNumberPrecision(4);
|
---|
976 | for (int ii = 0; ii < corrs(sys).size(); ii++) {
|
---|
977 | const cmbCorr* corr = corrs(sys)[ii];
|
---|
978 | out << epoTime.datestr().c_str() << ' '
|
---|
979 | << epoTime.timestr().c_str() << " "
|
---|
980 | << corr->_acName << ' ' << corr->_prn.mid(0,3);
|
---|
981 | out.setFieldWidth(10);
|
---|
982 | out << " res = " << vv[ii] << "\n";
|
---|
983 | out.setFieldWidth(0);
|
---|
984 | }
|
---|
985 | break;
|
---|
986 | }
|
---|
987 | }
|
---|
988 |
|
---|
989 | return success;
|
---|
990 | }
|
---|
991 |
|
---|
992 | // Print results
|
---|
993 | ////////////////////////////////////////////////////////////////////////////
|
---|
994 | void bncComb::printResults(bncTime epoTime, QTextStream& out,
|
---|
995 | const QMap<QString, cmbCorr*>& resCorr) {
|
---|
996 |
|
---|
997 | QMapIterator<QString, cmbCorr*> it(resCorr);
|
---|
998 | while (it.hasNext()) {
|
---|
999 | it.next();
|
---|
1000 | cmbCorr* corr = it.value();
|
---|
1001 | const t_eph* eph = corr->_eph;
|
---|
1002 | if (eph) {
|
---|
1003 | ColumnVector xc(6);
|
---|
1004 | ColumnVector vv(3);
|
---|
1005 | if (eph->getCrd(epoTime, xc, vv, false) != success) {
|
---|
1006 | continue;
|
---|
1007 | }
|
---|
1008 | out << epoTime.datestr().c_str() << " "
|
---|
1009 | << epoTime.timestr().c_str() << " ";
|
---|
1010 | out.setFieldWidth(3);
|
---|
1011 | out << "Full Clock " << corr->_prn.mid(0,3) << " " << corr->_iod << " ";
|
---|
1012 | out.setFieldWidth(14);
|
---|
1013 | out << (xc(4) + corr->_dClkResult) * t_CST::c << "\n";
|
---|
1014 | out.setFieldWidth(0);
|
---|
1015 | }
|
---|
1016 | else {
|
---|
1017 | out << "bncComb::printResults bug" << "\n";
|
---|
1018 | }
|
---|
1019 | out.flush();
|
---|
1020 | }
|
---|
1021 | }
|
---|
1022 |
|
---|
1023 | // Send results to RTNet Decoder and directly to PPP Client
|
---|
1024 | ////////////////////////////////////////////////////////////////////////////
|
---|
1025 | void bncComb::dumpResults(bncTime epoTime, const QMap<QString, cmbCorr*>& resCorr) {
|
---|
1026 |
|
---|
1027 | QList<t_orbCorr> orbCorrections;
|
---|
1028 | QList<t_clkCorr> clkCorrections;
|
---|
1029 | QList<t_satCodeBias> satCodeBiasList;
|
---|
1030 |
|
---|
1031 | unsigned year, month, day, hour, minute;
|
---|
1032 | double sec;
|
---|
1033 | epoTime.civil_date(year, month, day);
|
---|
1034 | epoTime.civil_time(hour, minute, sec);
|
---|
1035 |
|
---|
1036 | QString outLines = QString().asprintf("* %4d %2d %2d %d %d %12.8f\n",
|
---|
1037 | year, month, day, hour, minute, sec);
|
---|
1038 |
|
---|
1039 | QMapIterator<QString, cmbCorr*> it(resCorr);
|
---|
1040 | while (it.hasNext()) {
|
---|
1041 | it.next();
|
---|
1042 | cmbCorr* corr = it.value();
|
---|
1043 |
|
---|
1044 | // ORBIT
|
---|
1045 | t_orbCorr orbCorr(static_cast<t_orbCorr>(*corr->_orbCorr));
|
---|
1046 | orbCorr._staID = "INTERNAL";
|
---|
1047 | orbCorrections.push_back(orbCorr);
|
---|
1048 |
|
---|
1049 | // CLOCK
|
---|
1050 | t_clkCorr clkCorr(static_cast<t_clkCorr>(*corr->_clkCorr));
|
---|
1051 | clkCorr._staID = "INTERNAL";
|
---|
1052 | clkCorr._dClk = corr->_dClkResult;
|
---|
1053 | clkCorr._dotDClk = 0.0;
|
---|
1054 | clkCorr._dotDotDClk = 0.0;
|
---|
1055 | clkCorrections.push_back(clkCorr);
|
---|
1056 |
|
---|
1057 |
|
---|
1058 | ColumnVector xc(6);
|
---|
1059 | ColumnVector vv(3);
|
---|
1060 | corr->_eph->setClkCorr(dynamic_cast<const t_clkCorr*>(&clkCorr));
|
---|
1061 | corr->_eph->setOrbCorr(dynamic_cast<const t_orbCorr*>(&orbCorr));
|
---|
1062 | if (corr->_eph->getCrd(epoTime, xc, vv, true) != success) {
|
---|
1063 | delete corr;
|
---|
1064 | continue;
|
---|
1065 | }
|
---|
1066 |
|
---|
1067 | // Correction Phase Center --> CoM
|
---|
1068 | // -------------------------------
|
---|
1069 |
|
---|
1070 | ColumnVector dx(3); dx = 0.0;
|
---|
1071 | ColumnVector apc(3); apc = 0.0;
|
---|
1072 | ColumnVector com(3); com = 0.0;
|
---|
1073 | bool masterIsAPC = true;
|
---|
1074 | if (_antex) {
|
---|
1075 | double Mjd = epoTime.mjd() + epoTime.daysec()/86400.0;
|
---|
1076 | char sys = corr->_eph->prn().system();
|
---|
1077 | masterIsAPC = _masterIsAPC[sys];
|
---|
1078 | if (_antex->satCoMcorrection(corr->_prn, Mjd, xc.Rows(1,3), dx) != success) {
|
---|
1079 | dx = 0;
|
---|
1080 | _log += "antenna not found " + corr->_prn.mid(0,3).toLatin1() + '\n';
|
---|
1081 | }
|
---|
1082 | }
|
---|
1083 | if (masterIsAPC) {
|
---|
1084 | apc(1) = xc(1);
|
---|
1085 | apc(2) = xc(2);
|
---|
1086 | apc(3) = xc(3);
|
---|
1087 | com(1) = xc(1)-dx(1);
|
---|
1088 | com(2) = xc(2)-dx(2);
|
---|
1089 | com(3) = xc(3)-dx(3);
|
---|
1090 | }
|
---|
1091 | else {
|
---|
1092 | com(1) = xc(1);
|
---|
1093 | com(2) = xc(2);
|
---|
1094 | com(3) = xc(3);
|
---|
1095 | apc(1) = xc(1)+dx(1);
|
---|
1096 | apc(2) = xc(2)+dx(2);
|
---|
1097 | apc(3) = xc(3)+dx(3);
|
---|
1098 | }
|
---|
1099 |
|
---|
1100 | outLines += corr->_prn.mid(0,3);
|
---|
1101 | QString hlp = QString().asprintf(
|
---|
1102 | " APC 3 %15.4f %15.4f %15.4f"
|
---|
1103 | " Clk 1 %15.4f"
|
---|
1104 | " Vel 3 %15.4f %15.4f %15.4f"
|
---|
1105 | " CoM 3 %15.4f %15.4f %15.4f",
|
---|
1106 | apc(1), apc(2), apc(3),
|
---|
1107 | xc(4) * t_CST::c,
|
---|
1108 | vv(1), vv(2), vv(3),
|
---|
1109 | com(1), com(2), com(3));
|
---|
1110 | outLines += hlp;
|
---|
1111 | hlp.clear();
|
---|
1112 |
|
---|
1113 | // CODE BIASES
|
---|
1114 | if (corr->_satCodeBias) {
|
---|
1115 | t_satCodeBias satCodeBias(static_cast<t_satCodeBias>(*corr->_satCodeBias));
|
---|
1116 | satCodeBias._staID = "INTERNAL";
|
---|
1117 | satCodeBiasList.push_back(satCodeBias);
|
---|
1118 | hlp = QString().asprintf(" CodeBias %2lu", satCodeBias._bias.size());
|
---|
1119 | outLines += hlp;
|
---|
1120 | hlp.clear();
|
---|
1121 | for (unsigned ii = 0; ii < satCodeBias._bias.size(); ii++) {
|
---|
1122 | const t_frqCodeBias& frqCodeBias = satCodeBias._bias[ii];
|
---|
1123 | if (!frqCodeBias._rnxType2ch.empty()) {
|
---|
1124 | hlp = QString().asprintf(" %s%10.6f", frqCodeBias._rnxType2ch.c_str(), frqCodeBias._value);
|
---|
1125 | outLines += hlp;
|
---|
1126 | hlp.clear();
|
---|
1127 | }
|
---|
1128 | }
|
---|
1129 | }
|
---|
1130 | outLines += "\n";
|
---|
1131 | delete corr;
|
---|
1132 | }
|
---|
1133 |
|
---|
1134 | outLines += "EOE\n"; // End Of Epoch flag
|
---|
1135 | //cout << outLines.toStdString();
|
---|
1136 |
|
---|
1137 | if (!_rtnetDecoder) {
|
---|
1138 | _rtnetDecoder = new bncRtnetDecoder();
|
---|
1139 | }
|
---|
1140 |
|
---|
1141 | vector<string> errmsg;
|
---|
1142 | _rtnetDecoder->Decode(outLines.toLatin1().data(), outLines.length(), errmsg);
|
---|
1143 |
|
---|
1144 | // Send new Corrections to PPP etc.
|
---|
1145 | // --------------------------------
|
---|
1146 | if (orbCorrections.size() > 0 && clkCorrections.size() > 0) {
|
---|
1147 | emit newOrbCorrections(orbCorrections);
|
---|
1148 | emit newClkCorrections(clkCorrections);
|
---|
1149 | }
|
---|
1150 | if (satCodeBiasList.size()) {
|
---|
1151 | emit newCodeBiases(satCodeBiasList);
|
---|
1152 | }
|
---|
1153 | }
|
---|
1154 |
|
---|
1155 | // Create First Design Matrix and Vector of Measurements
|
---|
1156 | ////////////////////////////////////////////////////////////////////////////
|
---|
1157 | t_irc bncComb::createAmat(char sys, Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP,
|
---|
1158 | const ColumnVector& x0, QMap<QString, cmbCorr*>& resCorr) {
|
---|
1159 |
|
---|
1160 | unsigned nPar = _params[sys].size();
|
---|
1161 | unsigned nObs = corrs(sys).size();
|
---|
1162 |
|
---|
1163 | if (nObs == 0) {
|
---|
1164 | return failure;
|
---|
1165 | }
|
---|
1166 |
|
---|
1167 | int maxSat = _cmbSysPrn[sys];
|
---|
1168 |
|
---|
1169 | const int nCon = (_method == filter) ? 1 + maxSat : 0;
|
---|
1170 |
|
---|
1171 | AA.ReSize(nObs+nCon, nPar); AA = 0.0;
|
---|
1172 | ll.ReSize(nObs+nCon); ll = 0.0;
|
---|
1173 | PP.ReSize(nObs+nCon); PP = 1.0 / (sigObs * sigObs);
|
---|
1174 |
|
---|
1175 | int iObs = 0;
|
---|
1176 | QVectorIterator<cmbCorr*> itCorr(corrs(sys));
|
---|
1177 | while (itCorr.hasNext()) {
|
---|
1178 | cmbCorr* corr = itCorr.next();
|
---|
1179 | QString prn = corr->_prn;
|
---|
1180 |
|
---|
1181 | ++iObs;
|
---|
1182 |
|
---|
1183 | if (corr->_acName == _masterOrbitAC[sys] && resCorr.find(prn) == resCorr.end()) {
|
---|
1184 | resCorr[prn] = new cmbCorr(*corr);
|
---|
1185 | }
|
---|
1186 |
|
---|
1187 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
1188 | cmbParam* pp = _params[sys][iPar-1];
|
---|
1189 | AA(iObs, iPar) = pp->partial(sys, corr->_acName, prn);
|
---|
1190 | }
|
---|
1191 |
|
---|
1192 | ll(iObs) = (corr->_clkCorr->_dClk * t_CST::c - corr->_satCodeBiasIF) - DotProduct(AA.Row(iObs), x0);
|
---|
1193 |
|
---|
1194 | PP(iObs, iObs) *= 1.0 / (corr->_weightFactor * corr->_weightFactor);
|
---|
1195 | }
|
---|
1196 |
|
---|
1197 | // Regularization
|
---|
1198 | // --------------
|
---|
1199 | if (_method == filter) {
|
---|
1200 | const double Ph = 1.e6;
|
---|
1201 | PP(nObs+1) = Ph;
|
---|
1202 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
1203 | cmbParam* pp = _params[sys][iPar-1];
|
---|
1204 | if ( AA.Column(iPar).maximum_absolute_value() > 0.0 &&
|
---|
1205 | pp->type == cmbParam::clkSat ) {
|
---|
1206 | AA(nObs+1, iPar) = 1.0;
|
---|
1207 | }
|
---|
1208 | }
|
---|
1209 | unsigned flag = 0;
|
---|
1210 | if (sys == 'E') {
|
---|
1211 | flag = 1;
|
---|
1212 | }
|
---|
1213 | // if (sys == 'R') {
|
---|
1214 | // return success;
|
---|
1215 | // }
|
---|
1216 | int iCond = 1;
|
---|
1217 | // GNSS
|
---|
1218 | for (unsigned iGnss = 1; iGnss <= _cmbSysPrn[sys]; iGnss++) {
|
---|
1219 | QString prn = QString("%1%2_%3").arg(sys).arg(iGnss, 2, 10, QChar('0')).arg(flag);
|
---|
1220 | ++iCond;
|
---|
1221 | PP(nObs+iCond) = Ph;
|
---|
1222 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
1223 | cmbParam* pp = _params[sys][iPar-1];
|
---|
1224 | if ( pp &&
|
---|
1225 | AA.Column(iPar).maximum_absolute_value() > 0.0 &&
|
---|
1226 | pp->type == cmbParam::offACSat &&
|
---|
1227 | pp->prn == prn) {
|
---|
1228 | AA(nObs+iCond, iPar) = 1.0;
|
---|
1229 | }
|
---|
1230 | }
|
---|
1231 | }
|
---|
1232 | }
|
---|
1233 |
|
---|
1234 | return success;
|
---|
1235 | }
|
---|
1236 |
|
---|
1237 | // Process Epoch - Single-Epoch Method
|
---|
1238 | ////////////////////////////////////////////////////////////////////////////
|
---|
1239 | t_irc bncComb::processEpoch_singleEpoch(bncTime epoTime, char sys, QTextStream& out,
|
---|
1240 | QMap<QString, cmbCorr*>& resCorr,
|
---|
1241 | ColumnVector& dx) {
|
---|
1242 |
|
---|
1243 | // Check Satellite Positions for Outliers
|
---|
1244 | // --------------------------------------
|
---|
1245 | if (checkOrbits(epoTime, sys, out) != success) {
|
---|
1246 | return failure;
|
---|
1247 | }
|
---|
1248 |
|
---|
1249 | // Outlier Detection Loop
|
---|
1250 | // ----------------------
|
---|
1251 | while (true) {
|
---|
1252 |
|
---|
1253 | // Remove Satellites that are not in Master
|
---|
1254 | // ----------------------------------------
|
---|
1255 | QMutableVectorIterator<cmbCorr*> it(corrs(sys));
|
---|
1256 | while (it.hasNext()) {
|
---|
1257 | cmbCorr* corr = it.next();
|
---|
1258 | QString prn = corr->_prn;
|
---|
1259 | bool foundMaster = false;
|
---|
1260 | QVectorIterator<cmbCorr*> itHlp(corrs(sys));
|
---|
1261 | while (itHlp.hasNext()) {
|
---|
1262 | cmbCorr* corrHlp = itHlp.next();
|
---|
1263 | QString prnHlp = corrHlp->_prn;
|
---|
1264 | QString ACHlp = corrHlp->_acName;
|
---|
1265 | if (ACHlp == _masterOrbitAC[sys] && prn == prnHlp) {
|
---|
1266 | foundMaster = true;
|
---|
1267 | break;
|
---|
1268 | }
|
---|
1269 | }
|
---|
1270 | if (!foundMaster) {
|
---|
1271 | delete corr;
|
---|
1272 | it.remove();
|
---|
1273 | }
|
---|
1274 | }
|
---|
1275 |
|
---|
1276 | // Count Number of Observations per Satellite and per AC
|
---|
1277 | // -----------------------------------------------------
|
---|
1278 | QMap<QString, int> numObsPrn;
|
---|
1279 | QMap<QString, int> numObsAC;
|
---|
1280 | QVectorIterator<cmbCorr*> itCorr(corrs(sys));
|
---|
1281 | while (itCorr.hasNext()) {
|
---|
1282 | cmbCorr* corr = itCorr.next();
|
---|
1283 | QString prn = corr->_prn;
|
---|
1284 | QString AC = corr->_acName;
|
---|
1285 | if (numObsPrn.find(prn) == numObsPrn.end()) {
|
---|
1286 | numObsPrn[prn] = 1;
|
---|
1287 | }
|
---|
1288 | else {
|
---|
1289 | numObsPrn[prn] += 1;
|
---|
1290 | }
|
---|
1291 | if (numObsAC.find(AC) == numObsAC.end()) {
|
---|
1292 | numObsAC[AC] = 1;
|
---|
1293 | }
|
---|
1294 | else {
|
---|
1295 | numObsAC[AC] += 1;
|
---|
1296 | }
|
---|
1297 | }
|
---|
1298 |
|
---|
1299 | // Clean-Up the Parameters
|
---|
1300 | // -----------------------
|
---|
1301 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
1302 | delete _params[sys][iPar-1];
|
---|
1303 | }
|
---|
1304 | _params[sys].clear();
|
---|
1305 |
|
---|
1306 | // Set new Parameters
|
---|
1307 | // ------------------
|
---|
1308 | int nextPar = 0;
|
---|
1309 |
|
---|
1310 | QMapIterator<QString, int> itAC(numObsAC);
|
---|
1311 | while (itAC.hasNext()) {
|
---|
1312 | itAC.next();
|
---|
1313 | const QString& AC = itAC.key();
|
---|
1314 | int numObs = itAC.value();
|
---|
1315 | if (AC != _masterOrbitAC[sys] && numObs > 0) {
|
---|
1316 | _params[sys].push_back(new cmbParam(cmbParam::offACgnss, ++nextPar, AC, ""));
|
---|
1317 | }
|
---|
1318 | }
|
---|
1319 |
|
---|
1320 | QMapIterator<QString, int> itPrn(numObsPrn);
|
---|
1321 | while (itPrn.hasNext()) {
|
---|
1322 | itPrn.next();
|
---|
1323 | const QString& prn = itPrn.key();
|
---|
1324 | int numObs = itPrn.value();
|
---|
1325 | if (numObs > 0) {
|
---|
1326 | _params[sys].push_back(new cmbParam(cmbParam::clkSat, ++nextPar, "", prn));
|
---|
1327 | }
|
---|
1328 | }
|
---|
1329 |
|
---|
1330 | int nPar = _params[sys].size();
|
---|
1331 | ColumnVector x0(nPar);
|
---|
1332 | x0 = 0.0;
|
---|
1333 |
|
---|
1334 | // Create First-Design Matrix
|
---|
1335 | // --------------------------
|
---|
1336 | Matrix AA;
|
---|
1337 | ColumnVector ll;
|
---|
1338 | DiagonalMatrix PP;
|
---|
1339 | if (createAmat(sys, AA, ll, PP, x0, resCorr) != success) {
|
---|
1340 | return failure;
|
---|
1341 | }
|
---|
1342 |
|
---|
1343 | ColumnVector vv;
|
---|
1344 | try {
|
---|
1345 | Matrix ATP = AA.t() * PP;
|
---|
1346 | SymmetricMatrix NN; NN << ATP * AA;
|
---|
1347 | ColumnVector bb = ATP * ll;
|
---|
1348 | _QQ[sys] = NN.i();
|
---|
1349 | dx = _QQ[sys] * bb;
|
---|
1350 | vv = ll - AA * dx;
|
---|
1351 | }
|
---|
1352 | catch (Exception& exc) {
|
---|
1353 | out << exc.what() << "\n";
|
---|
1354 | return failure;
|
---|
1355 | }
|
---|
1356 |
|
---|
1357 | int maxResIndex;
|
---|
1358 | double maxRes = vv.maximum_absolute_value1(maxResIndex);
|
---|
1359 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
1360 | out.setRealNumberPrecision(3);
|
---|
1361 | out << epoTime.datestr().c_str() << " " << epoTime.timestr().c_str()
|
---|
1362 | << " Maximum Residuum " << maxRes << ' '
|
---|
1363 | << corrs(sys)[maxResIndex-1]->_acName << ' ' << corrs(sys)[maxResIndex-1]->_prn.mid(0,3);
|
---|
1364 |
|
---|
1365 | if (maxRes > _MAXRES) {
|
---|
1366 | out << " Outlier" << "\n";
|
---|
1367 | delete corrs(sys)[maxResIndex-1];
|
---|
1368 | corrs(sys).remove(maxResIndex-1);
|
---|
1369 | }
|
---|
1370 | else {
|
---|
1371 | out << " OK" << "\n";
|
---|
1372 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
1373 | out.setRealNumberPrecision(3);
|
---|
1374 | for (int ii = 0; ii < vv.Nrows(); ii++) {
|
---|
1375 | const cmbCorr* corr = corrs(sys)[ii];
|
---|
1376 | out << epoTime.datestr().c_str() << ' '
|
---|
1377 | << epoTime.timestr().c_str() << " "
|
---|
1378 | << corr->_acName << ' ' << corr->_prn.mid(0,3);
|
---|
1379 | out.setFieldWidth(6);
|
---|
1380 | out << " res = " << vv[ii] << "\n";
|
---|
1381 | out.setFieldWidth(0);
|
---|
1382 | }
|
---|
1383 | return success;
|
---|
1384 | }
|
---|
1385 |
|
---|
1386 | }
|
---|
1387 |
|
---|
1388 | return failure;
|
---|
1389 | }
|
---|
1390 |
|
---|
1391 | // Check Satellite Positions for Outliers
|
---|
1392 | ////////////////////////////////////////////////////////////////////////////
|
---|
1393 | t_irc bncComb::checkOrbits(bncTime epoTime, char sys, QTextStream& out) {
|
---|
1394 |
|
---|
1395 | const double MAX_DISPLACEMENT_INIT = 0.50;
|
---|
1396 |
|
---|
1397 | double MAX_DISPLACEMENT = MAX_DISPLACEMENT_INIT;
|
---|
1398 | if (sys == 'C') {
|
---|
1399 | MAX_DISPLACEMENT *= 10.0;
|
---|
1400 | }
|
---|
1401 | if (sys == 'R') {
|
---|
1402 | MAX_DISPLACEMENT *= 2.0;
|
---|
1403 | }
|
---|
1404 |
|
---|
1405 | // Switch to last ephemeris (if possible)
|
---|
1406 | // --------------------------------------
|
---|
1407 | QMutableVectorIterator<cmbCorr*> im(corrs(sys));
|
---|
1408 | while (im.hasNext()) {
|
---|
1409 | cmbCorr* corr = im.next();
|
---|
1410 | QString prn = corr->_prn;
|
---|
1411 |
|
---|
1412 | t_eph* ephLast = _ephUser.ephLast(prn);
|
---|
1413 | t_eph* ephPrev = _ephUser.ephPrev(prn);
|
---|
1414 |
|
---|
1415 | if (ephLast == 0) {
|
---|
1416 | out << "checkOrbit: missing eph (not found) " << corr->_prn.mid(0,3) << "\n";
|
---|
1417 | delete corr;
|
---|
1418 | im.remove();
|
---|
1419 | }
|
---|
1420 | else if (corr->_eph == 0) {
|
---|
1421 | out << "checkOrbit: missing eph (zero) " << corr->_prn.mid(0,3) << "\n";
|
---|
1422 | delete corr;
|
---|
1423 | im.remove();
|
---|
1424 | }
|
---|
1425 | else {
|
---|
1426 | if ( corr->_eph == ephLast || corr->_eph == ephPrev ) {
|
---|
1427 | switchToLastEph(ephLast, corr);
|
---|
1428 | }
|
---|
1429 | else {
|
---|
1430 | out << "checkOrbit: missing eph (deleted) " << corr->_prn.mid(0,3) << "\n";
|
---|
1431 | delete corr;
|
---|
1432 | im.remove();
|
---|
1433 | }
|
---|
1434 | }
|
---|
1435 | }
|
---|
1436 |
|
---|
1437 | while (true) {
|
---|
1438 |
|
---|
1439 | // Compute Mean Corrections for all Satellites
|
---|
1440 | // -------------------------------------------
|
---|
1441 | QMap<QString, int> numCorr;
|
---|
1442 | QMap<QString, ColumnVector> meanRao;
|
---|
1443 | QVectorIterator<cmbCorr*> it(corrs(sys));
|
---|
1444 | while (it.hasNext()) {
|
---|
1445 | cmbCorr* corr = it.next();
|
---|
1446 | QString prn = corr->_prn;
|
---|
1447 | if (meanRao.find(prn) == meanRao.end()) {
|
---|
1448 | meanRao[prn].ReSize(4);
|
---|
1449 | meanRao[prn].Rows(1,3) = corr->_orbCorr->_xr;
|
---|
1450 | meanRao[prn](4) = 1;
|
---|
1451 | }
|
---|
1452 | else {
|
---|
1453 | meanRao[prn].Rows(1,3) += corr->_orbCorr->_xr;
|
---|
1454 | meanRao[prn](4) += 1;
|
---|
1455 | }
|
---|
1456 | if (numCorr.find(prn) == numCorr.end()) {
|
---|
1457 | numCorr[prn] = 1;
|
---|
1458 | }
|
---|
1459 | else {
|
---|
1460 | numCorr[prn] += 1;
|
---|
1461 | }
|
---|
1462 | }
|
---|
1463 |
|
---|
1464 | // Compute Differences wrt. Mean, find Maximum
|
---|
1465 | // -------------------------------------------
|
---|
1466 | QMap<QString, cmbCorr*> maxDiff;
|
---|
1467 | it.toFront();
|
---|
1468 | while (it.hasNext()) {
|
---|
1469 | cmbCorr* corr = it.next();
|
---|
1470 | QString prn = corr->_prn;
|
---|
1471 | if (meanRao[prn](4) != 0) {
|
---|
1472 | meanRao[prn] /= meanRao[prn](4);
|
---|
1473 | meanRao[prn](4) = 0;
|
---|
1474 | }
|
---|
1475 | corr->_diffRao = corr->_orbCorr->_xr - meanRao[prn].Rows(1,3);
|
---|
1476 | if (maxDiff.find(prn) == maxDiff.end()) {
|
---|
1477 | maxDiff[prn] = corr;
|
---|
1478 | }
|
---|
1479 | else {
|
---|
1480 | double normMax = maxDiff[prn]->_diffRao.NormFrobenius();
|
---|
1481 | double norm = corr->_diffRao.NormFrobenius();
|
---|
1482 | if (norm > normMax) {
|
---|
1483 | maxDiff[prn] = corr;
|
---|
1484 | }
|
---|
1485 | }
|
---|
1486 | }
|
---|
1487 |
|
---|
1488 | if (_ACs.size() == 1) {
|
---|
1489 | break;
|
---|
1490 | }
|
---|
1491 |
|
---|
1492 | // Remove Outliers
|
---|
1493 | // ---------------
|
---|
1494 | bool removed = false;
|
---|
1495 | QMutableVectorIterator<cmbCorr*> im(corrs(sys));
|
---|
1496 | while (im.hasNext()) {
|
---|
1497 | cmbCorr* corr = im.next();
|
---|
1498 | QString prn = corr->_prn;
|
---|
1499 | if (numCorr[prn] < 2) {
|
---|
1500 | delete corr;
|
---|
1501 | im.remove();
|
---|
1502 | }
|
---|
1503 | else if (corr == maxDiff[prn]) {
|
---|
1504 | double norm = corr->_diffRao.NormFrobenius();
|
---|
1505 | if (norm > MAX_DISPLACEMENT) {
|
---|
1506 | out << epoTime.datestr().c_str() << " "
|
---|
1507 | << epoTime.timestr().c_str() << " "
|
---|
1508 | << "Orbit Outlier: "
|
---|
1509 | << corr->_acName.toLatin1().data() << " "
|
---|
1510 | << prn.mid(0,3).toLatin1().data() << " "
|
---|
1511 | << corr->_iod << " "
|
---|
1512 | << norm << "\n";
|
---|
1513 | delete corr;
|
---|
1514 | im.remove();
|
---|
1515 | removed = true;
|
---|
1516 | }
|
---|
1517 | }
|
---|
1518 | }
|
---|
1519 |
|
---|
1520 | if (!removed) {
|
---|
1521 | break;
|
---|
1522 | }
|
---|
1523 | }
|
---|
1524 |
|
---|
1525 | return success;
|
---|
1526 | }
|
---|
1527 |
|
---|
1528 | //
|
---|
1529 | ////////////////////////////////////////////////////////////////////////////
|
---|
1530 | void bncComb::slotProviderIDChanged(QString mountPoint) {
|
---|
1531 | QMutexLocker locker(&_mutex);
|
---|
1532 |
|
---|
1533 | QTextStream out(&_log, QIODevice::WriteOnly);
|
---|
1534 |
|
---|
1535 | // Find the AC Name
|
---|
1536 | // ----------------
|
---|
1537 | QString acName;
|
---|
1538 | QListIterator<cmbAC*> icAC(_ACs);
|
---|
1539 | while (icAC.hasNext()) {
|
---|
1540 | cmbAC *AC = icAC.next();
|
---|
1541 | if (AC->mountPoint == mountPoint) {
|
---|
1542 | acName = AC->name;
|
---|
1543 | out << "Provider ID changed: AC " << AC->name.toLatin1().data() << " "
|
---|
1544 | << _resTime.datestr().c_str() << " " << _resTime.timestr().c_str()
|
---|
1545 | << "\n";
|
---|
1546 | break;
|
---|
1547 | }
|
---|
1548 | }
|
---|
1549 | if (acName.isEmpty()) {
|
---|
1550 | return;
|
---|
1551 | }
|
---|
1552 | QMapIterator<char, unsigned> itSys(_cmbSysPrn);
|
---|
1553 | while (itSys.hasNext()) {
|
---|
1554 | itSys.next();
|
---|
1555 | char sys = itSys.key();
|
---|
1556 | // Remove all corrections of the corresponding AC
|
---|
1557 | // ----------------------------------------------
|
---|
1558 | QVector<cmbCorr*> &corrVec = _buffer[sys].corrs;
|
---|
1559 | QMutableVectorIterator<cmbCorr*> it(corrVec);
|
---|
1560 | while (it.hasNext()) {
|
---|
1561 | cmbCorr *corr = it.next();
|
---|
1562 | if (acName == corr->_acName) {
|
---|
1563 | delete corr;
|
---|
1564 | it.remove();
|
---|
1565 | }
|
---|
1566 | }
|
---|
1567 | // Reset Satellite Offsets
|
---|
1568 | // -----------------------
|
---|
1569 | if (_method == filter) {
|
---|
1570 | for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
|
---|
1571 | cmbParam *pp = _params[sys][iPar - 1];
|
---|
1572 | if (pp->AC == acName && pp->type == cmbParam::offACSat) {
|
---|
1573 | pp->xx = 0.0;
|
---|
1574 | _QQ[sys].Row(iPar) = 0.0;
|
---|
1575 | _QQ[sys].Column(iPar) = 0.0;
|
---|
1576 | _QQ[sys](iPar, iPar) = pp->sig0 * pp->sig0;
|
---|
1577 | }
|
---|
1578 | }
|
---|
1579 | }
|
---|
1580 | }
|
---|
1581 | }
|
---|