source: ntrip/trunk/BNC/src/bncsinextro.cpp@ 10460

Last change on this file since 10460 was 10149, checked in by stuerze, 16 months ago

sinex tropo file output updated

  • Property svn:keywords set to Author Date Id Rev URL;svn:eol-style=native
  • Property svn:mime-type set to text/plain
File size: 13.0 KB
RevLine 
[6653]1
2/* -------------------------------------------------------------------------
3 * BKG NTRIP Server
4 * -------------------------------------------------------------------------
5 *
6 * Class: bncSinexTro
7 *
8 * Purpose: writes SINEX TRO files
9 *
10 * Author: A. Stürze
11 *
12 * Created: 19-Feb-2015
13 *
14 * Changes:
15 *
16 * -----------------------------------------------------------------------*/
17
18#include <math.h>
19#include <iomanip>
20
21#include "bncsinextro.h"
22
23using namespace BNC_PPP;
24using namespace std;
25
26// Constructor
27////////////////////////////////////////////////////////////////////////////
28bncSinexTro::bncSinexTro(const t_pppOptions* opt,
29 const QString& sklFileName, const QString& intr,
30 int sampl)
31 : bncoutf(sklFileName, intr, sampl) {
[7521]32
[9889]33 _opt = opt;
[10130]34 _sampl = sampl;
[7521]35
[7862]36 _antex = 0;
[6653]37}
38
39// Destructor
40////////////////////////////////////////////////////////////////////////////
41bncSinexTro::~bncSinexTro() {
42 closeFile();
[7521]43 if (_antex)
44 delete _antex;
[6653]45}
46
47// Write Header
48////////////////////////////////////////////////////////////////////////////
49void bncSinexTro::writeHeader(const QDateTime& datTim) {
50 int GPSWeek;
51 double GPSWeeks;
[7521]52 bncSettings settings;
[6653]53 GPSweekFromDateAndTime(datTim, GPSWeek, GPSWeeks);
54 int daysec = int(fmod(GPSWeeks, 86400.0));
55 int dayOfYear = datTim.date().dayOfYear();
[10130]56 QString yyyy = datTim.toString("yyyy");
57 QString creationTime = QString("%1:%2:%3").arg(yyyy)
[6653]58 .arg(dayOfYear, 3, 10, QLatin1Char('0'))
59 .arg(daysec , 5, 10, QLatin1Char('0'));
60 QString startTime = creationTime;
[7521]61 QString intStr = settings.value("PPP/snxtroIntr").toString();
62 int intr, indHlp = 0;
63 if ((indHlp = intStr.indexOf("min")) != -1) {
64 intr = intStr.left(indHlp-1).toInt();
65 intr *= 60;
66 }
67 else if ((indHlp = intStr.indexOf("hour")) != -1) {
68 intr = intStr.left(indHlp-1).toInt();
69 intr *= 3600;
70 }
71 else if ((indHlp = intStr.indexOf("day")) != -1) {
72 intr = intStr.left(indHlp-1).toInt();
73 intr *= 86400;
74 }
[7767]75 int nominalStartSec = daysec - (int(fmod(double(daysec), double(intr))));
76 int nominalEndSec = nominalStartSec + intr - _sampl;
[10130]77 QString endTime = QString("%1:%2:%3").arg(yyyy)
[7767]78 .arg(dayOfYear , 3, 10, QLatin1Char('0'))
79 .arg(nominalEndSec , 5, 10, QLatin1Char('0'));
80 int numEpochs = ((nominalEndSec - daysec) / _sampl) +1;
[10127]81 QString epo = QString("%1").arg(numEpochs, 5, 10, QLatin1Char('0'));
82 QString ac = QString("%1").arg(settings.value("PPP/snxtroAc").toString(),3,QLatin1Char(' '));
83 QString solId = settings.value("PPP/snxtroSolId").toString();
[9889]84 QString corr = "";
85 if (settings.value("PPP/dataSource").toString() == "Real-Time Streams") {
86 corr = settings.value("PPP/corrMount").toString();
87 }
88 else if (settings.value("PPP/dataSource").toString() == "RINEX Files") {
89 corr = settings.value("PPP/corrFile").toString();
90 }
91 QString signalPriorities = QString::fromStdString(_opt->_signalPriorities);
92 if (!signalPriorities.size()) {
93 signalPriorities = "G:12&CWPSLX R:12&CP E:1&CBX E:5&QIX C:26&IQX";
94 }
95 QStringList priorList = signalPriorities.split(" ", QString::SkipEmptyParts);
96 QStringList frqStrList;
97 for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
98 t_frequency::type frqType = static_cast<t_frequency::type>(iFreq);
99 char frqSys = t_frequency::toString(frqType)[0];
100 char frqNum = t_frequency::toString(frqType)[1];
101 QStringList hlp;
102 for (int ii = 0; ii < priorList.size(); ii++) {
103 if (priorList[ii].indexOf(":") != -1) {
104 hlp = priorList[ii].split(":", QString::SkipEmptyParts);
105 if (hlp.size() == 2 && hlp[0].length() == 1 && hlp[0][0] == frqSys) {
106 hlp = hlp[1].split("&", QString::SkipEmptyParts);
107 }
108 if (hlp.size() == 2 && hlp[0].indexOf(frqNum) != -1) {
109 frqStrList.append(QString("%1%2").arg(frqSys).arg(frqNum));
110 }
111 }
112 }
113 }
114
[7764]115 _out << "%=TRO 2.00 " << ac.toStdString() << " "
[7767]116 << creationTime.toStdString() << " " << ac.toStdString() << " "
117 << startTime.toStdString() << " " << endTime.toStdString() << " P "
[10130]118 << _opt->_roverName.substr(0,9) << endl;
[10127]119 _out << "*-------------------------------------------------------------------------------" << endl;
[6653]120 _out << "+FILE/REFERENCE" << endl;
[10127]121 _out << "*INFO_TYPE_________ INFO________________________________________________________" << endl;
[6653]122 _out << " DESCRIPTION " << "BNC generated SINEX TRO file" << endl;
123 _out << " OUTPUT " << "Total Troposphere Zenith Path Delay Product" << endl;
[7764]124 _out << " SOFTWARE " << BNCPGMNAME << endl;
[10130]125 _out << " INPUT " << "OBS: " << _opt->_roverName.substr(0,9) << ", SSR: " << corr.toStdString() << endl;
[10149]126 _out << " VERSION NUMBER " << QString("%1").arg(solId, 3, QLatin1Char('0')).toStdString() << endl;
[10127]127 _out << "-FILE/REFERENCE" << endl;
128 _out << "*-------------------------------------------------------------------------------" << endl;
[6653]129
[10130]130 QString systems;
131 if (settings.value("PPP/lcGPS" ).toString() != "no") {systems += "G, ";}
132 if (settings.value("PPP/lcGLONASS").toString() != "no") {systems += "R, ";}
133 if (settings.value("PPP/lcGalileo").toString() != "no") {systems += "E, ";}
134 if (settings.value("PPP/lcBDS" ).toString() != "no") {systems += "C";}
[10127]135 QString blqFileName = QString::fromStdString(_opt->_blqFileName);
136 QString blqFileBaseName;
137 QString blqFileExtension;
138 if (! blqFileName.isEmpty()) {
139 QFileInfo fileInfo(blqFileName);
140 blqFileBaseName = fileInfo.baseName();
141 blqFileExtension = fileInfo.completeSuffix();
142 if (!blqFileExtension.isEmpty()) {
143 blqFileExtension = "." + blqFileExtension;
144 }
145 }
[10130]146 bool eleWeighting = false;
147 if (settings.value("PPP/eleWgtCode").toInt() > 0 ||
148 settings.value("PPP/eleWgtCode").toInt() > 0 ) {
149 eleWeighting = true;
150 }
151
[10127]152 _out << "+TROP/DESCRIPTION" << endl;
153 _out << "*KEYWORD______________________ VALUE(S)______________" << endl;
[10149]154 _out << " TROPO SAMPLING INTERVAL " << left << setw(22) << _sampl << endl;
155 _out << " DATA SAMPLING INTERVAL " << left << setw(22) << 1 << endl;
156 _out << " ELEVATION CUTOFF ANGLE " << left << setw(22) << int(_opt->_minEle * 180.0/M_PI) << endl;
[10130]157 _out << " OBSERVATION WEIGHTING " << ((eleWeighting) ? "SINEL" : "") << endl;
158 _out << " GNSS SYSTEMS " << systems.toStdString() << endl;
159 _out << " TIME SYSTEM " << "G" << endl;
160 _out << " TROPO MODELING METHOD " << "KALMAN FILTER" << endl;
[10127]161 if (! blqFileName.isEmpty()) {
162 _out << " OCEAN TIDE LOADING MODEL " << blqFileBaseName.toStdString() + blqFileExtension.toStdString() << endl;
163 }
164 _out << " TROP MAPPING FUNCTION " << "Saastamoinen" << endl;
[10130]165 _out << " TROPO PARAMETER NAMES " << "TROTOT STDEV" << endl;
166 _out << " TROPO PARAMETER UNITS " << "1e+03 1e+03" << endl;
[10127]167 _out << "-TROP/DESCRIPTION"<< endl;
168 _out << "*-------------------------------------------------------------------------------" << endl;
169
[7764]170 double recEll[3];
171 int lonD, lonM, latD, latM;
172 double lonS, latS;
173 xyz2ell(_opt->_xyzAprRover.data(), recEll);
[7788]174 deg2DMS(recEll[0] * 180.0 / M_PI, latD, latM, latS);
175 deg2DMS(recEll[1] * 180.0 / M_PI, lonD, lonM, lonS);
[7764]176 QString country;
177 QListIterator<QString> it(settings.value("mountPoints").toStringList());
178 while (it.hasNext()) {
179 QStringList hlp = it.next().split(" ");
180 if (hlp.size() < 7)
181 continue;
182 if (hlp.join(" ").indexOf(QString::fromStdString(_opt->_roverName), 0) != -1) {
183 country = hlp[2];
184 }
185 }
[7521]186 _out << "+SITE/ID" << endl;
[10127]187 _out << "*STATION__ PT __DOMES__ T _STATION_DESCRIPTION__ _LONGITUDE _LATITUDE_ _HGT_ELI_" << endl;
[9889]188 _out << " " << _opt->_roverName.substr(0,9) << " A P "
[7764]189 << country.toStdString() << " "
[10127]190 << QString(" %1").arg(recEll[0]* 180.0 / M_PI,10, 'f', 6, QLatin1Char(' ')).toStdString()
191 << QString(" %1").arg(recEll[1]* 180.0 / M_PI,10, 'f', 6, QLatin1Char(' ')).toStdString()
192 << QString(" %1").arg(recEll[2], 9, 'f', 3, QLatin1Char(' ')).toStdString()
[7764]193 << endl;
[10127]194 _out << "-SITE/ID" << endl;
195 _out << "*-------------------------------------------------------------------------------" << endl;
[7521]196
[10127]197 _out << "+TROP/COORDINATES" << endl;
[10130]198 _out << "*STATION__ PT SOLN T __DATA_START__ __DATA_END____ __STA_X_____ __STA_Y_____ __STA_Z_____ SYSTEM REMRK" << endl;
[10127]199 _out << " " << _opt->_roverName.substr(0,9) << " A "
[10130]200 << QString("%1").arg(solId, 4, QLatin1Char(' ')).toStdString() << " P "
201 << startTime.toStdString() << " " << endTime.toStdString()
[10127]202 << QString(" %1").arg(_opt->_xyzAprRover(1), 12, 'f', 3, QLatin1Char(' ')).toStdString()
203 << QString(" %1").arg(_opt->_xyzAprRover(2), 12, 'f', 3, QLatin1Char(' ')).toStdString()
204 << QString(" %1").arg(_opt->_xyzAprRover(3), 12, 'f', 3, QLatin1Char(' ')).toStdString()
[10130]205 << QString(" %1").arg("IGS20", 6, QLatin1Char(' ')).toStdString()
206 << QString(" %1").arg(ac, 5, QLatin1Char(' ')).toStdString() << endl;
[10127]207 _out << "-TROP/COORDINATES"<< endl;
208 _out << "*-------------------------------------------------------------------------------" << endl;
209
210
211 _out << "+SITE/ECCENTRICITY" << endl;
[10130]212 _out << "* UP______ NORTH___ EAST____" << endl;
213 _out << "*STATION__ PT SOLN T __DATA_START__ __DATA_END____ AXE MARKER->ARP(m)__________" << endl;
[10127]214 _out << " " << _opt->_roverName.substr(0,9) << " A "
[10130]215 << QString("%1").arg(solId, 4, QLatin1Char(' ')).toStdString() << " P "
216 << startTime.toStdString() << " " << endTime.toStdString()
217 << QString(" %1").arg("UNE", 3, QLatin1Char(' ')).toStdString()
218 << QString("%1").arg(_opt->_neuEccRover(3), 8, 'f', 4, QLatin1Char(' ')).toStdString()
219 << QString("%1").arg(_opt->_neuEccRover(1), 8, 'f', 4, QLatin1Char(' ')).toStdString()
220 << QString("%1").arg(_opt->_neuEccRover(2), 8, 'f', 4, QLatin1Char(' ')).toStdString() << endl;
[10127]221 _out << "-SITE/ECCENTRICITY" << endl;
222 _out << "*-------------------------------------------------------------------------------" << endl;
223
[7523]224 if (!_opt->_recNameRover.empty()) {
225 _out << "+SITE/RECEIVER" << endl;
[10127]226 _out << "*STATION__ PT SOLN T __DATA_START__ __DATA_END____ DESCRIPTION_________ S/N_________________ FIRMW______" << endl;
[10130]227 _out << " " << _opt->_roverName.substr(0,9) << " A "
228 << QString("%1").arg(solId, 4, QLatin1Char(' ')).toStdString() << " P "
[10149]229 << startTime.toStdString() << " " << endTime.toStdString() << " "
230 << left << std::setw(20) << _opt->_recNameRover
[10130]231 << " --------------------" << " -----------" << endl;
[10127]232 _out << "-SITE/RECEIVER" << endl;
233 _out << "*-------------------------------------------------------------------------------" << endl;
[7523]234 }
[7862]235 if (!_opt->_antexFileName.empty()) {
236 _antex = new bncAntex(_opt->_antexFileName.c_str());
[10130]237 _out << "+SITE/ANTENNA" << endl;
238 _out << "*STATION__ PT SOLN T __DATA_START__ __DATA_END____ DESCRIPTION_________ S/N_________________ PCV_MODEL_" << endl;
239 _out << " " << _opt->_roverName.substr(0,9) << " A "
240 << QString("%1").arg(solId, 4, QLatin1Char(' ')).toStdString() << " P "
241 << startTime.toStdString() << " " << endTime.toStdString()
242 << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
243 << " --------------------" << _antex->snxCodeSinexString(_opt->_antNameRover).toStdString() << endl;
244 _out << "-SITE/ANTENNA" << endl;
245 _out << "*-------------------------------------------------------------------------------" << endl;
[7862]246 delete _antex;
247 _antex = 0;
[10130]248}
[6653]249 _out << "+TROP/SOLUTION" << endl;
[10127]250 _out << "*STATION__ ____EPOCH_____ TROTOT STDDEV " << endl;
[6653]251}
252
253// Write One Epoch
254////////////////////////////////////////////////////////////////////////////
255t_irc bncSinexTro::write(QByteArray staID, int GPSWeek, double GPSWeeks,
256 double trotot, double stdev) {
257
258 QDateTime datTim = dateAndTimeFromGPSweek(GPSWeek, GPSWeeks);
259 int daysec = int(fmod(GPSWeeks, 86400.0));
260 int dayOfYear = datTim.date().dayOfYear();
[10131]261 QString yyyy = datTim.toString("yyyy");
262 QString time = QString("%1:%2:%3").arg(yyyy)
[6653]263 .arg(dayOfYear, 3, 10, QLatin1Char('0'))
264 .arg(daysec , 5, 10, QLatin1Char('0'));
265
266 if ((reopen(GPSWeek, GPSWeeks) == success) &&
267 (fmod(daysec, double(_sampl)) == 0.0)) {
[10131]268 _out << ' ' << staID.left(9).data() << ' ' << time.toStdString()
269 << QString(" %1").arg(trotot * 1000.0, 6, 'f', 1, QLatin1Char(' ')).toStdString()
270 << QString(" %1").arg(stdev * 1000.0, 6, 'f', 1, QLatin1Char(' ')).toStdString() << endl;
[6653]271 _out.flush();
272 return success;
273 } else {
274 return failure;
275 }
276}
277
278// Close File (write last lines)
279////////////////////////////////////////////////////////////////////////////
280void bncSinexTro::closeFile() {
281 _out << "-TROP/SOLUTION" << endl;
282 _out << "%=ENDTROP" << endl;
283 bncoutf::closeFile();
284}
285
286
287
288
Note: See TracBrowser for help on using the repository browser.