27 #include <QtCore/QDataStream>
28 #include <QtCore/QVector>
45 void subroutineParab(
const double* pX,
const double* pY,
int n,
double &dD,
double &dA,
double &dP);
51 const SgVector& pcFreqByChan,
double refFreq,
52 double& phaseCalGrd,
double& phaseCalGrdAmbig,
53 double& phaseCalPhd,
double& phaseCalPhdAmbig,
69 return "SgVlbiObservable";
86 fourfitOutputFName_(
""),
87 fourfitControlFile_(
""),
88 fourfitCommandOverride_(
""),
89 epochOfCorrelation_(
tZero),
90 epochOfFourfitting_(
tZero),
135 for (
int i=0; i<2; i++)
144 for (
int i=0; i<6; i++)
188 bandKey_(band?band->getKey():
""),
194 tapeQualityCode_(
""),
196 fourfitOutputFName_(
""),
197 fourfitControlFile_(
""),
198 fourfitCommandOverride_(
""),
199 epochOfCorrelation_(
tZero),
200 epochOfFourfitting_(
tZero),
202 epochCentral_(
tZero),
244 for (
int i=0; i<2; i++)
253 for (
int i=0; i<6; i++)
299 bandKey_(o.getBandKey()),
300 sbDelay_(o.sbDelay_),
301 grDelay_(o.grDelay_),
302 phDelay_(o.phDelay_),
303 phDRate_(o.phDRate_),
304 errorCode_(o.getErrorCode()),
305 tapeQualityCode_(o.getTapeQualityCode()),
306 fourfitOutputFName_(o.getFourfitOutputFName()),
307 fourfitControlFile_(o.getFourfitControlFile()),
308 fourfitCommandOverride_(o.getFourfitCommandOverride()),
309 epochOfCorrelation_(o.getEpochOfCorrelation()),
310 epochOfFourfitting_(o.getEpochOfFourfitting()),
311 epochOfScan_(o.getEpochOfScan()),
312 epochCentral_(o.getEpochCentral()),
313 tStart_(o.getTstart()),
357 for (
int i=0; i<2; i++)
369 for (
int i=0; i<6; i++)
644 QString srcN(
"?"), blnN(
"?:?");
695 ": allocateChannelsSetupStorages(): an attempt to allocate data with zero number of channels");
905 if (s.status() == QDataStream::Ok &&
910 return s.status() == QDataStream::Ok;
923 unsigned int attributes;
924 s >> bandKey >> mediaIdx >> is >> attributes;
925 if (s.status() == QDataStream::Ok)
930 ": loadIntermediateResults(): error reading " +
bandKey_ +
931 "-band data: bandKey mismatch: got [" + bandKey +
"], expected [" +
bandKey_ +
"]");
937 ": loadIntermediateResults(): error reading " +
bandKey_ +
938 "-band data: media index mismatch: got [" +
939 QString(
"").setNum(mediaIdx) +
"], expected [" + QString(
"").setNum(
mediaIdx_) +
"]");
951 ": loadIntermediateResults(): error reading data: " +
952 (s.status()==QDataStream::ReadPastEnd?
"read past end of the file":
"read corrupt data"));
967 ": calcPhaseDelay(): cannot calculate phase delay: the owner is NULL");
973 ": calcPhaseDelay(): cannot calculate phase delay: the band is NULL");
977 if (!(aux_1 && aux_2))
980 ": calcPhaseDelay(): cannot calculate phase delay: the aux obss are NULL");
983 double vPhDly, ePhDly, aPhDly, dNumAmbigs;
992 ": calcPhaseDelay(): got unusual value for SNR: " + QString(
"").setNum(
snr_));
1011 ": calcPhaseCalDelay(): cannot calculate phase cal effects: band is NULL");
1017 ": calcPhaseCalDelay(): cannot calculate phase cal effects: ref.freq storage is NULL");
1023 ": calcPhaseCalDelay(): cannot calculate phase cal effects: pcal phases @1 storage is NULL");
1029 ": calcPhaseCalDelay(): cannot calculate phase cal effects: pcal phases @2 storage is NULL");
1035 ": calcPhaseCalDelay(): cannot calculate phase cal effects: size mismatch for @1: " +
1036 QString(
"").sprintf(
"#chan(%d) != #PCchan(%d)",
1043 ": calcPhaseCalDelay(): cannot calculate phase cal effects: size mismatch for @2");
1052 for (
int i=0; i<n; i++)
1066 double phaseCalGrd=0.0;
1067 double phaseCalGrdAmbig=0.0;
1068 double phaseCalPhd=0.0;
1069 double phaseCalPhdAmbig=0.0;
1072 phaseCalGrd, phaseCalGrdAmbig, phaseCalPhd, phaseCalPhdAmbig,
strId()))
1081 phaseCalGrd, phaseCalGrdAmbig, phaseCalPhd, phaseCalPhdAmbig,
strId()))
1091 delete pcAmplitudes_1;
1092 delete pcAmplitudes_2;
1114 const SgVector& pcFreqByChan,
double refFreq,
1115 double& phaseCalGrd,
double& phaseCalGrdAmbig,
1116 double& phaseCalPhd,
double& phaseCalPhdAmbig,
1119 int nChan=pcFreqByChan.
n();
1120 phaseCalGrdAmbig = 0.0;
1121 phaseCalPhdAmbig = 0.0;
1125 "evaluatePhaseCals: number of actual channels is zero, nothing to do for the obs " + oId);
1131 "evaluatePhaseCals: have only one actual channel, nothing to do for the obs " + oId);
1137 double *pX=NULL, *pY=NULL;
1138 double *pXsvd=NULL, *pYsvd=NULL;
1144 double rfMin, diffMin, d;
1146 int *idxs=
new int[nChan], nData=512;
1165 for (
int i=0; i<nChan; i++)
1166 if ( (d=fabs(pcFreqByChan.
getElement(i))) < rfMin)
1176 for (
int i=0; i<nChan; i++)
1177 for (
int j=i+1; j<nChan; j++)
1180 if (0.0 < d && d < diffMin)
1188 phaseCalGrdAmbig = 1.0/diffMin*1.0e3;
1194 phaseCalPhdAmbig = 1.0/refFreq*1.0e3;
1206 for (
int i=0; i<nChan; i++)
1207 if (nData <= (idxs[i]=((fabs(pcFreqByChan.
getElement(i)) - rfMin)/diffMin)))
1210 "evaluatePCal4GrpDelay: Array overrun for the obs " + oId +
1211 QString(
"").sprintf(
": idxs[%d]=%d for %.2f and Fmin=%.2f Dmin=%.2f",
1212 i, idxs[i], pcFreqByChan.
getElement(i), rfMin, diffMin));
1227 pX =
new double[nData];
1228 pY =
new double[nData];
1229 pXsvd =
new double[nChan];
1230 pYsvd =
new double[nChan];
1231 for (
int i=0; i<nChan; i++)
1232 pXsvd[i] = pYsvd[i] = 0.0;
1233 for (
int i=0; i<nData; i++)
1234 pX[i] = pY[i] = 0.0;
1242 for (
int i=0; i<nChan; i++)
1259 fft(pX, pY, nData, -1);
1276 phaseCalGrd = phaseCalGrdAmbig*dD/nData;
1277 phaseCalGrd = fmod(phaseCalGrd + phaseCalGrdAmbig*2.5, phaseCalGrdAmbig) - 0.5*phaseCalGrdAmbig;
1287 phaseCalPhd = dP/(2.0*M_PI)*phaseCalPhdAmbig + (refFreq - rfMin)*1.0e-3*phaseCalGrd;
1344 void subroutineParab(
const double* pX,
const double* pY,
int n,
double &dD,
double &dA,
double &dP)
1365 double dP1, dP2, dP3, dA1, dA2, dA3;
1367 double dDrel, dAa, dAmax;
1369 int nI1=0, nI2=0, nI3=0;
1398 dA2 = dAmax = -1000.0;
1399 for (
int i=0; i<n; i++)
1401 dAa = hypot(pX[i], pY[i]);
1421 dA1 = hypot(pX[nI1], pY[nI1]);
1422 dA3 = hypot(pX[nI3], pY[nI3]);
1432 dDrel = (dA3 - dA1)/(2.0*(2.0*dA2 - dA1 - dA3));
1444 dA = dA2 + dDrel*(dA3 - dA1)/4.0;
1455 dP1 = atan2(pY[nI1], pX[nI1]);
1456 dP2 = atan2(pY[nI2], pX[nI2]);
1457 dP3 = atan2(pY[nI3], pX[nI3]);
1466 if (fabs(dP1-dP2)>=M_PI || fabs(dP2-dP3)>=M_PI)
1468 dP1 = dP2 + fmod(dP1 - dP2 + 5.0*M_PI, 2.0*M_PI) - M_PI;
1469 dP3 = dP2 + fmod(dP3 - dP2 + 5.0*M_PI, 2.0*M_PI) - M_PI;
1476 dP = dP2 + 0.5*(dP3 - dP1)*dDrel + 0.5*(dP3 - dP2 - dP2 + dP1)*dDrel*dDrel;
const SgMJD tZero(1957, 10, 4)
void fft(std::complex< double > buf[], int n)
bool evaluatePhaseCals(const SgVector &pcPhases, const SgVector &pcAmplitudes, const SgVector &pcFreqByChan, double refFreq, double &phaseCalGrd, double &phaseCalGrdAmbig, double &phaseCalPhd, double &phaseCalPhdAmbig, const QString &oId)
void subroutineParab(const double *pX, const double *pY, int n, double &dD, double &dA, double &dP)
bool isAttr(uint a) const
void setAttributes(unsigned int a)
unsigned int getAttributes() const
virtual void write(LogLevel, quint32, const QString &, bool=false)
@ F_YYYYMMDDHHMMSSSS
Long verbose: Fri, the 2nd of Apr, 2010; 17hr 02min 43.6400sec.
QString toString(Format format=F_Verbose) const
double getElement(unsigned int i, unsigned int j) const
unsigned int nCol() const
const QString & getKey() const
@ Attr_NOT_VALID
omit the observation;
bool getUseQualityCodeH() const
VlbiDelayType getUseDelayType() const
int getQualityCodeThreshold() const
VlbiRateType getUseRateType() const
bool getUseQualityCodeG() const
void setElement(unsigned int i, double d)
double getElement(unsigned int i) const
double getParallacticAngle() const
int getMaxNumOfChannels() const
@ Attr_USE_IONO4GRD
use ionosphere corrections for group delays;
@ Attr_USE_IONO4PHD
use ionosphere corrections for phase delays;
@ Attr_NOT_VALID
omit the baseline;
void setAmbiguitySpacing(double)
bool saveIntermediateResults(QDataStream &) const
bool loadIntermediateResults(QDataStream &)
bool saveIntermediateResults(QDataStream &) const
void releaseChannelsSetupStorages()
QVector< int > * corelIndexNumLSB()
QVector< int > * bbcIdxByChan_2_
double getPhaseCalPhDelays(int i) const
void setNumOfChannels(int)
double effIntegrationTime_
double getUvFrPerAsec(int i) const
bool isRestorable_old(const SgTaskConfig *)
double getPhaseCalGrDelays(int i) const
void setBitsPerSample(int bps)
const SgMJD & epoch() const
double calcFeedCorrDelay_
SgMatrix * phaseCalData_1ByChan_
int getQualityFactor() const
int phaseCalGrAmbigMultipliers_[2]
void setCorrClocks(int i, int j, double d)
void setTotalPhase(double)
void setHopsRevisionNumber(int num)
QVector< char > * chanIdByChan_
void setGrdDiffBand(double)
SgVlbiMeasurement phDelay_
SgVlbiStationInfo * getStn_1() const
void setPhaseCalGrDelays(int i, double d)
double getSampleRate() const
QVector< char > * polarization_1ByChan()
double getInstrDelay(int i) const
SgVector * loFreqByChan_1()
QVector< char > * chanIdByChan()
void setIncohSegmAddAmp(double d)
QVector< int > * corelIndexNumUSB()
double getFourfitSearchParameters(int i) const
int getNumOfChannels() const
void setupActiveMeasurements(const SgTaskConfig *)
SgVector * loFreqByChan_2_
double geocenterResidPhase_
void setPhaseCalModes(int modes)
SgMatrix * phaseCalData_2ByChan()
void setAcceptedRatio(double d)
const QString & getErrorCode() const
SgVector * fringeAmplitudeByChan_
double getSbdDiffBand() const
int getPhaseCalModes() const
double getIncohChanAddAmp() const
QVector< int > * bbcIdxByChan_1_
QVector< int > * corelIndexNumLSB_
SgVlbiObservation * owner()
double probabOfFalseDetection_
SgVlbiMeasurement sbDelay_
void setPhaseCalPhDelays(int i, double d)
SgVector * numOfSamplesByChan_USB_
SgVector * numOfAccPeriodsByChan_LSB()
double getAcceptedRatio() const
void setIncohChanAddAmp(double d)
double getCalcFeedCorrDelay() const
SgVlbiObservable(SgVlbiObservation *)
SgVector * numOfSamplesByChan_LSB_
void setCentrOffset(double offset)
double getProbabOfFalseDetection() const
double getPhrDiffBand() const
void setEffIntegrationTime(double d)
QVector< char > * polarization_2ByChan()
SgVector * numOfAccPeriodsByChan_USB()
QVector< int > * bbcIdxByChan_1()
static const QString className()
SgVlbiStationInfo * getStn_2() const
SgVlbiSourceInfo * getSrc() const
double phaseCalPhDelays_[2]
@ NUR_MATE_HAS_ERROR_CODE
@ NUR_DESELECTED_BASELINE
void setGeocenterResidPhase(double d)
void setCorrelStarElev_2(double v)
double getGrdDiffBand() const
void setProbabOfFalseDetection(double d)
void setQualityFactor(int)
int phaseCalPhAmbigMultipliers_[2]
double getCorrelZdelay_1() const
double getGeocenterTotalPhase() const
double geocenterTotalPhase_
void setGeocenterTotalPhase(double d)
double getEffIntegrationTime() const
SgMatrix * phaseCalData_2ByChan_
void setDiscardRatio(double d)
double referenceFrequency_
double getCorrClocks(int i, int j) const
double phaseCalGrAmbigSpacings_[2]
SgVector * fringeAmplitudeByChan()
void setCorrCoeff(double)
double phaseCalGrDelays_[2]
SgVlbiBaselineInfo * baseline_
void setUrVr(int i, double d)
void setCorrelZdelay_1(double v)
int getStartOffset() const
QVector< char > * polarization_1ByChan_
SgVector * fringePhaseByChan_
SgVector * refFreqByChan_
void checkUsability(const SgTaskConfig *)
double getUrVr(int i) const
double getCentrOffset() const
int errorCode2Int() const
SgVector * numOfSamplesByChan_LSB()
QVector< int > * corelIndexNumUSB_
void setPhrDiffBand(double)
double getAprioriDra(int i) const
void setAprioriDra(int i, double d)
void setInstrDelay(int i, double d)
double getCorrelStarElev_2() const
double getDiscardRatio() const
void setPhaseCalRates(int i, double d)
double getTotalPhase() const
void setStopOffset(int offset)
SgVlbiStationInfo * stn_2_
int getHopsRevisionNumber() const
int getFourfitVersion(int idx) const
double getIncohSegmAddAmp() const
int getStopOffset() const
void setUvFrPerAsec(int i, double d)
QVector< char > * polarization_2ByChan_
SgVector * numOfAccPeriodsByChan_LSB_
SgMatrix * phaseCalData_1ByChan()
SgVector * numOfSamplesByChan_USB()
SgVlbiBaselineInfo * getBaseline() const
void setReferenceFrequency(double)
double getPhaseCalRates(int i) const
void setCorrelZdelay_2(double v)
double getCalcFeedCorrRate() const
double getReferenceFrequency() const
void allocateChannelsSetupStorages(int numOfChans)
SgVlbiMeasurement * activeRate_
double getCorrelStarElev_1() const
bool loadIntermediateResults(QDataStream &)
SgVlbiMeasurement * activeDelay_
int getBitsPerSample() const
void setCalcFeedCorrDelay(double v)
double getCorrCoeff() const
SgVlbiMeasurement phDRate_
double fourfitSearchParameters_[6]
SgVector * loFreqByChan_2()
double phaseCalPhAmbigSpacings_[2]
SgVector * numOfAccPeriodsByChan_USB_
void setStartOffset(int offset)
void setSbdDiffBand(double)
SgAttribute nonUsableReason_
SgVector * fringePhaseByChan()
double getGeocenterResidPhase() const
SgVector * refFreqByChan()
void setFourfitSearchParameters(int i, double d)
SgVector * loFreqByChan_1_
void setSampleRate(double sr)
SgVlbiObservation * owner_
void setCorrelStarElev_1(double v)
void setCalcFeedCorrRate(double v)
QVector< int > * bbcIdxByChan_2()
SgVlbiStationInfo * stn_1_
double getCorrelZdelay_2() const
SgVlbiMeasurement grDelay_
@ Attr_SBD_NOT_VALID
omit the observation if single band delay is analysed;
SgVlbiStationInfo * stn_1()
SgVlbiAuxObservation * auxObs_2()
SgVlbiSession * session()
SgVlbiBaselineInfo * baseline()
QList< SgVlbiObservable * > & passiveObses()
short int getSourceIdx() const
SgVlbiStationInfo * stn_2()
int minQualityFactor() const
const QString & getScanName() const
QMap< QString, SgVlbiObservable * > & observableByKey()
SgVlbiAuxObservation * auxObs_1()
short int getBaselineIdx() const
@ Attr_HAS_IONO_CORR
the theoretical values are available;
QList< SgVlbiBand * > & bands()
SgVlbiSourceInfo * lookupSourceByIdx(int)
SgVlbiBaselineInfo * lookupBaselineByIdx(int)
@ Attr_NOT_VALID
omit the source;
@ Attr_NOT_VALID
omit the station;