General Purpose Geodetic Library
SgVlbiObservation.cpp
Go to the documentation of this file.
1 /*
2  *
3  * This file is a part of Space Geodetic Library. The library is used by
4  * nuSolve, a part of CALC/SOLVE system, and designed to make analysis of
5  * geodetic VLBI observations.
6  * Copyright (C) 2010-2020 Sergei Bolotin.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #include <iostream>
24 #include <stdlib.h>
25 
26 
27 #include <QtCore/QDataStream>
28 #include <QtCore/QRegExp>
29 
30 
31 #include <SgVlbiObservation.h>
32 
33 
34 #include <SgConstants.h>
35 #include <SgEstimator.h>
36 #include <SgLogger.h>
37 #include <SgRefraction.h>
38 #include <SgTaskConfig.h>
39 #include <SgTaskManager.h>
40 #include <SgVlbiBand.h>
41 #include <SgVlbiBaselineInfo.h>
42 #include <SgVlbiSession.h>
43 #include <SgVlbiSourceInfo.h>
44 #include <SgVlbiStationInfo.h>
45 
46 
47 
48 #define DBG_MODE_ 1
49 #define DBG_MODE_2_ 1
50 
51 
52 
53 /*=======================================================================================================
54 *
55 * METHODS:
56 *
57 *======================================================================================================*/
58 //
60 {
61  bool isOk = true;
62 
63  // make selfcheck here:
64  for (QMap<QString, SgVlbiObservable*>::iterator it=observableByKey_.begin();
65  it!=observableByKey_.end(); ++it)
66  {
67  SgVlbiObservable *o=it.value();
68  o->calcPhaseDelay();
69  };
70 
71  return isOk;
72 };
73 
74 
75 
76 // An empty constructor:
78  : SgObservation(),
79  observableByKey_(),
80  passiveObses_(),
81  scanName_(""),
82  corrRootFileName_(""),
83  scanId_(""),
84  scanFullName_(""),
85  rSun_(v3Zero),
86  vSun_(v3Zero),
87  rMoon_(v3Zero),
88  vMoon_(v3Zero),
89  rEarth_(v3Zero),
90  vEarth_(v3Zero),
91  aEarth_(v3Zero),
92  trf2crfVal_(m3E),
93  trf2crfRat_(m3E),
94  trf2crfAcc_(m3E),
95  dDel_dR_1_(v3Zero),
96  dRat_dR_1_(v3Zero),
97  dDel_dR_2_(v3Zero),
98  dRat_dR_2_(v3Zero),
99  userCorrections_(),
100  parameters_()
101 {
102  session_ = session;
104  station1Idx_ = -1;
105  station2Idx_ = -1;
106  sourceIdx_ = -1;
107  baselineIdx_ = -1;
108  activeObs_ = NULL;
109  primeObs_ = NULL;
110  apLength_ = 0.0;
111  dTec_ = 0.0;
112  dTecStdDev_ = 0.0;
113 
114  calcConsensusDelay_ = 0.0;
115  calcConsensusRate_ = 0.0;
117  calcConsBendingRate_ = 0.0;
124  calcOceanTideDelay_ = 0.0;
125  calcOceanTideRate_ = 0.0;
126  extDelayHiFyUt1_ = 0.0;
127  extRateHiFyUt1_ = 0.0;
128  extDelayHiFyPxy_ = 0.0;
129  extRateHiFyPxy_ = 0.0;
130  calcPoleTideDelay_ = 0.0;
131  calcPoleTideRate_ = 0.0;
132  calcEarthTideDelay_ = 0.0;
133  calcEarthTideRate_ = 0.0;
134  calcPxDelay_ = 0.0;
135  calcPxRate_ = 0.0;
136  calcPyDelay_ = 0.0;
137  calcPyRate_ = 0.0;
138  calcWobNutatContrib_ = 0.0;
139  calcFeedCorrDelay_ = 0.0;
140  calcFeedCorrRate_ = 0.0;
141  calcTiltRemvrDelay_ = 0.0;
142  calcTiltRemvrRate_ = 0.0;
143  calcHiFyUt1Delay_ = 0.0;
144  calcHiFyUt1Rate_ = 0.0;
145  calcHiFyPxyDelay_ = 0.0;
146  calcHiFyPxyRate_ = 0.0;
147  extDelayErp_ = 0.0;
148  extRateErp_ = 0.0;
149  aPrioriPxHfContrib_ = 0.0;
150  aPrioriPyHfContrib_ = 0.0;
152  aPrioriPxLfContrib_ = 0.0;
153  aPrioriPyLfContrib_ = 0.0;
155  aPrioriCxLfContrib_ = 0.0;
156  aPrioriCyLfContrib_ = 0.0;
157  //
165  calcOceanTideOldRate_ = 0.0;
166  calcPoleTideOldDelay_ = 0.0;
167  calcPoleTideOldRate_ = 0.0;
168  calcUt1_Tai_ = 0.0;
169  calcPmX_ = 0.0;
170  calcPmY_ = 0.0;
171  calcCipXv_ = 0.0;
172  calcCipYv_ = 0.0;
173  calcCipSv_ = 0.0;
174  calcCipXr_ = 0.0;
175  calcCipYr_ = 0.0;
176  calcCipSr_ = 0.0;
177  calcNutWahr_dPsiV_ = 0.0;
178  calcNutWahr_dEpsV_ = 0.0;
179  calcNutWahr_dPsiR_ = 0.0;
180  calcNutWahr_dEpsR_ = 0.0;
181  calcNut2006_dPsiV_ = 0.0;
182  calcNut2006_dEpsV_ = 0.0;
183  calcNut2006_dPsiR_ = 0.0;
184  calcNut2006_dEpsR_ = 0.0;
185  //
186  dDel_dRA_ = 0.0;
187  dRat_dRA_ = 0.0;
188  dDel_dDN_ = 0.0;
189  dRat_dDN_ = 0.0;
190  dDel_dBend_ = 0.0;
191  dRat_dBend_ = 0.0;
192  dDel_dUT1_ = 0.0;
193  dRat_dUT1_ = 0.0;
194  d2Del_dUT12_ = 0.0;
195  d2Rat_dUT12_ = 0.0;
196  dDel_dPx_ = 0.0;
197  dRat_dPx_ = 0.0;
198  dDel_dPy_ = 0.0;
199  dRat_dPy_ = 0.0;
200  dDel_dCipX_ = 0.0;
201  dRat_dCipX_ = 0.0;
202  dDel_dCipY_ = 0.0;
203  dRat_dCipY_ = 0.0;
204  dDel_dGamma_ = 0.0;
205  dRat_dGamma_ = 0.0;
206  dDel_dParallax_ = 0.0;
207  dRat_dParallax_ = 0.0;
208  dDel_dParallaxRev_ = 0.0;
209  dRat_dParallaxRev_ = 0.0;
210  dDel_dPolTideX_ = 0.0;
211  dRat_dPolTideX_ = 0.0;
212  dDel_dPolTideY_ = 0.0;
213  dRat_dPolTideY_ = 0.0;
214  fractC_ = 0.0;
215 
216  // ionoBits_ = (1<<1); // No matching group data for GION
217 
218  stn_1_ = NULL;
219  stn_2_ = NULL;
220  src_ = NULL;
221  baseline_ = NULL;
222  auxObs_1_ = NULL;
223  auxObs_2_ = NULL;
224  theoDelay_ = 0.0;
225  theoRate_ = 0.0;
228  baselineClock_F1_ = 0.0;
229  baselineClock_F1l_ = 0.0;
230  baselineClock_F1r_ = 0.0;
231  sumAX_4delay_ = sumAX_4rate_ = 0.0;
232  reweightAuxSum4delay_ = 0.0;
233  reweightAuxSum4rate_ = 0.0;
234 };
235 
236 
237 
238 // A destructor:
240 {
241  // clear the map:
242  for (QMap<QString, SgVlbiObservable*>::iterator it=observableByKey_.begin();
243  it!=observableByKey_.end(); ++it)
244  delete it.value();
245  observableByKey_.clear();
246  parameters_.clear();
247  userCorrections_.clear();
248  activeObs_ = NULL;
249  primeObs_ = NULL;
250  passiveObses_.clear();
251  stn_1_ = NULL;
252  stn_2_ = NULL;
253  src_ = NULL;
254  baseline_ = NULL;
255  auxObs_1_ = NULL;
256  auxObs_2_ = NULL;
257 };
258 
259 
260 
261 //
262 bool SgVlbiObservation::addObservable(const QString& bandKey, const SgVlbiObservable& o)
263 {
264  if (observableByKey_.contains(bandKey))
265  {
266  // at this point the credentials of the observable are not set up yet:
268  ":addObservable(): the observable for the " + bandKey + "-band already registered");
269  return false;
270  };
271  observableByKey_.insert(bandKey, new SgVlbiObservable(this, o));
272  return true;
273 };
274 
275 
276 
277 //
278 bool SgVlbiObservation::addObservable(const QString& bandKey, SgVlbiObservable* o)
279 {
280  if (observableByKey_.contains(bandKey))
281  {
282  // at this point the credentials of the observable are not set up yet:
284  ":addObservable(): the observable for the " + bandKey + "-band already registered");
285  return false;
286  };
287  observableByKey_.insert(bandKey, o);
288  return true;
289 };
290 
291 
292 
293 //
295 {
296  int qf=observableByKey_.begin().value()->getQualityFactor();
297  QMap<QString, SgVlbiObservable*>::const_iterator it;
298  for (it=observableByKey_.begin(); it!=observableByKey_.end(); ++it)
299  {
300  SgVlbiObservable *o=it.value();
301  if (o->getQualityFactor() < qf)
302  qf = o->getQualityFactor();
303  };
304  return qf;
305 };
306 
307 
308 
309 //
311 {
313  {
315  ": setupIdentities(): cannot find the station #1 (idx= " + QString("").setNum(station1Idx_) +
316  ") in the session's station infos map");
317  return;
318  };
320  {
322  ": setupIdentities(): cannot find the station #2 (idx= " + QString("").setNum(station2Idx_) +
323  ") in the session's station infos map");
324  return;
325  };
327  {
329  ": setupIdentities(): cannot find the source (idx= " + QString("").setNum(sourceIdx_) +
330  ") in the session's source infos map");
331  return;
332  };
334  {
336  ": setupIdentities(): cannot find the baseline (idx= " + QString("").setNum(baselineIdx_) +
337  ") in the session's baseline infos map");
338  return;
339  };
340  //
341  if (stn_1_->auxObservationByScanId()->contains(scanId_))
342  {
344  auxObs_1_->setOwner(this);
345  }
346  else
348  ": setupIdentities(): cannot find the auxObs_1 for the scan " + scanId_ + ", station: " +
349  stn_1_->getKey() + ", obsKey: " + key_, true);
350  if (stn_2_->auxObservationByScanId()->contains(scanId_))
351  {
353  auxObs_2_->setOwner(this);
354  }
355  else
357  ": setupIdentities(): cannot find the auxObs_2 for the scan " + scanId_ + ", station: " +
358  stn_1_->getKey() + ", obsKey: " + key_, true);
359 
360  // per band identities:
361  QMap<QString, SgVlbiObservable*>::iterator it;
362  for (it=observableByKey_.begin(); it!=observableByKey_.end(); ++it)
363  {
364  SgVlbiObservable *o=it.value();
365  if (session_->bandByKey().contains(o->getBandKey()))
366  {
367  SgVlbiBand *band=session_->bandByKey().value(o->getBandKey());
368  if (!(o->stn_1()=band->lookupStationByIdx(station1Idx_)))
369  {
371  ": setupIdentities(): cannot find the station #1 (idx= " + QString("").setNum(station1Idx_) +
372  ") in the band's station infos map", true);
373  return;
374  };
375  if (!(o->stn_2()=band->lookupStationByIdx(station2Idx_)))
376  {
378  ": setupIdentities(): cannot find the station #2 (idx= " + QString("").setNum(station2Idx_) +
379  ") in the band's station infos map", true);
380  return;
381  };
382  if (!(o->src()=band->lookupSourceByIdx(sourceIdx_)))
383  {
385  ": setupIdentities(): cannot find the source (idx= " + QString("").setNum(sourceIdx_) +
386  ") in the band's source infos map", true);
387  return;
388  };
389  if (!(o->baseline()=band->lookupBaselineByIdx(baselineIdx_)))
390  {
392  ": setupIdentities(): cannot find the baseline (idx= " + QString("").setNum(baselineIdx_) +
393  ") in the band's baseline infos map", true);
394  return;
395  };
396  // copy the sigmas to the band level:
398  band->observables().append(o);
399  o->baseline()->observables().append(o);
400  }
401  else
402  {
404  ": setupIdentities(): cannot find a band (key= " + o->getBandKey() +
405  ") in the band's map", true);
406  return;
407  };
408  };
409  //
410  if (observableByKey_.contains(session_->primaryBand()->getKey()))
412  else
413  {
414  primeObs_ = NULL;
416  ": setupIdentities(): a primary observable is NULL. Obs#" + QString("").setNum(mediaIdx_) +
417  " key: " + key_);
419  ": setupIdentities(): epoch=[" + toString() + "], scanName=[" + scanName_ +
420  "], numOfBands=" + QString("").setNum(observableByKey_.size()));
421  };
422 };
423 
424 
425 
426 //
427 void SgVlbiObservation::setupActiveObservable(const QString& bandKey)
428 {
429  // set up active obs:
430  QMap<QString, SgVlbiObservable*>::iterator it;
431  passiveObses_.clear();
432  activeObs_ = observable(bandKey);
433  if (!activeObs_)
434  {
435  if (bandKey == "X")
437  ": setupActiveObservable(): cannot find the an active observable for the observation " + key_ +
438  " at the X-band", true);
439  for (it=observableByKey_.begin(); it!=observableByKey_.end(); ++it)
440  passiveObses_.append(it.value());
441  }
442  else
443  for (it=observableByKey_.begin(); it!=observableByKey_.end(); ++it)
444  if (it.value()->getBandKey() != activeObs_->getBandKey())
445  passiveObses_.append(it.value());
446 };
447 
448 
449 
450 //
452 {
453  QMap<QString, SgVlbiObservable*>::iterator it;
454  for (it=observableByKey_.begin(); it!=observableByKey_.end(); ++it)
455  {
456  SgVlbiObservable *o=it.value();
457  o->setupActiveMeasurements(cfg);
458  // set up sigmas:
459  double s2add4delay=1.0E-12;
460  double s2add4rate =1.0E-15;
461  //
462  switch (cfg->getWcMode())
463  {
464  default:
466  if (cfg->getDoWeightCorrection())
467  {
468  s2add4delay = session_->bandByKey().value(it.key())->getSigma2add(DT_DELAY);
469  s2add4rate = session_->bandByKey().value(it.key())->getSigma2add(DT_RATE);
470  }
471  else if (cfg->getUseDelayType() == SgTaskConfig::VD_SB_DELAY)
472  s2add4delay = 100.0E-12;
473  break;
475 // s2add4delay = baseline_->getSigma2add(DT_DELAY);
476 // s2add4rate = baseline_->getSigma2add(DT_RATE);
477 // if (cfg->getDoWeightCorrection())
478 // {
479  s2add4delay = o->baseline()->getSigma2add(DT_DELAY);
480  s2add4rate = o->baseline()->getSigma2add(DT_RATE);
481 // };
482  break;
483  };
484  //
485  if (o->activeDelay()) // can be NULL:
486  {
487  o->activeDelay()->setSigma2add(s2add4delay);
488  o->activeDelay()->setupSigma2Apply(cfg);
489  };
490  o->phDRate().setSigma2add(s2add4rate);
491  o->phDRate().setupSigma2Apply(cfg);
492  };
493 };
494 
495 
496 
497 //
499 {
500  sumAX_4delay_ = sumAX_4rate_ = 0.0;
501 
502  for (QMap<QString, SgVlbiObservable*>::iterator it=observableByKey_.begin();
503  it!=observableByKey_.end(); ++it)
504  it.value()->checkUsability(cfg);
505 
506  //
507  // user turn it off explicitly, nothing to check:
508  if (!SgObservation::isEligible(cfg))
509  return false;
510  // did not pass selfCheck procedure, turn it off:
511  if (!selfCheck())
512  return false;
513  if (!activeObs_)
514  return false;
515 
516  // SB delay has its own flag:
518  return false;
519  //
520  return activeObs_->isUsable();
521 };
522 
523 
524 
525 //
527 {
528  QString str;
529  const SgTaskConfig *cfg=mgr->getTask()->config();
530 
533  // first, remove clock model:
534  // a priori clock functions:
535  double dt1( *this - session_->tRefer());
536  double dt2((*this - session_->tRefer()) + getCalcConsensusDelay()/DAY2SEC);
537  double d1(1.0), d2(1.0), c1(0.0), c2(0.0), b1(0.0), b2(0.0);
538  //
539  // delay:
540  for (int i=0; i<stn_1_->getClocksModelOrder(); i++)
541  {
542  c1 += stn_1_->getEstClockModel(i)*d1;
543  d1 *= dt1;
544  };
545  for (int i=0; i<stn_2_->getClocksModelOrder(); i++)
546  {
547  c2 += stn_2_->getEstClockModel(i)*d2;
548  d2 *= dt2;
549  };
550  theoDelay_ += (c2 - c1);
551  //
552  // rate:
553  d1 = d2 = 1.0;
554  for (int i=1; i<stn_1_->getClocksModelOrder(); i++)
555  {
556  b1 += i*stn_1_->getEstClockModel(i)*d1;
557  d1 *= dt1;
558  };
559  for (int i=1; i<stn_2_->getClocksModelOrder(); i++)
560  {
561  b2 += i*stn_2_->getEstClockModel(i)*d2;
562  d2 *= dt2;
563  };
564  theoRate_ += (b2 - b1)/DAY2SEC;
565  //
566  // a priori clocks (if exists):
571 
572 #ifdef DBG_MODE_
574  {
576  ": The observation #" + QString("").setNum(getMediaIdx()) + " of " + src_->getKey() +
577  " @ " + stn_1_->getKey() + ":" + stn_2_->getKey() + " on " +
579 
580  str.sprintf("Added contribution: clock model (ps): %18.2f", (c2 - c1)*1.0e12);
582  };
583 #endif
584  //
585  // then, other contributions:
586  /*double dtAtm1(0.0), dtAtm2(0.0), dtTroposphere(0.0)*/;
587  double dContrib(0.0), dContribA(0.0), dContribB(0.0);
588  //
589  // these contributions are already included in the delay:
590  //The delays (CONSNDEL) contain the following effects:
591  // axis offset corrections
592  // pole tide corrections
593  // solid Earth tide corrections
594  // nutation/precession
595  // UT1
596  // polar motion
597  // gravitational bending
598  // axis tilt corrections (if tilt is known)
599  if (!cfg->getHave2ApplyPxContrib())
600  {
603  };
604  if (!cfg->getHave2ApplyPyContrib())
605  {
608  };
609  if (!cfg->getHave2ApplyEarthTideContrib())
610  {
613  };
614  if (!cfg->getHave2ApplyPoleTideContrib())
615  {
618  };
619  if (cfg->getHave2ApplyTiltRemvrContrib()) // this one looks like should be added to remove the effect
620  {
623  };
624  // these contributions are not in the theoretical delay:
626  {
629  };
631  {
634  };
635  /* an alternative way:
636  if (cfg->getHave2ApplyOceanTideContrib() && auxObs_1_ && auxObs_2_)
637  {
638  setCalcOLoadDelay(
639  auxObs_1_->getCalcOLoadHorzDelay() + auxObs_1_->getCalcOLoadVertDelay()
640  - auxObs_2_->getCalcOLoadHorzDelay() - auxObs_2_->getCalcOLoadVertDelay() );
641  theoDelay_ += getCalcOLoadDelay();
642  };*/
643  //
645  {
648  };
650  {
653  };
654  if (cfg->getHave2ApplyFeedCorrContrib())
655  {
658  };
659  //
660 // if (session_->getCalcVersionValue()<11.0)
661  if (session_->calcInfo().getDversion() < 11.0)
662  {
664  {
666  //theoRate_ += getCalcWobNutatContrib(); ?
667  };
668  }
669  else
670  {
672  {
675  };
677  {
680  };
681  };
683  {
686  };
687  // old?
689  {
692  };
693  if (cfg->getHave2ApplyGpsIonoContrib())
694  {
697  };
698 
699 #ifdef DBG_MODE_
701  {
702  str.sprintf("Theoretical delay, initial (ps): %18.2f", getCalcConsensusDelay()*1.0e12);
704  str.sprintf("Theoretical delay after contributions (ps): %18.2f", theoDelay_*1.0e12);
706  // check for contributions:
707  // these contributions are already included:
708  str.sprintf(" Pole tides (ps): %18.2f", getCalcPoleTideDelay()*1.0e12);
710  str.sprintf(" Wobble x (ps): %18.2f", getCalcPxDelay()*1.0e12);
712  str.sprintf(" Wobble y (ps): %18.2f", getCalcPyDelay()*1.0e12);
714  str.sprintf(" Earth tides (ps): %18.2f", getCalcEarthTideDelay()*1.0e12);
716 
717  if (!cfg->getHave2ApplyPoleTideContrib())
718  {
719  str.sprintf("Removed contribution: Pole tides (ps): %18.2f", getCalcPoleTideDelay()*1.0e12);
721  };
722  if (!cfg->getHave2ApplyEarthTideContrib())
723  {
724  str.sprintf("Removed contribution: Earth tides (ps): %18.2f", getCalcEarthTideDelay()*1.0e12);
726  };
727  if (!cfg->getHave2ApplyPxContrib())
728  {
729  str.sprintf("Removed contribution: wobble x (ps): %18.2f", getCalcPxDelay()*1.0e12);
731  };
732  if (!cfg->getHave2ApplyPyContrib())
733  {
734  str.sprintf("Removed contribution: wobble y (ps): %18.2f", getCalcPyDelay()*1.0e12);
736  };
737  //
738  // these contributions are not in theo. delay:
740  {
741  str.sprintf("Added contribution: ocean loading (ps): %18.2f",
742  getCalcOceanTideDelay()*1.0e12);
744  };
746  {
747  str.sprintf("Added contribution: old ocean loading (ps): %18.2f",
748  getCalcOceanTideOldDelay()*1.0e12);
750  };
752  {
753  dContribA = getCalcHiFyPxyDelay();
754  str.sprintf("Added contribution: high freq PM (ps): %18.2f", dContribA*1.0e12);
756  };
758  {
759  dContribB = getCalcHiFyUt1Delay();
760  str.sprintf("Added contribution: high freq UT1 (ps): %18.2f", dContribB*1.0e12);
762  };
765  {
766  str.sprintf("Added contribution: sum high freq EOP (ps): %18.2f", (dContribA + dContribB)*1.0e12);
768  };
769  if (cfg->getHave2ApplyFeedCorrContrib())
770  {
771  str.sprintf("Added contribution: feed corr (ps): %18.2f", getCalcFeedCorrDelay()*1.0e12);
773  };
774  if (!cfg->getHave2ApplyTiltRemvrContrib())
775  {
776  str.sprintf("Removed contribution: tilt remover (ps): %18.2f", getCalcTiltRemvrDelay()*1.0e12);
778  };
779  if (session_->calcInfo().getDversion() < 11.0)
780  {
782  {
783  str.sprintf("Added contribution: hi freq nutation in PM: %18.2f",
784  getCalcWobNutatContrib()*1.0e12);
786  };
787  }
788  else
789  {
791  {
792  str.sprintf("Added contribution: libration in PM: %18.2f",
795  };
797  {
798  str.sprintf("Added contribution: libration in UT1: %18.2f",
801  };
802  };
804  {
805  str.sprintf("Added contribution: ocean pole tide (ps): %18.2f",
806  getCalcOceanPoleTideLdDelay()*1.0e12);
808  };
810  {
811  str.sprintf("Added contribution: old pole tide (ps): %18.2f",
812  getCalcPoleTideOldDelay()*1.0e12);
814  };
815  };
816 #endif
817  //
818  // External a priori:
819  //
820  double dStnPos(0.0), dSrcPos(0.0), dAxsOfs(0.0);
821  double dMeanGradients(0.0), dExternalErps(0.0);
822  double dEccCor1(0.0), dEccCor2(0.0), dHiFyPm(0.0), dHiFyUt1(0.0);
823  double dD, dR;
824  //
825  // if we have external a priori, correct the RHS:
829  {
830  evalExtApriori_StnPos(cfg, dD, dR);
831  extAprioriCorrections4delay_ += (dStnPos=dD);
833  };
835  {
836  evalExtApriori_SrcPos(dD, dR);
837  extAprioriCorrections4delay_ += (dSrcPos=dD);
839  };
840  if (cfg->getUseExtAPrioriAxisOffsets())
841  {
842  evalExtApriori_AxsOfs(dD, dR);
843  extAprioriCorrections4delay_ += (dAxsOfs=dD);
845  };
847  {
848  evalExtApriori_MeanGrads(dD, dR);
849  extAprioriCorrections4delay_ += (dMeanGradients=dD);
851  };
852 
853 
854 // -------------------
855 
857  {
858  extAprioriCorrections4delay_ -= (dExternalErps= getExtDelayErp());
860  };
861 
862  if (cfg->getUseExtAPrioriHiFyErp())
863  {
868  };
869 
870  if (stn_1_->getIsEccNonZero())
871  {
874  };
875  if (stn_2_->getIsEccNonZero())
876  {
879  };
880 //------------------------------
881 
882 #ifdef DBG_MODE_
884  {
885  str.sprintf("A priori adjustment: stations position (ps): %18.2f", dStnPos*1.0e12);
887  str.sprintf("A priori adjustment: source positions (ps): %18.2f", dSrcPos*1.0e12);
889  str.sprintf("A priori adjustment: axis offsets (ps): %18.2f", dAxsOfs*1.0e12);
891  str.sprintf("A priori adjustment: mean gradients (ps): %18.2f", dMeanGradients*1.0e12);
893  str.sprintf("A priori adjustment: eccentricities (ps): %18.2f", (dEccCor1+dEccCor2)*1.0e12);
895  str.sprintf("External HiFreq model of ERP: PM (ps): %18.2f", dHiFyPm*1.0e12);
897  str.sprintf("External HiFreq model of ERP: UT1(ps): %18.2f", dHiFyUt1*1.0e12);
899  str.sprintf("A priori adjustment: sum of all (ps): %18.2f",
902  };
903 #endif
904  //
905  //
906  // tropospheric delays:
907  double dDryZd_1, dDryZd_2, dWetZd_1, dWetZd_2;
908  double dDryMf_1, dDryMf_2, dWetMf_1, dWetMf_2;
909  double rDryMf_1, rDryMf_2, rWetMf_1, rWetMf_2;
910  if (auxObs_1_ && auxObs_2_)
911  {
912  if (!cfg->getHave2ApplyNdryContrib() || !cfg->getHave2ApplyNwetContrib())
913  {
916  dDryZd_1 = mgr->refraction()->dDryZD();
917  dWetZd_1 = mgr->refraction()->dWetZD();
918  dDryMf_1 = mgr->refraction()->dDryMF();
919  dWetMf_1 = mgr->refraction()->dWetMF();
920  rDryMf_1 = mgr->refraction()->dryMappingFunction()->dM_dE();
921  rWetMf_1 = mgr->refraction()->wetMappingFunction()->dM_dE();
922 
925  dDryZd_2 = mgr->refraction()->dDryZD();
926  dWetZd_2 = mgr->refraction()->dWetZD();
927  dDryMf_2 = mgr->refraction()->dDryMF();
928  dWetMf_2 = mgr->refraction()->dWetMF();
929  rDryMf_2 = mgr->refraction()->dryMappingFunction()->dM_dE();
930  rWetMf_2 = mgr->refraction()->wetMappingFunction()->dM_dE();
931  };
932  //
933  // hydrostatic part:
934  if (cfg->getHave2ApplyNdryContrib()) // from contributions:
935  {
937  theoDelay_ += dContribA;
939 
942 
947  }
948  else // from "flyby":
949  {
950  dContribA = dDryZd_2*rDryMf_2*auxObs_2_->getElevationAngleRate() -
951  dDryZd_1*rDryMf_1*auxObs_1_->getElevationAngleRate();
952  theoRate_ += dContribA/vLight;
953 
954  dContribA = dDryZd_2*dDryMf_2 - dDryZd_1*dDryMf_1;
955  theoDelay_ += dContribA/vLight;
956  auxObs_1_->setZenithDelayH(dDryZd_1);
957  auxObs_2_->setZenithDelayH(dDryZd_2);
958 
959  auxObs_1_->setSlantDelayH(dDryZd_1*dDryMf_1/vLight);
960  auxObs_2_->setSlantDelayH(dDryZd_2*dDryMf_2/vLight);
963  };
964  //
965  // wet part:
966  if (cfg->getHave2ApplyNwetContrib())
967  {
969  theoDelay_ += dContribB;
971 
974 
979  }
980  else
981  {
982  dContribB = dWetZd_2*rWetMf_2*auxObs_2_->getElevationAngleRate() -
983  dWetZd_1*rWetMf_1*auxObs_1_->getElevationAngleRate();
984  theoRate_ += dContribB/vLight;
985 
986  dContribB = dWetZd_2*dWetMf_2 - dWetZd_1*dWetMf_1;
987  theoDelay_ += dContribB/vLight;
988  auxObs_1_->setZenithDelayW(dWetZd_1);
989  auxObs_2_->setZenithDelayW(dWetZd_2);
990 
991  auxObs_1_->setSlantDelayW(dWetZd_1*dWetMf_1/vLight);
993  auxObs_2_->setSlantDelayW(dWetZd_2*dWetMf_2/vLight);
995  };
996 /*
997  if (cfg->getHave2ApplyNdryContrib() || cfg->getHave2ApplyNwetContrib())
998  {
999  theoDelay_ += (dContribA=auxObs_1_->getCalcNdryCont4Delay() + auxObs_2_->getCalcNdryCont4Delay());
1000  theoDelay_ += (dContribB=auxObs_1_->getCalcNwetCont4Delay() + auxObs_2_->getCalcNwetCont4Delay());
1001 
1002  theoRate_ += auxObs_1_->getCalcNdryCont4Rate() + auxObs_2_->getCalcNdryCont4Rate();
1003  theoRate_ += auxObs_1_->getCalcNwetCont4Rate() + auxObs_2_->getCalcNwetCont4Rate();
1004 
1005 #ifdef DBG_MODE_
1006  str.sprintf("Added contribution: NMF wet and dry (ps): %18.2f", (dContribA + dContribB)*1.0e12);
1007  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1008 #endif
1009  }
1010  else
1011  {
1012  dtAtm1 = mgr->refraction()->calcTroposphericDelay(*this, auxObs_1_->getMeteoData(),
1013  auxObs_1_->getElevationAngle(), auxObs_1_->getAzimuthAngle(),
1014  stn_1_, src_);
1015  auxObs_1_->setZenithDelayH(mgr->refraction()->dDryZD());
1016  auxObs_1_->setZenithDelayW(mgr->refraction()->dWetZD());
1017 
1018  dtAtm2 = mgr->refraction()->calcTroposphericDelay(*this, auxObs_2_->getMeteoData(),
1019  auxObs_2_->getElevationAngle(), auxObs_2_->getAzimuthAngle(),
1020  stn_2_, src_);
1021  auxObs_2_->setZenithDelayH(mgr->refraction()->dDryZD());
1022  auxObs_2_->setZenithDelayW(mgr->refraction()->dWetZD());
1023 
1024  dtTroposphere = dtAtm2 - dtAtm1;
1025 
1026  theoDelay_ += dtTroposphere/vLight;
1027 
1028 #ifdef DBG_MODE_
1029  if (logger->isEligible(SgLogger::DBG, SgLogger::DELAY))
1030  {
1031  str.sprintf("Tropospheric contrib at %-8s (ps): %18.2f",
1032  qPrintable(stn_2_->getKey()), dtAtm2/vLight*1.0e12);
1033  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1034  str.sprintf("Tropospheric contrib at %-8s (ps): %18.2f",
1035  qPrintable(stn_1_->getKey()), -dtAtm1/vLight*1.0e12);
1036  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1037  str.sprintf("Added contribution: wet and dry trop. (ps): %18.2f",
1038  dtTroposphere/vLight*1.0e12);
1039  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1040  };
1041 #endif
1042  };
1043 */
1044  //
1045  //
1046  if (!cfg->getHave2ApplyAxisOffsetContrib())
1047  {
1048  theoDelay_ -=
1050 #ifdef DBG_MODE_
1051  str.sprintf("Removed contribution: axis offsets (ps): %18.2f", -dContrib*1.0e12);
1052  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1053 #endif
1054  theoRate_ -=
1056  };
1057  if (cfg->getHave2ApplyUnPhaseCalContrib())
1058  {
1060 #ifdef DBG_MODE_
1061  str.sprintf("Added contribution: unphasecal (ps): %18.2f", dContrib*1.0e12);
1062  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1063 #endif
1064  };
1065  //
1066  //
1067  if (cfg->getIsTesting())
1068  {
1070  };
1071  //
1072  //
1073  // cable calibration corrections:
1074  theoDelay_ -=
1077  //
1078  }; // end of station dependent contribs
1079  //
1080  // session-wide clock breaks:
1081  theoDelay_ +=
1082  (stn_2_->clockBreaks().value(*this) - stn_1_->clockBreaks().value(*this))*1.0e-09;
1083  theoRate_ +=
1084  (stn_2_->clockBreaks().rate (*this) - stn_1_->clockBreaks().rate (*this))*1.0e-09;
1085  //
1086 #ifdef DBG_MODE_
1088  {
1089  str.sprintf("Cable calibraiton at %-8s (ps): %18.2f",
1090  qPrintable(stn_2_->getKey()),
1092  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1093  //
1094  str.sprintf("Cable calibraiton at %-8s (ps): %18.2f",
1095  qPrintable(stn_1_->getKey()),
1097  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1098  //
1099  str.sprintf("Added contribution: cable calibration (ps): %18.2f", dContrib*1.0e12);
1100  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1101  //
1102  str.sprintf("Theoretical delay, final (ps): %18.2f", theoDelay_*1.0e12);
1103  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str, true);
1104  };
1105 #endif
1106  //
1107  //
1108  //
1109  // User corrections:
1110  if (session_->getUserCorrectionsUse().size())
1111  {
1112  for (int i=0; i<session_->getUserCorrectionsUse().size(); i++)
1113  if (session_->getUserCorrectionsUse().at(i))
1114  theoDelay_ += userCorrections_.at(i);
1115  };
1116  //
1117  //
1118  if (activeObs_)
1119  {
1120  activeObs_->setTauS(0.0);
1121  if (cfg->getHave2ApplySourceSsm() &&
1123  src_->sModel().size())
1124  {
1125  double tauS;
1126  tauS = src_->tauS(activeObs_->getReferenceFrequency()*1.0e6,
1127  activeObs_->getUvFrPerAsec(0)*360.0*3600.0/2.0/M_PI,
1128  activeObs_->getUvFrPerAsec(1)*360.0*3600.0/2.0/M_PI);
1129  theoDelay_ += tauS;
1130  activeObs_->setTauS(tauS);
1131  };
1132  };
1133 };
1134 
1135 
1136 
1137 //
1139 {
1140  storage4O_C .setElement(0, 0.0);
1141  storage4Sigmas.setElement(0, 0.0);
1142  if (!activeObs_)
1143  return;
1144 
1145  QString str;
1146  const SgTaskConfig *cfg=mgr->getTask()->config();
1147  double bandClockBreakShift(0.0), bandClockBreakRate(0.0);
1148  double o_c(0.0), stdDev(0.0);
1149 
1151 
1152  // evaluate and submit the partials:
1153  fillPartials(mgr);
1154 
1155  // add "processed" flag to the obs and aux obses:
1159  //
1160  bandClockBreakShift = (activeObs_->stn_2()->clockBreaks().value(*this) -
1161  activeObs_->stn_1()->clockBreaks().value(*this) )*1.0e-09;
1162  bandClockBreakRate = (activeObs_->stn_2()->clockBreaks().rate (*this) -
1163  activeObs_->stn_1()->clockBreaks().rate (*this) )*1.0e-09;
1164  //
1165  //
1166  if (cfg->getDataType() == SgTaskConfig::VDT_DELAY)
1167  {
1168  switch (cfg->getUseDelayType())
1169  {
1170  case SgTaskConfig::VD_NONE:
1171  default:
1172  break;
1177  - theoDelay_;
1178  break;
1182  + activeObs_->grDelay().subAmbig()
1184  - (theoDelay_ + bandClockBreakShift);
1187  break;
1192  - (theoDelay_ + bandClockBreakShift);
1195  break;
1196  };
1197  stdDev = activeObs_->activeDelay()->sigma2Apply();
1199  stdDev *= 1.0e4;
1200  }
1201  else if (cfg->getDataType() == SgTaskConfig::VDT_RATE)
1202  {
1206  - (theoRate_ + bandClockBreakRate);
1207 
1208  stdDev = activeObs_->phDRate().sigma2Apply();
1209 // o_c *= DAY2SEC;
1210 // stdDev *= DAY2SEC;
1211  }
1212  else
1214  "::prepare4Analysis(): uknown data type");
1215 
1216  storage4O_C .setElement(0, o_c);
1217  storage4Sigmas.setElement(0, stdDev);
1218  //
1219  //
1220 #ifdef DBG_MODE_
1222  {
1223  str.sprintf("Ionospheric group delay (ps): %18.2f",
1224  activeObs_->grDelay().getIonoValue()*1.0e12);
1225  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1226 
1227  str.sprintf("Ambiguity correction (ps): %18.2f",
1228  activeObs_->grDelay().ambiguity()*1.0e12);
1229  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1230  str.sprintf("Observed group delay (ps): %18.2f",
1231  activeObs_->grDelay().getValue()*1.0e12);
1232  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1233 
1234  str.sprintf("Resulted O-C (ps): %18.2f",
1235  storage4O_C.getElement(0)*1.0e12);
1236 
1237  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1239 
1240  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": __ sigmas __");
1241  str.sprintf("Group delay sigma (ps): %8.4f", activeObs_->grDelay().getSigma()*1.0e12);
1242  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1243  str.sprintf("Iono. sigma: (ps) %8.4f", activeObs_->grDelay().getIonoSigma()*1.0e12);
1244  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1245  str.sprintf("Reweighting sigma (ps): %8.4f", activeObs_->activeDelay()->getSigma2add()*1.0e12);
1246  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1247  str.sprintf("Resulted sigma (ps): %8.4f", activeObs_->activeDelay()->sigma2Apply()*1.0e12);
1248  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1249  };
1250 #endif
1251 };
1252 
1253 
1254 
1255 //
1257 {
1258  SgTaskConfig *cfg=mgr->getTask()->config();
1259  const SgParametersDescriptor *parameters=mgr->getTask()->parameters();
1260  SgEstimator *estimator=mgr->estimator();
1261  QString str("");
1262 
1264  // delay:
1265  // zerofy all partials:
1266  estimator->clearPartials();
1267  // evaluate and submit the partials:
1269  fillPartials(mgr);
1270  sumAX_4delay_ = estimator->calcAX(getMJD(), true);
1272 // reweightAuxSum4delay_ = estimator->calc_aT_P_a_opt(getMJD());
1273  //
1274  //
1275  // rate:
1276  // zerofy all partials:
1277  estimator->clearPartials();
1278  // evaluate and submit the partials:
1280  fillPartials(mgr);
1281  sumAX_4rate_ = estimator->calcAX(getMJD(), true);
1283 // reweightAuxSum4rate_ = estimator->calc_aT_P_a_opt(getMJD());
1284  //
1285  //
1286  //
1287  // residuals themselves:
1288  double sbDelayResidual, grDelayResidual, phDelayResidual, phDRateResidual;
1289  QMap<QString, SgVlbiObservable*>::iterator
1290  it;
1291  for (it=observableByKey_.begin(); it!=observableByKey_.end(); ++it)
1292  {
1293  SgVlbiObservable *o=it.value();
1294  SgVlbiBand *band=session_->bandByKey().value(o->getBandKey());
1295  double bandClockBreakShift(0.0), bandClockBreakRate(0.0);
1296  bandClockBreakShift = (o->stn_2()->clockBreaks().value(*this) -
1297  o->stn_1()->clockBreaks().value(*this) )*1.0e-09;
1298  bandClockBreakRate = (o->stn_2()->clockBreaks().rate (*this) -
1299  o->stn_1()->clockBreaks().rate (*this) )*1.0e-09;
1300  //
1301  // sb delay:
1302  sbDelayResidual = (o->sbDelay().getValue()
1304  - sumAX_4delay_;
1305  // group delay:
1306  grDelayResidual = (o->grDelay().getValue() + o->grDelay().ambiguity() + o->grDelay().subAmbig()
1307  - (theoDelay_ + bandClockBreakShift) + extAprioriCorrections4delay_)
1308  - sumAX_4delay_;
1310  grDelayResidual -= o->grDelay().getIonoValue();
1311  // phase delay:
1312  phDelayResidual = (o->phDelay().getValue() + o->phDelay().ambiguity()
1313  - (theoDelay_ + bandClockBreakShift) + extAprioriCorrections4delay_)
1314  - sumAX_4delay_;
1316  phDelayResidual -= o->phDelay().getIonoValue();
1317  // rate:
1318  phDRateResidual = (o->phDRate().getValue() +
1319  - (theoRate_ + bandClockBreakRate) + extAprioriCorrections4rate_)
1320  - o->phDRate().getIonoValue()
1321  - sumAX_4rate_;
1322  //
1323  // store them:
1324  o->sbDelay().setResidual(sbDelayResidual);
1325  o->grDelay().setResidual(grDelayResidual);
1326  o->phDelay().setResidual(phDelayResidual);
1327  o->phDRate().setResidual(phDRateResidual);
1328  if (o->isUsable())
1329  {
1330  band->incNumUsable(DT_DELAY);
1331  o->stn_1()->incNumUsable(DT_DELAY);
1332  o->stn_2()->incNumUsable(DT_DELAY);
1333  o->src ()->incNumUsable(DT_DELAY);
1335  band->incNumUsable(DT_RATE);
1336  o->stn_1()->incNumUsable(DT_RATE);
1337  o->stn_2()->incNumUsable(DT_RATE);
1338  o->src ()->incNumUsable(DT_RATE);
1339  o->baseline()->incNumUsable(DT_RATE);
1340  };
1341 #ifdef DBG_MODE_
1343  {
1344  str.sprintf("GrD: Observation: %18.2f", o->grDelay().getValue()*1.0e12);
1345  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + "::evaluateResiduals(): " +
1346  it.key() + "-Band " + str);
1347  str.sprintf("GrD: Ambiguities: %18.2f", o->grDelay().ambiguity()*1.0e12);
1348  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + "::evaluateResiduals(): " +
1349  it.key() + "-Band " + str);
1350  str.sprintf("GrD: Ionosphere : %18.2f", o->grDelay().getIonoValue()*1.0e12);
1351  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + "::evaluateResiduals(): " +
1352  it.key() + "-Band " + str);
1353  str.sprintf("GrD: Theoretical: %18.2f", theoDelay_*1.0e12);
1354  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + "::evaluateResiduals(): " +
1355  it.key() + "-Band " + str);
1356  str.sprintf("GrD: BandClckBrk: %18.2f", bandClockBreakShift*1.0e12);
1357  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + "::evaluateResiduals(): " +
1358  it.key() + "-Band " + str);
1359  str.sprintf("GrD: ExtAPriori : %18.2f", extAprioriCorrections4delay_*1.0e12);
1360  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + "::evaluateResiduals(): " +
1361  it.key() + "-Band " + str);
1362  str.sprintf("GrD: A*x : %18.2f", sumAX_4delay_*1.0e12);
1363  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + "::evaluateResiduals(): " +
1364  it.key() + "-Band " + str);
1365  str.sprintf("Group Delay O-C (ps): %s %s %05d %18.2f %18.2f %18.2f",
1367  (grDelayResidual + sumAX_4delay_)*1.0e12, grDelayResidual*1.0e12,
1368  o->grDelay().sigma2Apply()*1.0e12);
1369  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + "::evaluateResiduals(): " +
1370  it.key() + "-Band " + str);
1371  };
1372 #endif
1373  //
1374  // update statistics:
1375  double appliedSigma, residual, weight;
1376  if (isAttr(Attr_PROCESSED))
1377  {
1378  if (o->activeDelay())
1379  {
1380  appliedSigma = o->activeDelay()->sigma2Apply();
1381  residual = o->activeDelay()->getResidual();
1382  weight = appliedSigma>0.0 ? 1.0/appliedSigma/appliedSigma : 1.0;
1383  o->stn_1() -> addWrms(DT_DELAY, *this, residual, weight, reweightAuxSum4delay_);
1384  o->stn_2() -> addWrms(DT_DELAY, *this, residual, weight, reweightAuxSum4delay_);
1385  o->src () -> addWrms(DT_DELAY, *this, residual, weight, reweightAuxSum4delay_);
1386  o->baseline()-> addWrms(DT_DELAY, *this, residual, weight, reweightAuxSum4delay_);
1387  band -> addWrms(DT_DELAY, *this, residual, weight, reweightAuxSum4delay_);
1388  };
1389  appliedSigma = o->phDRate().sigma2Apply();
1390  residual = o->phDRate().getResidual();
1391  weight = appliedSigma>0.0 ? 1.0/appliedSigma/appliedSigma : 1.0;
1392  o->stn_1() -> addWrms(DT_RATE, *this, residual, weight, reweightAuxSum4rate_);
1393  o->stn_2() -> addWrms(DT_RATE, *this, residual, weight, reweightAuxSum4rate_);
1394  o->src () -> addWrms(DT_RATE, *this, residual, weight, reweightAuxSum4rate_);
1395  o->baseline()-> addWrms(DT_RATE, *this, residual, weight, reweightAuxSum4rate_);
1396  band -> addWrms(DT_RATE, *this, residual, weight, reweightAuxSum4rate_);
1397  };
1398  };
1399  //
1400  // update station dependent time-varying estimates:
1401  double scale_c, scale_z, scale_g;
1402  scale_c = parameters->getClock0().getScale();
1403  scale_z = parameters->getZenith().getScale();
1404  scale_g = parameters->getAtmGrad().getScale();
1405  // the first station:
1407  {
1409  {
1412  }
1413  else
1414  {
1415  auxObs_1_->setEstClocks(0.0);
1417  };
1418  //
1421  //
1426  };
1427  // the second station:
1429  {
1431  {
1434  }
1435  else
1436  {
1437  auxObs_2_->setEstClocks(0.0);
1439  };
1440  //
1443  //
1448  };
1449 };
1450 
1451 
1452 
1453 //
1455 {
1456  return storage4O_C;
1457 };
1458 
1459 
1460 
1461 //
1463 {
1464  return storage4Sigmas;
1465 };
1466 
1467 
1468 
1469 //
1471 {
1472  if (mgr->getTask()->config()->getDataType() == SgTaskConfig::VDT_DELAY)
1473  fillPartials4delay(mgr);
1474  else if (mgr->getTask()->config()->getDataType() == SgTaskConfig::VDT_RATE)
1475  fillPartials4rate(mgr);
1476  else
1478  "::fillPartials(): unexpected data type");
1479 };
1480 
1481 
1482 
1483 //
1485 {
1486  SgTaskConfig *cfg=mgr->getTask()->config();
1487  QString str;
1488  double dt1 = (*this - session_->tRefer());
1489  double dt2 = (dt1 + getCalcConsensusDelay()/DAY2SEC);
1490  parameters_.clear();
1491 
1492  // partials for clocks:
1493  double d1=1.0;
1494  double d2=1.0;
1495  int nCl;
1496  nCl = mgr->getTask()->parameters()->getClock0Mode()==SgParameterCfg::PM_STC ? 1 :
1498 
1499  for (int i=0; i<nCl; i++)
1500  {
1501  // station #1:
1503  {
1504  stn_1_->pClocks(i)->setD(-d1);
1505  parameters_.append(stn_1_->pClocks(i));
1506  };
1507  // station #2:
1509  {
1510  stn_2_->pClocks(i)->setD(d2);
1511  parameters_.append(stn_2_->pClocks(i));
1512  };
1513  d1 *= dt1;
1514  d2 *= dt2;
1515  };
1516  // clock breaks:
1517  if (stn_1_->clockBreaks().size())
1518  stn_1_->clockBreaks().propagatePartials(parameters_, *this, dt1, -1.0);
1519  if (stn_2_->clockBreaks().size())
1520  stn_2_->clockBreaks().propagatePartials(parameters_, *this, dt2, 1.0);
1521 
1522 
1523 #ifdef DBG_MODE_
1525  {
1526  str.sprintf("Partials: %-30s: %32.15f",
1527  qPrintable(stn_1_->pClocks(0)->getName()), stn_1_->pClocks(0)->getD());
1529  "::fillPartials4delay(): " + str);
1530 
1531  str.sprintf("Partials: %-30s: %32.15f",
1532  qPrintable(stn_1_->pClocks(1)->getName()), stn_1_->pClocks(1)->getD());
1534  "::fillPartials4delay(): " + str);
1535 
1536  str.sprintf("Partials: %-30s: %32.15f",
1537  qPrintable(stn_1_->pClocks(2)->getName()), stn_1_->pClocks(2)->getD());
1539  "::fillPartials4delay(): " + str);
1540 
1541  str.sprintf("Partials: %-30s: %32.15f",
1542  qPrintable(stn_2_->pClocks(0)->getName()), stn_2_->pClocks(0)->getD());
1544  "::fillPartials4delay(): " + str);
1545 
1546  str.sprintf("Partials: %-30s: %32.15f",
1547  qPrintable(stn_2_->pClocks(1)->getName()), stn_2_->pClocks(1)->getD());
1549  "::fillPartials4delay(): " + str);
1550 
1551  str.sprintf("Partials: %-30s: %32.15f",
1552  qPrintable(stn_2_->pClocks(2)->getName()), stn_2_->pClocks(2)->getD());
1554  "::fillPartials4delay(): " + str);
1555  };
1556 #endif
1557 
1558  // refraction:
1559  if (auxObs_1_ && auxObs_2_)
1560  {
1561  double dWetMf_1, dWetMf_2; //, dGrdMf_1, dGrdMf_2;
1562 
1563 // if (!cfg->getHave2ApplyNdryContrib() || !cfg->getHave2ApplyNwetContrib()) // need flybys:
1564  {
1567  dWetMf_1 = mgr->refraction()->dWetMF();
1568 // dGrdMf_1 = mgr->refraction()->dGrdMF();
1569 
1570 
1573  dWetMf_2 = mgr->refraction()->dWetMF();
1574 // dGrdMf_2 = mgr->refraction()->dGrdMF();
1575  };
1576  //
1577  //
1578  // hydrostatic part: partials to the gradients:
1579  if (session_->hasGradPartials()) // from contributions:
1580  {
1582  {
1585  parameters_.append(stn_1_->pAtmGradN());
1586  parameters_.append(stn_1_->pAtmGradE());
1587  };
1589  {
1592  parameters_.append(stn_2_->pAtmGradN());
1593  parameters_.append(stn_2_->pAtmGradE());
1594  };
1595  };
1596 /*
1597  else // from "flyby":
1598  {
1599  if (stn_1_->pAtmGradN()->isAttr(SgPartial::Attr_IS_IN_RUN))
1600  {
1601  stn_1_->pAtmGradN()->setD(-cos(auxObs_1_->getAzimuthAngle())*dGrdMf_1/vLight);
1602  stn_1_->pAtmGradE()->setD(-sin(auxObs_1_->getAzimuthAngle())*dGrdMf_1/vLight);
1603  parameters_.append(stn_1_->pAtmGradN());
1604  parameters_.append(stn_1_->pAtmGradE());
1605  };
1606  if (stn_2_->pAtmGradN()->isAttr(SgPartial::Attr_IS_IN_RUN))
1607  {
1608  stn_2_->pAtmGradN()->setD( cos(auxObs_2_->getAzimuthAngle())*dGrdMf_2/vLight);
1609  stn_2_->pAtmGradE()->setD( sin(auxObs_2_->getAzimuthAngle())*dGrdMf_2/vLight);
1610  parameters_.append(stn_2_->pAtmGradN());
1611  parameters_.append(stn_2_->pAtmGradE());
1612  };
1613  };
1614 */
1615  //
1616  //
1617  // wet part: partials to the wet zenith delays:
1618  if (cfg->getHave2ApplyNwetContrib()) // from contributions:
1619  {
1621  {
1623  parameters_.append(stn_1_->pZenithDelay());
1624  };
1626  {
1628  parameters_.append(stn_2_->pZenithDelay());
1629  };
1632  }
1633  else // from "flyby":
1634  {
1636  {
1637  stn_1_->pZenithDelay()->setD(-dWetMf_1/vLight);
1638  parameters_.append(stn_1_->pZenithDelay());
1639  };
1641  {
1642  stn_2_->pZenithDelay()->setD( dWetMf_2/vLight);
1643  parameters_.append(stn_2_->pZenithDelay());
1644  };
1645  auxObs_1_->setPartDelayW(dWetMf_1);
1646  auxObs_2_->setPartDelayW(dWetMf_2);
1647  };
1648  };
1649 
1650 #ifdef DBG_MODE_
1652  {
1653  str.sprintf("Partials: %-30s: %32.15f or %32.15f",
1654  qPrintable(stn_1_->pZenithDelay()->getName()),
1655  stn_1_->pZenithDelay()->getD(),
1656  stn_1_->pZenithDelay()->getD()*vLight);
1658  "::fillPartials4delay(): " + str);
1659 
1660  str.sprintf("Partials: %-30s: %32.15f or %32.15f",
1661  qPrintable(stn_2_->pZenithDelay()->getName()),
1662  stn_2_->pZenithDelay()->getD(),
1663  stn_2_->pZenithDelay()->getD()*vLight);
1665  "::fillPartials4delay(): " + str);
1666  };
1667 #endif
1668 
1669  // Station #1:
1671  {
1672  stn_1_->pRx()->setD(getDdel_dR_1().at(X_AXIS));
1673  stn_1_->pRy()->setD(getDdel_dR_1().at(Y_AXIS));
1674  stn_1_->pRz()->setD(getDdel_dR_1().at(Z_AXIS));
1675  parameters_.append(stn_1_->pRx());
1676  parameters_.append(stn_1_->pRy());
1677  parameters_.append(stn_1_->pRz());
1678  };
1679 
1680  // Station #2:
1682  {
1683  stn_2_->pRx()->setD(getDdel_dR_2().at(X_AXIS));
1684  stn_2_->pRy()->setD(getDdel_dR_2().at(Y_AXIS));
1685  stn_2_->pRz()->setD(getDdel_dR_2().at(Z_AXIS));
1686  parameters_.append(stn_2_->pRx());
1687  parameters_.append(stn_2_->pRy());
1688  parameters_.append(stn_2_->pRz());
1689  };
1690 
1691  // Axis offsets:
1693  {
1695  parameters_.append(stn_1_->pAxisOffset());
1696  };
1698  {
1700  parameters_.append(stn_2_->pAxisOffset());
1701  };
1702  // Source:
1704  {
1705  src_->pRA()->setD(getDdel_dRA());
1706  src_->pDN()->setD(getDdel_dDN());
1707  parameters_.append(src_->pRA());
1708  parameters_.append(src_->pDN());
1709  };
1710 
1711  //
1712  //
1713  double scl=360.0*3600.0/2.0/M_PI;
1714  if (activeObs())
1715  {
1716 /*
1717  if (src_->getSmtType() == SgVlbiSourceInfo::SMT_TWO_POINTS)
1718  {
1719  // two-point SS-model (testing):
1720  if (src_->pK() && src_->pK()->isAttr(SgPartial::Attr_IS_IN_RUN))
1721  {
1722  src_->pK()->setD(src_->dTauS_dK(activeObs()->getReferenceFrequency()*1.0e6,
1723  activeObs()->getUvFrPerAsec(0)*scl, activeObs()->getUvFrPerAsec(1)*scl));
1724  parameters_.append(src_->pK());
1725  };
1726  if (src_->pB() && src_->pB()->isAttr(SgPartial::Attr_IS_IN_RUN))
1727  {
1728  src_->pB()->setD(src_->dTauS_dB(activeObs()->getReferenceFrequency()*1.0e6,
1729  activeObs()->getUvFrPerAsec(0)*scl, activeObs()->getUvFrPerAsec(1)*scl));
1730  parameters_.append(src_->pB());
1731  };
1732  if (src_->pX() && src_->pX()->isAttr(SgPartial::Attr_IS_IN_RUN))
1733  {
1734  src_->pX()->setD(src_->dTauS_dX(activeObs()->getReferenceFrequency()*1.0e6,
1735  activeObs()->getUvFrPerAsec(0)*scl, activeObs()->getUvFrPerAsec(1)*scl));
1736  parameters_.append(src_->pX());
1737  };
1738  if (src_->pY() && src_->pY()->isAttr(SgPartial::Attr_IS_IN_RUN))
1739  {
1740  src_->pY()->setD(src_->dTauS_dY(activeObs()->getReferenceFrequency()*1.0e6,
1741  activeObs()->getUvFrPerAsec(0)*scl, activeObs()->getUvFrPerAsec(1)*scl));
1742  parameters_.append(src_->pY());
1743  };
1744 //--
1745  if (src_->pA0() && src_->pA0()->isAttr(SgPartial::Attr_IS_IN_RUN))
1746  {
1747  src_->pA0()->setD(src_->dTauS_dA0(activeObs()->getReferenceFrequency()*1.0e6,
1748  activeObs()->getUvFrPerAsec(0)*scl, activeObs()->getUvFrPerAsec(1)*scl));
1749  parameters_.append(src_->pA0());
1750  };
1751  if (src_->pB0() && src_->pB0()->isAttr(SgPartial::Attr_IS_IN_RUN))
1752  {
1753  src_->pB0()->setD(src_->dTauS_dB0(activeObs()->getReferenceFrequency()*1.0e6,
1754  activeObs()->getUvFrPerAsec(0)*scl, activeObs()->getUvFrPerAsec(1)*scl));
1755  parameters_.append(src_->pB0());
1756  };
1757  if (src_->pTheta0() && src_->pTheta0()->isAttr(SgPartial::Attr_IS_IN_RUN))
1758  {
1759  src_->pTheta0()->setD(src_->dTauS_dTheta0(activeObs()->getReferenceFrequency()*1.0e6,
1760  activeObs()->getUvFrPerAsec(0)*scl, activeObs()->getUvFrPerAsec(1)*scl));
1761  parameters_.append(src_->pTheta0());
1762  };
1763 
1764  if (src_->pA1() && src_->pA1()->isAttr(SgPartial::Attr_IS_IN_RUN))
1765  {
1766  src_->pA1()->setD(src_->dTauS_dA1(activeObs()->getReferenceFrequency()*1.0e6,
1767  activeObs()->getUvFrPerAsec(0)*scl, activeObs()->getUvFrPerAsec(1)*scl));
1768  parameters_.append(src_->pA1());
1769  };
1770  if (src_->pB1() && src_->pB1()->isAttr(SgPartial::Attr_IS_IN_RUN))
1771  {
1772  src_->pB1()->setD(src_->dTauS_dB1(activeObs()->getReferenceFrequency()*1.0e6,
1773  activeObs()->getUvFrPerAsec(0)*scl, activeObs()->getUvFrPerAsec(1)*scl));
1774  parameters_.append(src_->pB1());
1775  };
1776  if (src_->pTheta1() && src_->pTheta1()->isAttr(SgPartial::Attr_IS_IN_RUN))
1777  {
1778  src_->pTheta1()->setD(src_->dTauS_dTheta1(activeObs()->getReferenceFrequency()*1.0e6,
1779  activeObs()->getUvFrPerAsec(0)*scl, activeObs()->getUvFrPerAsec(1)*scl));
1780  parameters_.append(src_->pTheta1());
1781  };
1782 //--
1783 
1784  }
1785  else if (src_->getSmtType() == SgVlbiSourceInfo::SMT_MULTIPLE_POINTS)
1786 */
1787  {
1788  // multipoint SS-model:
1789  if (cfg->getHave2ApplySourceSsm() &&
1790  src_->getIsSsModelEstimating() && src_->sModel().size())
1791  {
1793  activeObs()->getReferenceFrequency()*1.0e6,
1794  activeObs()->getUvFrPerAsec(0)*scl,
1795  activeObs()->getUvFrPerAsec(1)*scl);
1796  };
1797  };
1798  };
1799  //
1800 
1801  // Baseline:
1803  {
1804  baseline_->pClock()->setD(1.0);
1805  parameters_.append(baseline_->pClock());
1806  };
1808  {
1809  baseline_->pBx()->setD(getDdel_dR_2().at(X_AXIS));
1810  baseline_->pBy()->setD(getDdel_dR_2().at(Y_AXIS));
1811  baseline_->pBz()->setD(getDdel_dR_2().at(Z_AXIS));
1812  parameters_.append(baseline_->pBx());
1813  parameters_.append(baseline_->pBy());
1814  parameters_.append(baseline_->pBz());
1815  };
1816  // EOP:
1817  // UT1:
1819  {
1820  session_->pUT1()->setD(getDdel_dUT1());
1821  parameters_.append(session_->pUT1());
1822  };
1824  {
1825  session_->pUT1Rate()->setD(getDdel_dUT1()*dt1);
1826  parameters_.append(session_->pUT1Rate());
1827  };
1828  // P_x & P_y:
1830  {
1833  parameters_.append(session_->pPolusX());
1834  parameters_.append(session_->pPolusY());
1835  };
1836  // rates of P_x & P_y:
1838  {
1839  session_->pPolusXRate()->setD(getDdel_dPx()*dt1);
1840  session_->pPolusYRate()->setD(getDdel_dPy()*dt1);
1841  parameters_.append(session_->pPolusXRate());
1842  parameters_.append(session_->pPolusYRate());
1843  };
1844  // CIP_X & CIP_Y:
1846  {
1849  parameters_.append(session_->pNutX());
1850  parameters_.append(session_->pNutY());
1851  };
1852  // rates of CIP_X & CIP_Y:
1854  {
1855  session_->pNutXRate()->setD(getDdel_dCipX()*dt1);
1856  session_->pNutYRate()->setD(getDdel_dCipY()*dt1);
1857  parameters_.append(session_->pNutXRate());
1858  parameters_.append(session_->pNutYRate());
1859  };
1860 
1861  // notify PWLs:
1862  for (int i=0; i<parameters_.size(); i++)
1863  parameters_.at(i)->setDataDomain(SgPartial::DD_OFFSET);
1864 };
1865 
1866 
1867 
1868 //
1870 {
1871  QString str;
1872  double dt1=(*this - session_->tRefer());
1873  double dt2=(dt1 + getCalcConsensusDelay()/DAY2SEC);
1874  SgTaskConfig *cfg=mgr->getTask()->config();
1875  parameters_.clear();
1876 
1877 
1878  // partials for clocks:
1879  int nCl;
1880  nCl = mgr->getTask()->parameters()->getClock0Mode()==SgParameterCfg::PM_STC ? 1 :
1882 
1883  // special case:
1886  {
1888  {
1889  stn_1_->pClocks(0)->setD(-1.0/DAY2SEC);
1890  parameters_.append(stn_1_->pClocks(0));
1891  };
1892  // station #2:
1894  {
1895  stn_2_->pClocks(0)->setD( 1.0/DAY2SEC);
1896  parameters_.append(stn_2_->pClocks(0));
1897  };
1898  };
1899  //
1900  //
1901  double d1, d2;
1902  d1 = d2 = 1.0;
1903  for (int i=1; i<nCl; i++)
1904  {
1905  // station #1:
1907  {
1908  stn_1_->pClocks(i)->setD(-i*d1/DAY2SEC);
1909  parameters_.append(stn_1_->pClocks(i));
1910  };
1911  // station #2:
1913  {
1914  stn_2_->pClocks(i)->setD( i*d2/DAY2SEC);
1915  parameters_.append(stn_2_->pClocks(i));
1916  };
1917  d1 *= dt1 /* /DAY2SEC */;
1918  d2 *= dt2 /* /DAY2SEC */;
1919  };
1920  // clock breaks:
1921  if (stn_1_->clockBreaks().size())
1923  if (stn_2_->clockBreaks().size())
1925  //
1926  //
1927  // troposphere:
1928  //
1929  if (auxObs_1_ && auxObs_2_)
1930  {
1931 // double dDryZd_1, dDryZd_2, dWetZd_1, dWetZd_2;
1932 // double dDryMf_1, dDryMf_2, dWetMf_1, dWetMf_2;
1933 // double rDryMf_1, rDryMf_2, rWetMf_1, rWetMf_2;
1934  double rWetMf_1, rWetMf_2;
1935 // if (!cfg->getHave2ApplyNdryContrib() || !cfg->getHave2ApplyNwetContrib())
1936  {
1939 // dDryZd_1 = mgr->refraction()->dDryZD();
1940 // dWetZd_1 = mgr->refraction()->dWetZD();
1941 // dDryMf_1 = mgr->refraction()->dDryMF();
1942 // dWetMf_1 = mgr->refraction()->dWetMF();
1943 // rDryMf_1 = mgr->refraction()->dryMappingFunction()->dM_dE();
1944  rWetMf_1 = mgr->refraction()->wetMappingFunction()->dM_dE();
1945 
1948 // dDryZd_2 = mgr->refraction()->dDryZD();
1949 // dWetZd_2 = mgr->refraction()->dWetZD();
1950 // dDryMf_2 = mgr->refraction()->dDryMF();
1951 // dWetMf_2 = mgr->refraction()->dWetMF();
1952 // rDryMf_2 = mgr->refraction()->dryMappingFunction()->dM_dE();
1953  rWetMf_2 = mgr->refraction()->wetMappingFunction()->dM_dE();
1954  };
1955  //
1956  //
1957  // hydrostatic part: partials to the gradients:
1958  if (session_->hasGradPartials()) // from contributions:
1959  {
1961  {
1964  parameters_.append(stn_1_->pAtmGradN());
1965  parameters_.append(stn_1_->pAtmGradE());
1966  };
1968  {
1971  parameters_.append(stn_2_->pAtmGradN());
1972  parameters_.append(stn_2_->pAtmGradE());
1973  };
1974  };
1975 /*
1976  else // from "flyby":
1977  {
1978  if (stn_1_->pAtmGradN()->isAttr(SgPartial::Attr_IS_IN_RUN))
1979  {
1980  stn_1_->pAtmGradN()->setD(-cos(auxObs_1_->getAzimuthAngle())*dGrdMf_1/vLight);
1981  stn_1_->pAtmGradE()->setD(-sin(auxObs_1_->getAzimuthAngle())*dGrdMf_1/vLight);
1982  parameters_.append(stn_1_->pAtmGradN());
1983  parameters_.append(stn_1_->pAtmGradE());
1984 std::cout << qPrintable(baseline_->getKey() + " @" + src_->getKey() + " " + toString(SgMJD::F_Simple))
1985  << ": FLYBY gradN_1=" << stn_1_->pAtmGradN()->getD()
1986  << " gradE_1=" << stn_1_->pAtmGradE()->getD()
1987  << "\n";
1988  };
1989  if (stn_2_->pAtmGradN()->isAttr(SgPartial::Attr_IS_IN_RUN))
1990  {
1991  stn_2_->pAtmGradN()->setD( cos(auxObs_2_->getAzimuthAngle())*dGrdMf_2/vLight);
1992  stn_2_->pAtmGradE()->setD( sin(auxObs_2_->getAzimuthAngle())*dGrdMf_2/vLight);
1993  parameters_.append(stn_2_->pAtmGradN());
1994  parameters_.append(stn_2_->pAtmGradE());
1995 std::cout << qPrintable(baseline_->getKey() + " @" + src_->getKey() + " " + toString(SgMJD::F_Simple))
1996  << ": FLYBY gradN_2=" << stn_2_->pAtmGradN()->getD()
1997  << " gradE_2=" << stn_2_->pAtmGradE()->getD()
1998  << "\n";
1999  };
2000  };
2001 */
2002  //
2003  //
2004  // wet part: partials to the wet zenith delays:
2005  if (cfg->getHave2ApplyNwetContrib()) // from contributions:
2006  {
2008  {
2010  parameters_.append(stn_1_->pZenithDelay());
2011  };
2013  {
2015  parameters_.append(stn_2_->pZenithDelay());
2016  };
2019  }
2020  else // from "flyby":
2021  {
2023  {
2025  parameters_.append(stn_1_->pZenithDelay());
2026  };
2028  {
2030  parameters_.append(stn_2_->pZenithDelay());
2031  };
2034  };
2035  };
2036 
2037  // Station #1:
2039  {
2040  stn_1_->pRx()->setD( getDrat_dR_1().at(X_AXIS));
2041  stn_1_->pRy()->setD( getDrat_dR_1().at(Y_AXIS));
2042  stn_1_->pRz()->setD( getDrat_dR_1().at(Z_AXIS));
2043  parameters_.append(stn_1_->pRx());
2044  parameters_.append(stn_1_->pRy());
2045  parameters_.append(stn_1_->pRz());
2046  };
2047 
2048  // Station #2:
2050  {
2051  stn_2_->pRx()->setD( getDrat_dR_2().at(X_AXIS));
2052  stn_2_->pRy()->setD( getDrat_dR_2().at(Y_AXIS));
2053  stn_2_->pRz()->setD( getDrat_dR_2().at(Z_AXIS));
2054  parameters_.append( stn_2_->pRx());
2055  parameters_.append( stn_2_->pRy());
2056  parameters_.append( stn_2_->pRz());
2057  };
2058 
2059  // Axis offsets:
2061  {
2063  parameters_.append(stn_1_->pAxisOffset());
2064  };
2066  {
2068  parameters_.append(stn_2_->pAxisOffset());
2069  };
2070  // Source:
2072  {
2073  src_->pRA()->setD(getDrat_dRA());
2074  src_->pDN()->setD(getDrat_dDN());
2075  parameters_.append(src_->pRA());
2076  parameters_.append(src_->pDN());
2077  };
2078 
2079  // Baseline:
2081  {
2082  baseline_->pBx()->setD(getDrat_dR_2().at(X_AXIS));
2083  baseline_->pBy()->setD(getDrat_dR_2().at(Y_AXIS));
2084  baseline_->pBz()->setD(getDrat_dR_2().at(Z_AXIS));
2085  parameters_.append(baseline_->pBx());
2086  parameters_.append(baseline_->pBy());
2087  parameters_.append(baseline_->pBz());
2088  };
2089  // EOP:
2090  // UT1:
2092  {
2093  session_->pUT1()->setD(getDrat_dUT1());
2094  parameters_.append(session_->pUT1());
2095  };
2097  {
2098  session_->pUT1Rate()->setD(getDrat_dUT1()*dt1);
2099  parameters_.append(session_->pUT1Rate());
2100  };
2101  // P_x & P_y:
2103  {
2106  parameters_.append(session_->pPolusX());
2107  parameters_.append(session_->pPolusY());
2108  };
2109  // rates of P_x & P_y:
2111  {
2112  session_->pPolusXRate()->setD(getDrat_dPx()*dt1);
2113  session_->pPolusYRate()->setD(getDrat_dPy()*dt1);
2114  parameters_.append(session_->pPolusXRate());
2115  parameters_.append(session_->pPolusYRate());
2116  };
2117  // CIP_X & CIP_Y:
2119  {
2122  parameters_.append(session_->pNutX());
2123  parameters_.append(session_->pNutY());
2124  };
2125  // rates of CIP_X & CIP_Y:
2127  {
2128  session_->pNutXRate()->setD(getDrat_dCipX()*dt1);
2129  session_->pNutYRate()->setD(getDrat_dCipY()*dt1);
2130  parameters_.append(session_->pNutXRate());
2131  parameters_.append(session_->pNutYRate());
2132  };
2133 
2134  // notify PWLs:
2135  for (int i=0; i<parameters_.size(); i++)
2136  parameters_.at(i)->setDataDomain(SgPartial::DD_RATE);
2137 };
2138 
2139 
2140 
2141 //
2143 {
2144  if (isDelete)
2146  else
2148  return true;
2149 };
2150 
2151 
2152 
2153 //
2155 {
2156  QString str;
2157  double dT=0.0;
2159 
2160  dD = dR = 0.0;
2161 
2163  dT = session_->tRefer() - t0;
2164  else
2165  dT = *this - t0;
2166 
2167  Sg3dVector dR1_ea(stn_1_->getR_ea() + stn_1_->getV_ea()*dT);
2168  Sg3dVector dR2_ea(stn_2_->getR_ea() + stn_2_->getV_ea()*dT);
2169  Sg3dVector dR1 = stn_1_->getR() - dR1_ea;
2170  Sg3dVector dR2 = stn_2_->getR() - dR2_ea;
2171 
2172  // the signs for the first station are already reverted:
2173  dD = getDdel_dR_1()*dR1 + getDdel_dR_2()*dR2;
2174  dR = getDrat_dR_1()*dR1 + getDrat_dR_2()*dR2;
2175 
2176 #ifdef DBG_MODE_2_
2178  {
2179  str.sprintf("Epoch : %s", qPrintable(toString()));
2180  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2181  str.sprintf("T0 : %s", qPrintable(t0.toString()));
2182  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2183  str.sprintf("difference: %14.8f (days)", dT);
2184  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2185 
2186  // stn #1
2187  str.sprintf("St_1, database positions: %13.4f %13.4f %13.4f",
2188  stn_1_->getR().at(X_AXIS),
2189  stn_1_->getR().at(Y_AXIS),
2190  stn_1_->getR().at(Z_AXIS));
2191  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2192  str.sprintf("St_1, e.a.file positions: %13.4f %13.4f %13.4f",
2193  stn_1_->getR_ea().at(X_AXIS),
2194  stn_1_->getR_ea().at(Y_AXIS),
2195  stn_1_->getR_ea().at(Z_AXIS));
2196  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2197  str.sprintf("St_1, e.a.file velocity : %13.10f %13.10f %13.10f (mm/yr)",
2198  stn_1_->getV_ea().at(X_AXIS)*1000.0*365.25,
2199  stn_1_->getV_ea().at(Y_AXIS)*1000.0*365.25,
2200  stn_1_->getV_ea().at(Z_AXIS)*1000.0*365.25);
2201  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2202  str.sprintf("St_1, e.a.file velocity : %13.10f %13.10f %13.10f (m/d)",
2203  stn_1_->getV_ea().at(X_AXIS),
2204  stn_1_->getV_ea().at(Y_AXIS),
2205  stn_1_->getV_ea().at(Z_AXIS));
2206  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2207  str.sprintf("St_1, e.a.position at t : %13.4f %13.4f %13.4f",
2208  dR1_ea.at(X_AXIS), dR1_ea.at(Y_AXIS), dR1_ea.at(Z_AXIS));
2209  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2210  str.sprintf("St_1, difference db-e.a : %10.7f %10.7f %10.7f",
2211  dR1.at(X_AXIS), dR1.at(Y_AXIS), dR1.at(Z_AXIS));
2212  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2213 
2214  // stn #2
2215  str.sprintf("St_2, database positions: %13.4f %13.4f %13.4f",
2216  stn_2_->getR().at(X_AXIS),
2217  stn_2_->getR().at(Y_AXIS),
2218  stn_2_->getR().at(Z_AXIS));
2219  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2220  str.sprintf("St_2, e.a.file positions: %13.4f %13.4f %13.4f",
2221  stn_2_->getR_ea().at(X_AXIS),
2222  stn_2_->getR_ea().at(Y_AXIS),
2223  stn_2_->getR_ea().at(Z_AXIS));
2224  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2225  str.sprintf("St_2, e.a.file velocity : %13.10f %13.10f %13.10f (mm/yr)",
2226  stn_2_->getV_ea().at(X_AXIS)*1000.0*365.25,
2227  stn_2_->getV_ea().at(Y_AXIS)*1000.0*365.25,
2228  stn_2_->getV_ea().at(Z_AXIS)*1000.0*365.25);
2229  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2230  str.sprintf("St_2, e.a.file velocity : %13.10f %13.10f %13.10f (m/d)",
2231  stn_2_->getV_ea().at(X_AXIS),
2232  stn_2_->getV_ea().at(Y_AXIS),
2233  stn_2_->getV_ea().at(Z_AXIS));
2234  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2235 
2236  str.sprintf("St_2, e.a.position at t : %13.4f %13.4f %13.4f",
2237  dR2_ea.at(X_AXIS), dR2_ea.at(Y_AXIS), dR2_ea.at(Z_AXIS));
2238  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2239 
2240  str.sprintf("St_2, difference db-e.a : %10.7f %10.7f %10.7f",
2241  dR2.at(X_AXIS), dR2.at(Y_AXIS), dR2.at(Z_AXIS));
2242  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2243 
2244  str.sprintf("Partials, dTau/dSt_1_i: %20.12g %20.12g %20.12g",
2245  getDdel_dR_1().at(X_AXIS),
2246  getDdel_dR_1().at(Y_AXIS),
2247  getDdel_dR_1().at(Z_AXIS));
2248  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2249 
2250  str.sprintf("Partials, dTau/dSt_2_i: %20.12g %20.12g %20.12g",
2251  getDdel_dR_2().at(X_AXIS),
2252  getDdel_dR_2().at(Y_AXIS),
2253  getDdel_dR_2().at(Z_AXIS));
2254  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2255 
2256  str.sprintf("Resulted correction (ps): %8.4f", dD*1.0e12);
2257  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2258  };
2259 #endif
2260 
2261  return;
2262 };
2263 
2264 
2265 
2266 //
2267 void SgVlbiObservation::evalExtApriori_SrcPos(double& dD, double& dR)
2268 {
2269  dD = getDdel_dRA()*(src_->getRA() - src_->getRA_ea()) +
2270  getDdel_dDN()*(src_->getDN() - src_->getDN_ea()) ;
2271  dR = getDrat_dRA()*(src_->getRA() - src_->getRA_ea()) +
2272  getDrat_dDN()*(src_->getDN() - src_->getDN_ea()) ;
2273 };
2274 
2275 
2276 
2277 //
2278 void SgVlbiObservation::evalExtApriori_AxsOfs(double& dD, double& dR)
2279 {
2280  dD = dR = 0.0;
2281  if (auxObs_1_ && auxObs_2_)
2282  {
2287  };
2288 };
2289 
2290 
2291 
2292 //
2294 {
2295  dD = dR = 0.0;
2296  if (session_->hasGradPartials())
2297  {
2302  dD /= -1.0*vLight;
2307  dD /= -1.0*vLight;
2308  }
2309  else
2310  {
2311 // c = (stn_2_->getGradientDelay() - stn_1_->getGradientDelay());
2312  };
2313  //
2315 // return -c/vLight;
2316 };
2317 
2318 
2319 
2320 //
2322 {
2323  for (QMap<QString, SgVlbiObservable*>::iterator it=observableByKey_.begin();
2324  it!=observableByKey_.end(); ++it)
2325  it.value()->zerofyIono();
2326 };
2327 
2328 
2329 
2330 //
2332 {
2333  if (observableByKey_.size()!=2)
2334  {
2335  if (!cfg && observableByKey_.size()>2)
2337  ": calcIonoCorrections(): cannot calculate, number of bands (" +
2338  QString("").setNum(observableByKey_.size()) + ") is not equal 2; " +
2339  baseline_->getKey() + " on " + src_->getKey());
2340  return;
2341  };
2342 
2343  bool isSimpleMode=(cfg?false:true);
2344  bool hasEffFreqs=true;
2345  double coeff4SB = 0.0;
2346  double coeff4GR = 0.0;
2347  double coeff4GRp= 0.0;
2348  double coeff4PH = 0.0;
2349  double coeff4RT = 0.0;
2350  double sbdQ=0.0, grdQ=0.0, phrQ=0.0;
2351  SgVlbiObservable *o[2];
2352  double corr4SB[2];
2353  double corr4GR[2];
2354  double dClB4GR[2];
2355  double corr4PH[2];
2356  double corr4RT[2];
2357  double sigma4SB[2];
2358  double sigma4GR[2];
2359  double sigma4PH[2];
2360  double sigma4RT[2];
2361  int idx;
2362  double sDif, xDif, rDif, pDif;
2363 
2364  for (int i=0; i<2; i++)
2365  {
2366  o[i] = NULL;
2367  corr4SB[i] = corr4GR[i] = corr4PH[i] = corr4RT[i] = sigma4SB[i] = sigma4GR[i] =
2368  sigma4PH[i] = sigma4RT[i] = 0.0;
2369  dClB4GR[i] = (stn_2_->clockBreaks().value(*this) - stn_1_->clockBreaks().value(*this))*1.0e-09;
2370 
2371  /*
2372  if (o[i]->grDelay().getEffFreq() <= 0.0)
2373  {
2374  hasEffFreqs = false;
2375  logger->write(SgLogger::WRN, SgLogger::IONO, className() +
2376  ": calcIonoCorrections(): cannot calculate, the group delay ionosphere effective frequency is "
2377  "zero on " + o[i]->strId());
2378  }
2379  if (o[i]->phDelay().getEffFreq() <= 0.0)
2380  {
2381  hasEffFreqs = false;
2382  logger->write(SgLogger::WRN, SgLogger::IONO, className() +
2383  ": calcIonoCorrections(): cannot calculate, the phase delay ionosphere effective frequency is "
2384  "zero on " + o[i]->strId());
2385  }
2386  if (o[i]->phDRate().getEffFreq() <= 0.0)
2387  {
2388  hasEffFreqs = false;
2389  logger->write(SgLogger::WRN, SgLogger::IONO, className() +
2390  ": calcIonoCorrections(): cannot calculate, the phase rate ionosphere effective frequency is "
2391  "zero on " + o[i]->strId());
2392  }
2393  */
2394  };
2395  //
2396 
2397 
2398  QMap<double, SgVlbiObservable*>
2399  observableByFrq;
2400  QMap<QString, SgVlbiObservable*>::iterator
2401  it_name;
2402  idx = 0;
2403  for (it_name=observableByKey_.begin(); it_name!=observableByKey_.end() && idx<2; ++it_name, idx++)
2404  {
2405  SgVlbiObservable* oo=it_name.value();
2406  if (observableByFrq.contains(oo->getReferenceFrequency()))
2407  {
2409  ": calcIonoCorrections(): cannot calculate, the reference frequency is the same for two bands "
2410  " on " + oo->strId());
2411  return;
2412  }
2413  else
2414  observableByFrq.insert(oo->getReferenceFrequency(), oo);
2415 
2416  if (oo->grDelay().getEffFreq() <= 0.0)
2417  {
2418  hasEffFreqs = false;
2420  ": calcIonoCorrections(): cannot calculate, the group delay ionosphere effective frequency is "
2421  "zero on " + oo->strId());
2422  }
2423  if (oo->phDelay().getEffFreq() <= 0.0)
2424  {
2425  hasEffFreqs = false;
2427  ": calcIonoCorrections(): cannot calculate, the phase delay ionosphere effective frequency is "
2428  "zero on " + oo->strId());
2429  }
2430  if (oo->phDRate().getEffFreq() <= 0.0)
2431  {
2432  hasEffFreqs = false;
2434  ": calcIonoCorrections(): cannot calculate, the phase rate ionosphere effective frequency is "
2435  "zero on " + oo->strId());
2436  }
2437  };
2438  if (!hasEffFreqs)
2439  return;
2440 
2441 
2442  idx = 0;
2443  QMap<double, SgVlbiObservable*>::iterator it_frq;
2444  for (it_frq=observableByFrq.begin(); it_frq!=observableByFrq.end() && idx<2; ++it_frq, idx++)
2445  {
2446  SgVlbiObservable *obs=it_frq.value();
2447  o[idx] = obs;
2448  SgVlbiStationInfo *stn1=obs->stn_1();
2449  SgVlbiStationInfo *stn2=obs->stn_2();
2450  if (stn1 && stn2)
2451  dClB4GR[idx] += (stn2->clockBreaks().value(*this) - stn1->clockBreaks().value(*this))*1.0e-09;
2452  };
2453 
2454  // 0 -> S
2455  // 1 -> X
2456  /*
2457  if (false)
2458  {
2459  coeff4GR = o[0]->getReferenceFrequency()*o[0]->getReferenceFrequency()/
2460  (o[1]->getReferenceFrequency()*o[1]->getReferenceFrequency() -
2461  o[0]->getReferenceFrequency()*o[0]->getReferenceFrequency());
2462  }
2463  else
2464  {
2465  coeff4GR = o[0]->grDelay().getEffFreq()*o[0]->grDelay().getEffFreq()/
2466  (o[1]->grDelay().getEffFreq()*o[1]->grDelay().getEffFreq() -
2467  o[0]->grDelay().getEffFreq()*o[0]->grDelay().getEffFreq());
2468  };
2469  */
2470 
2471  coeff4GR = o[0]->grDelay().getEffFreq()*o[0]->grDelay().getEffFreq()/
2472  (o[1]->grDelay().getEffFreq()*o[1]->grDelay().getEffFreq() -
2473  o[0]->grDelay().getEffFreq()*o[0]->grDelay().getEffFreq());
2474  coeff4PH = o[0]->phDelay().getEffFreq()*o[0]->phDelay().getEffFreq()/
2475  (o[1]->phDelay().getEffFreq()*o[1]->phDelay().getEffFreq() -
2476  o[0]->phDelay().getEffFreq()*o[0]->phDelay().getEffFreq());
2477  coeff4RT = o[0]->phDRate().getEffFreq()*o[0]->phDRate().getEffFreq()/
2478  (o[1]->phDRate().getEffFreq()*o[1]->phDRate().getEffFreq() -
2479  o[0]->phDRate().getEffFreq()*o[0]->phDRate().getEffFreq());
2480  coeff4GRp= (1.0 + coeff4GR)/coeff4GR;
2481  coeff4SB = coeff4GR;
2482 
2483  sDif = o[1]->sbDelay().getValue() - o[0]->sbDelay().getValue();
2484  xDif = o[1]->grDelay().getValue() + o[1]->grDelay().ambiguity() -
2485  (o[0]->grDelay().getValue() + o[0]->grDelay().ambiguity()) - (dClB4GR[1] - dClB4GR[0]);
2486  pDif = o[1]->phDelay().getValue() + o[1]->phDelay().ambiguity() -
2487  (o[0]->phDelay().getValue() + o[0]->phDelay().ambiguity());
2488  rDif = o[1]->phDRate().getValue() - o[0]->phDRate().getValue();
2489 
2490  o[1]->grDelay().setQ2(coeff4GR);
2491  o[0]->grDelay().setQ2(o[1]->grDelay().getEffFreq()*o[1]->grDelay().getEffFreq()/
2492  (o[0]->grDelay().getEffFreq()*o[0]->grDelay().getEffFreq() -
2493  o[1]->grDelay().getEffFreq()*o[1]->grDelay().getEffFreq()));
2494  o[1]->setSbdDiffBand(-sDif); // opposite band with respect to this one
2495  o[0]->setSbdDiffBand( sDif);
2496  o[1]->setGrdDiffBand(-xDif);
2497  o[0]->setGrdDiffBand( xDif);
2498  o[1]->setPhrDiffBand(-rDif);
2499  o[0]->setPhrDiffBand( rDif);
2500 
2501  sbdQ = o[1]->phDelay().getEffFreq()*o[1]->phDelay().getEffFreq()*
2502  o[0]->phDelay().getEffFreq()*o[0]->phDelay().getEffFreq()/
2503  (o[1]->phDelay().getEffFreq()*o[1]->phDelay().getEffFreq() -
2504  o[0]->phDelay().getEffFreq()*o[0]->phDelay().getEffFreq())*sDif;
2505 /*
2506  if (false)
2507  {
2508  grdQ = o[1]->getReferenceFrequency()*o[1]->getReferenceFrequency()*
2509  o[0]->getReferenceFrequency()*o[0]->getReferenceFrequency()/
2510  (o[1]->getReferenceFrequency()*o[1]->getReferenceFrequency() -
2511  o[0]->getReferenceFrequency()*o[0]->getReferenceFrequency())*xDif;
2512  }
2513  else
2514  {
2515  grdQ = o[1]->grDelay().getEffFreq()*o[1]->grDelay().getEffFreq()*
2516  o[0]->grDelay().getEffFreq()*o[0]->grDelay().getEffFreq()/
2517  (o[1]->grDelay().getEffFreq()*o[1]->grDelay().getEffFreq() -
2518  o[0]->grDelay().getEffFreq()*o[0]->grDelay().getEffFreq())*xDif;
2519  };
2520 */
2521  grdQ = o[1]->grDelay().getEffFreq()*o[1]->grDelay().getEffFreq()*
2522  o[0]->grDelay().getEffFreq()*o[0]->grDelay().getEffFreq()/
2523  (o[1]->grDelay().getEffFreq()*o[1]->grDelay().getEffFreq() -
2524  o[0]->grDelay().getEffFreq()*o[0]->grDelay().getEffFreq())*xDif;
2525  phrQ = o[1]->phDRate().getEffFreq()*o[1]->phDRate().getEffFreq()*
2526  o[0]->phDRate().getEffFreq()*o[0]->phDRate().getEffFreq()/
2527  (o[1]->phDRate().getEffFreq()*o[1]->phDRate().getEffFreq() -
2528  o[0]->phDRate().getEffFreq()*o[0]->phDRate().getEffFreq())*rDif;
2529 
2530  o[1]->setSbdQ(sbdQ);
2531  o[0]->setSbdQ(sbdQ);
2532  o[1]->setGrdQ(grdQ);
2533  o[0]->setGrdQ(grdQ);
2534  o[1]->setPhrQ(phrQ);
2535  o[0]->setPhrQ(phrQ);
2536 
2537  if (!isSimpleMode)
2538  {
2539  corr4GR[1] = - coeff4GR*xDif;
2540  corr4RT[1] = - coeff4RT*rDif;
2541  corr4PH[1] = - coeff4PH*pDif;
2542  corr4GR[0] = - (1.0 + coeff4GR)*xDif;
2543  corr4RT[0] = - (1.0 + coeff4RT)*rDif;
2544  corr4PH[0] = - (1.0 + coeff4PH)*pDif;
2545 
2546 // sigma4GR[1] = coeff4GR*sqrt(o[1]->getSigmaGroupDelay()*o[1]->getSigmaGroupDelay() +
2547 // o[0]->getSigmaGroupDelay()*o[0]->getSigmaGroupDelay());
2548 
2549  sigma4GR[1] = coeff4GR*sqrt(
2550  o[1]->grDelay().getSigma()*o[1]->grDelay().getSigma()*(coeff4GR + 2.0)/coeff4GR +
2551  o[0]->grDelay().getSigma()*o[0]->grDelay().getSigma());
2552 
2553 // sigma4GR[1] = coeff4GR*sqrt(
2554 // o[1]->getSigmaGroupDelay()*o[1]->getSigmaGroupDelay() +
2555 // o[0]->getSigmaGroupDelay()*o[0]->getSigmaGroupDelay() +
2556 // 2.0*o[1]->getSigmaGroupDelay()*o[1]->getSigmaGroupDelay()/coeff4GR
2557 // );
2558 
2559  sigma4RT[1] = coeff4GR*sqrt(o[1]->phDRate().getSigma()*o[1]->phDRate().getSigma() +
2560  o[0]->phDRate().getSigma()*o[0]->phDRate().getSigma());
2561  sigma4PH[1] = coeff4PH*sqrt(o[1]->phDelay().getSigma()*o[1]->phDelay().getSigma() +
2562  o[0]->phDelay().getSigma()*o[0]->phDelay().getSigma());
2563  sigma4GR[0] = coeff4GRp*sigma4GR[1];
2564  sigma4RT[0] = coeff4GRp*sigma4RT[1];
2565  sigma4PH[0] = coeff4GRp*sigma4PH[1];
2566  };
2567 
2568  corr4SB[1] = - coeff4SB*sDif;
2569  corr4SB[0] = - (1.0 + coeff4SB)*sDif;
2570  sigma4SB[1] = coeff4SB*sqrt(o[1]->sbDelay().getSigma()*o[1]->sbDelay().getSigma() +
2571  o[0]->sbDelay().getSigma()*o[0]->sbDelay().getSigma());
2572  sigma4SB[0] = (1.0 + coeff4SB)/coeff4SB*sigma4SB[1];
2573 
2574  o[1]->sbDelay().setIonoValue(corr4SB[1]);
2575  o[1]->sbDelay().setIonoSigma(sigma4SB[1]);
2576  o[0]->sbDelay().setIonoValue(corr4SB[0]);
2577  o[0]->sbDelay().setIonoSigma(sigma4SB[0]);
2578 
2579  if (!isSimpleMode)
2580  {
2581  o[1]->grDelay().setIonoValue(corr4GR[1]);
2582  o[1]->grDelay().setIonoSigma(sigma4GR[1]);
2583  o[0]->grDelay().setIonoValue(corr4GR[0]);
2584  o[0]->grDelay().setIonoSigma(sigma4GR[0]);
2585 
2586  o[1]->phDRate().setIonoValue(corr4RT[1]);
2587  o[1]->phDRate().setIonoSigma(sigma4RT[1]);
2588  o[0]->phDRate().setIonoValue(corr4RT[0]);
2589  o[0]->phDRate().setIonoSigma(sigma4RT[0]);
2590 
2591  o[1]->phDelay().setIonoValue(corr4PH[1]);
2592  o[1]->phDelay().setIonoSigma(sigma4PH[1]);
2593  o[0]->phDelay().setIonoValue(corr4PH[0]);
2594  o[0]->phDelay().setIonoSigma(sigma4PH[0]);
2595  };
2596  //
2597  return;
2598 };
2599 
2600 
2601 
2602 //
2604 {
2606  // delAttr(Attr_PROCESSED);
2611  for (QMap<QString, SgVlbiObservable*>::iterator it=observableByKey_.begin();
2612  it!=observableByKey_.end(); ++it)
2613  it.value()->resetAllEditings();
2614 };
2615 
2616 
2617 
2618 //
2620 {
2621  s << key_ << getAttributes() << observableByKey_.size();
2622  for (QMap<QString, SgVlbiObservable*>::const_iterator it=observableByKey_.begin();
2623  it!=observableByKey_.end(); ++it)
2624  if (s.status() == QDataStream::Ok)
2625  it.value()->saveIntermediateResults(s);
2626  else
2627  return false;
2628 
2629  return s.status() == QDataStream::Ok;
2630 };
2631 
2632 
2633 
2634 //
2636 {
2637  QString key;
2638  int num;
2639  unsigned int attributes;
2640  s >> key >> attributes >> num;
2641  if (s.status() != QDataStream::Ok)
2642  {
2644  ": loadIntermediateResults(): error reading data: " +
2645  (s.status()==QDataStream::ReadPastEnd?"read past end of the file":"read corrupt data"));
2646  return false;
2647  };
2648  if (key_ != key)
2649  {
2651  ": loadIntermediateResults(): error reading data: bandKey mismatch: got [" + key +
2652  "], expected [" + key_ + "]");
2653  return false;
2654  };
2655  setAttributes(attributes);
2656  if (num != observableByKey_.size())
2657  {
2659  ": loadIntermediateResults(): error reading data: observableByKey_ size mismatch: got [" +
2660  QString("").setNum(num) + "], expected [" + QString("").setNum(observableByKey_.size()) + "]");
2661  return false;
2662  };
2663  for (QMap<QString, SgVlbiObservable*>::iterator it=observableByKey_.begin();
2664  it!=observableByKey_.end(); ++it)
2665  {
2666  if (s.status() == QDataStream::Ok)
2667  it.value()->loadIntermediateResults(s);
2668  else
2669  {
2671  ": loadIntermediateResults(): error reading data for the " + it.value()->getBandKey() +
2672  "-band of " + key_);
2673  return false;
2674  };
2675  };
2676  return s.status()==QDataStream::Ok;
2677 };
2678 
2679 
2680 
2681 //
2683 {
2684  int bits;
2685  bits = 0;
2686 
2687  if (!primeObs_)
2688  {
2690  ": calculateIonoBits(): the prime band obs is NULL");
2691  return bits;
2692  };
2693  if (observableByKey_.size()!=2)
2694  {
2695  if (2 < observableByKey_.size())
2697  ": calculateIonoBits(): cannot calculate, number of bands (" +
2698  QString("").setNum(observableByKey_.size()) + ") is not equal 2; " +
2699  baseline_->getKey() + " on " + src_->getKey());
2700  return bits;
2701  };
2702  SgVlbiObservable *secObs=NULL;
2703  for (QMap<QString, SgVlbiObservable*>::iterator it=observableByKey_.begin();
2704  it!=observableByKey_.end(); ++it)
2705  {
2706  if (it.value()->getBandKey() != primeObs_->getBandKey())
2707  secObs = it.value();
2708  };
2709  //
2710  // ! Apply to corrections using group delay:
2711  // ! 0001 1 Matching obs has quality code of
2712  // ! 8 or 9, but was unweighted by SOLVE
2713  // ! 0002 2 No matching group data for GION
2714  // ! 0004 3 Matching obs has quality code of
2715  // ! 1 to 7 (not used after 2001.01.17)
2716  // ! 0010 4 GION correction available
2717  // ! 0020 5 Downweight flag for GION (replaces IUNW=8)
2718  // ! (can be reset by other programs only if
2719  // ! bits 2 and 6 are not turned on)
2720  // ! ( not used after 2001.01.17 )
2721  // ! 0040 6 Matching obs has quality code of
2722  // ! 0 ("no fringes")
2723  // !
2724  // ! Apply to corrections using phase delay:
2725  // ! 0100 7 Matching obs has quality code of
2726  // ! 8 or 9, but was unweighted by SOLVE
2727  // ! 0200 8 No matching phase data for PHION
2728  // ! 0400 9 Matching obs has quality code of
2729  // ! 1 to 7
2730  // ! 1000 10 PHION correction available
2731  // ! 2000 11 Downweight flag for PHION (replaces IUNW=8)
2732  // ! (can be reset by other programs only if
2733  // ! bits 8 and 12 are not turned on)
2734  // ! 4000 12 Matching obs has quality code of
2735  // ! 0 ("no fringes")
2736 
2737  // currently, only group delays are reported:
2738  if (0.0 < primeObs_->grDelay().getIonoSigma())
2739  bits |= 1<<3;
2740 
2741  if (!secObs)
2742  bits |= 1<<1;
2743  else
2744  {
2745  int qCode4MatchedObs=secObs->getQualityFactor();
2746  if (7<qCode4MatchedObs && isAttr(Attr_NOT_VALID))
2747  bits |= 1<<0;
2748  else if (qCode4MatchedObs <= 0)
2749  bits |= 1<<5;
2750  };
2751  return bits;
2752 };
2753 
2754 
2755 
2756 
2757 
2758 /*=====================================================================================================*/
2759 
2760 
2761 
2762 
2763 /*=====================================================================================================*/
2764 //
2765 // FRIENDS:
2766 //
2767 /*=====================================================================================================*/
2768 //
2769 
2770 
2771 /*=====================================================================================================*/
2772 //
2773 // aux functions:
2774 //
2775 /*=====================================================================================================*/
2776 
2777 
2778 /*=====================================================================================================*/
2779 //
2780 // statics:
2781 //
2784 /*=====================================================================================================*/
2785 
2786 
2787 
2788 
2789 /*=====================================================================================================*/
const Sg3dMatrix m3E(Sg3dVector(1.0, 0.0, 0.0), Sg3dVector(0.0, 1.0, 0.0), Sg3dVector(0.0, 0.0, 1.0))
const Sg3dVector v3Zero(0.0, 0.0, 0.0)
const double vLight
Definition: SgConstants.cpp:33
SgLogger * logger
Definition: SgLogger.cpp:231
#define DAY2SEC
radians to mas:
Definition: SgMathSupport.h:56
@ Z_AXIS
Definition: SgMathSupport.h:68
@ X_AXIS
Definition: SgMathSupport.h:68
@ Y_AXIS
Definition: SgMathSupport.h:68
@ TECH_VLBI
R: Radio interferometry;.
Definition: SgObservation.h:48
@ DT_DELAY
Definition: SgWrmsable.h:44
@ DT_RATE
Definition: SgWrmsable.h:45
double at(DIRECTION i) const
Definition: Sg3dVector.h:91
const SgMJD & getT0() const
bool isAttr(uint a) const
Definition: SgAttribute.h:226
void setAttributes(unsigned int a)
Definition: SgAttribute.h:191
unsigned int getAttributes() const
Definition: SgAttribute.h:183
void delAttr(uint a)
Definition: SgAttribute.h:210
void addAttr(uint a)
Definition: SgAttribute.h:202
double value(const SgMJD &t) const
double rate(const SgMJD &t) const
void propagatePartials4rates(QList< SgParameter * > &parameters, const SgMJD &t, double tau, double sign)
void propagatePartials(QList< SgParameter * > &parameters, const SgMJD &t, double tau, double sign)
double calcAX(const SgMJD &, bool)
double calc_aT_P_a_opt(const SgMJD &)
void clearPartials()
virtual void write(LogLevel, quint32, const QString &, bool=false)
Definition: SgLogger.cpp:88
@ DELAY
Definition: SgLogger.h:83
@ IO_BIN
Definition: SgLogger.h:64
@ SOURCE
Definition: SgLogger.h:76
@ IONO
Definition: SgLogger.h:81
@ DATA
Definition: SgLogger.h:78
@ STATION
Definition: SgLogger.h:75
bool isEligible(LogLevel lvl, quint32 f) const
Definition: SgLogger.h:151
Definition: SgMJD.h:59
@ F_YYYYMMDDHHMMSSSS
Long verbose: Fri, the 2nd of Apr, 2010; 17hr 02min 43.6400sec.
Definition: SgMJD.h:67
QString toString(Format format=F_Verbose) const
Definition: SgMJD.cpp:1007
double dM_dE() const
double getDversion() const
Definition: SgModelsInfo.h:114
void copySigmas2add(SgObjectInfo *)
Definition: SgObjectInfo.h:604
double getSigma2add(DataType) const
Definition: SgObjectInfo.h:367
const QString & getKey() const
Definition: SgObjectInfo.h:319
void incNumUsable(DataType, int=1)
Definition: SgObjectInfo.h:534
virtual int getMediaIdx() const
virtual bool isEligible(const SgTaskConfig *)
TechniqueID techniqueID_
@ Attr_FORCE_2_PROCESS
include the observation in data analysis in any condition;
Definition: SgObservation.h:80
@ Attr_NOT_VALID
omit the observation;
Definition: SgObservation.h:78
@ Attr_PROCESSED
the observation has been processed;
Definition: SgObservation.h:79
virtual const SgMJD & getMJD() const
double getScale() const
double getSolution() const
Definition: SgParameter.h:435
double getSigma() const
Definition: SgParameter.h:443
const SgParameterCfg & getZenith() const
const SgParameterCfg & getAtmGrad() const
SgParameterCfg::PMode getClock0Mode() const
const SgParameterCfg & getClock0() const
void setD(double d)
Definition: SgPartial.h:347
@ DD_OFFSET
Definition: SgPartial.h:58
const QString & getName() const
Definition: SgPartial.h:283
double getD() const
Definition: SgPartial.h:291
@ Attr_IS_IN_RUN
Definition: SgPartial.h:52
double dDryZD() const
Definition: SgRefraction.h:158
double dWetMF() const
Definition: SgRefraction.h:182
const SgMappingFunction * wetMappingFunction() const
Definition: SgRefraction.h:104
double dWetZD() const
Definition: SgRefraction.h:166
const SgMappingFunction * dryMappingFunction() const
Definition: SgRefraction.h:103
double dDryMF() const
Definition: SgRefraction.h:174
double calcTroposphericDelay(const SgMJD &epoch, const SgMeteoData &meteo, double e, double a, SgVlbiStationInfo *stnInfo, const SgVlbiSourceInfo *srcInfo)
bool getHave2ApplyNutationHFContrib() const
Definition: SgTaskConfig.h:374
bool getIsTesting() const
bool getHave2ApplyOldPoleTideContrib() const
Definition: SgTaskConfig.h:381
bool getUseExtAPrioriHiFyErp() const
bool getUseExtAPrioriSitesPositions() const
bool getUseExtAPrioriErp() const
bool getIsSolveCompatible() const
Definition: SgTaskConfig.h:897
bool getDoDownWeight() const
Definition: SgTaskConfig.h:945
VlbiDelayType getUseDelayType() const
Definition: SgTaskConfig.h:857
bool getDoWeightCorrection() const
Definition: SgTaskConfig.h:889
bool getUseExtAPrioriMeanGradients() const
bool getHave2ApplyEarthTideContrib() const
Definition: SgTaskConfig.h:367
WeightCorrectionMode getWcMode() const
Definition: SgTaskConfig.h:929
bool getHave2ApplyPyContrib() const
Definition: SgTaskConfig.h:366
VlbiDataType getDataType() const
Definition: SgTaskConfig.h:187
bool getHave2ApplyOceanTideContrib() const
Definition: SgTaskConfig.h:368
bool getUseExtAPrioriSourcesPositions() const
bool getHave2ApplyNdryContrib() const
Definition: SgTaskConfig.h:385
VlbiRateType getUseRateType() const
Definition: SgTaskConfig.h:865
bool getHave2ApplyUt1OceanTideHFContrib() const
Definition: SgTaskConfig.h:372
bool getHave2ApplyPxyOceanTideHFContrib() const
Definition: SgTaskConfig.h:373
bool getHave2ApplyOldOceanTideContrib() const
Definition: SgTaskConfig.h:380
bool getHave2ApplyPoleTideContrib() const
Definition: SgTaskConfig.h:369
bool getUseExtAPrioriAxisOffsets() const
bool getHave2ApplyGpsIonoContrib() const
Definition: SgTaskConfig.h:370
bool getHave2ApplyPxyLibrationContrib() const
Definition: SgTaskConfig.h:376
void setDataType(VlbiDataType t)
Definition: SgTaskConfig.h:419
bool getHave2ApplyTiltRemvrContrib() const
Definition: SgTaskConfig.h:379
bool getHave2ApplySourceSsm() const
Definition: SgTaskConfig.h:371
bool getHave2ApplyPxContrib() const
Definition: SgTaskConfig.h:365
bool getHave2ApplyOceanPoleTideContrib() const
Definition: SgTaskConfig.h:377
bool getHave2ApplyFeedCorrContrib() const
Definition: SgTaskConfig.h:378
bool getHave2ApplyNwetContrib() const
Definition: SgTaskConfig.h:386
bool getHave2ApplyUt1LibrationContrib() const
Definition: SgTaskConfig.h:375
bool getHave2ApplyUnPhaseCalContrib() const
Definition: SgTaskConfig.h:384
bool getHave2ApplyAxisOffsetContrib() const
Definition: SgTaskConfig.h:383
SgEstimator * estimator()
SgRefraction * refraction()
SgTask * getTask() const
SgParametersDescriptor * parameters()
Definition: SgTask.h:211
SgTaskConfig * config()
Definition: SgTask.h:204
void setElement(unsigned int i, double d)
Definition: SgVector.h:348
double getElement(unsigned int i) const
Definition: SgVector.h:362
double getDrat_dAxsOfs() const
double getCalcAxisOffset4Rate() const
double getDdel_dTzdGrdN() const
double getCableCalibration() const
double getCalcUnPhaseCal() const
void setEstAtmGradESigma(double s)
double getCalcAxisOffset4Delay() const
void setEstClocksSigma(double e)
void setEstAtmGradNSigma(double s)
double getElevationAngle() const
double getDrat_dTzdWet() const
double getCalcNwetCont4Delay() const
double getElevationAngleRate() const
double getDrat_dTzdGrdN() const
double getRefClockOffset() const
double getCalcNdryCont4Rate() const
double getCalcNdryCont4Delay() const
void setEstZenithDelaySigma(double e)
const SgMeteoData & getMeteoData() const
double getDdel_dTzdWet() const
double getCalcNwetCont4Rate() const
void setEstZenithDelay(double d)
double getAzimuthAngle() const
double getDdel_dTzdDry() const
void setOwner(SgVlbiObservation *)
double getDdel_dAxsOfs() const
double getDrat_dTzdGrdE() const
double getDdel_dTzdGrdE() const
QList< SgVlbiObservable * > & observables()
Definition: SgVlbiBand.h:288
SgVlbiBaselineInfo * lookupBaselineByIdx(int)
Definition: SgVlbiBand.h:491
SgVlbiSourceInfo * lookupSourceByIdx(int)
Definition: SgVlbiBand.h:480
SgVlbiStationInfo * lookupStationByIdx(int)
Definition: SgVlbiBand.h:469
@ Attr_USE_IONO4GRD
use ionosphere corrections for group delays;
@ Attr_USE_IONO4PHD
use ionosphere corrections for phase delays;
QList< SgVlbiObservable * > & observables()
SgParameter * pClock()
double sigma2Apply() const
double getEffFreq() const
void setIonoSigma(double)
void setResidual(double)
double ambiguity() const
double subAmbig() const
double getValue() const
void setIonoValue(double)
void setSigma2add(double)
double getSigma() const
double getIonoValue() const
double getSigma2add() const
double getResidual() const
void setupSigma2Apply(const SgTaskConfig *)
double getIonoSigma() const
bool isUsable() const
double getUvFrPerAsec(int i) const
int getQualityFactor() const
void setGrdQ(double)
SgVlbiStationInfo *& stn_2()
void setGrdDiffBand(double)
SgVlbiStationInfo *& stn_1()
void setupActiveMeasurements(const SgTaskConfig *)
void setTauS(double d)
void setPhrQ(double)
SgVlbiMeasurement & phDRate()
QString strId() const
SgVlbiSourceInfo *& src()
void setPhrDiffBand(double)
const QString & getBandKey() const
SgVlbiBaselineInfo *& baseline()
double getReferenceFrequency() const
SgVlbiMeasurement & phDelay()
SgVlbiMeasurement * activeDelay()
SgVlbiMeasurement & grDelay()
void setSbdDiffBand(double)
SgVlbiMeasurement & sbDelay()
void setSbdQ(double)
double getDrat_dCipY() const
double getExtDelayHiFyUt1() const
virtual const SgVector & o_c()
QList< SgVlbiObservable * > passiveObses_
SgVlbiBaselineInfo * baseline_
double getCalcTiltRemvrRate() const
@ Attr_PASSED_CL_FN1
the observation participated in the procedure "calc clc fn#1"
@ Attr_SBD_NOT_VALID
omit the observation if single band delay is analysed;
@ Attr_CLOCK_BREAK_AT_2
clock break occured at station #2
@ Attr_CLOCK_BREAK_AT_1
clock break occured at station #1
double getCalcPoleTideOldDelay() const
double getCalcTiltRemvrDelay() const
SgVlbiSourceInfo * src_
double getCalcOceanPoleTideLdDelay() const
bool addObservable(const QString &, const SgVlbiObservable &)
SgVlbiSession * session()
double calcConsBendingSunHigherRate_
double extAprioriCorrections4delay_
double getCalcPxDelay() const
virtual void prepare4Analysis(SgTaskManager *)
void fillPartials(SgTaskManager *)
double getCalcOceanTideDelay() const
double getExtRateHiFyPxy() const
double getDdel_dDN() const
double calcGpsIonoCorrectionDelay_
void evalExtApriori_MeanGrads(double &dD, double &dR)
double getCalcOceanPoleTideLdRate() const
void evalExtApriori_SrcPos(double &dD, double &dR)
virtual const QString className() const
double calcConsBendingSunHigherDelay_
void setupActiveMeasurement(const SgTaskConfig *)
double getCalcPyDelay() const
QVector< double > userCorrections_
double getDdel_dPy() const
virtual bool selfCheck()
double getExtDelayErp() const
double getDrat_dPx() const
double getCalcGpsIonoCorrectionDelay() const
void setupActiveObservable(const QString &)
bool modifyNotValidAttribute(bool=false)
SgVlbiAuxObservation * auxObs_1_
double getCalcPoleTideOldRate() const
double getCalcFeedCorrRate() const
QMap< QString, SgVlbiObservable * > observableByKey_
void fillPartials4rate(SgTaskManager *)
double getCalcEarthTideDelay() const
const Sg3dVector & getDdel_dR_1() const
double getCalcConsensusRate() const
double getCalcHiFyPxyRate() const
SgVlbiObservation(SgVlbiSession *)
double getDrat_dCipX() const
double getCalcPxRate() const
double getCalcGpsIonoCorrectionRate() const
double getCalcPyRate() const
double getCalcPoleTideRate() const
double getCalcWobNutatContrib() const
SgVlbiObservable * activeObs_
double getCalcHiFyUt1LibrationRate() const
static SgVector storage4O_C
SgVlbiSession * session_
double extAprioriCorrections4rate_
double getDdel_dCipY() const
int minQualityFactor() const
const Sg3dVector & getDdel_dR_2() const
double getCalcHiFyPxyLibrationRate() const
SgVlbiStationInfo * stn_1_
void calcIonoCorrections(const SgTaskConfig *)
bool loadIntermediateResults(QDataStream &)
SgVlbiObservable * observable(const QString &)
bool saveIntermediateResults(QDataStream &) const
SgVlbiStationInfo * stn_2_
SgVlbiObservable * primeObs_
double getDrat_dUT1() const
virtual const SgVector & sigma()
QList< SgParameter * > parameters_
double getCalcEarthTideRate() const
void evalExtApriori_StnPos(const SgTaskConfig *, double &dD, double &dR)
double getDdel_dPx() const
double getDrat_dPy() const
const Sg3dVector & getDrat_dR_1() const
double getCalcHiFyPxyLibrationDelay() const
double getExtRateErp() const
double getDdel_dUT1() const
double getDrat_dRA() const
virtual bool isEligible(const SgTaskConfig *)
double getExtDelayHiFyPxy() const
const Sg3dVector & getDrat_dR_2() const
double getCalcOceanTideRate() const
static SgVector storage4Sigmas
double getCalcPoleTideDelay() const
virtual void evaluateTheoreticalValues(SgTaskManager *)
double getCalcFeedCorrDelay() const
double getCalcHiFyUt1Delay() const
double getCalcOceanTideOldDelay() const
void evalExtApriori_AxsOfs(double &dD, double &dR)
double getCalcConsensusDelay() const
double getDrat_dDN() const
double getCalcHiFyPxyDelay() const
double getCalcHiFyUt1Rate() const
double getCalcHiFyUt1LibrationDelay() const
SgVlbiObservable * activeObs()
void fillPartials4delay(SgTaskManager *)
double getDdel_dCipX() const
double getDdel_dRA() const
virtual void evaluateResiduals(SgTaskManager *)
SgVlbiAuxObservation * auxObs_2_
double getCalcOceanTideOldRate() const
double getExtRateHiFyUt1() const
SgVlbiBand * primaryBand()
const SgAPriories & getApStationVelocities() const
QMap< QString, SgVlbiBand * > & bandByKey()
SgVlbiStationInfo * lookupStationByIdx(int)
SgModelsInfo & calcInfo()
SgParameter * pUT1()
bool hasGradPartials() const
const QVector< bool > & getUserCorrectionsUse() const
SgParameter * pPolusYRate()
const SgMJD & tRefer() const
SgParameter * pNutYRate()
SgParameter * pPolusY()
SgParameter * pUT1Rate()
SgParameter * pPolusXRate()
SgParameter * pNutXRate()
SgVlbiSourceInfo * lookupSourceByIdx(int)
SgParameter * pNutY()
SgParameter * pNutX()
SgVlbiBaselineInfo * lookupBaselineByIdx(int)
bool isAble2InterpolateErp() const
SgParameter * pPolusX()
double getDN_ea() const
double getRA_ea() const
double tauS(double f, double u, double v)
bool getIsSsModelEstimating() const
double getRA() const
QList< StructModelMp > & sModel()
void processPartials4SrcStructModel(QList< SgParameter * > &parameters, double f, double u, double v)
SgParameter * pRA()
double getDN() const
SgParameter * pDN()
@ Attr_APPLY_SSM
apply the source structure model;
SgParameter * pAtmGradN()
QMap< QString, SgVlbiAuxObservation * > * auxObservationByScanId()
const Sg3dVector & getV_ea()
SgParameter * pRz()
double getGradNorth() const
double getAxisOffset() const
const Sg3dVector & getV3Ecc() const
SgParameter * pClock0()
SgParameter * pRx()
double getGradEast() const
const Sg3dVector & getR()
SgParameter * pClocks(int i)
bool getIsEccNonZero() const
SgParameter * pAtmGradE()
SgParameter * pZenithDelay()
double effectiveCableCalMultiplier() const
double getAxisOffset_ea() const
const Sg3dVector & getR_ea()
SgBreakModel & clockBreaks()
int getClocksModelOrder() const
double getEstClockModel(int idx) const
SgParameter * pAxisOffset()
bool getNeed2useAPrioriClocks() const
SgParameter * pRy()
double getAPrioriClockTerm_0() const
SgTaskConfig config
Definition: nuSolve.cpp:59