27 #include <QtCore/QDir>
28 #include <QtCore/QFile>
29 #include <QtCore/QRegularExpression>
30 #include <QtCore/QTextStream>
46 {
"CABL DEL",
"UNPHASCL",
"NDRYCONT",
"NWETCONT",
" ",
"WVR DELY" };
49 {
"CFAKBDRY",
"CFAKBWET",
"CFAJJDRY",
"IFADRFLY",
"IFADRYSS",
"MTTDRFLY",
"MTTDRYSS",
"NMFDRFLY" };
52 {
"PTD CONT",
"WOBXCONT",
"WOBYCONT",
"ETD CONT",
"OCE CONT",
"PTOLDCON",
53 "UT1ORTHO",
"WOBORTHO",
"WOBNUTAT",
"FEED.COR",
"WAHRCONT",
"TILTRMVR" };
56 {
"PTD CONT",
"WOBXCONT",
"WOBYCONT",
"ETD CONT",
"OCE CONT",
"UT1ORTHO",
"WOBORTHO",
57 "WOBLIBRA",
"UT1LIBRA",
"OPTLCONT",
"FEED.COR",
"OCE_OLD ",
"TILTRMVR",
"PTOLDCON" };
60 {
"AZEL",
"EQUA",
"X_YN",
"X_YE",
"RICHMOND",
"UNKN"};
104 const QString& acAbbName,
105 QString& path2wrapperFile, QString& wrapperFileName, QString& sessionName,
int& version,
bool noYears)
112 "::guessWrapperFileNameBySession(): processing: " + inputArg);
120 QRegularExpression reVer(
".*_V([0-9]{3}).*");
121 QRegularExpression reOldDbName(
"^(\\d{2}[A-Z]{3}\\d{2}[A-Z0-9]{1,2}).*");
122 QRegularExpression reNewDbName(
"^(\\d{8})-([^\\s_]{2,12}).*");
123 QRegularExpressionMatch match;
127 if ((match=reVer.match(inputArg)).hasMatch())
129 nn = match.captured(1).toInt(&isOk);
133 vVer.sprintf(
"_V%03d", version);
135 "::guessWrapperFileNameBySession(): user provided version is: " + QString(
"").setNum(version));
140 "::guessWrapperFileNameBySession(): cannot guess the version number form: \"" + inputArg +
"\"");
145 if ((match=reOldDbName.match(inputArg)).hasMatch())
147 sessionName = match.captured(1);
148 sYr = sessionName.left(2);
150 else if ((match=reNewDbName.match(inputArg)).hasMatch())
152 sessionName = match.captured(1) +
"-" + match.captured(2);
153 sYr = sessionName.left(4);
157 path2wrapperFile = path2VgosDb;
158 if (path2wrapperFile.right(1) ==
'/')
159 path2wrapperFile.chop(1);
165 if (77 < nn && nn < 100)
169 sYr.sprintf(
"%4d", nn);
170 if (path2wrapperFile.right(4) != sYr)
171 path2wrapperFile +=
"/" + sYr;
173 path2wrapperFile +=
"/" + sessionName;
176 if (!QDir(path2wrapperFile).exists())
179 "::guessWrapperFileNameBySession(): the input directory \"" + path2wrapperFile +
180 "\" does not exist");
185 "::guessWrapperFileNameBySession(): the path to the wrapper file is: \"" + path2wrapperFile +
200 fltList << sessionName + vVer +
"*.wrp";
201 QStringList fList=QDir(path2wrapperFile).entryList(fltList,
202 QDir::Files | QDir::Readable, QDir::Name);
203 if (fList.size() == 0)
206 "::guessWrapperFileNameBySession(): no any wrapper file was found in \"" + path2wrapperFile +
210 else if (fList.size() == 1)
215 wrapperFileName = fList.at(0);
218 if ((match=reVer.match(wrapperFileName)).hasMatch())
220 nn = match.captured(1).toInt(&isOk);
225 "::guessWrapperFileNameBySession(): guessed version is: " + QString(
"").setNum(version));
230 "::guessWrapperFileNameBySession(): cannot guess the version number form: \"" +
231 wrapperFileName +
"\"");
237 "::guessWrapperFileNameBySession(): the wrapper file name is: \"" + wrapperFileName +
"\"");
245 QString str=fList.at(fList.size() - 1);
247 QRegularExpression reSn(
"^(\\d{2}[A-Z]{3}\\d{2}[A-Z0-9]{1,2}|\\d{8}-[\\S]{2,12})_V([0-9]{3}).*");
251 if ((match=reSn.match(str)).hasMatch())
257 vVer = match.captured(2);
260 nn = vVer.toInt(&isOk);
264 vVer.sprintf(
"_V%03d", version);
266 "::guessWrapperFileNameBySession(): guessed version is: " + QString(
"").setNum(version));
271 "::guessWrapperFileNameBySession(): cannot guess a database version from the file \"" +
279 "::guessWrapperFileNameBySession(): cannot parse the string \"" + str +
280 "\", need to update the template");
286 fltList << sessionName + vVer +
"*.wrp";
287 fList = QDir(path2wrapperFile).entryList(fltList, QDir::Files | QDir::Readable, QDir::Name);
288 if (fList.size() == 1)
290 wrapperFileName = fList.at(0);
292 "::guessWrapperFileNameBySession(): guessed the wrapper file name: \"" + wrapperFileName +
298 QStringList noK, kAll;
299 for (
int i=0; i<fList.size(); i++)
301 if (fList.at(i).contains(
"_kall", Qt::CaseInsensitive))
303 if (!fList.at(i).contains(
"_k", Qt::CaseInsensitive))
308 wrapperFileName = noK.at(0);
310 "::guessWrapperFileNameBySession(): guessed the wrapper file name: \"" + wrapperFileName +
"\"");
313 else if (kAll.size() == 1)
315 wrapperFileName = kAll.at(0);
317 "::guessWrapperFileNameBySession(): guessed the wrapper file name: \"" + wrapperFileName +
"\"");
320 else if ( 1 < kAll.size())
322 QStringList noI, iUs, iIvs;
323 QString usId(
"_i"), ivsId(
"_iIVS");
325 for (
int i=0; i<kAll.size(); i++)
327 if (kAll.at(i).contains(usId, Qt::CaseInsensitive))
329 if (kAll.at(i).contains(ivsId, Qt::CaseInsensitive))
332 if (!kAll.at(i).contains(
"_i", Qt::CaseInsensitive))
337 wrapperFileName = iUs.at(0);
339 "::guessWrapperFileNameBySession(): guessed the wrapper file name: \"" +
340 wrapperFileName +
"\"");
343 if (iIvs.size() == 1)
345 wrapperFileName = iIvs.at(0);
347 "::guessWrapperFileNameBySession(): guessed the wrapper file name: \"" +
348 wrapperFileName +
"\"");
351 else if (noI.size() == 1)
353 wrapperFileName = noI.at(0);
355 "::guessWrapperFileNameBySession(): guessed the wrapper file name: \"" +
356 wrapperFileName +
"\"");
359 else if (1 < iUs.size())
361 wrapperFileName = iUs.at(0);
363 "::guessWrapperFileNameBySession(): guessed the wrapper file name: \"" +
364 wrapperFileName +
"\"");
367 else if (1 < iIvs.size())
369 wrapperFileName = iIvs.at(0);
371 "::guessWrapperFileNameBySession(): guessed the wrapper file name: \"" +
372 wrapperFileName +
"\"");
375 else if (1 < noI.size())
377 wrapperFileName = noI.at(0);
379 "::guessWrapperFileNameBySession(): guessed the wrapper file name: \"" +
380 wrapperFileName +
"\"");
385 wrapperFileName = kAll.at(0);
387 "::guessWrapperFileNameBySession(): guessed the wrapper file name (last resort): \"" +
388 wrapperFileName +
"\"");
395 "::guessWrapperFileNameBySession(): cannot guess wrapper file name: noK.size()=" +
396 QString(
"").setNum(noK.size()) +
", kAll.size()=" + QString(
"").setNum(kAll.size()) );
408 QString& path2wrapperFile, QString& wrapperFileName, QString& sessionName,
int& version)
411 "::guessSessionByWrapperFileName(): processing: " + inputArg);
414 int idx=inputArg.lastIndexOf(
"/");
417 path2wrapperFile =
".";
418 wrapperFileName = inputArg;
422 path2wrapperFile =
"/";
423 wrapperFileName = inputArg.mid(1);
427 path2wrapperFile = inputArg.left(idx);
428 wrapperFileName = inputArg.mid(idx + 1);
431 if (path2wrapperFile.at(0) != QChar(
'/') && path2wrapperFile.at(0) != QChar(
'.'))
433 path2wrapperFile = path2VgosDb +
"/" + path2wrapperFile;
435 "::guessSessionByWrapperFileName(): the path to wrapper file has been modified to \"" +
436 path2wrapperFile +
"\"");
440 if (!QFile::exists((path2wrapperFile.size()?path2wrapperFile +
"/" :
"") + wrapperFileName))
443 "::guessSessionByWrapperFileName(): the provided file, " + path2wrapperFile +
"/" +
444 wrapperFileName +
", does not exist");
452 QRegularExpression reOldDbName(
".*(\\d{2}[A-Z]{3}\\d{2}[A-Z0-9]{1,2})_V([0-9]{3}).*");
453 QRegularExpression reNewDbName(
".*(\\d{8})-([\\S]{2,12})_V([0-9]{3}).*");
454 QRegularExpressionMatch match;
456 if ((match=reOldDbName.match(inputArg)).hasMatch())
458 sessionName = match.captured(1);
459 sVer = match.captured(2);
461 else if ((match=reNewDbName.match(inputArg)).hasMatch())
463 sessionName = match.captured(1) +
"-" + match.captured(2);
464 sVer = match.captured(3);
469 "::guessSessionByWrapperFileName(): cannot guess a database name from the string \"" +
475 v = sVer.toInt(&isOk);
480 "::guessSessionByWrapperFileName(): cannot guess a database version from the string \"" +
491 int num=calList.size();
496 "::applyObsCalibrationSetup(): for the version " + QString(
"").setNum(
calcInfo_.
getDversion()) +
497 " of CALC the size of calibration list is unexpected, " + QString(
"").setNum(num) +
504 "::applyObsCalibrationSetup(): all the bit flags are zeros, nothing to apply");
526 for (
int i=0; i<num; i++)
528 const QString &str=calList.at(i);
529 isOn = bitFlags & (1<<i);
530 if (str ==
"PTD CONT")
532 else if (str ==
"WOBXCONT")
534 else if (str ==
"WOBYCONT")
536 else if (str ==
"ETD CONT")
538 else if (str ==
"OCE CONT")
540 else if (str ==
"UT1ORTHO")
542 else if (str ==
"WOBORTHO")
544 else if (str ==
"WOBNUTAT")
546 else if (str ==
"FEED.COR")
548 else if (str ==
"TILTRMVR")
550 else if (str ==
"WOBLIBRA")
552 else if (str ==
"UT1LIBRA")
554 else if (str ==
"OPTLCONT")
556 else if (str ==
"OCE_OLD ")
558 else if (str ==
"PTOLDCON")
560 else if (str ==
"WAHRCONT")
564 "::applyObsCalibrationSetup(): got an unexpected contribution code: " + str +
"; ignored");
568 "::applyObsCalibrationSetup(): calibration set up has been applied assuming version #" +
581 for (
int i=0; i<12; i++)
609 for (
int i=0; i<14; i++)
642 "::formObsCalibrationSetup(): calibration set up has been formed assuming version #" +
650 QMap<QString, QString>& map4Src, QMap<QString, QString>& map4Bnd)
656 if (!mapFileName.size())
660 QFile f(mapFileName);
664 "::importMapFile(): the map file [" + f.fileName() +
"] does not exist");
669 if (f.open(QFile::ReadOnly))
672 QString str(
""), from(
""), to(
"");
673 int numOfStrs, numOfSrc, numOfStn, numOfBnd;
674 QRegExp reStn(
"^stn:\\s*([0-9A-Z]{1}[\\.0-9A-Z\\s_+-]{1,6}[0-9A-Z_]{1})\\s*=>"
675 "\\s*([0-9A-Z-]{1}[0-9A-Z\\s_+-]{1,6}[0-9A-Z_-]{1}).*");
676 QRegExp reSrc(
"^src:\\s*([0-9A-Z]{1}[\\.0-9A-Z\\s_+-]{1,6}[0-9A-Z_]{1})\\s*=>"
677 "\\s*([0-9A-Z-]{1}[0-9A-Z\\s_+-]{1,6}[0-9A-Z_-]{1}).*");
678 QRegExp reBnd(
"^bnd:\\s*([0-9A-Za-z]{1,2})\\s*=>\\s*([0-9A-Za-z-]{1,3}).*");
679 numOfStrs = numOfSrc = numOfStn = numOfBnd = 0;
686 if (-1 < reStn.indexIn(str))
690 from = reStn.cap(1).leftJustified(8,
' ',
true);
691 if (!map4Stn.contains(from))
696 "::importMapFile(): the station \"" + from +
"\" will be excluded from the session");
700 from = reStn.cap(1).leftJustified(8,
' ',
true);
701 to = reStn.cap(2).leftJustified(8,
' ',
true);
702 if (!map4Stn.contains(from))
704 map4Stn.insert(from, to);
706 "::importMapFile(): a station map record added: \"" + from +
"\" => \"" + to +
"\"");
708 else if (map4Stn.value(from) == to)
710 "::importMapFile(): a station map record \"" + from +
"\" => \"" + to +
711 "\" is already in the map");
714 "::importMapFile(): an attempt to change a station map record \"" + from +
715 "\" => \"" + to +
"\"; ignored");
718 else if (str.left(4) ==
"stn:")
720 "::importMapFile(): cannot parse a station map string: \"" + str +
"\"");
723 if (-1 < reSrc.indexIn(str))
727 from = reSrc.cap(1).leftJustified(8,
' ',
true);
728 if (!map4Src.contains(from))
733 "::importMapFile(): the source \"" + from +
"\" will be excluded from the session");
737 from = reSrc.cap(1).leftJustified(8,
' ',
true);
738 to = reSrc.cap(2).leftJustified(8,
' ',
true);;
739 if (!map4Src.contains(from))
741 map4Src.insert(from, to);
743 "::importMapFile(): a source map record added: \"" + from +
"\" => \"" + to +
"\"");
745 else if (map4Src.value(from) == to)
747 "::importMapFile(): a source map record \"" + from +
"\" => \"" + to +
748 "\" is already in the map");
751 "::importMapFile(): an attempt to change a source map record \"" + from +
752 "\" => \"" + to +
"\"; ignored");
755 else if (str.left(4) ==
"src:")
757 "::importMapFile(): cannot parse a source map string: \"" + str +
"\"");
760 if (-1 < reBnd.indexIn(str))
764 from = reBnd.cap(1).trimmed();
765 if (!map4Bnd.contains(from))
770 "::importMapFile(): the band \"" + from +
"\" will be excluded from the session");
774 from = reBnd.cap(1).trimmed();
775 to = reBnd.cap(2).trimmed();
776 if (!map4Bnd.contains(from))
778 map4Bnd.insert(from, to);
780 "::importMapFile(): a band map record added: \"" + from +
"\" => \"" + to +
"\"");
782 else if (map4Bnd.value(from) == to)
784 "::importMapFile(): a band map record \"" + from +
"\" => \"" + to +
785 "\" is already in the map");
788 "::importMapFile(): an attempt to change a band map record \"" + from +
789 "\" => \"" + to +
"\"; ignored");
792 else if (str.left(4) ==
"bnd:")
794 "::importMapFile(): cannot parse a band map string: \"" + str +
"\"");
800 "::importMapFile(): read " + QString(
"").setNum(numOfStrs) +
801 " strings from the map file [" + f.fileName() +
"]");
806 "::importMapFile(): cannot open the map file [" + f.fileName() +
"] for read access");
820 if (map.contains(name))
825 "::check4stationNameMap(): the object \"" + name +
"\" have to be skipped");
829 "::check4stationNameMap(): the input object name \"" + name +
"\" is mapping to \"" +
830 map.value(name) +
"\"");
831 name = map.value(name);
const QString sObsCalibrationList_v11[]
const QString sObsCalibrationList_v10[]
const QString sAntennaMountTypes[]
const QString sFlybyCalibrationList[]
const QString sStationCalibrationList[]
virtual void write(LogLevel, quint32, const QString &, bool=false)
double getDversion() const
void setHave2ApplyUt1OceanTideHFContrib(bool b)
bool getHave2ApplyNutationHFContrib() const
bool getHave2ApplyOldPoleTideContrib() const
void setContribsAreFromDatabase(bool b)
void setHave2ApplyEarthTideContrib(bool b)
void setHave2ApplyOceanPoleTideContrib(bool b)
void setHave2ApplyTiltRemvrContrib(bool b)
bool getHave2ApplyEarthTideContrib() const
bool getHave2ApplyPyContrib() const
bool getHave2ApplyOceanTideContrib() const
bool getHave2ApplyUt1OceanTideHFContrib() const
bool getHave2ApplyPxyOceanTideHFContrib() const
void setHave2ApplyOceanTideContrib(bool b)
bool getHave2ApplyOldOceanTideContrib() const
bool getHave2ApplyPoleTideContrib() const
void setHave2ApplyPoleTideContrib(bool b)
void setHave2ApplyOldPoleTideContrib(bool b)
bool getHave2ApplyPxyLibrationContrib() const
void setHave2ApplyPxyOceanTideHFContrib(bool b)
bool getHave2ApplyTiltRemvrContrib() const
void setHave2ApplyOldOceanTideContrib(bool b)
bool getHave2ApplyPxContrib() const
void setHave2ApplyPxyLibrationContrib(bool b)
void setHave2ApplyPyContrib(bool b)
void setHave2ApplyPxContrib(bool b)
void setHave2ApplyFeedCorrContrib(bool b)
void setHave2ApplyNutationHFContrib(bool b)
void setHave2ApplyUt1LibrationContrib(bool b)
bool getHave2ApplyFeedCorrContrib() const
bool getHave2ApplyUt1LibrationContrib() const
void formObsCalibrationSetup(int &bitFlags, QList< QString > &calList)
void applyObsCalibrationSetup(int bitFlags, const QList< QString > &calList)
static bool guessSessionByWrapperFileName(const QString &inputArg, const QString &path2VgosDb, QString &path2wrapperFile, QString &wrapperFileName, QString &sessionName, int &version)
void importMapFile(const QString &mapFileName, QMap< QString, QString > &map4Stn, QMap< QString, QString > &map4Src, QMap< QString, QString > &map4Bnd)
static bool guessWrapperFileNameBySession(const QString &inputArg, const QString &path2VgosDb, const QString &acAbbName, QString &path2wrapperFile, QString &wrapperFileName, QString &sessionName, int &version, bool noYears=false)
static const QString sSkipCode_
static QString className()
bool check4NameMap(const QMap< QString, QString > &map, QString &name)