1 | #include <iostream>
|
---|
2 | #include <iomanip>
|
---|
3 | #include <sstream>
|
---|
4 | #include <newmatio.h>
|
---|
5 |
|
---|
6 | #include "satObs.h"
|
---|
7 |
|
---|
8 | using namespace std;
|
---|
9 |
|
---|
10 | // Constructor
|
---|
11 | ////////////////////////////////////////////////////////////////////////////
|
---|
12 | t_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 | ////////////////////////////////////////////////////////////////////////////
|
---|
22 | void 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(3) << 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 | ////////////////////////////////////////////////////////////////////////////
|
---|
47 | void 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 |
|
---|
67 | corr._dClk /= t_CST::c;
|
---|
68 | corr._dotDClk /= t_CST::c;
|
---|
69 | corr._dotDotDClk /= t_CST::c;
|
---|
70 |
|
---|
71 | corrList.push_back(corr);
|
---|
72 | }
|
---|
73 | }
|
---|
74 |
|
---|
75 | // Constructor
|
---|
76 | ////////////////////////////////////////////////////////////////////////////
|
---|
77 | t_orbCorr::t_orbCorr() {
|
---|
78 | _updateInt = 0;
|
---|
79 | _iod = 0;
|
---|
80 | _system = 'R';
|
---|
81 | _xr.ReSize(3); _xr = 0.0;
|
---|
82 | _dotXr.ReSize(3); _dotXr = 0.0;
|
---|
83 | }
|
---|
84 |
|
---|
85 | //
|
---|
86 | ////////////////////////////////////////////////////////////////////////////
|
---|
87 | void t_orbCorr::writeEpoch(ostream* out, const QList<t_orbCorr>& corrList) {
|
---|
88 | if (!out || corrList.size() == 0) {
|
---|
89 | return;
|
---|
90 | }
|
---|
91 | out->setf(ios::fixed);
|
---|
92 | bncTime epoTime;
|
---|
93 | QListIterator<t_orbCorr> it(corrList);
|
---|
94 | while (it.hasNext()) {
|
---|
95 | const t_orbCorr& corr = it.next();
|
---|
96 | if (!epoTime.valid()) {
|
---|
97 | epoTime = corr._time;
|
---|
98 | *out << "> ORBIT " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
|
---|
99 | << corr._updateInt << " "
|
---|
100 | << corrList.size() << ' ' << corr._staID << endl;
|
---|
101 | }
|
---|
102 | *out << corr._prn.toString() << ' ' << setw(3) << corr._iod << ' '
|
---|
103 | << setw(10) << setprecision(4) << corr._xr[0] << ' '
|
---|
104 | << setw(10) << setprecision(4) << corr._xr[1] << ' '
|
---|
105 | << setw(10) << setprecision(4) << corr._xr[2] << " "
|
---|
106 | << setw(10) << setprecision(4) << corr._dotXr[0] << ' '
|
---|
107 | << setw(10) << setprecision(4) << corr._dotXr[1] << ' '
|
---|
108 | << setw(10) << setprecision(4) << corr._dotXr[2] << endl;
|
---|
109 | }
|
---|
110 | out->flush();
|
---|
111 | }
|
---|
112 |
|
---|
113 | //
|
---|
114 | ////////////////////////////////////////////////////////////////////////////
|
---|
115 | void t_orbCorr::readEpoch(const string& epoLine, istream& inStream, QList<t_orbCorr>& corrList) {
|
---|
116 | bncTime epoTime;
|
---|
117 | unsigned int updateInt;
|
---|
118 | int numCorr;
|
---|
119 | string staID;
|
---|
120 | if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numCorr, staID) != t_corrSSR::orbCorr) {
|
---|
121 | return;
|
---|
122 | }
|
---|
123 | for (int ii = 0; ii < numCorr; ii++) {
|
---|
124 | t_orbCorr corr;
|
---|
125 | corr._time = epoTime;
|
---|
126 | corr._updateInt = updateInt;
|
---|
127 | corr._staID = staID;
|
---|
128 |
|
---|
129 | string line;
|
---|
130 | getline(inStream, line);
|
---|
131 | istringstream in(line.c_str());
|
---|
132 |
|
---|
133 | in >> corr._prn >> corr._iod
|
---|
134 | >> corr._xr[0] >> corr._xr[1] >> corr._xr[2]
|
---|
135 | >> corr._dotXr[0] >> corr._dotXr[1] >> corr._dotXr[2];
|
---|
136 |
|
---|
137 | corrList.push_back(corr);
|
---|
138 | }
|
---|
139 | }
|
---|
140 |
|
---|
141 | //
|
---|
142 | ////////////////////////////////////////////////////////////////////////////
|
---|
143 | void t_satCodeBias::writeEpoch(ostream* out, const QList<t_satCodeBias>& biasList) {
|
---|
144 | if (!out || biasList.size() == 0) {
|
---|
145 | return;
|
---|
146 | }
|
---|
147 | out->setf(ios::fixed);
|
---|
148 | bncTime epoTime;
|
---|
149 | QListIterator<t_satCodeBias> it(biasList);
|
---|
150 | while (it.hasNext()) {
|
---|
151 | const t_satCodeBias& satCodeBias = it.next();
|
---|
152 | if (!epoTime.valid()) {
|
---|
153 | epoTime = satCodeBias._time;
|
---|
154 | *out << "> CODE_BIAS " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
|
---|
155 | << satCodeBias._updateInt << " "
|
---|
156 | << biasList.size() << ' ' << satCodeBias._staID << endl;
|
---|
157 | }
|
---|
158 | *out << satCodeBias._prn.toString() << " " << setw(2) << satCodeBias._bias.size();
|
---|
159 | for (unsigned ii = 0; ii < satCodeBias._bias.size(); ii++) {
|
---|
160 | const t_frqCodeBias& frqCodeBias = satCodeBias._bias[ii];
|
---|
161 | *out << " " << frqCodeBias._rnxType2ch << ' '
|
---|
162 | << setw(10) << setprecision(4) << frqCodeBias._value;
|
---|
163 | }
|
---|
164 | *out << endl;
|
---|
165 | }
|
---|
166 | out->flush();
|
---|
167 | }
|
---|
168 |
|
---|
169 | //
|
---|
170 | ////////////////////////////////////////////////////////////////////////////
|
---|
171 | void t_satCodeBias::readEpoch(const string& epoLine, istream& inStream, QList<t_satCodeBias>& biasList) {
|
---|
172 | bncTime epoTime;
|
---|
173 | unsigned int updateInt;
|
---|
174 | int numSat;
|
---|
175 | string staID;
|
---|
176 | if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numSat, staID) != t_corrSSR::codeBias) {
|
---|
177 | return;
|
---|
178 | }
|
---|
179 | for (int ii = 0; ii < numSat; ii++) {
|
---|
180 | t_satCodeBias satCodeBias;
|
---|
181 | satCodeBias._time = epoTime;
|
---|
182 | satCodeBias._updateInt = updateInt;
|
---|
183 | satCodeBias._staID = staID;
|
---|
184 |
|
---|
185 | string line;
|
---|
186 | getline(inStream, line);
|
---|
187 | istringstream in(line.c_str());
|
---|
188 |
|
---|
189 | int numBias;
|
---|
190 | in >> satCodeBias._prn >> numBias;
|
---|
191 |
|
---|
192 | while (in.good()) {
|
---|
193 | t_frqCodeBias frqCodeBias;
|
---|
194 | in >> frqCodeBias._rnxType2ch >> frqCodeBias._value;
|
---|
195 | if (!frqCodeBias._rnxType2ch.empty()) {
|
---|
196 | satCodeBias._bias.push_back(frqCodeBias);
|
---|
197 | }
|
---|
198 | }
|
---|
199 |
|
---|
200 | biasList.push_back(satCodeBias);
|
---|
201 | }
|
---|
202 | }
|
---|
203 |
|
---|
204 | //
|
---|
205 | ////////////////////////////////////////////////////////////////////////////
|
---|
206 | void t_satPhaseBias::writeEpoch(ostream* out, const QList<t_satPhaseBias>& biasList) {
|
---|
207 | if (!out || biasList.size() == 0) {
|
---|
208 | return;
|
---|
209 | }
|
---|
210 | out->setf(ios::fixed);
|
---|
211 | bncTime epoTime;
|
---|
212 | QListIterator<t_satPhaseBias> it(biasList);
|
---|
213 | while (it.hasNext()) {
|
---|
214 | const t_satPhaseBias& satPhaseBias = it.next();
|
---|
215 | if (!epoTime.valid()) {
|
---|
216 | epoTime = satPhaseBias._time;
|
---|
217 | *out << "> PHASE_BIAS " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
|
---|
218 | << satPhaseBias._updateInt << " "
|
---|
219 | << biasList.size() << ' ' << satPhaseBias._staID << endl;
|
---|
220 | *out << " " << satPhaseBias._dispBiasConstistInd << " "
|
---|
221 | << satPhaseBias._MWConsistInd << endl;
|
---|
222 | }
|
---|
223 | *out << satPhaseBias._prn.toString() << ' '
|
---|
224 | << setw(12) << setprecision(8) << satPhaseBias._yawDeg << ' '
|
---|
225 | << setw(12) << setprecision(8) << satPhaseBias._yawDegRate << " "
|
---|
226 | << setw(2) << satPhaseBias._bias.size();
|
---|
227 | for (unsigned ii = 0; ii < satPhaseBias._bias.size(); ii++) {
|
---|
228 | const t_frqPhaseBias& frqPhaseBias = satPhaseBias._bias[ii];
|
---|
229 | *out << " " << frqPhaseBias._rnxType2ch << ' '
|
---|
230 | << setw(10) << setprecision(4) << frqPhaseBias._value << ' '
|
---|
231 | << setw(3) << frqPhaseBias._fixIndicator << ' '
|
---|
232 | << setw(3) << frqPhaseBias._fixWideLaneIndicator << ' '
|
---|
233 | << setw(3) << frqPhaseBias._jumpCounter;
|
---|
234 | }
|
---|
235 | *out << endl;
|
---|
236 | }
|
---|
237 | out->flush();
|
---|
238 | }
|
---|
239 |
|
---|
240 | //
|
---|
241 | ////////////////////////////////////////////////////////////////////////////
|
---|
242 | void t_satPhaseBias::readEpoch(const string& epoLine, istream& inStream, QList<t_satPhaseBias>& biasList) {
|
---|
243 | bncTime epoTime;
|
---|
244 | unsigned int updateInt;
|
---|
245 | int numSat;
|
---|
246 | string staID;
|
---|
247 | unsigned int dispInd;
|
---|
248 | unsigned int mwInd;
|
---|
249 | if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numSat, staID) != t_corrSSR::phaseBias) {
|
---|
250 | return;
|
---|
251 | }
|
---|
252 | for (int ii = 0; ii <= numSat; ii++) {
|
---|
253 | t_satPhaseBias satPhaseBias;
|
---|
254 | satPhaseBias._time = epoTime;
|
---|
255 | satPhaseBias._updateInt = updateInt;
|
---|
256 | satPhaseBias._staID = staID;
|
---|
257 |
|
---|
258 | string line;
|
---|
259 | getline(inStream, line);
|
---|
260 | istringstream in(line.c_str());
|
---|
261 |
|
---|
262 | if (ii == 0) {
|
---|
263 | in >> dispInd >> mwInd;
|
---|
264 | continue;
|
---|
265 | }
|
---|
266 | satPhaseBias._dispBiasConstistInd = dispInd;
|
---|
267 | satPhaseBias._MWConsistInd = mwInd;
|
---|
268 |
|
---|
269 | int numBias;
|
---|
270 | in >> satPhaseBias._prn >> satPhaseBias._yawDeg >> satPhaseBias._yawDegRate
|
---|
271 | >> numBias;
|
---|
272 |
|
---|
273 | while (in.good()) {
|
---|
274 | t_frqPhaseBias frqPhaseBias;
|
---|
275 | in >> frqPhaseBias._rnxType2ch >> frqPhaseBias._value
|
---|
276 | >> frqPhaseBias._fixIndicator >> frqPhaseBias._fixWideLaneIndicator
|
---|
277 | >> frqPhaseBias._jumpCounter;
|
---|
278 | if (!frqPhaseBias._rnxType2ch.empty()) {
|
---|
279 | satPhaseBias._bias.push_back(frqPhaseBias);
|
---|
280 | }
|
---|
281 | }
|
---|
282 |
|
---|
283 | biasList.push_back(satPhaseBias);
|
---|
284 | }
|
---|
285 | }
|
---|
286 |
|
---|
287 | //
|
---|
288 | ////////////////////////////////////////////////////////////////////////////
|
---|
289 | void t_vTec::write(ostream* out, const t_vTec& vTec) {
|
---|
290 | if (!out || vTec._layers.size() == 0) {
|
---|
291 | return;
|
---|
292 | }
|
---|
293 | out->setf(ios::fixed);
|
---|
294 | bncTime epoTime = vTec._time;
|
---|
295 | *out << "> VTEC " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
|
---|
296 | << vTec._updateInt << " "
|
---|
297 | << vTec._layers.size() << ' ' << vTec._staID << endl;
|
---|
298 | for (unsigned ii = 0; ii < vTec._layers.size(); ii++) {
|
---|
299 | const t_vTecLayer& layer = vTec._layers[ii];
|
---|
300 | *out << setw(2) << ii+1 << ' '
|
---|
301 | << setw(2) << layer._C.Nrows()-1 << ' '
|
---|
302 | << setw(2) << layer._C.Ncols()-1 << ' '
|
---|
303 | << setw(10) << setprecision(1) << layer._height << endl
|
---|
304 | << setw(10) << setprecision(4) << layer._C
|
---|
305 | << setw(10) << setprecision(4) << layer._S;
|
---|
306 | }
|
---|
307 | out->flush();
|
---|
308 | }
|
---|
309 |
|
---|
310 | //
|
---|
311 | ////////////////////////////////////////////////////////////////////////////
|
---|
312 | void t_vTec::read(const string& epoLine, istream& inStream, t_vTec& vTec) {
|
---|
313 | bncTime epoTime;
|
---|
314 | unsigned int updateInt;
|
---|
315 | int numLayers;
|
---|
316 | string staID;
|
---|
317 | if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numLayers, staID) != t_corrSSR::vTec) {
|
---|
318 | return;
|
---|
319 | }
|
---|
320 | if (numLayers <= 0) {
|
---|
321 | return;
|
---|
322 | }
|
---|
323 | vTec._time = epoTime;
|
---|
324 | vTec._updateInt = updateInt;
|
---|
325 | vTec._staID = staID;
|
---|
326 | for (int ii = 0; ii < numLayers; ii++) {
|
---|
327 | t_vTecLayer layer;
|
---|
328 |
|
---|
329 | string line;
|
---|
330 | getline(inStream, line);
|
---|
331 | istringstream in(line.c_str());
|
---|
332 |
|
---|
333 | int dummy, maxDeg, maxOrd;
|
---|
334 | in >> dummy >> maxDeg >> maxOrd >> layer._height;
|
---|
335 |
|
---|
336 | layer._C.ReSize(maxDeg+1, maxOrd+1);
|
---|
337 | layer._S.ReSize(maxDeg+1, maxOrd+1);
|
---|
338 |
|
---|
339 | for (int iDeg = 0; iDeg <= maxDeg; iDeg++) {
|
---|
340 | for (int iOrd = 0; iOrd <= maxOrd; iOrd++) {
|
---|
341 | inStream >> layer._C[iDeg][iOrd];
|
---|
342 | }
|
---|
343 | }
|
---|
344 | for (int iDeg = 0; iDeg <= maxDeg; iDeg++) {
|
---|
345 | for (int iOrd = 0; iOrd <= maxOrd; iOrd++) {
|
---|
346 | inStream >> layer._S[iDeg][iOrd];
|
---|
347 | }
|
---|
348 | }
|
---|
349 |
|
---|
350 | vTec._layers.push_back(layer);
|
---|
351 | }
|
---|
352 | }
|
---|
353 |
|
---|
354 | //
|
---|
355 | ////////////////////////////////////////////////////////////////////////////
|
---|
356 | t_corrSSR::e_type t_corrSSR::readEpoLine(const string& line, bncTime& epoTime,
|
---|
357 | unsigned int& updateInt, int& numEntries,
|
---|
358 | string& staID) {
|
---|
359 |
|
---|
360 | istringstream inLine(line.c_str());
|
---|
361 |
|
---|
362 | char epoChar;
|
---|
363 | string typeString;
|
---|
364 | int year, month, day, hour, min;
|
---|
365 | double sec;
|
---|
366 |
|
---|
367 | inLine >> epoChar >> typeString
|
---|
368 | >> year >> month >> day >> hour >> min >> sec >> updateInt >> numEntries >> staID;
|
---|
369 |
|
---|
370 | if (epoChar == '>') {
|
---|
371 | epoTime.set(year, month, day, hour, min, sec);
|
---|
372 | if (typeString == "CLOCK") {
|
---|
373 | return clkCorr;
|
---|
374 | }
|
---|
375 | else if (typeString == "ORBIT") {
|
---|
376 | return orbCorr;
|
---|
377 | }
|
---|
378 | else if (typeString == "CODE_BIAS") {
|
---|
379 | return codeBias;
|
---|
380 | }
|
---|
381 | else if (typeString == "PHASE_BIAS") {
|
---|
382 | return phaseBias;
|
---|
383 | }
|
---|
384 | else if (typeString == "VTEC") {
|
---|
385 | return vTec;
|
---|
386 | }
|
---|
387 | }
|
---|
388 |
|
---|
389 | return unknown;
|
---|
390 | }
|
---|