27 #include <QtCore/QDir>
28 #include <QtCore/QFile>
29 #include <QtCore/QTextStream>
45 {
"CABL DEL",
"UNPHASCL",
"NDRYCONT",
"NWETCONT",
" ",
"WVR DELY" };
48 {
"CFAKBDRY",
"CFAKBWET",
"CFAJJDRY",
"IFADRFLY",
"IFADRYSS",
"MTTDRFLY",
"MTTDRYSS",
"NMFDRFLY" };
51 {
"PTD CONT",
"WOBXCONT",
"WOBYCONT",
"ETD CONT",
"OCE CONT",
"PTOLDCON",
52 "UT1ORTHO",
"WOBORTHO",
"WOBNUTAT",
"FEED.COR",
"WAHRCONT",
"TILTRMVR" };
55 {
"PTD CONT",
"WOBXCONT",
"WOBYCONT",
"ETD CONT",
"OCE CONT",
"UT1ORTHO",
"WOBORTHO",
56 "WOBLIBRA",
"UT1LIBRA",
"OPTLCONT",
"FEED.COR",
"OCE_OLD ",
"TILTRMVR",
"PTOLDCON" };
59 {
"AZEL",
"EQUA",
"X_YN",
"X_YE",
"RICHMOND",
"UNKN"};
103 const QString& acAbbName,
104 QString& path2wrapperFile, QString& wrapperFileName, QString& sessionName,
int& version,
bool noYears)
111 "::guessWrapperFileNameBySession(): processing: " + inputArg);
118 QRegExp reVer(
".*_V([0-9]{3}).*");
122 if (-1 < reVer.indexIn(inputArg))
124 sessionName = inputArg.mid(0, 9);
126 nn = reVer.cap(1).toInt(&isOk);
130 vVer.sprintf(
"_V%03d", version);
132 "::guessWrapperFileNameBySession(): user provided version is: " + QString(
"").setNum(version));
137 "::guessWrapperFileNameBySession(): cannot guess the version number form: \"" + inputArg +
"\"");
142 sessionName = inputArg;
144 path2wrapperFile = path2VgosDb;
145 if (path2wrapperFile.right(1) ==
'/')
146 path2wrapperFile.chop(1);
150 nn = inputArg.mid(0,2).toInt();
155 sYr.sprintf(
"%4d", nn);
156 if (path2wrapperFile.right(4) != sYr)
157 path2wrapperFile +=
"/" + sYr;
159 path2wrapperFile +=
"/" + sessionName;
161 if (!QDir(path2wrapperFile).exists())
164 "::guessWrapperFileNameBySession(): the input directory \"" + path2wrapperFile +
165 "\" does not exist");
170 "::guessWrapperFileNameBySession(): the path to the wrapper file is: \"" + path2wrapperFile +
175 fltList << sessionName + vVer +
"*.wrp";
176 QStringList fList=QDir(path2wrapperFile).entryList(fltList,
177 QDir::Files | QDir::Readable, QDir::Name);
178 if (fList.size() == 0)
181 "::guessWrapperFileNameBySession(): no any wrapper file was found in \"" + path2wrapperFile +
185 else if (fList.size() == 1)
187 wrapperFileName = fList.at(0);
190 if (-1 < reVer.indexIn(wrapperFileName))
192 nn = reVer.cap(1).toInt(&isOk);
197 "::guessWrapperFileNameBySession(): guessed version is: " + QString(
"").setNum(version));
202 "::guessWrapperFileNameBySession(): cannot guess the version number form: \"" +
203 wrapperFileName +
"\"");
209 "::guessWrapperFileNameBySession(): the wrapper file name is: \"" + wrapperFileName +
"\"");
217 QString str=fList.at(fList.size() - 1);
218 QRegExp reSn(
".*([0-9]{2}[A-Z]{3}[0-9]{2}[A-Z0-9]{1,2})_V([0-9]{3}).*");
220 if (-1 < reSn.indexIn(str))
225 nn = vVer.toInt(&isOk);
229 vVer.sprintf(
"_V%03d", version);
231 "::guessWrapperFileNameBySession(): guessed version is: " + QString(
"").setNum(version));
236 "::guessWrapperFileNameBySession(): cannot guess a database version from the file \"" +
244 "::guessWrapperFileNameBySession(): cannot parse the string \"" + str +
245 "\", need to update the template");
251 fltList << sessionName + vVer +
"*.wrp";
252 fList = QDir(path2wrapperFile).entryList(fltList, QDir::Files | QDir::Readable, QDir::Name);
253 if (fList.size() == 1)
255 wrapperFileName = fList.at(0);
257 "::guessWrapperFileNameBySession(): guessed the wrapper file name: \"" + wrapperFileName +
263 QStringList noK, kAll;
264 for (
int i=0; i<fList.size(); i++)
266 if (fList.at(i).contains(
"_kall", Qt::CaseInsensitive))
268 if (!fList.at(i).contains(
"_k", Qt::CaseInsensitive))
273 wrapperFileName = noK.at(0);
275 "::guessWrapperFileNameBySession(): guessed the wrapper file name: \"" + wrapperFileName +
"\"");
278 else if (kAll.size() == 1)
280 wrapperFileName = kAll.at(0);
282 "::guessWrapperFileNameBySession(): guessed the wrapper file name: \"" + wrapperFileName +
"\"");
285 else if ( 1 < kAll.size())
287 QStringList noI, iUs, iIvs;
288 QString usId(
"_i"), ivsId(
"_iIVS");
290 for (
int i=0; i<kAll.size(); i++)
292 if (kAll.at(i).contains(usId, Qt::CaseInsensitive))
294 if (kAll.at(i).contains(ivsId, Qt::CaseInsensitive))
297 if (!kAll.at(i).contains(
"_i", Qt::CaseInsensitive))
302 wrapperFileName = iUs.at(0);
304 "::guessWrapperFileNameBySession(): guessed the wrapper file name: \"" +
305 wrapperFileName +
"\"");
308 if (iIvs.size() == 1)
310 wrapperFileName = iIvs.at(0);
312 "::guessWrapperFileNameBySession(): guessed the wrapper file name: \"" +
313 wrapperFileName +
"\"");
316 else if (noI.size() == 1)
318 wrapperFileName = noI.at(0);
320 "::guessWrapperFileNameBySession(): guessed the wrapper file name: \"" +
321 wrapperFileName +
"\"");
324 else if (1 < iUs.size())
326 wrapperFileName = iUs.at(0);
328 "::guessWrapperFileNameBySession(): guessed the wrapper file name: \"" +
329 wrapperFileName +
"\"");
332 else if (1 < iIvs.size())
334 wrapperFileName = iIvs.at(0);
336 "::guessWrapperFileNameBySession(): guessed the wrapper file name: \"" +
337 wrapperFileName +
"\"");
340 else if (1 < noI.size())
342 wrapperFileName = noI.at(0);
344 "::guessWrapperFileNameBySession(): guessed the wrapper file name: \"" +
345 wrapperFileName +
"\"");
350 wrapperFileName = kAll.at(0);
352 "::guessWrapperFileNameBySession(): guessed the wrapper file name (last resort): \"" +
353 wrapperFileName +
"\"");
360 "::guessWrapperFileNameBySession(): cannot guess wrapper file name: noK.size()=" +
361 QString(
"").setNum(noK.size()) +
", kAll.size()=" + QString(
"").setNum(kAll.size()) );
373 QString& path2wrapperFile, QString& wrapperFileName, QString& sessionName,
int& version)
376 "::guessSessionByWrapperFileName(): processing: " + inputArg);
379 int idx=inputArg.lastIndexOf(
"/");
382 path2wrapperFile =
".";
383 wrapperFileName = inputArg;
387 path2wrapperFile =
"/";
388 wrapperFileName = inputArg.mid(1);
392 path2wrapperFile = inputArg.left(idx);
393 wrapperFileName = inputArg.mid(idx + 1);
396 if (path2wrapperFile.at(0) != QChar(
'/') && path2wrapperFile.at(0) != QChar(
'.'))
398 path2wrapperFile = path2VgosDb +
"/" + path2wrapperFile;
400 "::guessSessionByWrapperFileName(): the path to wrapper file has been modified to \"" +
401 path2wrapperFile +
"\"");
405 if (!QFile::exists((path2wrapperFile.size()?path2wrapperFile +
"/" :
"") + wrapperFileName))
408 "::guessSessionByWrapperFileName(): the provided file, " + path2wrapperFile +
"/" +
409 wrapperFileName +
", does not exist");
415 QRegExp reSn(
".*([0-9]{2}[A-Z]{3}[0-9]{2}[A-Z0-9]{1,2})_V([0-9]{3}).*");
417 if (-1 < reSn.indexIn(inputArg))
419 sessionName = reSn.cap(1);
423 v = sVer.toInt(&isOk);
428 "::guessSessionByWrapperFileName(): cannot guess a database version from the string \"" +
434 "::guessSessionByWrapperFileName(): cannot guess a database name from the string \"" +
447 int num=calList.size();
452 "::applyObsCalibrationSetup(): for the version " + QString(
"").setNum(
calcInfo_.
getDversion()) +
453 " of CALC the size of calibration list is unexpected, " + QString(
"").setNum(num) +
460 "::applyObsCalibrationSetup(): all the bit flags are zeros, nothing to apply");
482 for (
int i=0; i<num; i++)
484 const QString &str=calList.at(i);
485 isOn = bitFlags & (1<<i);
486 if (str ==
"PTD CONT")
488 else if (str ==
"WOBXCONT")
490 else if (str ==
"WOBYCONT")
492 else if (str ==
"ETD CONT")
494 else if (str ==
"OCE CONT")
496 else if (str ==
"UT1ORTHO")
498 else if (str ==
"WOBORTHO")
500 else if (str ==
"WOBNUTAT")
502 else if (str ==
"FEED.COR")
504 else if (str ==
"TILTRMVR")
506 else if (str ==
"WOBLIBRA")
508 else if (str ==
"UT1LIBRA")
510 else if (str ==
"OPTLCONT")
512 else if (str ==
"OCE_OLD ")
514 else if (str ==
"PTOLDCON")
516 else if (str ==
"WAHRCONT")
520 "::applyObsCalibrationSetup(): got an unexpected contribution code: " + str +
"; ignored");
524 "::applyObsCalibrationSetup(): calibration set up has been applied assuming version #" +
537 for (
int i=0; i<12; i++)
565 for (
int i=0; i<14; i++)
598 "::formObsCalibrationSetup(): calibration set up has been formed assuming version #" +
606 QMap<QString, QString>& map4Src, QMap<QString, QString>& map4Bnd)
612 if (!mapFileName.size())
616 QFile f(mapFileName);
620 "::importMapFile(): the map file [" + f.fileName() +
"] does not exist");
625 if (f.open(QFile::ReadOnly))
628 QString str(
""), from(
""), to(
"");
629 int numOfStrs, numOfSrc, numOfStn, numOfBnd;
630 QRegExp reStn(
"^stn:\\s*([0-9A-Z]{1}[0-9A-Z\\s_+-]{1,6}[0-9A-Z_]{1})\\s*=>"
631 "\\s*([0-9A-Z-]{1}[0-9A-Z\\s_+-]{1,6}[0-9A-Z_-]{1}).*");
632 QRegExp reSrc(
"^src:\\s*([0-9A-Z]{1}[0-9A-Z\\s_+-]{1,6}[0-9A-Z_]{1})\\s*=>"
633 "\\s*([0-9A-Z-]{1}[0-9A-Z\\s_+-]{1,6}[0-9A-Z_-]{1}).*");
634 QRegExp reBnd(
"^bnd:\\s*([0-9A-Za-z]{1,2})\\s*=>\\s*([0-9A-Za-z-]{1,3}).*");
635 numOfStrs = numOfSrc = numOfStn = numOfBnd = 0;
643 if (-1 < reStn.indexIn(str))
647 from = reStn.cap(1).leftJustified(8,
' ',
true);
648 if (!map4Stn.contains(from))
653 "::importMapFile(): the station \"" + from +
"\" will be excluded from the session");
657 from = reStn.cap(1).leftJustified(8,
' ',
true);
658 to = reStn.cap(2).leftJustified(8,
' ',
true);
659 if (!map4Stn.contains(from))
661 map4Stn.insert(from, to);
663 "::importMapFile(): a station map record added: \"" + from +
"\" => \"" + to +
"\"");
665 else if (map4Stn.value(from) == to)
667 "::importMapFile(): a station map record \"" + from +
"\" => \"" + to +
668 "\" is already in the map");
671 "::importMapFile(): an attempt to change a station map record \"" + from +
672 "\" => \"" + to +
"\"; ignored");
675 else if (str.left(4) ==
"stn:")
677 "::importMapFile(): cannot parse a station map string: \"" + str +
"\"");
680 if (-1 < reSrc.indexIn(str))
684 from = reSrc.cap(1).leftJustified(8,
' ',
true);
685 if (!map4Src.contains(from))
690 "::importMapFile(): the source \"" + from +
"\" will be excluded from the session");
694 from = reSrc.cap(1).leftJustified(8,
' ',
true);
695 to = reSrc.cap(2).leftJustified(8,
' ',
true);;
696 if (!map4Src.contains(from))
698 map4Src.insert(from, to);
700 "::importMapFile(): a source map record added: \"" + from +
"\" => \"" + to +
"\"");
702 else if (map4Src.value(from) == to)
704 "::importMapFile(): a source map record \"" + from +
"\" => \"" + to +
705 "\" is already in the map");
708 "::importMapFile(): an attempt to change a source map record \"" + from +
709 "\" => \"" + to +
"\"; ignored");
712 else if (str.left(4) ==
"src:")
714 "::importMapFile(): cannot parse a source map string: \"" + str +
"\"");
717 if (-1 < reBnd.indexIn(str))
721 from = reBnd.cap(1).trimmed();
722 if (!map4Bnd.contains(from))
727 "::importMapFile(): the band \"" + from +
"\" will be excluded from the session");
731 from = reBnd.cap(1).trimmed();
732 to = reBnd.cap(2).trimmed();
733 if (!map4Bnd.contains(from))
735 map4Bnd.insert(from, to);
737 "::importMapFile(): a band map record added: \"" + from +
"\" => \"" + to +
"\"");
739 else if (map4Bnd.value(from) == to)
741 "::importMapFile(): a band map record \"" + from +
"\" => \"" + to +
742 "\" is already in the map");
745 "::importMapFile(): an attempt to change a band map record \"" + from +
746 "\" => \"" + to +
"\"; ignored");
749 else if (str.left(4) ==
"bnd:")
751 "::importMapFile(): cannot parse a band map string: \"" + str +
"\"");
757 "::importMapFile(): read " + QString(
"").setNum(numOfStrs) +
758 " strings from the map file [" + f.fileName() +
"]");
763 "::importMapFile(): cannot open the map file [" + f.fileName() +
"] for read access");
777 if (map.contains(name))
782 "::check4stationNameMap(): the object \"" + name +
"\" have to be skipped");
786 "::check4stationNameMap(): the input object name \"" + name +
"\" is mapping to \"" +
787 map.value(name) +
"\"");
788 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)