27 #include <QtCore/QDataStream>
28 #include <QtCore/QVector>
44 void findPeak(
const std::complex<double> *cA,
int n,
double &dD,
double &dP);
48 const SgVector& pcFreqByChan,
double refFreq,
49 double& phaseCalGrd,
double& phaseCalGrdAmbig,
50 double& phaseCalPhd,
double& phaseCalPhdAmbig,
64 return "SgVlbiObservable";
81 fourfitOutputFName_(
""),
82 fourfitControlFile_(
""),
83 fourfitCommandOverride_(
""),
84 epochOfCorrelation_(
tZero),
85 epochOfFourfitting_(
tZero),
130 for (
int i=0; i<2; i++)
139 for (
int i=0; i<6; i++)
183 bandKey_(band?band->getKey():
""),
189 tapeQualityCode_(
""),
191 fourfitOutputFName_(
""),
192 fourfitControlFile_(
""),
193 fourfitCommandOverride_(
""),
194 epochOfCorrelation_(
tZero),
195 epochOfFourfitting_(
tZero),
197 epochCentral_(
tZero),
239 for (
int i=0; i<2; i++)
248 for (
int i=0; i<6; i++)
294 bandKey_(o.getBandKey()),
295 sbDelay_(o.sbDelay_),
296 grDelay_(o.grDelay_),
297 phDelay_(o.phDelay_),
298 phDRate_(o.phDRate_),
299 errorCode_(o.getErrorCode()),
300 tapeQualityCode_(o.getTapeQualityCode()),
301 fourfitOutputFName_(o.getFourfitOutputFName()),
302 fourfitControlFile_(o.getFourfitControlFile()),
303 fourfitCommandOverride_(o.getFourfitCommandOverride()),
304 epochOfCorrelation_(o.getEpochOfCorrelation()),
305 epochOfFourfitting_(o.getEpochOfFourfitting()),
306 epochOfScan_(o.getEpochOfScan()),
307 epochCentral_(o.getEpochCentral()),
308 tStart_(o.getTstart()),
352 for (
int i=0; i<2; i++)
364 for (
int i=0; i<6; i++)
639 QString srcN(
"?"), blnN(
"?:?");
690 ": allocateChannelsSetupStorages(): an attempt to allocate data with zero number of channels");
900 if (s.status() == QDataStream::Ok &&
905 return s.status() == QDataStream::Ok;
918 unsigned int attributes;
919 s >> bandKey >> mediaIdx >> is >> attributes;
920 if (s.status() == QDataStream::Ok)
925 ": loadIntermediateResults(): error reading " +
bandKey_ +
926 "-band data: bandKey mismatch: got [" + bandKey +
"], expected [" +
bandKey_ +
"]");
932 ": loadIntermediateResults(): error reading " +
bandKey_ +
933 "-band data: media index mismatch: got [" +
934 QString(
"").setNum(mediaIdx) +
"], expected [" + QString(
"").setNum(
mediaIdx_) +
"]");
946 ": loadIntermediateResults(): error reading data: " +
947 (s.status()==QDataStream::ReadPastEnd?
"read past end of the file":
"read corrupt data"));
962 ": calcPhaseDelay(): cannot calculate phase delay: the owner is NULL");
968 ": calcPhaseDelay(): cannot calculate phase delay: the band is NULL");
972 if (!(aux_1 && aux_2))
975 ": calcPhaseDelay(): cannot calculate phase delay: the aux obss are NULL");
978 double vPhDly, ePhDly, aPhDly, dNumAmbigs;
987 ": calcPhaseDelay(): got unusual value for SNR: " + QString(
"").setNum(
snr_));
1006 ": calcPhaseCalDelay(): cannot calculate phase cal effects: band is NULL");
1012 ": calcPhaseCalDelay(): cannot calculate phase cal effects: ref.freq storage is NULL");
1018 ": calcPhaseCalDelay(): cannot calculate phase cal effects: pcal phases @1 storage is NULL");
1024 ": calcPhaseCalDelay(): cannot calculate phase cal effects: pcal phases @2 storage is NULL");
1030 ": calcPhaseCalDelay(): cannot calculate phase cal effects: size mismatch for @1: " +
1031 QString(
"").sprintf(
"#chan(%d) != #PCchan(%d)",
1038 ": calcPhaseCalDelay(): cannot calculate phase cal effects: size mismatch for @2");
1047 for (
int i=0; i<n; i++)
1063 double phaseCalGrd=0.0;
1064 double phaseCalGrdAmbig=0.0;
1065 double phaseCalPhd=0.0;
1066 double phaseCalPhdAmbig=0.0;
1069 phaseCalGrd, phaseCalGrdAmbig, phaseCalPhd, phaseCalPhdAmbig,
strId()))
1078 phaseCalGrd, phaseCalGrdAmbig, phaseCalPhd, phaseCalPhdAmbig,
strId()))
1088 delete pcAmplitudes_1;
1089 delete pcAmplitudes_2;
1111 const SgVector& pcFreqByChan,
double refFreq,
1112 double& phaseCalGrd,
double& phaseCalGrdAmbig,
1113 double& phaseCalPhd,
double& phaseCalPhdAmbig,
1116 int nChan=pcFreqByChan.
n();
1117 phaseCalGrdAmbig = 0.0;
1118 phaseCalPhdAmbig = 0.0;
1122 "evaluatePhaseCals: number of actual channels is zero, nothing to do for the obs " + oId);
1128 "evaluatePhaseCals: have only one actual channel, nothing to do for the obs " + oId);
1132 std::complex<double> *x_a, *x_A;
1133 double rfMin, diffMin, d;
1134 int *idxs=
new int[nChan], nData=512;
1139 for (
int i=0; i<nChan; i++)
1141 if ( (d=fabs(pcFreqByChan.
getElement(i))) < rfMin)
1143 for (
int j=i+1; j<nChan; j++)
1146 if (0.0 < d && d < diffMin)
1150 phaseCalGrdAmbig = 1.0/diffMin*1.0e3;
1151 phaseCalPhdAmbig = 1.0/refFreq*1.0e3;
1153 for (
int i=0; i<nChan; i++)
1154 if (nData <= (idxs[i]=((fabs(pcFreqByChan.
getElement(i)) - rfMin)/diffMin)))
1157 "evaluatePCal4GrpDelay: Array overrun for the obs " + oId +
1158 QString(
"").sprintf(
": idxs[%d]=%d for %.2f and Fmin=%.2f Dmin=%.2f",
1159 i, idxs[i], pcFreqByChan.
getElement(i), rfMin, diffMin));
1164 x_a =
new std::complex<double>[nData];
1165 x_A =
new std::complex<double>[nData];
1166 for (
int i=0; i<nData; i++)
1167 x_a[i] = x_A[i] = std::complex<double>(0.0, 0.0);
1168 for (
int i=0; i<nChan; i++)
1177 phaseCalGrd = phaseCalGrdAmbig*dD/nData;
1178 phaseCalGrd = fmod(phaseCalGrd + phaseCalGrdAmbig*2.5, phaseCalGrdAmbig) - 0.5*phaseCalGrdAmbig;
1180 phaseCalPhd = dP/(2.0*M_PI)*phaseCalPhdAmbig + (refFreq - rfMin)*1.0e-3*phaseCalGrd;
1191 void findPeak(
const std::complex<double> *cA,
int n,
double &dD,
double &dP)
1193 double dX1, dX2, dX3, dA1, dA2, dA3, dP1, dP2, dP3;
1195 int idx1, idx2, idx3;
1197 idx1 = idx2 = idx3 = 0;
1198 dX1 = dX2 = dX3 = dA1 = dA3 = dP1 = dP2 = dP3 = 0.0;
1200 for (
int i=0; i<n; i++)
1201 if (dA2 <= (d=abs(cA[i])) )
1204 idx1 = idx2 = idx3 = i;
1215 dA1 = abs(cA[idx1]);
1216 dA3 = abs(cA[idx3]);
1217 dP1 = arg(cA[idx1]);
1218 dP2 = arg(cA[idx2]);
1219 dP3 = arg(cA[idx3]);
1221 if (M_PI <= fabs(dP1 - dP2))
1222 dP1 = dP2 + fmod(dP1 - dP2 + 5.0*M_PI, 2.0*M_PI) - M_PI;
1223 if (M_PI <= fabs(dP2 - dP3))
1224 dP3 = dP2 + fmod(dP3 - dP2 + 5.0*M_PI, 2.0*M_PI) - M_PI;
1228 dD = 0.5*(dX3*dX3*(dA1 - dA2) + dX2*dX2*(dA3 - dA1) + dX1*dX1*(dA2 - dA3))/
1229 (dX3* (dA1 - dA2) + dX2* (dA3 - dA1) + dX1* (dA2 - dA3));
1234 dx = 0.5*(dA1 - dA3)/(dA1 - 2.0*dA2 + dA3);
1239 dP = dP2 + 0.5*(dP3 - dP1)*dx + 0.5*(dP1 - 2.0*dP2 + dP3)*dx*dx;
const SgMJD tZero(1957, 10, 4)
void fft(std::complex< double > x_a[], std::complex< double > x_A[], unsigned int n, FFT_Direction dir)
void findPeak(const std::complex< double > *cA, int n, double &dD, double &dP)
bool evaluatePhaseCals(const SgVector &pcPhases, const SgVector &pcAmplitudes, const SgVector &pcFreqByChan, double refFreq, double &phaseCalGrd, double &phaseCalGrdAmbig, double &phaseCalPhd, double &phaseCalPhdAmbig, const QString &oId)
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;