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

Last change on this file since 10583 was 10565, checked in by stuerze, 2 months ago

bug fixed in writing CodeBiases into a SSR file

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 << ' '
[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 }
[10565]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 }
[6567]224 *out << satCodeBias._prn.toString() << " " << setw(2) << satCodeBias._bias.size();
[6477]225 for (unsigned ii = 0; ii < satCodeBias._bias.size(); ii++) {
226 const t_frqCodeBias& frqCodeBias = satCodeBias._bias[ii];
227 *out << " " << frqCodeBias._rnxType2ch << ' '
228 << setw(10) << setprecision(4) << frqCodeBias._value;
229 }
[6476]230 *out << endl;
231 }
232 out->flush();
[6475]233}
234
[8483]235//
[6475]236////////////////////////////////////////////////////////////////////////////
[6507]237void t_satCodeBias::readEpoch(const string& epoLine, istream& inStream, QList<t_satCodeBias>& biasList) {
[6556]238 bncTime epoTime;
239 unsigned int updateInt;
240 int numSat;
241 string staID;
242 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numSat, staID) != t_corrSSR::codeBias) {
[6505]243 return;
244 }
245 for (int ii = 0; ii < numSat; ii++) {
246 t_satCodeBias satCodeBias;
[6556]247 satCodeBias._time = epoTime;
248 satCodeBias._updateInt = updateInt;
249 satCodeBias._staID = staID;
[6505]250
251 string line;
[6507]252 getline(inStream, line);
[6505]253 istringstream in(line.c_str());
[8483]254
[6567]255 int numBias;
256 in >> satCodeBias._prn >> numBias;
[6505]257
258 while (in.good()) {
259 t_frqCodeBias frqCodeBias;
260 in >> frqCodeBias._rnxType2ch >> frqCodeBias._value;
261 if (!frqCodeBias._rnxType2ch.empty()) {
262 satCodeBias._bias.push_back(frqCodeBias);
263 }
264 }
265
266 biasList.push_back(satCodeBias);
267 }
[6475]268}
[6481]269
[8483]270//
[6481]271////////////////////////////////////////////////////////////////////////////
[6507]272void t_satPhaseBias::writeEpoch(ostream* out, const QList<t_satPhaseBias>& biasList) {
[6493]273 if (!out || biasList.size() == 0) {
274 return;
275 }
276 out->setf(ios::fixed);
277 bncTime epoTime;
278 QListIterator<t_satPhaseBias> it(biasList);
279 while (it.hasNext()) {
280 const t_satPhaseBias& satPhaseBias = it.next();
281 if (!epoTime.valid()) {
282 epoTime = satPhaseBias._time;
[6556]283 *out << "> PHASE_BIAS " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
284 << satPhaseBias._updateInt << " "
[6857]285 << biasList.size() << ' ' << satPhaseBias._staID << endl;
[6859]286 *out << " " << satPhaseBias._dispBiasConstistInd << " "
287 << satPhaseBias._MWConsistInd << endl;
[6493]288 }
[6494]289 *out << satPhaseBias._prn.toString() << ' '
[8617]290 << setw(12) << setprecision(8) << satPhaseBias._yaw * 180.0 / M_PI << ' '
291 << setw(12) << setprecision(8) << satPhaseBias._yawRate * 180.0 / M_PI<< " "
[6567]292 << setw(2) << satPhaseBias._bias.size();
[6493]293 for (unsigned ii = 0; ii < satPhaseBias._bias.size(); ii++) {
294 const t_frqPhaseBias& frqPhaseBias = satPhaseBias._bias[ii];
295 *out << " " << frqPhaseBias._rnxType2ch << ' '
[6494]296 << setw(10) << setprecision(4) << frqPhaseBias._value << ' '
297 << setw(3) << frqPhaseBias._fixIndicator << ' '
298 << setw(3) << frqPhaseBias._fixWideLaneIndicator << ' '
299 << setw(3) << frqPhaseBias._jumpCounter;
[6493]300 }
301 *out << endl;
302 }
303 out->flush();
[6481]304}
[8483]305
306//
[6481]307////////////////////////////////////////////////////////////////////////////
[6507]308void t_satPhaseBias::readEpoch(const string& epoLine, istream& inStream, QList<t_satPhaseBias>& biasList) {
[6556]309 bncTime epoTime;
310 unsigned int updateInt;
311 int numSat;
312 string staID;
[6859]313 unsigned int dispInd;
314 unsigned int mwInd;
[6556]315 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numSat, staID) != t_corrSSR::phaseBias) {
[6506]316 return;
317 }
[6859]318 for (int ii = 0; ii <= numSat; ii++) {
[6506]319 t_satPhaseBias satPhaseBias;
[6556]320 satPhaseBias._time = epoTime;
321 satPhaseBias._updateInt = updateInt;
322 satPhaseBias._staID = staID;
[6506]323
324 string line;
[6507]325 getline(inStream, line);
[6506]326 istringstream in(line.c_str());
[6857]327
[6859]328 if (ii == 0) {
329 in >> dispInd >> mwInd;
330 continue;
331 }
332 satPhaseBias._dispBiasConstistInd = dispInd;
333 satPhaseBias._MWConsistInd = mwInd;
334
[6567]335 int numBias;
[8617]336 double yawDeg, yawDegRate;
337 in >> satPhaseBias._prn >> yawDeg >> yawDegRate >> numBias;
338 satPhaseBias._yaw = yawDeg * M_PI / 180.0;
339 satPhaseBias._yawRate = yawDegRate * M_PI / 180.0;
[6506]340
341 while (in.good()) {
342 t_frqPhaseBias frqPhaseBias;
343 in >> frqPhaseBias._rnxType2ch >> frqPhaseBias._value
344 >> frqPhaseBias._fixIndicator >> frqPhaseBias._fixWideLaneIndicator
345 >> frqPhaseBias._jumpCounter;
346 if (!frqPhaseBias._rnxType2ch.empty()) {
347 satPhaseBias._bias.push_back(frqPhaseBias);
348 }
349 }
350
351 biasList.push_back(satPhaseBias);
352 }
[6481]353}
[6482]354
[8483]355//
[6482]356////////////////////////////////////////////////////////////////////////////
[6507]357void t_vTec::write(ostream* out, const t_vTec& vTec) {
[6493]358 if (!out || vTec._layers.size() == 0) {
359 return;
360 }
361 out->setf(ios::fixed);
362 bncTime epoTime = vTec._time;
[6556]363 *out << "> VTEC " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
364 << vTec._updateInt << " "
[6493]365 << vTec._layers.size() << ' ' << vTec._staID << endl;
[6495]366 for (unsigned ii = 0; ii < vTec._layers.size(); ii++) {
367 const t_vTecLayer& layer = vTec._layers[ii];
[6496]368 *out << setw(2) << ii+1 << ' '
[6878]369 << setw(2) << layer._C.Nrows()-1 << ' '
370 << setw(2) << layer._C.Ncols()-1 << ' '
[8483]371 << setw(10) << setprecision(1) << layer._height << endl
372 << setw(10) << setprecision(4) << layer._C
[6495]373 << setw(10) << setprecision(4) << layer._S;
374 }
[6493]375 out->flush();
[6482]376}
377
[8483]378//
[6482]379////////////////////////////////////////////////////////////////////////////
[6507]380void t_vTec::read(const string& epoLine, istream& inStream, t_vTec& vTec) {
[6556]381 bncTime epoTime;
382 unsigned int updateInt;
383 int numLayers;
384 string staID;
385 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numLayers, staID) != t_corrSSR::vTec) {
[6507]386 return;
387 }
388 if (numLayers <= 0) {
389 return;
390 }
[6556]391 vTec._time = epoTime;
392 vTec._updateInt = updateInt;
393 vTec._staID = staID;
[6507]394 for (int ii = 0; ii < numLayers; ii++) {
395 t_vTecLayer layer;
396
397 string line;
398 getline(inStream, line);
399 istringstream in(line.c_str());
400
401 int dummy, maxDeg, maxOrd;
[6515]402 in >> dummy >> maxDeg >> maxOrd >> layer._height;
[6507]403
[6878]404 layer._C.ReSize(maxDeg+1, maxOrd+1);
405 layer._S.ReSize(maxDeg+1, maxOrd+1);
[6507]406
[6878]407 for (int iDeg = 0; iDeg <= maxDeg; iDeg++) {
408 for (int iOrd = 0; iOrd <= maxOrd; iOrd++) {
[6508]409 inStream >> layer._C[iDeg][iOrd];
410 }
411 }
[6878]412 for (int iDeg = 0; iDeg <= maxDeg; iDeg++) {
413 for (int iOrd = 0; iOrd <= maxOrd; iOrd++) {
[6508]414 inStream >> layer._S[iDeg][iOrd];
415 }
416 }
[6507]417
418 vTec._layers.push_back(layer);
419 }
[6482]420}
[6498]421
[8483]422//
[6498]423////////////////////////////////////////////////////////////////////////////
[8483]424t_corrSSR::e_type t_corrSSR::readEpoLine(const string& line, bncTime& epoTime,
[6556]425 unsigned int& updateInt, int& numEntries,
426 string& staID) {
[6498]427
[6500]428 istringstream inLine(line.c_str());
429
430 char epoChar;
431 string typeString;
432 int year, month, day, hour, min;
433 double sec;
434
[8483]435 inLine >> epoChar >> typeString
[6556]436 >> year >> month >> day >> hour >> min >> sec >> updateInt >> numEntries >> staID;
[6500]437
438 if (epoChar == '>') {
439 epoTime.set(year, month, day, hour, min, sec);
440 if (typeString == "CLOCK") {
441 return clkCorr;
442 }
443 else if (typeString == "ORBIT") {
444 return orbCorr;
445 }
446 else if (typeString == "CODE_BIAS") {
447 return codeBias;
448 }
449 else if (typeString == "PHASE_BIAS") {
450 return phaseBias;
451 }
452 else if (typeString == "VTEC") {
453 return vTec;
454 }
[8483]455 else if (typeString == "URA") {
456 return URA;
457 }
[6500]458 }
459
460 return unknown;
[6498]461}
Note: See TracBrowser for help on using the repository browser.