28 #include <QtCore/QDateTime>
29 #include <QtCore/QDir>
30 #include <QtCore/QFile>
31 #include <QtCore/QFileInfo>
32 #include <QtCore/QList>
33 #include <QtCore/QMap>
34 #include <QtCore/QRegularExpression>
35 #include <QtCore/QTextStream>
36 #include <QtCore/QVector>
66 extern QMap<QString, QString>
stn2stn;
67 extern QMap<QString, QString>
src2src;
77 const QString& altDatabaseName,
const QString& altCorrelatorName,
78 const QString& historyFileName,
const QString& mapFileName,
bool need2correctRefClocks)
83 QStringList entryList;
84 QRegExp reKombFileName(
"B[0-9]{2,}");
86 QString correlatorComments(historyFileName);
90 QMap<QString, QString> bnd2bnd;
91 QRegularExpression reOldDbName(
"(\\d{2})([A-Z]{3})(\\d{2})([A-Z0-9]{1,2})");
92 QRegularExpression reNewDbName(
"(\\d{8})-([\\S]{2,12})");
93 QRegularExpressionMatch match;
96 if (need2correctRefClocks)
100 files2read = dir.entryList(QDir::Files | QDir::Readable | QDir::NoDotAndDotDot, QDir::Name);
101 if (files2read.size() == 0)
104 "::getDataFromKombFiles(): nothing to read");
113 "::getDataFromKombFiles(): loaded " + QString(
"").setNum(
stn2stn.size()) +
114 " entries for station name maps");
117 "::getDataFromKombFiles(): loaded " + QString(
"").setNum(
src2src.size()) +
118 " entries for source name maps");
121 "::getDataFromKombFiles(): loaded " + QString(
"").setNum(bnd2bnd.size()) +
122 " entries for band code maps");
125 for (
int i=0; i<files2read.size(); i++)
126 if (files2read.at(i).contains(reKombFileName))
127 entryList << files2read.at(i);
129 "::getDataFromKombFiles(): filtered " + QString(
"").setNum(entryList.size()) +
130 " scan entries from " + QString(
"").setNum(files2read.size()) +
" total number of directories");
134 for (
int i=0; i<entryList.size(); i++)
136 const QString &inKombFileName=entryList.at(i);
137 QFileInfo fi(path2data +
"/" + inKombFileName);
138 int kombFileSize=QFileInfo(path2data +
"/" + inKombFileName).size();
139 if (kombFileSize%256 != 0)
141 "::getDataFromKombFiles(): unexpected size of the file " + path2data +
"/" + inKombFileName +
142 ": " + QString(
"").setNum(kombFileSize) +
", skipped");
152 "::getDataFromKombFiles(): nothing useful found");
167 if (2 < altDatabaseName.size())
169 if ((match=reOldDbName.match(altDatabaseName)).hasMatch())
177 "::getDataFromKombFiles(): database name was explicitly set to " + altDatabaseName +
178 ", a version 1 database name pattern");
180 else if ((match=reNewDbName.match(altDatabaseName)).hasMatch())
188 "::getDataFromFringeFiles(): database name was explicitly set to " + altDatabaseName +
189 ", a version 2 database name pattern");
193 "::getDataFromKombFiles(): the provided database name, " + altDatabaseName +
194 ", does not fit any known pattern and was ignored");
198 QMap<double, SgVlbiBand*> bandByFreq;
200 for (
int i=0; i<
bands_.size(); i++)
203 QString bandKey=band->
getKey();
217 "::getDataFromKombFiles(): cannot set up a frequency for " + bandKey +
"-band");
221 "::getDataFromKombFiles(): the frequency " + QString(
"").setNum(band->
getFrequency()) +
222 " is already registered");
231 if (correlatorComments.size()==0)
233 dir.setPath(path2data +
"/../control/");
237 "::getDataFromKombFiles(): cannot get correlator comments, the directory does not exist: " +
242 entryList = dir.entryList(QStringList() <<
"*.corr",
243 QDir::Files | QDir::NoDotAndDotDot | QDir::Readable, QDir::Name);
244 if (entryList.size() == 0)
247 "::getDataFromKombFiles(): cannot get correlator comments, no any *.corr file found: " +
250 else if (entryList.size() > 1)
253 "::getDataFromKombFiles(): found more than one file with correlator comments:");
254 for (
int j=0; j<entryList.size(); j++)
256 "::getDataFromKombFiles(): " + entryList.at(j));
257 str = entryList.at(0);
259 "::getDataFromKombFiles(): picked up this one: " + str);
262 str = entryList.at(0);
265 correlatorComments = path2data +
"/../control/" + str;
267 if (correlatorComments.size())
271 for (
int i=0; i<
bands_.size(); i++)
273 bands_.at(i)->history().addHistoryRecord(
"== The correlator report was not provided. ==",
278 "::getDataFromKombFiles(): the correlator report was not provided.");
284 QString primeBandKey;
288 "::getDataFromKombFiles(): importing typical IVS session");
294 "::getDataFromKombFiles(): importing a foreign session setup");
295 if (bandByFreq.size() > 1)
321 "::getDataFromKombFiles(): " + QString(
"").setNum(num) +
322 " second-band-only observation" + (num==1?
"":
"s") +
" were removed");
327 "::getDataFromKombFiles(): session selfcheck complete");
331 "::getDataFromKombFiles(): the selfcheck for the session failed");
336 if (altCorrelatorName.size())
340 "::getDataFromKombFiles(): correlator name was explicitly set to " + altCorrelatorName);
347 for (QMap<QString, SgVlbiObservable*>::iterator it=obs->
observableByKey().begin();
355 "::getDataFromKombFiles(): phase cal delays were calculated");
366 const QMap<QString, QString>&
stn2stn,
const QMap<QString, QString>&
src2src,
367 const QMap<QString, QString>& bnd2bnd)
373 "::processKombFile(): reading KOMB file " + kombFileName);
374 kombReader.
readFile(path2file +
"/" + kombFileName);
375 if (!kombReader.
isOk())
378 "::processKombFile(): the KOMB file " + kombFileName +
" is not Ok; skipped");
388 QString station1Name, station2Name, sourceName, baselineName;
389 QString scanName, scanId, obsKey;
403 bool isSbdSigmaNan, isSbdSigmaInf;
404 bool isGrdSigmaNan, isGrdSigmaInf;
405 bool isPhrSigmaNan, isPhrSigmaInf;
408 double effFreq4GR=0.0, effFreq4PH=0.0, effFreq4RT=0.0;
410 double ap_0, ap_1, ap_2, ap_3, prtOffset;
411 ap_0 = ap_1 = ap_2 = ap_3 = 0.0;
421 "::processKombFile(): the KOMB file " + kombFileName +
" is belong to another session, " + str +
427 for (QMap<QString, QString>::const_iterator it=kombReader.
mapOfBands().begin();
430 bandKey = QString(it.key()).simplified();
437 "::processKombFile(): skipping the observation " + kombFileName +
438 ": the band \"" + bandKey +
"\" have to be skipped");
463 "::processKombFile(): the KOMB file " + kombFileName +
": BD01 record is NULL for the " +
464 bandKey +
"-band; skipped");
470 "::processKombFile(): the KOMB file " + kombFileName +
": BD02 record is NULL for the " +
471 bandKey +
"-band; skipped");
477 "::processKombFile(): the KOMB file " + kombFileName +
": BD03 record is NULL for the " +
478 bandKey +
"-band; skipped");
484 "::processKombFile(): the KOMB file " + kombFileName +
": BD04 record is NULL for the " +
485 bandKey +
"-band; skipped");
491 "::processKombFile(): the KOMB file " + kombFileName +
": BD05 record is NULL for the " +
492 bandKey +
"-band; skipped");
499 sourceName .sprintf(
"%-8s", ob01->
sourceName());
507 "::processKombFile(): skipping the observation " + kombFileName +
508 ": the station \"" + station1Name +
"\" have to be skipped");
514 "::processKombFile(): skipping the observation " + kombFileName +
515 ": the station \"" + station2Name +
"\" have to be skipped");
524 "::processKombFile(): skipping the observation " + kombFileName +
525 ": the source \"" + sourceName +
"\" have to be skipped");
531 baselineName = station1Name +
":" + station2Name;
534 scanName.sprintf(
"%03d-%02d%02d ",
544 if (isinf(f) != 0 || isnan(f) != 0)
547 "::processKombFile(): an observation from KOMB input file \"" + kombFileName +
548 "\" (the baseline " + baselineName +
550 ") contains wrong group delay (NaN or Inf); the observation is skipped",
true);
554 if (isinf(f) != 0 || isnan(f) != 0)
557 "::processKombFile(): an observation from KOMB input file \"" + kombFileName +
558 "\" (the baseline " + baselineName +
560 ") contains wrong delay rate (NaN or Inf); the observation is skipped",
true);
599 station1Info->
setSid(
'-',
'-');
610 station2Info->
setSid(
'-',
'-');
687 if (need2adjust4clocks)
692 dDel = ap_1*prtOffset + 1.0/2.0*ap_2*prtOffset*prtOffset +
693 1.0/6.0*ap_3*prtOffset*prtOffset*prtOffset;
697 dRat = ap_2*prtOffset + 1.0/2.0*ap_3*prtOffset*prtOffset;
714 isSbdSigmaNan = isSbdSigmaInf = isGrdSigmaNan = isGrdSigmaInf = isPhrSigmaNan =
715 isPhrSigmaInf =
false;
721 "::processKombFile(): the observation #" + QString(
"").setNum(obsIdx) +
722 " at the baseline " + baselineName +
" observing " + sourceName +
" source at " +
724 " contains wrong sigma (inf) for the single band delay",
true);
725 isSbdSigmaInf =
true;
731 "::processKombFile(): the observation #" + QString(
"").setNum(obsIdx) +
732 " at the baseline " + baselineName +
" observing " + sourceName +
" source at " +
734 " contains wrong sigma (nan) for the single band delay",
true);
735 isSbdSigmaNan =
true;
745 "::processKombFile(): the observation #" + QString(
"").setNum(obsIdx) +
746 " at the baseline " + baselineName +
" observing " + sourceName +
" source at " +
748 " contains wrong sigma (inf) for the group delay",
true);
749 isGrdSigmaInf =
true;
755 "::processKombFile(): the observation #" + QString(
"").setNum(obsIdx) +
756 " at the baseline " + baselineName +
" observing " + sourceName +
" source at " +
758 " contains wrong sigma (nan) for the group delay",
true);
759 isGrdSigmaNan =
true;
769 "::processKombFile(): the observation #" + QString(
"").setNum(obsIdx) +
770 " at the baseline " + baselineName +
" observing " + sourceName +
" source at " +
772 " contains wrong sigma (inf) for the group delay",
true);
773 isPhrSigmaInf =
true;
779 "::processKombFile(): the observation #" + QString(
"").setNum(obsIdx) +
780 " at the baseline " + baselineName +
" observing " + sourceName +
" source at " +
782 " contains wrong sigma (nan) for the group delay",
true);
783 isPhrSigmaNan =
true;
788 if (isSbdSigmaNan || isSbdSigmaInf ||
789 isGrdSigmaNan || isGrdSigmaInf ||
790 isPhrSigmaNan || isPhrSigmaInf )
792 QString s1(
""), s2(
""), s3(
"");
793 s1 = (isSbdSigmaNan || isGrdSigmaNan || isPhrSigmaNan)?
"(nan)":
"(inf)";
794 if (isSbdSigmaNan || isSbdSigmaInf)
795 s2 =
"single band delay, ";
796 if (isGrdSigmaNan || isGrdSigmaInf)
797 s2+=
"group delay, ";
798 if (isPhrSigmaNan || isPhrSigmaInf)
800 s2 = s2.left(s2.size() - 2);
804 "::processKombFile(): The observation #" + QString(
"").setNum(obsIdx) +
805 ", " + s3 +
" contains wrong sigma " + s1 +
" for " + s2 +
".");
820 nTmp = str.toInt(&isTmp);
873 "::processKombFile(): the observation #" + QString(
"").setNum(obsIdx) +
874 " extracted from the KOMB file " + kombFileName +
875 " at the baseline " + baselineName +
" observing " + sourceName +
" at " +
878 ") that differs from previous data value (" +
883 if (prtOffset != 0.0)
918 for (
int i=0; i<numOfChannels; i++)
965 for (
int i=0; i<numOfChannels; i++)
967 for (
int j=0; j<5; j++)
972 "::processKombFile(): st1 one of phase cal values is NAN " +
973 QString(
"").sprintf(
"(chan=%d:dat=%d)", i, j) +
" from the scan " + obs->
getScanName() +
974 " KOMB file " + kombFileName);
980 "::processKombFile(): st2 one of phase cal values is NAN " +
981 QString(
"").sprintf(
"(chan=%d:dat=%d)", i, j) +
" from the scan " + obs->
getScanName() +
982 " KOMB file " + kombFileName);
const SgMJD tZero(1957, 10, 4)
#define DAY2SEC
radians to mas:
#define DEG2RAD
degrees to seconds:
QMap< QString, QString > src2src
QMap< QString, QString > stn2stn
void evaluateEffectiveFreqs(const SgVector &numOfAccPeriodsByChan_USB, const SgVector &numOfAccPeriodsByChan_LSB, const SgVector &refFreqByChan, const SgVector &fringeAmplitudeByChan, const SgVector &numOfSamplesByChan_USB, const SgVector &numOfSamplesByChan_LSB, double sampleRate, double refFreq, int numOfChannels, double &effFreq4GR, double &effFreq4PH, double &effFreq4RT, const QString &correlatorType, const QString &oId, bool useEqualWeights=false)
bool isAttr(uint a) const
const char * tapeQualityCode() const
double rfFreqs(int i) const
short totalNumOfProcChannels() const
const SgMJD & tProcByKomb() const
double procRefFreq() const
const char * kombQualityCode() const
double obsDelayRateAtCentrlEpoch() const
float obsTotalPhaseAtReferEpoch() const
float obsTotalPhaseAtEarthCenterEpoch() const
short procPpNumTable(int i, int j) const
float searchWndCoarseDelay(int i) const
double obsDelayAtCentrlEpoch() const
float obsResidPhaseAtEarthCenterEpoch() const
float searchWndFineDelay(int i) const
float searchWndFineDelayRate(int i) const
float obsTotalPhaseAtCentrlEpoch() const
float effectiveIntegrationPeriod() const
const SgMJD & tObsCentral() const
float rejectionRate() const
float phaseCalAmpPhase1(int i, int j) const
double phaseCalRate2() const
double phaseCalRate1() const
float phaseCalAmpPhase2(int i, int j) const
float obsDelaySigma() const
double obsCoarseDelayResid() const
float fringeAmpPhase(int i, int j) const
double obsDelayResid() const
double phaseDelayAtReferEpoch() const
double phaseDelayAtReferEpochPlus_1sec() const
double phaseDelayAtReferEpochMinus_1sec() const
double obsDelayRateResid() const
float obsDelayAmbiguity() const
float falseDetectionProbability() const
double obsDelayRateAtReferEpoch() const
float fineSearchFringeAmplitude() const
double obsCoarseDelayAtReferEpoch() const
float obsCoarseDelaySigma() const
float incohFringeAmplitude() const
float coarseSearchFringeAmplitude() const
float obsDelayRateSigma() const
double obsDelayAtReferEpoch() const
const SgMJD & tStart() const
float videoBandWidth() const
const char * station1Name() const
const SgMJD & tRefer() const
double aPrioriObses(int i) const
double aPrioriClockError() const
const SgMJD & tProcByCorr() const
double aPrioriRefClockOffset() const
const char * station2Name() const
const SgMJD & tFinis() const
const char * sourceName() const
const char * baselineId() const
const char * correlatorFileName() const
float phCalFreqs(int i) const
const SgKombOb03Record & ob03() const
const SgKombBd03Record * bd03(const QString &bandKey) const
const SgKombBd04Record * bd04(const QString &bandKey) const
const SgKombBd05Record * bd05(const QString &bandKey) const
const SgKombBd01Record * bd01(const QString &bandKey) const
const SgKombBd02Record * bd02(const QString &bandKey) const
const SgKombOb01Record & ob01() const
void readFile(const QString &fileName)
const char * experimentCode() const
const QMap< QString, QString > & mapOfBands() const
virtual void write(LogLevel, quint32, const QString &, bool=false)
@ F_YYYYMMDDHHMMSSSS
Long verbose: Fri, the 2nd of Apr, 2010; 17hr 02min 43.6400sec.
@ F_INTERNAL
Digits, date and time: 20100402.71.
QString toString(Format format=F_Verbose) const
int calcDayOfYear() const
static SgMJD currentMJD()
void setElement(unsigned int i, unsigned int j, double d)
double getElement(unsigned int i, unsigned int j) const
void setKey(const QString &key)
void incNumTotal(DataType, int=1)
const QString & getKey() const
virtual int getMediaIdx() const
virtual void setMediaIdx(int idx)
virtual void setMJD(const SgMJD &)
void setElement(unsigned int i, double d)
double getRefClockOffset() const
void setRefClockOffset(double d)
void setFrequency(double f)
void setTCreation(const SgMJD &t)
QMap< QString, SgVlbiBaselineInfo * > & baselinesByName()
QMap< QString, SgVlbiStationInfo * > & stationsByName()
void setInputFileName(const QString &fileName)
void setInputFileVersion(int version)
QMap< int, SgVlbiBaselineInfo * > & baselinesByIdx()
QMap< QString, SgVlbiSourceInfo * > & sourcesByName()
QMap< int, SgVlbiSourceInfo * > & sourcesByIdx()
double getFrequency() const
QMap< int, SgVlbiStationInfo * > & stationsByIdx()
@ Attr_PRIMARY
the band is a primary band;
void setAmbiguitySpacing(double)
void setResidualFringeFitting(double r)
void setGeocenterValue(double)
void setAlternateValue(double)
void setEpochOfCorrelation(const SgMJD &)
const QString & getFourfitOutputFName() const
void setEpochCentral(const SgMJD &)
void setTstart(const SgMJD &t)
void setTotalPhase(double)
double getSampleRate() const
void setIncohSegmAddAmp(double d)
SgMatrix * phaseCalData_2ByChan()
void setAcceptedRatio(double d)
void setTstop(const SgMJD &t)
void setEpochOfFourfitting(const SgMJD &)
SgVector * numOfAccPeriodsByChan_LSB()
void setIncohChanAddAmp(double d)
void setCentrOffset(double offset)
void setEffIntegrationTime(double d)
void setFourfitOutputFName(const QString &)
SgVector * numOfAccPeriodsByChan_USB()
SgVlbiMeasurement & phDRate()
void setGeocenterResidPhase(double d)
void setProbabOfFalseDetection(double d)
void setQualityFactor(int)
void setGeocenterTotalPhase(double d)
void setDiscardRatio(double d)
SgVector * fringeAmplitudeByChan()
void setCorrCoeff(double)
void setEpochOfScan(const SgMJD &)
SgVector * numOfSamplesByChan_LSB()
void setAprioriDra(int i, double d)
void setPhaseCalRates(int i, double d)
void setStopOffset(int offset)
void setErrorCode(const QString &)
SgMatrix * phaseCalData_1ByChan()
SgVector * numOfSamplesByChan_USB()
void setReferenceFrequency(double)
double getReferenceFrequency() const
void allocateChannelsSetupStorages(int numOfChans)
SgVlbiMeasurement & phDelay()
void setTapeQualityCode(const QString &code)
SgVlbiMeasurement & grDelay()
void setStartOffset(int offset)
SgVlbiMeasurement & sbDelay()
SgVector * fringePhaseByChan()
SgVector * refFreqByChan()
void setFourfitSearchParameters(int i, double d)
void setSampleRate(double sr)
void setStation1Idx(short int idx)
void setScanId(const QString &sId)
void setSourceIdx(short int idx)
bool addObservable(const QString &, const SgVlbiObservable &)
void setScanName(const QString &sName)
void setupActiveObservable(const QString &)
void setCorrRootFileName(const QString &sName)
void setStation2Idx(short int idx)
SgVlbiObservable * observable(const QString &)
const QString & getScanName() const
QMap< QString, SgVlbiObservable * > & observableByKey()
void setBaselineIdx(short int idx)
void setKey(const QString &)
const QString & getCorrelatorType() const
void setOfficialName(const QString &name)
void setSchedulerName(const QString &name)
void setSessionCode(const QString &code)
@ OT_KOMB
observations are from KOMB output (generated by NICT, Japan);
void setName(const QString &name)
void setCorrelatorType(const QString &name)
CorrelatorPostProcSoftware cppsSoft_
@ Attr_REF_CLOCKS_ADJUSTED
@ Attr_FF_CREATED
the session has been imported from correlator;//vgosDbMake
@ CPPS_UNKNOWN
unknown (=all others);
void setNetworkSuffix(const QString &suffix)
QString sessionCode_
official session code (from Masterfile);
void setSubmitterName(const QString &name)
void setCorrelatorName(const QString &name)
void setOriginType(OriginType type)
StationsByName stationsByName_
QMap< QString, SgVlbiObservation * > observationByKey_
QList< SgVlbiBand * > bands_
bool getDataFromKombFiles(const QString &path2, const QString &altDatabaseName, const QString &altCorrelatorName, const QString &historyFileName, const QString &mapFileName, bool need2correctRefClocks)
bool selfCheck(bool guiExpected)
void processKombFile(const QString &path2file, const QString &kombFileName, const QMap< QString, QString > &stn2stn, const QMap< QString, QString > &src2src, const QMap< QString, QString > &bnd2bnd)
QMap< QString, SgVlbiBand * > bandByKey_
QList< SgVlbiObservation * > observations_
bool getCorrelatorHistory(const QString &fileName)
QMap< int, SgVlbiStationInfo * > stationsByIdx_
void importMapFile(const QString &mapFileName, QMap< QString, QString > &map4Stn, QMap< QString, QString > &map4Src, QMap< QString, QString > &map4Bnd)
BaselinesByName baselinesByName_
SgVlbiBand * primaryBand_
static QString className()
QMap< int, SgVlbiBaselineInfo * > baselinesByIdx_
SourcesByName sourcesByName_
bool check4NameMap(const QMap< QString, QString > &map, QString &name)
QMap< int, SgVlbiSourceInfo * > sourcesByIdx_
QMap< QString, SgVlbiAuxObservation * > * auxObservationByScanId()
void setSid(char c1, char c2)