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

Last change on this file since 10468 was 10311, checked in by stuerze, 11 months ago

minor changes

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