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

Last change on this file since 8654 was 8617, checked in by stuerze, 6 years ago

a computed lock time is added for RTCM3 phase observations as an optional feed engine output

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