source: ntrip/trunk/BNC/src/satObs.cpp@ 9682

Last change on this file since 9682 was 9682, checked in by stuerze, 2 years ago

units are changed now from m/sec into mm/sec for some ssr corrections

File size: 14.2 KB
RevLine 
[6176]1#include <iostream>
[6177]2#include <iomanip>
[6176]3#include <sstream>
[6495]4#include <newmatio.h>
[6144]5
6#include "satObs.h"
[6178]7
[6144]8using namespace std;
9
[6466]10// Constructor
[6144]11////////////////////////////////////////////////////////////////////////////
[6466]12t_clkCorr::t_clkCorr() {
[6589]13 _updateInt = 0;
[6160]14 _iod = 0;
15 _dClk = 0.0;
16 _dotDClk = 0.0;
17 _dotDotDClk = 0.0;
[6144]18}
19
[8483]20//
[6144]21////////////////////////////////////////////////////////////////////////////
[6507]22void t_clkCorr::writeEpoch(ostream* out, const QList<t_clkCorr>& corrList) {
[6456]23 if (!out || corrList.size() == 0) {
24 return;
25 }
[6457]26 out->setf(ios::fixed);
27 bncTime epoTime;
28 QListIterator<t_clkCorr> it(corrList);
29 while (it.hasNext()) {
30 const t_clkCorr& corr = it.next();
31 if (!epoTime.valid()) {
32 epoTime = corr._time;
[6556]33 *out << "> CLOCK " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
34 << corr._updateInt << " "
[6458]35 << corrList.size() << ' ' << corr._staID << endl;
[6457]36 }
[7058]37 *out << corr._prn.toString() << ' ' << setw(11) << corr._iod << ' '
[9682]38 << setw(10) << setprecision(4) << corr._dClk * t_CST::c << ' '
39 << setw(10) << setprecision(4) << corr._dotDClk * t_CST::c *1.e3 << ' ' // m/s => mm/s
40 << setw(10) << setprecision(4) << corr._dotDotDClk * t_CST::c *1.e3 << endl; // m/s => mm/s
[6457]41 }
[6456]42 out->flush();
[6144]43}
44
[8483]45//
[6144]46////////////////////////////////////////////////////////////////////////////
[6507]47void t_clkCorr::readEpoch(const string& epoLine, istream& inStream, QList<t_clkCorr>& corrList) {
[6556]48 bncTime epoTime;
49 unsigned int updateInt;
50 int numCorr;
51 string staID;
52 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numCorr, staID) != t_corrSSR::clkCorr) {
[6502]53 return;
54 }
[6503]55 for (int ii = 0; ii < numCorr; ii++) {
[6504]56 t_clkCorr corr;
[6556]57 corr._time = epoTime;
58 corr._updateInt = updateInt;
59 corr._staID = staID;
[6503]60
61 string line;
[6507]62 getline(inStream, line);
[6503]63 istringstream in(line.c_str());
[8483]64
[6504]65 in >> corr._prn >> corr._iod >> corr._dClk >> corr._dotDClk >> corr._dotDotDClk;
[7003]66 if (corr._prn.system() == 'E') {
67 corr._prn.setFlags(1);// I/NAV
68 }
[7014]69 corr._dClk /= t_CST::c;
70 corr._dotDClk /= t_CST::c;
71 corr._dotDotDClk /= t_CST::c;
72
[9682]73 corr._dotDClk /= 1.e3; // mm/s => m/s
74 corr._dotDotDClk /= 1.e3; // mm/s => m/s
75
[6504]76 corrList.push_back(corr);
[6503]77 }
[6180]78}
79
[6466]80// Constructor
[6180]81////////////////////////////////////////////////////////////////////////////
[6466]82t_orbCorr::t_orbCorr() {
[6589]83 _updateInt = 0;
84 _iod = 0;
85 _system = 'R';
[6160]86 _xr.ReSize(3); _xr = 0.0;
87 _dotXr.ReSize(3); _dotXr = 0.0;
[6144]88}
89
[8483]90//
[6144]91////////////////////////////////////////////////////////////////////////////
[6507]92void t_orbCorr::writeEpoch(ostream* out, const QList<t_orbCorr>& corrList) {
[6456]93 if (!out || corrList.size() == 0) {
94 return;
95 }
[6460]96 out->setf(ios::fixed);
97 bncTime epoTime;
98 QListIterator<t_orbCorr> it(corrList);
99 while (it.hasNext()) {
100 const t_orbCorr& corr = it.next();
101 if (!epoTime.valid()) {
102 epoTime = corr._time;
[6556]103 *out << "> ORBIT " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
104 << corr._updateInt << " "
[6460]105 << corrList.size() << ' ' << corr._staID << endl;
106 }
[7058]107 *out << corr._prn.toString() << ' ' << setw(11) << corr._iod << ' '
[6460]108 << setw(10) << setprecision(4) << corr._xr[0] << ' '
109 << setw(10) << setprecision(4) << corr._xr[1] << ' '
110 << setw(10) << setprecision(4) << corr._xr[2] << " "
[9682]111 << setw(10) << setprecision(4) << corr._dotXr[0] * 1.e3 << ' ' // m/s => mm/s
112 << setw(10) << setprecision(4) << corr._dotXr[1] * 1.e3 << ' ' // m/s => mm/s
113 << setw(10) << setprecision(4) << corr._dotXr[2] * 1.e3 << endl; // m/s => mm/s
[6460]114 }
[6456]115 out->flush();
[6144]116}
117
[8483]118//
[6455]119////////////////////////////////////////////////////////////////////////////
[6507]120void t_orbCorr::readEpoch(const string& epoLine, istream& inStream, QList<t_orbCorr>& corrList) {
[6556]121 bncTime epoTime;
122 unsigned int updateInt;
123 int numCorr;
124 string staID;
125 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numCorr, staID) != t_corrSSR::orbCorr) {
[6504]126 return;
127 }
128 for (int ii = 0; ii < numCorr; ii++) {
129 t_orbCorr corr;
[6556]130 corr._time = epoTime;
131 corr._updateInt = updateInt;
132 corr._staID = staID;
[6504]133
134 string line;
[6507]135 getline(inStream, line);
[6504]136 istringstream in(line.c_str());
[8483]137
[7003]138 in >> corr._prn >> corr._iod
[8483]139 >> corr._xr[0] >> corr._xr[1] >> corr._xr[2]
[6504]140 >> corr._dotXr[0] >> corr._dotXr[1] >> corr._dotXr[2];
141
[9682]142 corr._dotXr /= 1.e3; // mm/s => m/s
143
[7003]144 if (corr._prn.system() == 'E') {
145 corr._prn.setFlags(1);// I/NAV
146 }
[6504]147 corrList.push_back(corr);
148 }
[6455]149}
[6475]150
[8483]151// Constructor
[6475]152////////////////////////////////////////////////////////////////////////////
[8483]153t_URA::t_URA() {
154 _updateInt = 0;
155 _iod = 0;
156 _ura = 0.0;
157}
158
159//
160////////////////////////////////////////////////////////////////////////////
161void t_URA::writeEpoch(ostream* out, const QList<t_URA>& corrList) {
162 if (!out || corrList.size() == 0) {
163 return;
164 }
165 out->setf(ios::fixed);
166 bncTime epoTime;
167 QListIterator<t_URA> it(corrList);
168 while (it.hasNext()) {
169 const t_URA& corr = it.next();
170 if (!epoTime.valid()) {
171 epoTime = corr._time;
172 *out << "> URA " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
173 << corr._updateInt << " "
174 << corrList.size() << ' ' << corr._staID << endl;
175 }
176 *out << corr._prn.toString() << ' ' << setw(11) << corr._iod << ' '
177 << setw(10) << setprecision(4) << corr._ura << endl;
178 }
179 out->flush();
180}
181
182//
183////////////////////////////////////////////////////////////////////////////
184void t_URA::readEpoch(const string& epoLine, istream& inStream, QList<t_URA>& corrList) {
185 bncTime epoTime;
186 unsigned int updateInt;
187 int numCorr;
188 string staID;
189 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numCorr, staID) != t_corrSSR::URA) {
190 return;
191 }
192 for (int ii = 0; ii < numCorr; ii++) {
193 t_URA corr;
194 corr._time = epoTime;
195 corr._updateInt = updateInt;
196 corr._staID = staID;
197
198 string line;
199 getline(inStream, line);
200 istringstream in(line.c_str());
201
202 in >> corr._prn >> corr._iod >> corr._ura;
203
204 corrList.push_back(corr);
205 }
206}
207
208//
209////////////////////////////////////////////////////////////////////////////
[6507]210void t_satCodeBias::writeEpoch(ostream* out, const QList<t_satCodeBias>& biasList) {
[6476]211 if (!out || biasList.size() == 0) {
212 return;
213 }
214 out->setf(ios::fixed);
215 bncTime epoTime;
216 QListIterator<t_satCodeBias> it(biasList);
217 while (it.hasNext()) {
218 const t_satCodeBias& satCodeBias = it.next();
219 if (!epoTime.valid()) {
220 epoTime = satCodeBias._time;
[6556]221 *out << "> CODE_BIAS " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
222 << satCodeBias._updateInt << " "
[6476]223 << biasList.size() << ' ' << satCodeBias._staID << endl;
224 }
[8694]225 if (!satCodeBias._bias.size()) {
226 continue;
227 }
[6567]228 *out << satCodeBias._prn.toString() << " " << setw(2) << satCodeBias._bias.size();
[6477]229 for (unsigned ii = 0; ii < satCodeBias._bias.size(); ii++) {
230 const t_frqCodeBias& frqCodeBias = satCodeBias._bias[ii];
231 *out << " " << frqCodeBias._rnxType2ch << ' '
232 << setw(10) << setprecision(4) << frqCodeBias._value;
233 }
[6476]234 *out << endl;
235 }
236 out->flush();
[6475]237}
238
[8483]239//
[6475]240////////////////////////////////////////////////////////////////////////////
[6507]241void t_satCodeBias::readEpoch(const string& epoLine, istream& inStream, QList<t_satCodeBias>& biasList) {
[6556]242 bncTime epoTime;
243 unsigned int updateInt;
244 int numSat;
245 string staID;
246 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numSat, staID) != t_corrSSR::codeBias) {
[6505]247 return;
248 }
249 for (int ii = 0; ii < numSat; ii++) {
250 t_satCodeBias satCodeBias;
[6556]251 satCodeBias._time = epoTime;
252 satCodeBias._updateInt = updateInt;
253 satCodeBias._staID = staID;
[6505]254
255 string line;
[6507]256 getline(inStream, line);
[6505]257 istringstream in(line.c_str());
[8483]258
[6567]259 int numBias;
260 in >> satCodeBias._prn >> numBias;
[6505]261
262 while (in.good()) {
263 t_frqCodeBias frqCodeBias;
264 in >> frqCodeBias._rnxType2ch >> frqCodeBias._value;
265 if (!frqCodeBias._rnxType2ch.empty()) {
266 satCodeBias._bias.push_back(frqCodeBias);
267 }
268 }
269
270 biasList.push_back(satCodeBias);
271 }
[6475]272}
[6481]273
[8483]274//
[6481]275////////////////////////////////////////////////////////////////////////////
[6507]276void t_satPhaseBias::writeEpoch(ostream* out, const QList<t_satPhaseBias>& biasList) {
[6493]277 if (!out || biasList.size() == 0) {
278 return;
279 }
280 out->setf(ios::fixed);
281 bncTime epoTime;
282 QListIterator<t_satPhaseBias> it(biasList);
283 while (it.hasNext()) {
284 const t_satPhaseBias& satPhaseBias = it.next();
285 if (!epoTime.valid()) {
286 epoTime = satPhaseBias._time;
[6556]287 *out << "> PHASE_BIAS " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
288 << satPhaseBias._updateInt << " "
[6857]289 << biasList.size() << ' ' << satPhaseBias._staID << endl;
[6859]290 *out << " " << satPhaseBias._dispBiasConstistInd << " "
291 << satPhaseBias._MWConsistInd << endl;
[6493]292 }
[6494]293 *out << satPhaseBias._prn.toString() << ' '
[8617]294 << setw(12) << setprecision(8) << satPhaseBias._yaw * 180.0 / M_PI << ' '
295 << setw(12) << setprecision(8) << satPhaseBias._yawRate * 180.0 / M_PI<< " "
[6567]296 << setw(2) << satPhaseBias._bias.size();
[6493]297 for (unsigned ii = 0; ii < satPhaseBias._bias.size(); ii++) {
298 const t_frqPhaseBias& frqPhaseBias = satPhaseBias._bias[ii];
299 *out << " " << frqPhaseBias._rnxType2ch << ' '
[6494]300 << setw(10) << setprecision(4) << frqPhaseBias._value << ' '
301 << setw(3) << frqPhaseBias._fixIndicator << ' '
302 << setw(3) << frqPhaseBias._fixWideLaneIndicator << ' '
303 << setw(3) << frqPhaseBias._jumpCounter;
[6493]304 }
305 *out << endl;
306 }
307 out->flush();
[6481]308}
[8483]309
310//
[6481]311////////////////////////////////////////////////////////////////////////////
[6507]312void t_satPhaseBias::readEpoch(const string& epoLine, istream& inStream, QList<t_satPhaseBias>& biasList) {
[6556]313 bncTime epoTime;
314 unsigned int updateInt;
315 int numSat;
316 string staID;
[6859]317 unsigned int dispInd;
318 unsigned int mwInd;
[6556]319 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numSat, staID) != t_corrSSR::phaseBias) {
[6506]320 return;
321 }
[6859]322 for (int ii = 0; ii <= numSat; ii++) {
[6506]323 t_satPhaseBias satPhaseBias;
[6556]324 satPhaseBias._time = epoTime;
325 satPhaseBias._updateInt = updateInt;
326 satPhaseBias._staID = staID;
[6506]327
328 string line;
[6507]329 getline(inStream, line);
[6506]330 istringstream in(line.c_str());
[6857]331
[6859]332 if (ii == 0) {
333 in >> dispInd >> mwInd;
334 continue;
335 }
336 satPhaseBias._dispBiasConstistInd = dispInd;
337 satPhaseBias._MWConsistInd = mwInd;
338
[6567]339 int numBias;
[8617]340 double yawDeg, yawDegRate;
341 in >> satPhaseBias._prn >> yawDeg >> yawDegRate >> numBias;
342 satPhaseBias._yaw = yawDeg * M_PI / 180.0;
343 satPhaseBias._yawRate = yawDegRate * M_PI / 180.0;
[6506]344
345 while (in.good()) {
346 t_frqPhaseBias frqPhaseBias;
347 in >> frqPhaseBias._rnxType2ch >> frqPhaseBias._value
348 >> frqPhaseBias._fixIndicator >> frqPhaseBias._fixWideLaneIndicator
349 >> frqPhaseBias._jumpCounter;
350 if (!frqPhaseBias._rnxType2ch.empty()) {
351 satPhaseBias._bias.push_back(frqPhaseBias);
352 }
353 }
354
355 biasList.push_back(satPhaseBias);
356 }
[6481]357}
[6482]358
[8483]359//
[6482]360////////////////////////////////////////////////////////////////////////////
[6507]361void t_vTec::write(ostream* out, const t_vTec& vTec) {
[6493]362 if (!out || vTec._layers.size() == 0) {
363 return;
364 }
365 out->setf(ios::fixed);
366 bncTime epoTime = vTec._time;
[6556]367 *out << "> VTEC " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
368 << vTec._updateInt << " "
[6493]369 << vTec._layers.size() << ' ' << vTec._staID << endl;
[6495]370 for (unsigned ii = 0; ii < vTec._layers.size(); ii++) {
371 const t_vTecLayer& layer = vTec._layers[ii];
[6496]372 *out << setw(2) << ii+1 << ' '
[6878]373 << setw(2) << layer._C.Nrows()-1 << ' '
374 << setw(2) << layer._C.Ncols()-1 << ' '
[8483]375 << setw(10) << setprecision(1) << layer._height << endl
376 << setw(10) << setprecision(4) << layer._C
[6495]377 << setw(10) << setprecision(4) << layer._S;
378 }
[6493]379 out->flush();
[6482]380}
381
[8483]382//
[6482]383////////////////////////////////////////////////////////////////////////////
[6507]384void t_vTec::read(const string& epoLine, istream& inStream, t_vTec& vTec) {
[6556]385 bncTime epoTime;
386 unsigned int updateInt;
387 int numLayers;
388 string staID;
389 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numLayers, staID) != t_corrSSR::vTec) {
[6507]390 return;
391 }
392 if (numLayers <= 0) {
393 return;
394 }
[6556]395 vTec._time = epoTime;
396 vTec._updateInt = updateInt;
397 vTec._staID = staID;
[6507]398 for (int ii = 0; ii < numLayers; ii++) {
399 t_vTecLayer layer;
400
401 string line;
402 getline(inStream, line);
403 istringstream in(line.c_str());
404
405 int dummy, maxDeg, maxOrd;
[6515]406 in >> dummy >> maxDeg >> maxOrd >> layer._height;
[6507]407
[6878]408 layer._C.ReSize(maxDeg+1, maxOrd+1);
409 layer._S.ReSize(maxDeg+1, maxOrd+1);
[6507]410
[6878]411 for (int iDeg = 0; iDeg <= maxDeg; iDeg++) {
412 for (int iOrd = 0; iOrd <= maxOrd; iOrd++) {
[6508]413 inStream >> layer._C[iDeg][iOrd];
414 }
415 }
[6878]416 for (int iDeg = 0; iDeg <= maxDeg; iDeg++) {
417 for (int iOrd = 0; iOrd <= maxOrd; iOrd++) {
[6508]418 inStream >> layer._S[iDeg][iOrd];
419 }
420 }
[6507]421
422 vTec._layers.push_back(layer);
423 }
[6482]424}
[6498]425
[8483]426//
[6498]427////////////////////////////////////////////////////////////////////////////
[8483]428t_corrSSR::e_type t_corrSSR::readEpoLine(const string& line, bncTime& epoTime,
[6556]429 unsigned int& updateInt, int& numEntries,
430 string& staID) {
[6498]431
[6500]432 istringstream inLine(line.c_str());
433
434 char epoChar;
435 string typeString;
436 int year, month, day, hour, min;
437 double sec;
438
[8483]439 inLine >> epoChar >> typeString
[6556]440 >> year >> month >> day >> hour >> min >> sec >> updateInt >> numEntries >> staID;
[6500]441
442 if (epoChar == '>') {
443 epoTime.set(year, month, day, hour, min, sec);
444 if (typeString == "CLOCK") {
445 return clkCorr;
446 }
447 else if (typeString == "ORBIT") {
448 return orbCorr;
449 }
450 else if (typeString == "CODE_BIAS") {
451 return codeBias;
452 }
453 else if (typeString == "PHASE_BIAS") {
454 return phaseBias;
455 }
456 else if (typeString == "VTEC") {
457 return vTec;
458 }
[8483]459 else if (typeString == "URA") {
460 return URA;
461 }
[6500]462 }
463
464 return unknown;
[6498]465}
Note: See TracBrowser for help on using the repository browser.