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

Last change on this file since 9683 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
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 *1.e3 << ' ' // m/s => mm/s
40 << setw(10) << setprecision(4) << corr._dotDotDClk * t_CST::c *1.e3 << endl; // m/s => mm/s
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 corr._dotDClk /= 1.e3; // mm/s => m/s
74 corr._dotDotDClk /= 1.e3; // mm/s => m/s
75
76 corrList.push_back(corr);
77 }
78}
79
80// Constructor
81////////////////////////////////////////////////////////////////////////////
82t_orbCorr::t_orbCorr() {
83 _updateInt = 0;
84 _iod = 0;
85 _system = 'R';
86 _xr.ReSize(3); _xr = 0.0;
87 _dotXr.ReSize(3); _dotXr = 0.0;
88}
89
90//
91////////////////////////////////////////////////////////////////////////////
92void t_orbCorr::writeEpoch(ostream* out, const QList<t_orbCorr>& corrList) {
93 if (!out || corrList.size() == 0) {
94 return;
95 }
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;
103 *out << "> ORBIT " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
104 << corr._updateInt << " "
105 << corrList.size() << ' ' << corr._staID << endl;
106 }
107 *out << corr._prn.toString() << ' ' << setw(11) << corr._iod << ' '
108 << setw(10) << setprecision(4) << corr._xr[0] << ' '
109 << setw(10) << setprecision(4) << corr._xr[1] << ' '
110 << setw(10) << setprecision(4) << corr._xr[2] << " "
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
114 }
115 out->flush();
116}
117
118//
119////////////////////////////////////////////////////////////////////////////
120void t_orbCorr::readEpoch(const string& epoLine, istream& inStream, QList<t_orbCorr>& corrList) {
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) {
126 return;
127 }
128 for (int ii = 0; ii < numCorr; ii++) {
129 t_orbCorr corr;
130 corr._time = epoTime;
131 corr._updateInt = updateInt;
132 corr._staID = staID;
133
134 string line;
135 getline(inStream, line);
136 istringstream in(line.c_str());
137
138 in >> corr._prn >> corr._iod
139 >> corr._xr[0] >> corr._xr[1] >> corr._xr[2]
140 >> corr._dotXr[0] >> corr._dotXr[1] >> corr._dotXr[2];
141
142 corr._dotXr /= 1.e3; // mm/s => m/s
143
144 if (corr._prn.system() == 'E') {
145 corr._prn.setFlags(1);// I/NAV
146 }
147 corrList.push_back(corr);
148 }
149}
150
151// Constructor
152////////////////////////////////////////////////////////////////////////////
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////////////////////////////////////////////////////////////////////////////
210void t_satCodeBias::writeEpoch(ostream* out, const QList<t_satCodeBias>& biasList) {
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;
221 *out << "> CODE_BIAS " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
222 << satCodeBias._updateInt << " "
223 << biasList.size() << ' ' << satCodeBias._staID << endl;
224 }
225 if (!satCodeBias._bias.size()) {
226 continue;
227 }
228 *out << satCodeBias._prn.toString() << " " << setw(2) << satCodeBias._bias.size();
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 }
234 *out << endl;
235 }
236 out->flush();
237}
238
239//
240////////////////////////////////////////////////////////////////////////////
241void t_satCodeBias::readEpoch(const string& epoLine, istream& inStream, QList<t_satCodeBias>& biasList) {
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) {
247 return;
248 }
249 for (int ii = 0; ii < numSat; ii++) {
250 t_satCodeBias satCodeBias;
251 satCodeBias._time = epoTime;
252 satCodeBias._updateInt = updateInt;
253 satCodeBias._staID = staID;
254
255 string line;
256 getline(inStream, line);
257 istringstream in(line.c_str());
258
259 int numBias;
260 in >> satCodeBias._prn >> numBias;
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 }
272}
273
274//
275////////////////////////////////////////////////////////////////////////////
276void t_satPhaseBias::writeEpoch(ostream* out, const QList<t_satPhaseBias>& biasList) {
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;
287 *out << "> PHASE_BIAS " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
288 << satPhaseBias._updateInt << " "
289 << biasList.size() << ' ' << satPhaseBias._staID << endl;
290 *out << " " << satPhaseBias._dispBiasConstistInd << " "
291 << satPhaseBias._MWConsistInd << endl;
292 }
293 *out << satPhaseBias._prn.toString() << ' '
294 << setw(12) << setprecision(8) << satPhaseBias._yaw * 180.0 / M_PI << ' '
295 << setw(12) << setprecision(8) << satPhaseBias._yawRate * 180.0 / M_PI<< " "
296 << setw(2) << satPhaseBias._bias.size();
297 for (unsigned ii = 0; ii < satPhaseBias._bias.size(); ii++) {
298 const t_frqPhaseBias& frqPhaseBias = satPhaseBias._bias[ii];
299 *out << " " << frqPhaseBias._rnxType2ch << ' '
300 << setw(10) << setprecision(4) << frqPhaseBias._value << ' '
301 << setw(3) << frqPhaseBias._fixIndicator << ' '
302 << setw(3) << frqPhaseBias._fixWideLaneIndicator << ' '
303 << setw(3) << frqPhaseBias._jumpCounter;
304 }
305 *out << endl;
306 }
307 out->flush();
308}
309
310//
311////////////////////////////////////////////////////////////////////////////
312void t_satPhaseBias::readEpoch(const string& epoLine, istream& inStream, QList<t_satPhaseBias>& biasList) {
313 bncTime epoTime;
314 unsigned int updateInt;
315 int numSat;
316 string staID;
317 unsigned int dispInd;
318 unsigned int mwInd;
319 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numSat, staID) != t_corrSSR::phaseBias) {
320 return;
321 }
322 for (int ii = 0; ii <= numSat; ii++) {
323 t_satPhaseBias satPhaseBias;
324 satPhaseBias._time = epoTime;
325 satPhaseBias._updateInt = updateInt;
326 satPhaseBias._staID = staID;
327
328 string line;
329 getline(inStream, line);
330 istringstream in(line.c_str());
331
332 if (ii == 0) {
333 in >> dispInd >> mwInd;
334 continue;
335 }
336 satPhaseBias._dispBiasConstistInd = dispInd;
337 satPhaseBias._MWConsistInd = mwInd;
338
339 int numBias;
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;
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 }
357}
358
359//
360////////////////////////////////////////////////////////////////////////////
361void t_vTec::write(ostream* out, const t_vTec& vTec) {
362 if (!out || vTec._layers.size() == 0) {
363 return;
364 }
365 out->setf(ios::fixed);
366 bncTime epoTime = vTec._time;
367 *out << "> VTEC " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
368 << vTec._updateInt << " "
369 << vTec._layers.size() << ' ' << vTec._staID << endl;
370 for (unsigned ii = 0; ii < vTec._layers.size(); ii++) {
371 const t_vTecLayer& layer = vTec._layers[ii];
372 *out << setw(2) << ii+1 << ' '
373 << setw(2) << layer._C.Nrows()-1 << ' '
374 << setw(2) << layer._C.Ncols()-1 << ' '
375 << setw(10) << setprecision(1) << layer._height << endl
376 << setw(10) << setprecision(4) << layer._C
377 << setw(10) << setprecision(4) << layer._S;
378 }
379 out->flush();
380}
381
382//
383////////////////////////////////////////////////////////////////////////////
384void t_vTec::read(const string& epoLine, istream& inStream, t_vTec& vTec) {
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) {
390 return;
391 }
392 if (numLayers <= 0) {
393 return;
394 }
395 vTec._time = epoTime;
396 vTec._updateInt = updateInt;
397 vTec._staID = staID;
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;
406 in >> dummy >> maxDeg >> maxOrd >> layer._height;
407
408 layer._C.ReSize(maxDeg+1, maxOrd+1);
409 layer._S.ReSize(maxDeg+1, maxOrd+1);
410
411 for (int iDeg = 0; iDeg <= maxDeg; iDeg++) {
412 for (int iOrd = 0; iOrd <= maxOrd; iOrd++) {
413 inStream >> layer._C[iDeg][iOrd];
414 }
415 }
416 for (int iDeg = 0; iDeg <= maxDeg; iDeg++) {
417 for (int iOrd = 0; iOrd <= maxOrd; iOrd++) {
418 inStream >> layer._S[iDeg][iOrd];
419 }
420 }
421
422 vTec._layers.push_back(layer);
423 }
424}
425
426//
427////////////////////////////////////////////////////////////////////////////
428t_corrSSR::e_type t_corrSSR::readEpoLine(const string& line, bncTime& epoTime,
429 unsigned int& updateInt, int& numEntries,
430 string& staID) {
431
432 istringstream inLine(line.c_str());
433
434 char epoChar;
435 string typeString;
436 int year, month, day, hour, min;
437 double sec;
438
439 inLine >> epoChar >> typeString
440 >> year >> month >> day >> hour >> min >> sec >> updateInt >> numEntries >> staID;
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 }
459 else if (typeString == "URA") {
460 return URA;
461 }
462 }
463
464 return unknown;
465}
Note: See TracBrowser for help on using the repository browser.