source: ntrip/trunk/BNC/combination/bnccomb.cpp@ 3464

Last change on this file since 3464 was 3464, checked in by mervart, 13 years ago
File size: 20.0 KB
RevLine 
[2898]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
[2933]17#include <newmatio.h>
[2921]18#include <iomanip>
[3214]19#include <sstream>
[2898]20
21#include "bnccomb.h"
22#include "bncapp.h"
[3201]23#include "upload/bncrtnetdecoder.h"
[2910]24#include "bncsettings.h"
[2933]25#include "bncmodel.h"
[2988]26#include "bncutils.h"
[3027]27#include "bncpppclient.h"
[3181]28#include "bncsp3.h"
[3052]29#include "bncantex.h"
[3055]30#include "bnctides.h"
[2898]31
[3455]32const int moduloTime = 10;
[2898]33
[3455]34const double sig0_offAC = 1000.0;
35const double sig0_offACSat = 100.0;
[3464]36const double sigP_offACSat = 0.01;
[3455]37const double sig0_clkSat = 100.0;
38
39const double sigObs = 0.05;
40
[3134]41const int MAXPRN_GPS = 32;
42
[3455]43using namespace std;
44
[2898]45// Constructor
46////////////////////////////////////////////////////////////////////////////
[3429]47cmbParam::cmbParam(parType type_, int index_,
48 const QString& ac_, const QString& prn_) {
[3032]49
[3433]50 type = type_;
51 index = index_;
52 AC = ac_;
53 prn = prn_;
54 xx = 0.0;
[3455]55 eph = 0;
[3429]56
57 if (type == offAC) {
[3455]58 epoSpec = true;
59 sig0 = sig0_offAC;
60 sigP = sig0;
[3429]61 }
62 else if (type == offACSat) {
[3455]63 epoSpec = false;
64 sig0 = sig0_offACSat;
65 sigP = sigP_offACSat;
[3429]66 }
67 else if (type == clkSat) {
[3455]68 epoSpec = true;
69 sig0 = sig0_clkSat;
70 sigP = sig0;
[3429]71 }
[2933]72}
73
74// Destructor
75////////////////////////////////////////////////////////////////////////////
76cmbParam::~cmbParam() {
77}
78
79// Partial
80////////////////////////////////////////////////////////////////////////////
[3429]81double cmbParam::partial(const QString& AC_, const QString& prn_) {
[2933]82
[3429]83 if (type == offAC) {
[3032]84 if (AC == AC_) {
[2934]85 return 1.0;
86 }
87 }
[3429]88 else if (type == offACSat) {
89 if (AC == AC_ && prn == prn_) {
[2933]90 return 1.0;
91 }
92 }
[3429]93 else if (type == clkSat) {
94 if (prn == prn_) {
[2933]95 return 1.0;
96 }
97 }
98
99 return 0.0;
100}
101
[2990]102//
103////////////////////////////////////////////////////////////////////////////
104QString cmbParam::toString() const {
[2933]105
[2990]106 QString outStr;
107
[3429]108 if (type == offAC) {
[2992]109 outStr = "AC offset " + AC;
[2990]110 }
[3429]111 else if (type == offACSat) {
[2992]112 outStr = "Sat Offset " + AC + " " + prn;
[2990]113 }
[3429]114 else if (type == clkSat) {
[2992]115 outStr = "Clk Corr " + prn;
[2990]116 }
[2933]117
[2990]118 return outStr;
119}
120
[2933]121// Constructor
122////////////////////////////////////////////////////////////////////////////
[2898]123bncComb::bncComb() {
[2910]124
125 bncSettings settings;
126
127 QStringList combineStreams = settings.value("combineStreams").toStringList();
[2918]128
[3455]129 _masterMissingEpochs = 0;
130
[3143]131 if (combineStreams.size() >= 1 && !combineStreams[0].isEmpty()) {
[2910]132 QListIterator<QString> it(combineStreams);
133 while (it.hasNext()) {
134 QStringList hlp = it.next().split(" ");
[2918]135 cmbAC* newAC = new cmbAC();
136 newAC->mountPoint = hlp[0];
137 newAC->name = hlp[1];
138 newAC->weight = hlp[2].toDouble();
[3453]139 if (_masterOrbitAC.isEmpty()) {
140 _masterOrbitAC = newAC->name;
141 }
[3429]142 _ACs.append(newAC);
[2910]143 }
144 }
[2927]145
[3211]146 _rtnetDecoder = 0;
[3201]147
[2990]148 connect(this, SIGNAL(newMessage(QByteArray,bool)),
149 ((bncApp*)qApp), SLOT(slotMessage(const QByteArray,bool)));
[2933]150
[3032]151
152 // Initialize Parameters (model: Clk_Corr = AC_Offset + Sat_Offset + Clk)
153 // ----------------------------------------------------------------------
[2933]154 int nextPar = 0;
[3429]155 QListIterator<cmbAC*> it(_ACs);
[2991]156 while (it.hasNext()) {
[3429]157 cmbAC* AC = it.next();
158 _params.push_back(new cmbParam(cmbParam::offAC, ++nextPar, AC->name, ""));
[3134]159 for (int iGps = 1; iGps <= MAXPRN_GPS; iGps++) {
160 QString prn = QString("G%1").arg(iGps, 2, 10, QChar('0'));
[3429]161 _params.push_back(new cmbParam(cmbParam::offACSat, ++nextPar,
162 AC->name, prn));
[2991]163 }
164 }
[3134]165 for (int iGps = 1; iGps <= MAXPRN_GPS; iGps++) {
[2933]166 QString prn = QString("G%1").arg(iGps, 2, 10, QChar('0'));
[3429]167 _params.push_back(new cmbParam(cmbParam::clkSat, ++nextPar, "", prn));
[2933]168 }
169
[3032]170 // Initialize Variance-Covariance Matrix
171 // -------------------------------------
172 _QQ.ReSize(_params.size());
[2933]173 _QQ = 0.0;
174 for (int iPar = 1; iPar <= _params.size(); iPar++) {
175 cmbParam* pp = _params[iPar-1];
[3455]176 _QQ(iPar,iPar) = pp->sig0 * pp->sig0;
[2933]177 }
[3035]178
[3052]179 // ANTEX File
180 // ----------
181 _antex = 0;
182 QString antexFileName = settings.value("pppAntex").toString();
183 if (!antexFileName.isEmpty()) {
184 _antex = new bncAntex();
185 if (_antex->readFile(antexFileName) != success) {
186 emit newMessage("wrong ANTEX file", true);
187 delete _antex;
188 _antex = 0;
189 }
190 }
[3138]191
[3329]192 // Maximal Residuum
193 // ----------------
194 _MAXRES = settings.value("cmbMaxres").toDouble();
195 if (_MAXRES <= 0.0) {
196 _MAXRES = 999.0;
197 }
[2898]198}
199
200// Destructor
201////////////////////////////////////////////////////////////////////////////
202bncComb::~bncComb() {
[3429]203 QListIterator<cmbAC*> icAC(_ACs);
204 while (icAC.hasNext()) {
205 delete icAC.next();
[2918]206 }
[3201]207 delete _rtnetDecoder;
[3052]208 delete _antex;
[3296]209 for (int iPar = 1; iPar <= _params.size(); iPar++) {
210 delete _params[iPar-1];
211 }
[3434]212 QVectorIterator<cmbCorr*> itCorr(corrs());
[3429]213 while (itCorr.hasNext()) {
214 delete itCorr.next();
215 }
[2898]216}
217
[2928]218// Read and store one correction line
[2898]219////////////////////////////////////////////////////////////////////////////
220void bncComb::processCorrLine(const QString& staID, const QString& line) {
[2906]221 QMutexLocker locker(&_mutex);
[2913]222
[3431]223 // Find the AC Name
224 // ----------------
225 QString acName;
226 QListIterator<cmbAC*> icAC(_ACs);
227 while (icAC.hasNext()) {
228 cmbAC* AC = icAC.next();
229 if (AC->mountPoint == staID) {
230 acName = AC->name;
231 break;
232 }
233 }
234 if (acName.isEmpty()) {
235 return;
236 }
237
[2918]238 // Read the Correction
239 // -------------------
[3429]240 cmbCorr* newCorr = new cmbCorr();
[3431]241 newCorr->acName = acName;
[2913]242 if (!newCorr->readLine(line) == success) {
243 delete newCorr;
244 return;
245 }
246
[3274]247 // Check Modulo Time
248 // -----------------
249 if (int(newCorr->tt.gpssec()) % moduloTime != 0.0) {
250 delete newCorr;
251 return;
252 }
253
[3299]254 // Delete old corrections
255 // ----------------------
[3437]256 if (_resTime.valid() && newCorr->tt <= _resTime) {
[2924]257 delete newCorr;
258 return;
259 }
260
[3029]261 // Check the Ephemeris
262 //--------------------
[2986]263 if (_eph.find(newCorr->prn) == _eph.end()) {
264 delete newCorr;
265 return;
266 }
267 else {
268 t_eph* lastEph = _eph[newCorr->prn]->last;
269 t_eph* prevEph = _eph[newCorr->prn]->prev;
[3029]270 if (lastEph && lastEph->IOD() == newCorr->iod) {
271 newCorr->eph = lastEph;
[2986]272 }
[3029]273 else if (prevEph && prevEph->IOD() == newCorr->iod) {
274 newCorr->eph = prevEph;
[3429]275 switchToLastEph(lastEph, newCorr);
[3029]276 }
277 else {
[2986]278 delete newCorr;
279 return;
280 }
281 }
282
[3435]283 // Process previous Epoch(s)
284 // -------------------------
285 QListIterator<bncTime> itTime(_buffer.keys());
286 while (itTime.hasNext()) {
287 bncTime epoTime = itTime.next();
[3438]288 if (epoTime < newCorr->tt - moduloTime) {
[3435]289 _resTime = epoTime;
290 processEpoch();
291 }
[2927]292 }
293
[3429]294 // Merge or add the correction
295 // ---------------------------
[3435]296 QVector<cmbCorr*>& corrs = _buffer[newCorr->tt].corrs;
[3429]297 cmbCorr* existingCorr = 0;
[3435]298 QVectorIterator<cmbCorr*> itCorr(corrs);
[3429]299 while (itCorr.hasNext()) {
300 cmbCorr* hlp = itCorr.next();
301 if (hlp->prn == newCorr->prn && hlp->acName == newCorr->prn) {
302 existingCorr = hlp;
[2918]303 break;
304 }
305 }
[3429]306 if (existingCorr) {
[3298]307 delete newCorr;
[3429]308 existingCorr->readLine(line); // merge (multiple messages)
[2918]309 }
[2919]310 else {
[3435]311 corrs.append(newCorr);
[2919]312 }
[2898]313}
314
[2986]315// Change the correction so that it refers to last received ephemeris
316////////////////////////////////////////////////////////////////////////////
[3029]317void bncComb::switchToLastEph(const t_eph* lastEph, t_corr* corr) {
[3028]318
[3429]319 if (corr->eph == lastEph) {
320 return;
321 }
322
[2987]323 ColumnVector oldXC(4);
324 ColumnVector oldVV(3);
[3029]325 corr->eph->position(corr->tt.gpsw(), corr->tt.gpssec(),
326 oldXC.data(), oldVV.data());
[2988]327
[2987]328 ColumnVector newXC(4);
329 ColumnVector newVV(3);
[3029]330 lastEph->position(corr->tt.gpsw(), corr->tt.gpssec(),
[2987]331 newXC.data(), newVV.data());
[2988]332
333 ColumnVector dX = newXC.Rows(1,3) - oldXC.Rows(1,3);
[2989]334 ColumnVector dV = newVV - oldVV;
335 double dC = newXC(4) - oldXC(4);
336
[2988]337 ColumnVector dRAO(3);
338 XYZ_to_RSW(newXC.Rows(1,3), newVV, dX, dRAO);
[2989]339
340 ColumnVector dDotRAO(3);
341 XYZ_to_RSW(newXC.Rows(1,3), newVV, dV, dDotRAO);
342
[3455]343 QString msg = "switch corr " + corr->prn
[3029]344 + QString(" %1 -> %2 %3").arg(corr->iod,3)
[3013]345 .arg(lastEph->IOD(),3).arg(dC*t_CST::c, 8, 'f', 4);
346
[3029]347 emit newMessage(msg.toAscii(), false);
[3028]348
[3029]349 corr->iod = lastEph->IOD();
350 corr->eph = lastEph;
[3031]351 corr->rao += dRAO;
352 corr->dotRao += dDotRAO;
[3029]353 corr->dClk -= dC;
[2986]354}
355
[3429]356// Process Epoch
[2928]357////////////////////////////////////////////////////////////////////////////
[3429]358void bncComb::processEpoch() {
[2918]359
[3429]360 int nPar = _params.size();
361
[2990]362 _log.clear();
363
364 QTextStream out(&_log, QIODevice::WriteOnly);
365
[3371]366 out << endl << "Combination:" << endl
[3275]367 << "------------------------------" << endl;
[2990]368
[3433]369 // Observation Statistics
370 // ----------------------
[3455]371 bool masterPresent = false;
[3433]372 QListIterator<cmbAC*> icAC(_ACs);
373 while (icAC.hasNext()) {
374 cmbAC* AC = icAC.next();
375 AC->numObs = 0;
[3434]376 QVectorIterator<cmbCorr*> itCorr(corrs());
[3433]377 while (itCorr.hasNext()) {
378 cmbCorr* corr = itCorr.next();
379 if (corr->acName == AC->name) {
380 AC->numObs += 1;
[3453]381 if (AC->name == _masterOrbitAC) {
382 masterPresent = true;
383 }
[3433]384 }
385 }
386 out << AC->name.toAscii().data() << ": " << AC->numObs << endl;
387 }
388
[3453]389 // If Master not present, switch to another one
390 // --------------------------------------------
[3456]391 if (masterPresent) {
392 _masterMissingEpochs = 0;
393 }
394 else {
[3455]395 ++_masterMissingEpochs;
[3459]396 if (_masterMissingEpochs < 10) {
[3457]397 out << "Missing Master, Epoch skipped" << endl;
[3455]398 _buffer.remove(_resTime);
399 emit newMessage(_log, false);
400 return;
[3453]401 }
[3455]402 else {
403 _masterMissingEpochs = 0;
404 QListIterator<cmbAC*> icAC(_ACs);
405 while (icAC.hasNext()) {
406 cmbAC* AC = icAC.next();
407 if (AC->numObs > 0) {
408 out << "Switching Master AC "
409 << _masterOrbitAC.toAscii().data() << " --> "
410 << AC->name.toAscii().data() << " "
411 << _resTime.datestr().c_str() << " "
412 << _resTime.timestr().c_str() << endl;
413 _masterOrbitAC = AC->name;
414 break;
415 }
[3452]416 }
417 }
418 }
419
[3429]420 // Prediction Step
421 // ---------------
[2933]422 ColumnVector x0(nPar);
423 for (int iPar = 1; iPar <= _params.size(); iPar++) {
[3455]424 cmbParam* pp = _params[iPar-1];
425 if (pp->epoSpec) {
[3451]426 pp->xx = 0.0;
[3455]427 _QQ.Row(iPar) = 0.0;
428 _QQ.Column(iPar) = 0.0;
429 _QQ(iPar,iPar) = pp->sig0 * pp->sig0;
[3451]430 }
[3455]431 else {
432 _QQ(iPar,iPar) += pp->sigP * pp->sigP;
433 }
[2933]434 x0(iPar) = pp->xx;
435 }
436
[3455]437 SymmetricMatrix QQ_sav = _QQ;
[3441]438
[3455]439 ColumnVector dx;
[3429]440 QMap<QString, t_corr*> resCorr;
[3455]441
442 // Update and outlier detection loop
443 // ---------------------------------
444 while (true) {
[3135]445
[3455]446 Matrix AA;
447 ColumnVector ll;
448 DiagonalMatrix PP;
[3429]449
[3455]450 if (createAmat(AA, ll, PP, x0, resCorr) != success) {
451 _buffer.remove(_resTime);
452 emit newMessage(_log, false);
453 return;
[3441]454 }
[2933]455
[3429]456 bncModel::kalman(AA, ll, PP, _QQ, dx);
457 ColumnVector vv = ll - AA * dx;
[3080]458
[3429]459 int maxResIndex;
460 double maxRes = vv.maximum_absolute_value1(maxResIndex);
461 out.setRealNumberNotation(QTextStream::FixedNotation);
462 out.setRealNumberPrecision(3);
463 out << _resTime.datestr().c_str() << " " << _resTime.timestr().c_str()
[3432]464 << " Maximum Residuum " << maxRes << ' '
[3434]465 << corrs()[maxResIndex-1]->acName << ' ' << corrs()[maxResIndex-1]->prn;
[3080]466
[3432]467 if (maxRes > _MAXRES) {
468 for (int iPar = 1; iPar <= _params.size(); iPar++) {
469 cmbParam* pp = _params[iPar-1];
470 if (pp->type == cmbParam::offACSat &&
[3434]471 pp->AC == corrs()[maxResIndex-1]->acName &&
472 pp->prn == corrs()[maxResIndex-1]->prn) {
[3432]473 QQ_sav.Row(iPar) = 0.0;
474 QQ_sav.Column(iPar) = 0.0;
[3455]475 QQ_sav(iPar,iPar) = pp->sig0 * pp->sig0;
[3432]476 }
477 }
478
479 out << " Outlier" << endl;
480 _QQ = QQ_sav;
[3455]481 corrs().remove(maxResIndex-1);
[3432]482 }
483 else {
484 out << " OK" << endl;
485 break;
486 }
487 }
488
489 // Update Parameter Values
490 // -----------------------
[3429]491 for (int iPar = 1; iPar <= _params.size(); iPar++) {
492 cmbParam* pp = _params[iPar-1];
493 pp->xx += dx(iPar);
494 if (pp->type == cmbParam::clkSat) {
495 if (resCorr.find(pp->prn) != resCorr.end()) {
496 resCorr[pp->prn]->dClk = pp->xx / t_CST::c;
[3080]497 }
498 }
[3429]499 out << _resTime.datestr().c_str() << " "
500 << _resTime.timestr().c_str() << " ";
501 out.setRealNumberNotation(QTextStream::FixedNotation);
502 out.setFieldWidth(8);
503 out.setRealNumberPrecision(4);
504 out << pp->toString() << " "
505 << pp->xx << " +- " << sqrt(_QQ(pp->index,pp->index)) << endl;
506 out.setFieldWidth(0);
[2918]507 }
[2919]508
[3432]509 // Print Results
510 // -------------
[3429]511 printResults(out, resCorr);
512 dumpResults(resCorr);
[2928]513
[2990]514 emit newMessage(_log, false);
[3296]515
[3432]516 // Delete Data
517 // -----------
[3434]518 _buffer.remove(_resTime);
[2918]519}
[3011]520
[3201]521// Print results
[3011]522////////////////////////////////////////////////////////////////////////////
[3429]523void bncComb::printResults(QTextStream& out,
[3011]524 const QMap<QString, t_corr*>& resCorr) {
525
526 QMapIterator<QString, t_corr*> it(resCorr);
527 while (it.hasNext()) {
528 it.next();
529 t_corr* corr = it.value();
[3029]530 const t_eph* eph = corr->eph;
[3015]531 if (eph) {
532 double xx, yy, zz, cc;
[3429]533 eph->position(_resTime.gpsw(), _resTime.gpssec(), xx, yy, zz, cc);
[3015]534
[3429]535 out << _resTime.datestr().c_str() << " "
536 << _resTime.timestr().c_str() << " ";
[3015]537 out.setFieldWidth(3);
538 out << "Full Clock " << corr->prn << " " << corr->iod << " ";
539 out.setFieldWidth(14);
540 out << (cc + corr->dClk) * t_CST::c << endl;
[3370]541 out.setFieldWidth(0);
[3015]542 }
543 else {
544 out << "bncComb::printResuls bug" << endl;
545 }
[3011]546 }
547}
[3202]548
549// Send results to RTNet Decoder and directly to PPP Client
550////////////////////////////////////////////////////////////////////////////
[3429]551void bncComb::dumpResults(const QMap<QString, t_corr*>& resCorr) {
[3202]552
[3214]553 ostringstream out; out.setf(std::ios::fixed);
[3216]554 QStringList corrLines;
[3214]555
556 unsigned year, month, day, hour, minute;
557 double sec;
[3429]558 _resTime.civil_date(year, month, day);
559 _resTime.civil_time(hour, minute, sec);
[3214]560
561 out << "* "
562 << setw(4) << year << " "
563 << setw(2) << month << " "
564 << setw(2) << day << " "
565 << setw(2) << hour << " "
566 << setw(2) << minute << " "
567 << setw(12) << setprecision(8) << sec << " "
568 << endl;
569
[3202]570 QMapIterator<QString, t_corr*> it(resCorr);
571 while (it.hasNext()) {
572 it.next();
573 t_corr* corr = it.value();
574
[3214]575 double dT = 60.0;
[3202]576
[3214]577 for (int iTime = 1; iTime <= 2; iTime++) {
578
[3429]579 bncTime time12 = (iTime == 1) ? _resTime : _resTime + dT;
[3214]580
581 ColumnVector xc(4);
582 ColumnVector vv(3);
583 corr->eph->position(time12.gpsw(), time12.gpssec(),
584 xc.data(), vv.data());
585 bncPPPclient::applyCorr(time12, corr, xc, vv);
586
587 // Relativistic Correction
588 // -----------------------
589 double relCorr = - 2.0 * DotProduct(xc.Rows(1,3),vv) / t_CST::c / t_CST::c;
590 xc(4) -= relCorr;
591
592 // Code Biases
593 // -----------
594 double dcbP1C1 = 0.0;
595 double dcbP1P2 = 0.0;
596
597 // Correction Phase Center --> CoM
598 // -------------------------------
599 ColumnVector dx(3); dx = 0.0;
600 if (_antex) {
601 double Mjd = time12.mjd() + time12.daysec()/86400.0;
602 if (_antex->satCoMcorrection(corr->prn, Mjd, xc.Rows(1,3), dx) == success) {
603 xc(1) -= dx(1);
604 xc(2) -= dx(2);
605 xc(3) -= dx(3);
606 }
607 else {
608 cout << "antenna not found" << endl;
609 }
610 }
611
612 if (iTime == 1) {
613 out << 'P' << corr->prn.toAscii().data()
614 << setw(14) << setprecision(6) << xc(1) / 1000.0
615 << setw(14) << setprecision(6) << xc(2) / 1000.0
616 << setw(14) << setprecision(6) << xc(3) / 1000.0
617 << setw(14) << setprecision(6) << xc(4) * 1e6
618 << setw(14) << setprecision(6) << relCorr * 1e6
619 << setw(8) << setprecision(3) << dx(1)
620 << setw(8) << setprecision(3) << dx(2)
621 << setw(8) << setprecision(3) << dx(3)
622 << setw(8) << setprecision(3) << dcbP1C1
623 << setw(8) << setprecision(3) << dcbP1P2
624 << setw(6) << setprecision(1) << dT;
[3216]625
[3218]626 QString line;
[3217]627 int messageType = COTYPE_GPSCOMBINED;
[3218]628 int updateInt = 0;
629 line.sprintf("%d %d %d %.1f %s"
630 " %3d"
631 " %8.3f %8.3f %8.3f %8.3f"
632 " %10.5f %10.5f %10.5f %10.5f"
[3262]633 " %10.5f %10.5f %10.5f %10.5f INTERNAL",
[3218]634 messageType, updateInt, time12.gpsw(), time12.gpssec(),
635 corr->prn.toAscii().data(),
636 corr->iod,
[3219]637 corr->dClk * t_CST::c,
[3218]638 corr->rao[0],
639 corr->rao[1],
640 corr->rao[2],
[3219]641 corr->dotDClk * t_CST::c,
[3218]642 corr->dotRao[0],
643 corr->dotRao[1],
644 corr->dotRao[2],
[3262]645 corr->dotDotDClk * t_CST::c,
646 corr->dotDotRao[0],
647 corr->dotDotRao[1],
648 corr->dotDotRao[2]);
[3220]649 corrLines << line;
[3214]650 }
651 else {
652 out << setw(14) << setprecision(6) << xc(1) / 1000.0
653 << setw(14) << setprecision(6) << xc(2) / 1000.0
654 << setw(14) << setprecision(6) << xc(3) / 1000.0 << endl;
655 }
656 }
657
658 delete corr;
659 }
[3228]660 out << "EOE" << endl; // End Of Epoch flag
[3214]661
[3215]662 if (!_rtnetDecoder) {
663 _rtnetDecoder = new bncRtnetDecoder();
664 }
[3221]665
[3215]666 vector<string> errmsg;
[3221]667 _rtnetDecoder->Decode((char*) out.str().data(), out.str().size(), errmsg);
[3215]668
[3216]669 // Optionally send new Corrections to PPP
670 // --------------------------------------
671 bncApp* app = (bncApp*) qApp;
672 if (app->_bncPPPclient) {
673 app->_bncPPPclient->slotNewCorrections(corrLines);
674 }
[3202]675}
[3455]676
677// Create First Design Matrix and Vector of Measurements
678////////////////////////////////////////////////////////////////////////////
679t_irc bncComb::createAmat(Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP,
680 const ColumnVector& x0,
681 QMap<QString, t_corr*>& resCorr) {
682
683 unsigned nPar = _params.size();
684 unsigned nObs = corrs().size();
685
686 if (nObs == 0) {
687 return failure;
688 }
689
[3461]690 const int nCon = 1 + MAXPRN_GPS;
[3455]691
692 AA.ReSize(nObs+nCon, nPar); AA = 0.0;
693 ll.ReSize(nObs+nCon); ll = 0.0;
694 PP.ReSize(nObs+nCon); PP = 1.0 / (sigObs * sigObs);
695
696 int iObs = 0;
697
698 QVectorIterator<cmbCorr*> itCorr(corrs());
699 while (itCorr.hasNext()) {
700 cmbCorr* corr = itCorr.next();
701 QString prn = corr->prn;
702 switchToLastEph(_eph[prn]->last, corr);
703 ++iObs;
704
705 if (corr->acName == _masterOrbitAC && resCorr.find(prn) == resCorr.end()) {
706 resCorr[prn] = new t_corr(*corr);
707 }
708
709 for (int iPar = 1; iPar <= _params.size(); iPar++) {
710 cmbParam* pp = _params[iPar-1];
711 AA(iObs, iPar) = pp->partial(corr->acName, prn);
712 }
713
714 ll(iObs) = corr->dClk * t_CST::c - DotProduct(AA.Row(iObs), x0);
715 }
716
717 // Regularization
718 // --------------
719 const double Ph = 1.e6;
[3461]720 PP(nObs+1) = Ph;
[3455]721 for (int iPar = 1; iPar <= _params.size(); iPar++) {
722 cmbParam* pp = _params[iPar-1];
[3461]723 if (AA.Column(iPar).maximum_absolute_value() > 0.0) {
724 if (pp->type == cmbParam::clkSat) {
725 AA(nObs+1, iPar) = 1.0;
726 }
[3455]727 }
728 }
[3461]729 int iCond = 1;
730 for (int iGps = 1; iGps <= MAXPRN_GPS; iGps++) {
731 QString prn = QString("G%1").arg(iGps, 2, 10, QChar('0'));
732 ++iCond;
733 PP(nObs+iCond) = Ph;
734 for (int iPar = 1; iPar <= _params.size(); iPar++) {
735 cmbParam* pp = _params[iPar-1];
736 if (pp->type == cmbParam::offACSat && pp->prn == prn) {
737 AA(nObs+iCond, iPar) = 1.0;
[3455]738 }
739 }
740 }
741
742 return success;
743}
Note: See TracBrowser for help on using the repository browser.