27 #include <QtCore/QFile>
28 #include <QtCore/QRegExp>
29 #include <QtCore/QStringList>
30 #include <QtCore/QTextStream>
45 return "SgAPrioriRec";
71 for (
int i=0; i<recs.size(); i++)
84 while (str.at(idx) ==
' ')
86 rec.
setKey(str.mid(idx, 8));
88 QStringList l = str.mid(idx+8).simplified().split(
' ', QString::SkipEmptyParts);
92 ": parseString4StnGrd(): cannot parse the string [" + str.mid(idx+8).simplified() +
93 "], not enough data: l=" + QString(
"").setNum(l.size()));
107 r(0) = l.at(0).toDouble(&isOk);
110 r(1) = l.at(1).toDouble(&isOk);
113 r(2) = l.at(2).toDouble(&isOk);
118 rec[0].setDvalue(
"0", r(0));
119 rec[0].setDvalue(
"1", r(1));
120 rec[0].setDvalue(
"2", r(2));
123 nYr = l.at(3).toInt(&isOk);
126 nMn = l.at(4).toInt(&isOk);
129 nDy = l.at(5).toInt(&isOk);
132 if (nYr==0 && nMn==0 && nDy==0)
151 while (str.at(idx) ==
' ')
153 rec.
setKey(str.mid(idx, 8));
155 QStringList l = str.mid(idx+8).simplified().split(
' ', QString::SkipEmptyParts);
159 ": parseString4StnGrd(): cannot parse the string [" + str.mid(idx+8).simplified() +
160 "], not enough data: l=" + QString(
"").setNum(l.size()));
173 v(0) = l.at(0).toDouble(&isOk);
176 v(1) = l.at(1).toDouble(&isOk);
179 v(2) = l.at(2).toDouble(&isOk);
184 v *= 1.0e-3/365.242198781250;
186 rec[0].setDvalue(
"0", v(0));
187 rec[0].setDvalue(
"1", v(1));
188 rec[0].setDvalue(
"2", v(2));
205 while (str.at(idx) ==
' ')
207 rec.
setKey(str.mid(idx, 8));
209 QStringList l=str.mid(idx+8).simplified().split(
' ', QString::SkipEmptyParts);
213 ": parseString4StnGrd(): cannot parse the string [" + str.mid(idx+8).simplified() +
214 "], not enough data: l=" + QString(
"").setNum(l.size()));
218 double dg, hr, mn, sc;
228 hr = l.at(0).toDouble(&isOk);
231 mn = l.at(1).toDouble(&isOk);
234 sc = l.at(2).toDouble(&isOk);
237 k(0) = (hr + (mn + sc/60.0)/60.0)/
RAD2HR;
239 dg = l.at(3).toDouble(&isOk);
242 mn = l.at(4).toDouble(&isOk);
245 sc = l.at(5).toDouble(&isOk);
248 if (l.at(3).at(0) !=
'-')
249 k(1) = (dg + (mn + sc/60.0)/60.0)/
RAD2DEG;
251 k(1) = (dg - (mn + sc/60.0)/60.0)/
RAD2DEG;
254 rec[0].setDvalue(
"0", k(0));
255 rec[0].setDvalue(
"1", k(1));
261 for (
int i=6; i<l.size(); i++)
262 str += l.at(i) +
" ";
281 while (str.at(idx) ==
' ')
283 rec.
setKey(str.mid(idx, 8));
285 QStringList l=str.mid(idx+8).simplified().split(
' ', QString::SkipEmptyParts);
289 ": parseString4StnGrd(): cannot parse the string [" + str.mid(idx+8).simplified() +
290 "], not enough data: l=" + QString(
"").setNum(l.size()));
302 o(0) = l.at(0).toDouble(&isOk);
305 o(1) = l.at(1).toDouble(&isOk);
309 rec[0].setDvalue(
"0", o(0));
310 rec[0].setDvalue(
"1", o(1));
327 while (str.at(idx) ==
' ')
329 rec.
setKey(str.mid(idx, 8));
331 QStringList l=str.mid(idx+8).simplified().split(
' ', QString::SkipEmptyParts);
335 ": parseString4StnGrd(): cannot parse the string [" + str.mid(idx+8).simplified() +
336 "], not enough data: l=" + QString(
"").setNum(l.size()));
352 o(0) = l.at(0).toDouble(&isOk)/1000.0;
355 o(1) = l.at(2).toDouble(&isOk)/1000.0;
359 rec[0].setDvalue(
"0", o(0));
360 rec[0].setDvalue(
"1", o(1));
428 ": the file [" + fileName +
"] with a priori data does not exist");
438 ": the data type of the file [" + fileName +
"] is not specified; skipping it");
443 if (f.open(QFile::ReadOnly))
457 yr = str.mid( 0, 2).toInt(&isOk);
460 mn = str.mid( 2, 2).toInt(&isOk);
463 dy = str.mid( 4, 2).toInt(&isOk);
466 if (0<mn && mn<13 && 0<dy && dy<32)
470 "::readFile(): got an initial epoch: " +
t0_.
toString() +
" for the a priori set");
474 "::readFile(): got a suspicious epoch: " + str +
", skipping");
480 if (str.size()>8 && str.at(0)!=
'$' && str.at(0)!=
'#' && str.at(0)!=
'*')
506 insert(apdRec->
getKey(), apdRec);
524 bool estR, estK, estB;
528 QString str(
""), ss(
""), srcName(
""), sModelType(
"");
529 QRegExp reSrc(
".*Src:([\\.A-Z0-9+-]{2,8}).*", Qt::CaseInsensitive);
530 QRegExp reTsince(
".*T:([\\d]{4})/([\\d]{2})/([\\d]{2}).*", Qt::CaseInsensitive);
531 QRegExp reModelType(
".*SSM_T:([\\w]+)\\s+.*", Qt::CaseInsensitive);
532 QRegExp reMptX(
".*X:([\\s\\.\\d+-]+).*", Qt::CaseInsensitive);
533 QRegExp reMptY(
".*Y:([\\s\\.\\d+-]+).*", Qt::CaseInsensitive);
534 QRegExp reMptK(
".*K:([\\s\\.\\d+-]+).*", Qt::CaseInsensitive);
535 QRegExp reMptB(
".*B:([\\s\\.\\d+-]+).*", Qt::CaseInsensitive);
536 QRegExp reMptEr(
".*ER:([\\w]+).*", Qt::CaseInsensitive);
537 QRegExp reMptEk(
".*EK:([\\w]+).*", Qt::CaseInsensitive);
538 QRegExp reMptEb(
".*EB:([\\w]+).*", Qt::CaseInsensitive);
553 estR = estK = estB =
false;
554 px = py = k = b = 0.0;
559 if (str.size()>8 && str.at(0)!=
'$' && str.at(0)!=
'#' && str.at(0)!=
'*' && str.at(0)!=
'/')
561 if (reSrc.indexIn(str) != -1)
564 srcName = reSrc.cap(1);
565 rec->
setKey(srcName.leftJustified(8,
' '));
569 insert(rec->
getKey(), rec);
571 if (reModelType.indexIn(str) != -1)
573 sModelType = reModelType.cap(1);
574 if (sModelType.toUpper() ==
"MP")
578 "::parseFileSrcSsm(): MP: got an unknown type of model: \"" + sModelType +
"\"");
583 if (reMptX.indexIn(str) != -1)
585 px = (ss = reMptX.cap(1)).toDouble(&isOk);
588 "::parseFileSrcSsm(): MPT_X: cannot convert \"" + ss +
"\" to double");
590 if (reMptY.indexIn(str) != -1)
592 py = (ss = reMptY.cap(1)).toDouble(&isOk);
595 "::parseFileSrcSsm(): MPT_Y: cannot convert \"" + ss +
"\" to double");
597 if (reMptK.indexIn(str) != -1)
599 k = (ss = reMptK.cap(1)).toDouble(&isOk);
602 "::parseFileSrcSsm(): MPT_K: cannot convert \"" + ss +
"\" to double");
604 if (reMptB.indexIn(str) != -1)
606 b = (ss = reMptB.cap(1)).toDouble(&isOk);
609 "::parseFileSrcSsm(): MPT_B: cannot convert \"" + ss +
"\" to double");
611 if (reTsince.indexIn(str) != -1)
613 nY = (ss = reTsince.cap(1)).toDouble(&isOk);
616 nM = (ss = reTsince.cap(2)).toDouble(&isOk);
619 nD = (ss = reTsince.cap(3)).toDouble(&isOk);
622 tFrom =
SgMJD(nY, nM, nD);
628 "::parseFileSrcSsm(): MPT_T: cannot convert \"" + ss +
"\" to days");
632 "::parseFileSrcSsm(): MPT_T: cannot convert \"" + ss +
"\" to month");
636 "::parseFileSrcSsm(): MPT_T: cannot convert \"" + ss +
"\" to years");
638 if (reMptEr.indexIn(str) != -1)
640 estR = (reMptEr.cap(1).toUpper().at(0) ==
'Y');
642 if (reMptEk.indexIn(str) != -1)
644 estK = (reMptEk.cap(1).toUpper().at(0) ==
'Y');
646 if (reMptEb.indexIn(str) != -1)
648 estB = (reMptEb.cap(1).toUpper().at(0) ==
'Y');
682 QMap<double, SgAPrioriRec*> recByEpoch;
683 for (
int i=0; i<recs.size(); i++)
684 recByEpoch.insert(recs.at(i)->getTsince().toDouble(), recs.at(i));
686 recs = recByEpoch.values();
691 if (recs.last()->getTsince() <= t)
694 int idx=recs.size() - 1;
695 while (0<idx && t<=recs.at(idx)->getTsince())
const SgMJD tZero(1957, 10, 4)
#define RAD2HR
degrees to radians:
#define RAD2DEG
radians to degrees:
void setBvalue(const QString &idx, bool b)
void setDvalue(const QString &idx, double v)
const QString & getKey() const
static const QString className()
void setComments(const QString &str)
void setTsince(const SgMJD &)
void setKey(const QString &)
static const QString className()
bool parseString4StnPos(const QString &str, SgAPrioriRec &rec)
bool parseString4StnGrd(const QString &str, SgAPrioriRec &rec)
bool parseString4AxsOfs(const QString &str, SgAPrioriRec &rec)
SgAPrioriRec * lookupApRecord(const QString &, const SgMJD &=tZero)
bool parseString4SrcPos(const QString &str, SgAPrioriRec &rec)
bool parseString4StnVel(const QString &str, SgAPrioriRec &rec)
bool readFile(const QString &fileName, DataType=DT_UNDEF)
bool parseFileSrcSsm(QTextStream &s)
virtual void write(LogLevel, quint32, const QString &, bool=false)
QString toString(Format format=F_Verbose) const
void setUpEpoch(int year, int month, int day, int hour, int min, double sec)