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 
911  dDryZd_1 = dDryZd_2 = dWetZd_1 = dWetZd_2 = dDryMf_1 = dDryMf_2 = dWetMf_1 = dWetMf_2 =
912  rDryMf_1 = rDryMf_2 = rWetMf_1 = rWetMf_2 = 0.0;
913 
914  if (auxObs_1_ && auxObs_2_)
915  {
916 // if (!cfg->getHave2ApplyNdryContrib() || !cfg->getHave2ApplyNwetContrib())
918  {
921  dDryZd_1 = mgr->refraction()->dDryZD();
922  dDryMf_1 = mgr->refraction()->dDryMF();
923  rDryMf_1 = mgr->refraction()->dryMappingFunction()->dM_dE();
924  dWetZd_1 = mgr->refraction()->dWetZD();
925  dWetMf_1 = mgr->refraction()->dWetMF();
926  rWetMf_1 = mgr->refraction()->wetMappingFunction()->dM_dE();
927 
930  dDryZd_2 = mgr->refraction()->dDryZD();
931  dDryMf_2 = mgr->refraction()->dDryMF();
932  rDryMf_2 = mgr->refraction()->dryMappingFunction()->dM_dE();
933  dWetZd_2 = mgr->refraction()->dWetZD();
934  dWetMf_2 = mgr->refraction()->dWetMF();
935  rWetMf_2 = mgr->refraction()->wetMappingFunction()->dM_dE();
936  };
937  if (cfg->getHave2ApplyNdryContrib())
938  {
941  dDryMf_1 = auxObs_1_->getDdel_dTzdDry();
942  dDryMf_2 = auxObs_2_->getDdel_dTzdDry();
943  };
944  if (cfg->getHave2ApplyNwetContrib())
945  {
948  dWetMf_1 = auxObs_1_->getDdel_dTzdWet();
949  dWetMf_2 = auxObs_2_->getDdel_dTzdWet();
950  };
951 
952  //
953  // hydrostatic part:
954  if (cfg->getHave2ApplyNdryContrib()) // from contributions:
955  {
957  theoDelay_ += dContribA;
959 
960  auxObs_1_->setZenithDelayH(dDryZd_1);
961  auxObs_2_->setZenithDelayH(dDryZd_2);
962 
967  }
968  else // from "flyby":
969  {
970  dContribA = dDryZd_2*rDryMf_2*auxObs_2_->getElevationAngleRate() -
971  dDryZd_1*rDryMf_1*auxObs_1_->getElevationAngleRate();
972  theoRate_ += dContribA/vLight;
973 
974  dContribA = dDryZd_2*dDryMf_2 - dDryZd_1*dDryMf_1;
975  theoDelay_ += dContribA/vLight;
976  auxObs_1_->setZenithDelayH(dDryZd_1);
977  auxObs_2_->setZenithDelayH(dDryZd_2);
978 
979  auxObs_1_->setSlantDelayH(dDryZd_1*dDryMf_1/vLight);
980  auxObs_2_->setSlantDelayH(dDryZd_2*dDryMf_2/vLight);
983  };
985  {
986  str.sprintf(" dry MFunction= %20.16f", dDryMf_1);
988  stn_1_->getKey() + ": " + str);
989  str.sprintf(" dry zenithDelay= %20.16f (m)", dDryZd_1);
991  stn_1_->getKey() + ": " + str);
992  str.sprintf(" dry contrib= %20.16f(m)", dDryZd_1*dDryMf_1);
994  stn_1_->getKey() + ": " + str);
995 
996  str.sprintf(" dry MFunction= %20.16f", dDryMf_2);
998  stn_2_->getKey() + ": " + str);
999  str.sprintf(" dry zenithDelay= %20.16f (m)", dDryZd_2);
1001  stn_2_->getKey() + ": " + str);
1002  str.sprintf(" dry contrib= %20.16f(m)", dDryZd_2*dDryMf_2);
1004  stn_2_->getKey() + ": " + str);
1005  };
1006 
1007  //
1008  // wet part:
1009  if (cfg->getHave2ApplyNwetContrib())
1010  {
1012  theoDelay_ += dContribB;
1014 
1017 
1022  }
1023  else
1024  {
1025  dContribB = dWetZd_2*rWetMf_2*auxObs_2_->getElevationAngleRate() -
1026  dWetZd_1*rWetMf_1*auxObs_1_->getElevationAngleRate();
1027  theoRate_ += dContribB/vLight;
1028 
1029  dContribB = dWetZd_2*dWetMf_2 - dWetZd_1*dWetMf_1;
1030  theoDelay_ += dContribB/vLight;
1031  auxObs_1_->setZenithDelayW(dWetZd_1);
1032  auxObs_2_->setZenithDelayW(dWetZd_2);
1033 
1034  auxObs_1_->setSlantDelayW(dWetZd_1*dWetMf_1/vLight);
1036  auxObs_2_->setSlantDelayW(dWetZd_2*dWetMf_2/vLight);
1038  };
1040  {
1041  str.sprintf(" wet MFunction= %20.16f", dWetMf_1);
1043  stn_1_->getKey() + ": " + str);
1044  str.sprintf(" wet zenithDelay= %20.16f (m)", dWetZd_1);
1046  stn_1_->getKey() + ": " + str);
1047  str.sprintf(" wet contrib= %20.16f(m)", dWetZd_1*dWetMf_1);
1049  stn_1_->getKey() + ": " + str);
1050 
1051  str.sprintf(" wet MFunction= %20.16f", dWetMf_2);
1053  stn_2_->getKey() + ": " + str);
1054  str.sprintf(" wet zenithDelay= %20.16f (m)", dWetZd_2);
1056  stn_2_->getKey() + ": " + str);
1057  str.sprintf(" wet contrib= %20.16f(m)", dWetZd_2*dWetMf_2);
1059  stn_2_->getKey() + ": " + str);
1060  };
1061  //
1062  //
1063  //
1064  if (!cfg->getHave2ApplyAxisOffsetContrib())
1065  {
1066  theoDelay_ -=
1068 #ifdef DBG_MODE_
1069  str.sprintf("Removed contribution: axis offsets (ps): %18.2f", -dContrib*1.0e12);
1070  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1071 #endif
1072  theoRate_ -=
1074  };
1075  if (cfg->getHave2ApplyUnPhaseCalContrib())
1076  {
1078 #ifdef DBG_MODE_
1079  str.sprintf("Added contribution: unphasecal (ps): %18.2f", dContrib*1.0e12);
1080  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1081 #endif
1082  };
1083  //
1084  //
1085  if (cfg->getIsTesting())
1086  {
1088  };
1089  //
1090  //
1091  // cable calibration corrections:
1092  theoDelay_ -=
1093  (dContrib=
1096 /*
1097  (dContrib=(stn_2_->effectiveCableCalMultiplier()*auxObs_2_->getCableCalibration() -
1098  stn_1_->effectiveCableCalMultiplier()*auxObs_1_->getCableCalibration() ));
1099 */
1100  //
1101  }; // end of station dependent contribs
1102  //
1103  // session-wide clock breaks:
1104  theoDelay_ +=
1105  (stn_2_->clockBreaks().value(*this) - stn_1_->clockBreaks().value(*this))*1.0e-09;
1106  theoRate_ +=
1107  (stn_2_->clockBreaks().rate (*this) - stn_1_->clockBreaks().rate (*this))*1.0e-09;
1108  //
1109 #ifdef DBG_MODE_
1111  {
1112  str.sprintf("Cable calibraiton at %-8s (ps): %18.2f",
1113  qPrintable(stn_2_->getKey()),
1115 // stn_2_->effectiveCableCalMultiplier()*auxObs_2_->getCableCalibration()*1.0e12);
1116  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1117  //
1118  str.sprintf("Cable calibraiton at %-8s (ps): %18.2f",
1119  qPrintable(stn_1_->getKey()),
1121 // - stn_1_->effectiveCableCalMultiplier()*auxObs_1_->getCableCalibration()*1.0e12);
1122  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1123  //
1124  str.sprintf("Added contribution: cable calibration (ps): %18.2f", dContrib*1.0e12);
1125  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1126  //
1127  str.sprintf("Theoretical delay, final (ps): %18.2f", theoDelay_*1.0e12);
1128  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str, true);
1129  };
1130 #endif
1131  //
1132  //
1133  //
1134  // User corrections:
1135  if (session_->getUserCorrectionsUse().size())
1136  {
1137  for (int i=0; i<session_->getUserCorrectionsUse().size(); i++)
1138  if (session_->getUserCorrectionsUse().at(i))
1139  theoDelay_ += userCorrections_.at(i);
1140  };
1141  //
1142  //
1143  if (activeObs_)
1144  {
1145  activeObs_->setTauS(0.0);
1146  if (cfg->getHave2ApplySourceSsm() &&
1148  src_->sModel().size())
1149  {
1150  double tauS;
1151  tauS = src_->tauS(activeObs_->getReferenceFrequency()*1.0e6,
1152  activeObs_->getUvFrPerAsec(0)*360.0*3600.0/2.0/M_PI,
1153  activeObs_->getUvFrPerAsec(1)*360.0*3600.0/2.0/M_PI);
1154  theoDelay_ += tauS;
1155  activeObs_->setTauS(tauS);
1156  };
1157  };
1158 };
1159 
1160 
1161 
1162 //
1164 {
1165  storage4O_C .setElement(0, 0.0);
1166  storage4Sigmas.setElement(0, 0.0);
1167  if (!activeObs_)
1168  return;
1169 
1170  QString str;
1171  const SgTaskConfig *cfg=mgr->getTask()->config();
1172  double bandClockBreakShift(0.0), bandClockBreakRate(0.0);
1173  double o_c(0.0), stdDev(0.0);
1174 
1176 
1177  // evaluate and submit the partials:
1178  fillPartials(mgr);
1179 
1180  // add "processed" flag to the obs and aux obses:
1184  //
1185  bandClockBreakShift = (activeObs_->stn_2()->clockBreaks().value(*this) -
1186  activeObs_->stn_1()->clockBreaks().value(*this) )*1.0e-09;
1187  bandClockBreakRate = (activeObs_->stn_2()->clockBreaks().rate (*this) -
1188  activeObs_->stn_1()->clockBreaks().rate (*this) )*1.0e-09;
1189  //
1190  //
1191  if (cfg->getDataType() == SgTaskConfig::VDT_DELAY)
1192  {
1193  switch (cfg->getUseDelayType())
1194  {
1195  case SgTaskConfig::VD_NONE:
1196  default:
1197  break;
1202  - theoDelay_;
1203  break;
1207  + activeObs_->grDelay().subAmbig()
1209  - (theoDelay_ + bandClockBreakShift);
1212  break;
1217  - (theoDelay_ + bandClockBreakShift);
1220  break;
1221  };
1222  stdDev = activeObs_->activeDelay()->sigma2Apply();
1224  stdDev *= 1.0e4;
1225  }
1226  else if (cfg->getDataType() == SgTaskConfig::VDT_RATE)
1227  {
1231  - (theoRate_ + bandClockBreakRate);
1232 
1233  stdDev = activeObs_->phDRate().sigma2Apply();
1234 // o_c *= DAY2SEC;
1235 // stdDev *= DAY2SEC;
1236  }
1237  else
1239  "::prepare4Analysis(): uknown data type");
1240 
1241  storage4O_C .setElement(0, o_c);
1242  storage4Sigmas.setElement(0, stdDev);
1243  //
1244  //
1245 #ifdef DBG_MODE_
1247  {
1248  str.sprintf("Ionospheric group delay (ps): %18.2f",
1249  activeObs_->grDelay().getIonoValue()*1.0e12);
1250  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1251 
1252  str.sprintf("Ambiguity correction (ps): %18.2f",
1253  activeObs_->grDelay().ambiguity()*1.0e12);
1254  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1255  str.sprintf("Observed group delay (ps): %18.2f",
1256  activeObs_->grDelay().getValue()*1.0e12);
1257  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1258 
1259  str.sprintf("Resulted O-C (ps): %18.2f",
1260  storage4O_C.getElement(0)*1.0e12);
1261 
1262  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1264 
1265  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": __ sigmas __");
1266  str.sprintf("Group delay sigma (ps): %8.4f", activeObs_->grDelay().getSigma()*1.0e12);
1267  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1268  str.sprintf("Iono. sigma: (ps) %8.4f", activeObs_->grDelay().getIonoSigma()*1.0e12);
1269  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1270  str.sprintf("Reweighting sigma (ps): %8.4f", activeObs_->activeDelay()->getSigma2add()*1.0e12);
1271  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1272  str.sprintf("Resulted sigma (ps): %8.4f", activeObs_->activeDelay()->sigma2Apply()*1.0e12);
1273  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": " + str);
1274  };
1275 #endif
1276 };
1277 
1278 
1279 
1280 //
1282 {
1283  SgTaskConfig *cfg=mgr->getTask()->config();
1284  const SgParametersDescriptor *parameters=mgr->getTask()->parameters();
1285  SgEstimator *estimator=mgr->estimator();
1286  QString str("");
1287 
1289  // delay:
1290  // zerofy all partials:
1291  estimator->clearPartials();
1292  // evaluate and submit the partials:
1294  fillPartials(mgr);
1295  sumAX_4delay_ = estimator->calcAX(getMJD(), true);
1297 // reweightAuxSum4delay_ = estimator->calc_aT_P_a_opt(getMJD());
1298  //
1299  //
1300  // rate:
1301  // zerofy all partials:
1302  estimator->clearPartials();
1303  // evaluate and submit the partials:
1305  fillPartials(mgr);
1306  sumAX_4rate_ = estimator->calcAX(getMJD(), true);
1308 // reweightAuxSum4rate_ = estimator->calc_aT_P_a_opt(getMJD());
1309  //
1310  //
1311  //
1312  // residuals themselves:
1313  double sbDelayResidual, grDelayResidual, phDelayResidual, phDRateResidual;
1314  QMap<QString, SgVlbiObservable*>::iterator
1315  it;
1316  for (it=observableByKey_.begin(); it!=observableByKey_.end(); ++it)
1317  {
1318  SgVlbiObservable *o=it.value();
1319  SgVlbiBand *band=session_->bandByKey().value(o->getBandKey());
1320  double bandClockBreakShift(0.0), bandClockBreakRate(0.0);
1321  bandClockBreakShift = (o->stn_2()->clockBreaks().value(*this) -
1322  o->stn_1()->clockBreaks().value(*this) )*1.0e-09;
1323  bandClockBreakRate = (o->stn_2()->clockBreaks().rate (*this) -
1324  o->stn_1()->clockBreaks().rate (*this) )*1.0e-09;
1325  //
1326  // sb delay:
1327  sbDelayResidual = (o->sbDelay().getValue()
1329  - sumAX_4delay_;
1330  // group delay:
1331  grDelayResidual = (o->grDelay().getValue() + o->grDelay().ambiguity() + o->grDelay().subAmbig()
1332  - (theoDelay_ + bandClockBreakShift) + extAprioriCorrections4delay_)
1333  - sumAX_4delay_;
1335  grDelayResidual -= o->grDelay().getIonoValue();
1336  // phase delay:
1337  phDelayResidual = (o->phDelay().getValue() + o->phDelay().ambiguity()
1338  - (theoDelay_ + bandClockBreakShift) + extAprioriCorrections4delay_)
1339  - sumAX_4delay_;
1341  phDelayResidual -= o->phDelay().getIonoValue();
1342  // rate:
1343  phDRateResidual = (o->phDRate().getValue() +
1344  - (theoRate_ + bandClockBreakRate) + extAprioriCorrections4rate_)
1345  - o->phDRate().getIonoValue()
1346  - sumAX_4rate_;
1347  //
1348  // store them:
1349  o->sbDelay().setResidual(sbDelayResidual);
1350  o->grDelay().setResidual(grDelayResidual);
1351  o->phDelay().setResidual(phDelayResidual);
1352  o->phDRate().setResidual(phDRateResidual);
1353  if (o->isUsable())
1354  {
1355  band->incNumUsable(DT_DELAY);
1356  o->stn_1()->incNumUsable(DT_DELAY);
1357  o->stn_2()->incNumUsable(DT_DELAY);
1358  o->src ()->incNumUsable(DT_DELAY);
1360  band->incNumUsable(DT_RATE);
1361  o->stn_1()->incNumUsable(DT_RATE);
1362  o->stn_2()->incNumUsable(DT_RATE);
1363  o->src ()->incNumUsable(DT_RATE);
1364  o->baseline()->incNumUsable(DT_RATE);
1365  };
1366 #ifdef DBG_MODE_
1368  {
1369  str.sprintf("GrD: Observation: %18.2f", o->grDelay().getValue()*1.0e12);
1370  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + "::evaluateResiduals(): " +
1371  it.key() + "-Band " + str);
1372  str.sprintf("GrD: Ambiguities: %18.2f", o->grDelay().ambiguity()*1.0e12);
1373  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + "::evaluateResiduals(): " +
1374  it.key() + "-Band " + str);
1375  str.sprintf("GrD: Ionosphere : %18.2f", o->grDelay().getIonoValue()*1.0e12);
1376  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + "::evaluateResiduals(): " +
1377  it.key() + "-Band " + str);
1378  str.sprintf("GrD: Theoretical: %18.2f", theoDelay_*1.0e12);
1379  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + "::evaluateResiduals(): " +
1380  it.key() + "-Band " + str);
1381  str.sprintf("GrD: BandClckBrk: %18.2f", bandClockBreakShift*1.0e12);
1382  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + "::evaluateResiduals(): " +
1383  it.key() + "-Band " + str);
1384  str.sprintf("GrD: ExtAPriori : %18.2f", extAprioriCorrections4delay_*1.0e12);
1385  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + "::evaluateResiduals(): " +
1386  it.key() + "-Band " + str);
1387  str.sprintf("GrD: A*x : %18.2f", sumAX_4delay_*1.0e12);
1388  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + "::evaluateResiduals(): " +
1389  it.key() + "-Band " + str);
1390  str.sprintf("Group Delay O-C (ps): %s %s %05d %18.2f %18.2f %18.2f",
1392  (grDelayResidual + sumAX_4delay_)*1.0e12, grDelayResidual*1.0e12,
1393  o->grDelay().sigma2Apply()*1.0e12);
1394  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + "::evaluateResiduals(): " +
1395  it.key() + "-Band " + str);
1396  };
1397 #endif
1398  //
1399  // update statistics:
1400  double appliedSigma, residual, weight;
1401  if (isAttr(Attr_PROCESSED))
1402  {
1403  if (o->activeDelay())
1404  {
1405  appliedSigma = o->activeDelay()->sigma2Apply();
1406  residual = o->activeDelay()->getResidual();
1407  weight = appliedSigma>0.0 ? 1.0/appliedSigma/appliedSigma : 1.0;
1408  o->stn_1() -> addWrms(DT_DELAY, *this, residual, weight, reweightAuxSum4delay_);
1409  o->stn_2() -> addWrms(DT_DELAY, *this, residual, weight, reweightAuxSum4delay_);
1410  o->src () -> addWrms(DT_DELAY, *this, residual, weight, reweightAuxSum4delay_);
1411  o->baseline()-> addWrms(DT_DELAY, *this, residual, weight, reweightAuxSum4delay_);
1412  band -> addWrms(DT_DELAY, *this, residual, weight, reweightAuxSum4delay_);
1413  };
1414  appliedSigma = o->phDRate().sigma2Apply();
1415  residual = o->phDRate().getResidual();
1416  weight = appliedSigma>0.0 ? 1.0/appliedSigma/appliedSigma : 1.0;
1417  o->stn_1() -> addWrms(DT_RATE, *this, residual, weight, reweightAuxSum4rate_);
1418  o->stn_2() -> addWrms(DT_RATE, *this, residual, weight, reweightAuxSum4rate_);
1419  o->src () -> addWrms(DT_RATE, *this, residual, weight, reweightAuxSum4rate_);
1420  o->baseline()-> addWrms(DT_RATE, *this, residual, weight, reweightAuxSum4rate_);
1421  band -> addWrms(DT_RATE, *this, residual, weight, reweightAuxSum4rate_);
1422  };
1423  };
1424  //
1425  // update station dependent time-varying estimates:
1426  double scale_c, scale_z, scale_g;
1427  scale_c = parameters->getClock0().getScale();
1428  scale_z = parameters->getZenith().getScale();
1429  scale_g = parameters->getAtmGrad().getScale();
1430  // the first station:
1432  {
1434  {
1437  }
1438  else
1439  {
1440  auxObs_1_->setEstClocks(0.0);
1442  };
1443  //
1446  //
1451  };
1452  // the second station:
1454  {
1456  {
1459  }
1460  else
1461  {
1462  auxObs_2_->setEstClocks(0.0);
1464  };
1465  //
1468  //
1473  };
1474 };
1475 
1476 
1477 
1478 //
1480 {
1481  return storage4O_C;
1482 };
1483 
1484 
1485 
1486 //
1488 {
1489  return storage4Sigmas;
1490 };
1491 
1492 
1493 
1494 //
1496 {
1497  if (mgr->getTask()->config()->getDataType() == SgTaskConfig::VDT_DELAY)
1498  fillPartials4delay(mgr);
1499  else if (mgr->getTask()->config()->getDataType() == SgTaskConfig::VDT_RATE)
1500  fillPartials4rate(mgr);
1501  else
1503  "::fillPartials(): unexpected data type");
1504 };
1505 
1506 
1507 
1508 //
1510 {
1511  SgTaskConfig *cfg=mgr->getTask()->config();
1512  QString str;
1513  double dt1 = (*this - session_->tRefer());
1514  double dt2 = (dt1 + getCalcConsensusDelay()/DAY2SEC);
1515  parameters_.clear();
1516 
1517  // partials for clocks:
1518  double d1=1.0;
1519  double d2=1.0;
1520  int nCl;
1521  nCl = mgr->getTask()->parameters()->getClock0Mode()==SgParameterCfg::PM_STC ? 1 :
1523 
1524  for (int i=0; i<nCl; i++)
1525  {
1526  // station #1:
1528  {
1529  stn_1_->pClocks(i)->setD(-d1);
1530  parameters_.append(stn_1_->pClocks(i));
1531  };
1532  // station #2:
1534  {
1535  stn_2_->pClocks(i)->setD(d2);
1536  parameters_.append(stn_2_->pClocks(i));
1537  };
1538  d1 *= dt1;
1539  d2 *= dt2;
1540  };
1541  // clock breaks:
1542  if (stn_1_->clockBreaks().size())
1543  stn_1_->clockBreaks().propagatePartials(parameters_, *this, dt1, -1.0);
1544  if (stn_2_->clockBreaks().size())
1545  stn_2_->clockBreaks().propagatePartials(parameters_, *this, dt2, 1.0);
1546 
1547 
1548 #ifdef DBG_MODE_
1550  {
1551  str.sprintf("Partials: %-30s: %32.15f",
1552  qPrintable(stn_1_->pClocks(0)->getName()), stn_1_->pClocks(0)->getD());
1554  "::fillPartials4delay(): " + str);
1555 
1556  str.sprintf("Partials: %-30s: %32.15f",
1557  qPrintable(stn_1_->pClocks(1)->getName()), stn_1_->pClocks(1)->getD());
1559  "::fillPartials4delay(): " + str);
1560 
1561  str.sprintf("Partials: %-30s: %32.15f",
1562  qPrintable(stn_1_->pClocks(2)->getName()), stn_1_->pClocks(2)->getD());
1564  "::fillPartials4delay(): " + str);
1565 
1566  str.sprintf("Partials: %-30s: %32.15f",
1567  qPrintable(stn_2_->pClocks(0)->getName()), stn_2_->pClocks(0)->getD());
1569  "::fillPartials4delay(): " + str);
1570 
1571  str.sprintf("Partials: %-30s: %32.15f",
1572  qPrintable(stn_2_->pClocks(1)->getName()), stn_2_->pClocks(1)->getD());
1574  "::fillPartials4delay(): " + str);
1575 
1576  str.sprintf("Partials: %-30s: %32.15f",
1577  qPrintable(stn_2_->pClocks(2)->getName()), stn_2_->pClocks(2)->getD());
1579  "::fillPartials4delay(): " + str);
1580  };
1581 #endif
1582 
1583  // refraction:
1584  if (auxObs_1_ && auxObs_2_)
1585  {
1586  double dWetMf_1, dWetMf_2; //, dGrdMf_1, dGrdMf_2;
1587 // if (!cfg->getHave2ApplyNdryContrib() || !cfg->getHave2ApplyNwetContrib()) // need flybys:
1588  dWetMf_1 = dWetMf_2 = 0.0;
1590  {
1593  dWetMf_1 = mgr->refraction()->dWetMF();
1594 
1597  dWetMf_2 = mgr->refraction()->dWetMF();
1598  };
1599  //
1600  //
1601  // hydrostatic part: partials to the gradients:
1602  if (session_->hasGradPartials()) // from contributions:
1603  {
1605  {
1608  parameters_.append(stn_1_->pAtmGradN());
1609  parameters_.append(stn_1_->pAtmGradE());
1610  };
1612  {
1615  parameters_.append(stn_2_->pAtmGradN());
1616  parameters_.append(stn_2_->pAtmGradE());
1617  };
1618  };
1619 /*
1620  else // from "flyby":
1621  {
1622  if (stn_1_->pAtmGradN()->isAttr(SgPartial::Attr_IS_IN_RUN))
1623  {
1624  stn_1_->pAtmGradN()->setD(-cos(auxObs_1_->getAzimuthAngle())*dGrdMf_1/vLight);
1625  stn_1_->pAtmGradE()->setD(-sin(auxObs_1_->getAzimuthAngle())*dGrdMf_1/vLight);
1626  parameters_.append(stn_1_->pAtmGradN());
1627  parameters_.append(stn_1_->pAtmGradE());
1628  };
1629  if (stn_2_->pAtmGradN()->isAttr(SgPartial::Attr_IS_IN_RUN))
1630  {
1631  stn_2_->pAtmGradN()->setD( cos(auxObs_2_->getAzimuthAngle())*dGrdMf_2/vLight);
1632  stn_2_->pAtmGradE()->setD( sin(auxObs_2_->getAzimuthAngle())*dGrdMf_2/vLight);
1633  parameters_.append(stn_2_->pAtmGradN());
1634  parameters_.append(stn_2_->pAtmGradE());
1635  };
1636  };
1637 */
1638  //
1639  //
1640  // wet part: partials to the wet zenith delays:
1641  if (cfg->getHave2ApplyNwetContrib()) // from contributions:
1642  {
1644  {
1646  parameters_.append(stn_1_->pZenithDelay());
1647  };
1649  {
1651  parameters_.append(stn_2_->pZenithDelay());
1652  };
1655  }
1656  else // from "flyby":
1657  {
1659  {
1660  stn_1_->pZenithDelay()->setD(-dWetMf_1/vLight);
1661  parameters_.append(stn_1_->pZenithDelay());
1662  };
1664  {
1665  stn_2_->pZenithDelay()->setD( dWetMf_2/vLight);
1666  parameters_.append(stn_2_->pZenithDelay());
1667  };
1668  auxObs_1_->setPartDelayW(dWetMf_1);
1669  auxObs_2_->setPartDelayW(dWetMf_2);
1670  };
1671  };
1672 
1673 #ifdef DBG_MODE_
1675  {
1676  str.sprintf("Partials: %-30s: %32.15f or %32.15f",
1677  qPrintable(stn_1_->pZenithDelay()->getName()),
1678  stn_1_->pZenithDelay()->getD(),
1679  stn_1_->pZenithDelay()->getD()*vLight);
1681  "::fillPartials4delay(): " + str);
1682 
1683  str.sprintf("Partials: %-30s: %32.15f or %32.15f",
1684  qPrintable(stn_2_->pZenithDelay()->getName()),
1685  stn_2_->pZenithDelay()->getD(),
1686  stn_2_->pZenithDelay()->getD()*vLight);
1688  "::fillPartials4delay(): " + str);
1689  };
1690 #endif
1691 
1692  // Station #1:
1694  {
1695  stn_1_->pRx()->setD(getDdel_dR_1().at(X_AXIS));
1696  stn_1_->pRy()->setD(getDdel_dR_1().at(Y_AXIS));
1697  stn_1_->pRz()->setD(getDdel_dR_1().at(Z_AXIS));
1698  parameters_.append(stn_1_->pRx());
1699  parameters_.append(stn_1_->pRy());
1700  parameters_.append(stn_1_->pRz());
1701  };
1702 
1703  // Station #2:
1705  {
1706  stn_2_->pRx()->setD(getDdel_dR_2().at(X_AXIS));
1707  stn_2_->pRy()->setD(getDdel_dR_2().at(Y_AXIS));
1708  stn_2_->pRz()->setD(getDdel_dR_2().at(Z_AXIS));
1709  parameters_.append(stn_2_->pRx());
1710  parameters_.append(stn_2_->pRy());
1711  parameters_.append(stn_2_->pRz());
1712  };
1713 
1714  // Axis offsets:
1716  {
1718  parameters_.append(stn_1_->pAxisOffset());
1719  };
1721  {
1723  parameters_.append(stn_2_->pAxisOffset());
1724  };
1725  // Source:
1727  {
1728  src_->pRA()->setD(getDdel_dRA());
1729  src_->pDN()->setD(getDdel_dDN());
1730  parameters_.append(src_->pRA());
1731  parameters_.append(src_->pDN());
1732  };
1733 
1734  //
1735  //
1736  double scl=360.0*3600.0/2.0/M_PI;
1737  if (activeObs())
1738  {
1739 /*
1740  if (src_->getSmtType() == SgVlbiSourceInfo::SMT_TWO_POINTS)
1741  {
1742  // two-point SS-model (testing):
1743  if (src_->pK() && src_->pK()->isAttr(SgPartial::Attr_IS_IN_RUN))
1744  {
1745  src_->pK()->setD(src_->dTauS_dK(activeObs()->getReferenceFrequency()*1.0e6,
1746  activeObs()->getUvFrPerAsec(0)*scl, activeObs()->getUvFrPerAsec(1)*scl));
1747  parameters_.append(src_->pK());
1748  };
1749  if (src_->pB() && src_->pB()->isAttr(SgPartial::Attr_IS_IN_RUN))
1750  {
1751  src_->pB()->setD(src_->dTauS_dB(activeObs()->getReferenceFrequency()*1.0e6,
1752  activeObs()->getUvFrPerAsec(0)*scl, activeObs()->getUvFrPerAsec(1)*scl));
1753  parameters_.append(src_->pB());
1754  };
1755  if (src_->pX() && src_->pX()->isAttr(SgPartial::Attr_IS_IN_RUN))
1756  {
1757  src_->pX()->setD(src_->dTauS_dX(activeObs()->getReferenceFrequency()*1.0e6,
1758  activeObs()->getUvFrPerAsec(0)*scl, activeObs()->getUvFrPerAsec(1)*scl));
1759  parameters_.append(src_->pX());
1760  };
1761  if (src_->pY() && src_->pY()->isAttr(SgPartial::Attr_IS_IN_RUN))
1762  {
1763  src_->pY()->setD(src_->dTauS_dY(activeObs()->getReferenceFrequency()*1.0e6,
1764  activeObs()->getUvFrPerAsec(0)*scl, activeObs()->getUvFrPerAsec(1)*scl));
1765  parameters_.append(src_->pY());
1766  };
1767 //--
1768  if (src_->pA0() && src_->pA0()->isAttr(SgPartial::Attr_IS_IN_RUN))
1769  {
1770  src_->pA0()->setD(src_->dTauS_dA0(activeObs()->getReferenceFrequency()*1.0e6,
1771  activeObs()->getUvFrPerAsec(0)*scl, activeObs()->getUvFrPerAsec(1)*scl));
1772  parameters_.append(src_->pA0());
1773  };
1774  if (src_->pB0() && src_->pB0()->isAttr(SgPartial::Attr_IS_IN_RUN))
1775  {
1776  src_->pB0()->setD(src_->dTauS_dB0(activeObs()->getReferenceFrequency()*1.0e6,
1777  activeObs()->getUvFrPerAsec(0)*scl, activeObs()->getUvFrPerAsec(1)*scl));
1778  parameters_.append(src_->pB0());
1779  };
1780  if (src_->pTheta0() && src_->pTheta0()->isAttr(SgPartial::Attr_IS_IN_RUN))
1781  {
1782  src_->pTheta0()->setD(src_->dTauS_dTheta0(activeObs()->getReferenceFrequency()*1.0e6,
1783  activeObs()->getUvFrPerAsec(0)*scl, activeObs()->getUvFrPerAsec(1)*scl));
1784  parameters_.append(src_->pTheta0());
1785  };
1786 
1787  if (src_->pA1() && src_->pA1()->isAttr(SgPartial::Attr_IS_IN_RUN))
1788  {
1789  src_->pA1()->setD(src_->dTauS_dA1(activeObs()->getReferenceFrequency()*1.0e6,
1790  activeObs()->getUvFrPerAsec(0)*scl, activeObs()->getUvFrPerAsec(1)*scl));
1791  parameters_.append(src_->pA1());
1792  };
1793  if (src_->pB1() && src_->pB1()->isAttr(SgPartial::Attr_IS_IN_RUN))
1794  {
1795  src_->pB1()->setD(src_->dTauS_dB1(activeObs()->getReferenceFrequency()*1.0e6,
1796  activeObs()->getUvFrPerAsec(0)*scl, activeObs()->getUvFrPerAsec(1)*scl));
1797  parameters_.append(src_->pB1());
1798  };
1799  if (src_->pTheta1() && src_->pTheta1()->isAttr(SgPartial::Attr_IS_IN_RUN))
1800  {
1801  src_->pTheta1()->setD(src_->dTauS_dTheta1(activeObs()->getReferenceFrequency()*1.0e6,
1802  activeObs()->getUvFrPerAsec(0)*scl, activeObs()->getUvFrPerAsec(1)*scl));
1803  parameters_.append(src_->pTheta1());
1804  };
1805 //--
1806 
1807  }
1808  else if (src_->getSmtType() == SgVlbiSourceInfo::SMT_MULTIPLE_POINTS)
1809 */
1810  {
1811  // multipoint SS-model:
1812  if (cfg->getHave2ApplySourceSsm() &&
1813  src_->getIsSsModelEstimating() && src_->sModel().size())
1814  {
1816  activeObs()->getReferenceFrequency()*1.0e6,
1817  activeObs()->getUvFrPerAsec(0)*scl,
1818  activeObs()->getUvFrPerAsec(1)*scl);
1819  };
1820  };
1821  };
1822  //
1823 
1824  // Baseline:
1826  {
1827  baseline_->pClock()->setD(1.0);
1828  parameters_.append(baseline_->pClock());
1829  };
1831  {
1832  baseline_->pBx()->setD(getDdel_dR_2().at(X_AXIS));
1833  baseline_->pBy()->setD(getDdel_dR_2().at(Y_AXIS));
1834  baseline_->pBz()->setD(getDdel_dR_2().at(Z_AXIS));
1835  parameters_.append(baseline_->pBx());
1836  parameters_.append(baseline_->pBy());
1837  parameters_.append(baseline_->pBz());
1838  };
1839  // EOP:
1840  // UT1:
1842  {
1843  session_->pUT1()->setD(getDdel_dUT1());
1844  parameters_.append(session_->pUT1());
1845  };
1847  {
1848  session_->pUT1Rate()->setD(getDdel_dUT1()*dt1);
1849  parameters_.append(session_->pUT1Rate());
1850  };
1851  // P_x & P_y:
1853  {
1856  parameters_.append(session_->pPolusX());
1857  parameters_.append(session_->pPolusY());
1858  };
1859  // rates of P_x & P_y:
1861  {
1862  session_->pPolusXRate()->setD(getDdel_dPx()*dt1);
1863  session_->pPolusYRate()->setD(getDdel_dPy()*dt1);
1864  parameters_.append(session_->pPolusXRate());
1865  parameters_.append(session_->pPolusYRate());
1866  };
1867  // CIP_X & CIP_Y:
1869  {
1872  parameters_.append(session_->pNutX());
1873  parameters_.append(session_->pNutY());
1874  };
1875  // rates of CIP_X & CIP_Y:
1877  {
1878  session_->pNutXRate()->setD(getDdel_dCipX()*dt1);
1879  session_->pNutYRate()->setD(getDdel_dCipY()*dt1);
1880  parameters_.append(session_->pNutXRate());
1881  parameters_.append(session_->pNutYRate());
1882  };
1883 
1884  // notify PWLs:
1885  for (int i=0; i<parameters_.size(); i++)
1886  parameters_.at(i)->setDataDomain(SgPartial::DD_OFFSET);
1887 };
1888 
1889 
1890 
1891 //
1893 {
1894  QString str;
1895  double dt1=(*this - session_->tRefer());
1896  double dt2=(dt1 + getCalcConsensusDelay()/DAY2SEC);
1897  SgTaskConfig *cfg=mgr->getTask()->config();
1898  parameters_.clear();
1899 
1900 
1901  // partials for clocks:
1902  int nCl;
1903  nCl = mgr->getTask()->parameters()->getClock0Mode()==SgParameterCfg::PM_STC ? 1 :
1905 
1906  // special case:
1909  {
1911  {
1912  stn_1_->pClocks(0)->setD(-1.0/DAY2SEC);
1913  parameters_.append(stn_1_->pClocks(0));
1914  };
1915  // station #2:
1917  {
1918  stn_2_->pClocks(0)->setD( 1.0/DAY2SEC);
1919  parameters_.append(stn_2_->pClocks(0));
1920  };
1921  };
1922  //
1923  //
1924  double d1, d2;
1925  d1 = d2 = 1.0;
1926  for (int i=1; i<nCl; i++)
1927  {
1928  // station #1:
1930  {
1931  stn_1_->pClocks(i)->setD(-i*d1/DAY2SEC);
1932  parameters_.append(stn_1_->pClocks(i));
1933  };
1934  // station #2:
1936  {
1937  stn_2_->pClocks(i)->setD( i*d2/DAY2SEC);
1938  parameters_.append(stn_2_->pClocks(i));
1939  };
1940  d1 *= dt1 /* /DAY2SEC */;
1941  d2 *= dt2 /* /DAY2SEC */;
1942  };
1943  // clock breaks:
1944  if (stn_1_->clockBreaks().size())
1946  if (stn_2_->clockBreaks().size())
1948  //
1949  //
1950  // troposphere:
1951  //
1952  if (auxObs_1_ && auxObs_2_)
1953  {
1954 // double dDryZd_1, dDryZd_2, dWetZd_1, dWetZd_2;
1955 // double dDryMf_1, dDryMf_2, dWetMf_1, dWetMf_2;
1956 // double rDryMf_1, rDryMf_2, rWetMf_1, rWetMf_2;
1957  double rWetMf_1, rWetMf_2;
1958 // if (!cfg->getHave2ApplyNdryContrib() || !cfg->getHave2ApplyNwetContrib())
1959  rWetMf_1 = rWetMf_2 = 0.0;
1961  {
1964 // dDryZd_1 = mgr->refraction()->dDryZD();
1965 // dWetZd_1 = mgr->refraction()->dWetZD();
1966 // dDryMf_1 = mgr->refraction()->dDryMF();
1967 // dWetMf_1 = mgr->refraction()->dWetMF();
1968 // rDryMf_1 = mgr->refraction()->dryMappingFunction()->dM_dE();
1969  rWetMf_1 = mgr->refraction()->wetMappingFunction()->dM_dE();
1970 
1973 // dDryZd_2 = mgr->refraction()->dDryZD();
1974 // dWetZd_2 = mgr->refraction()->dWetZD();
1975 // dDryMf_2 = mgr->refraction()->dDryMF();
1976 // dWetMf_2 = mgr->refraction()->dWetMF();
1977 // rDryMf_2 = mgr->refraction()->dryMappingFunction()->dM_dE();
1978  rWetMf_2 = mgr->refraction()->wetMappingFunction()->dM_dE();
1979  };
1980  //
1981  //
1982  // hydrostatic part: partials to the gradients:
1983  if (session_->hasGradPartials()) // from contributions:
1984  {
1986  {
1989  parameters_.append(stn_1_->pAtmGradN());
1990  parameters_.append(stn_1_->pAtmGradE());
1991  };
1993  {
1996  parameters_.append(stn_2_->pAtmGradN());
1997  parameters_.append(stn_2_->pAtmGradE());
1998  };
1999  };
2000 /*
2001  else // from "flyby":
2002  {
2003  if (stn_1_->pAtmGradN()->isAttr(SgPartial::Attr_IS_IN_RUN))
2004  {
2005  stn_1_->pAtmGradN()->setD(-cos(auxObs_1_->getAzimuthAngle())*dGrdMf_1/vLight);
2006  stn_1_->pAtmGradE()->setD(-sin(auxObs_1_->getAzimuthAngle())*dGrdMf_1/vLight);
2007  parameters_.append(stn_1_->pAtmGradN());
2008  parameters_.append(stn_1_->pAtmGradE());
2009 std::cout << qPrintable(baseline_->getKey() + " @" + src_->getKey() + " " + toString(SgMJD::F_Simple))
2010  << ": FLYBY gradN_1=" << stn_1_->pAtmGradN()->getD()
2011  << " gradE_1=" << stn_1_->pAtmGradE()->getD()
2012  << "\n";
2013  };
2014  if (stn_2_->pAtmGradN()->isAttr(SgPartial::Attr_IS_IN_RUN))
2015  {
2016  stn_2_->pAtmGradN()->setD( cos(auxObs_2_->getAzimuthAngle())*dGrdMf_2/vLight);
2017  stn_2_->pAtmGradE()->setD( sin(auxObs_2_->getAzimuthAngle())*dGrdMf_2/vLight);
2018  parameters_.append(stn_2_->pAtmGradN());
2019  parameters_.append(stn_2_->pAtmGradE());
2020 std::cout << qPrintable(baseline_->getKey() + " @" + src_->getKey() + " " + toString(SgMJD::F_Simple))
2021  << ": FLYBY gradN_2=" << stn_2_->pAtmGradN()->getD()
2022  << " gradE_2=" << stn_2_->pAtmGradE()->getD()
2023  << "\n";
2024  };
2025  };
2026 */
2027  //
2028  //
2029  // wet part: partials to the wet zenith delays:
2030  if (cfg->getHave2ApplyNwetContrib()) // from contributions:
2031  {
2033  {
2035  parameters_.append(stn_1_->pZenithDelay());
2036  };
2038  {
2040  parameters_.append(stn_2_->pZenithDelay());
2041  };
2044  }
2045  else // from "flyby":
2046  {
2048  {
2050  parameters_.append(stn_1_->pZenithDelay());
2051  };
2053  {
2055  parameters_.append(stn_2_->pZenithDelay());
2056  };
2059  };
2060  };
2061 
2062  // Station #1:
2064  {
2065  stn_1_->pRx()->setD( getDrat_dR_1().at(X_AXIS));
2066  stn_1_->pRy()->setD( getDrat_dR_1().at(Y_AXIS));
2067  stn_1_->pRz()->setD( getDrat_dR_1().at(Z_AXIS));
2068  parameters_.append(stn_1_->pRx());
2069  parameters_.append(stn_1_->pRy());
2070  parameters_.append(stn_1_->pRz());
2071  };
2072 
2073  // Station #2:
2075  {
2076  stn_2_->pRx()->setD( getDrat_dR_2().at(X_AXIS));
2077  stn_2_->pRy()->setD( getDrat_dR_2().at(Y_AXIS));
2078  stn_2_->pRz()->setD( getDrat_dR_2().at(Z_AXIS));
2079  parameters_.append( stn_2_->pRx());
2080  parameters_.append( stn_2_->pRy());
2081  parameters_.append( stn_2_->pRz());
2082  };
2083 
2084  // Axis offsets:
2086  {
2088  parameters_.append(stn_1_->pAxisOffset());
2089  };
2091  {
2093  parameters_.append(stn_2_->pAxisOffset());
2094  };
2095  // Source:
2097  {
2098  src_->pRA()->setD(getDrat_dRA());
2099  src_->pDN()->setD(getDrat_dDN());
2100  parameters_.append(src_->pRA());
2101  parameters_.append(src_->pDN());
2102  };
2103 
2104  // Baseline:
2106  {
2107  baseline_->pBx()->setD(getDrat_dR_2().at(X_AXIS));
2108  baseline_->pBy()->setD(getDrat_dR_2().at(Y_AXIS));
2109  baseline_->pBz()->setD(getDrat_dR_2().at(Z_AXIS));
2110  parameters_.append(baseline_->pBx());
2111  parameters_.append(baseline_->pBy());
2112  parameters_.append(baseline_->pBz());
2113  };
2114  // EOP:
2115  // UT1:
2117  {
2118  session_->pUT1()->setD(getDrat_dUT1());
2119  parameters_.append(session_->pUT1());
2120  };
2122  {
2123  session_->pUT1Rate()->setD(getDrat_dUT1()*dt1);
2124  parameters_.append(session_->pUT1Rate());
2125  };
2126  // P_x & P_y:
2128  {
2131  parameters_.append(session_->pPolusX());
2132  parameters_.append(session_->pPolusY());
2133  };
2134  // rates of P_x & P_y:
2136  {
2137  session_->pPolusXRate()->setD(getDrat_dPx()*dt1);
2138  session_->pPolusYRate()->setD(getDrat_dPy()*dt1);
2139  parameters_.append(session_->pPolusXRate());
2140  parameters_.append(session_->pPolusYRate());
2141  };
2142  // CIP_X & CIP_Y:
2144  {
2147  parameters_.append(session_->pNutX());
2148  parameters_.append(session_->pNutY());
2149  };
2150  // rates of CIP_X & CIP_Y:
2152  {
2153  session_->pNutXRate()->setD(getDrat_dCipX()*dt1);
2154  session_->pNutYRate()->setD(getDrat_dCipY()*dt1);
2155  parameters_.append(session_->pNutXRate());
2156  parameters_.append(session_->pNutYRate());
2157  };
2158 
2159  // notify PWLs:
2160  for (int i=0; i<parameters_.size(); i++)
2161  parameters_.at(i)->setDataDomain(SgPartial::DD_RATE);
2162 };
2163 
2164 
2165 
2166 //
2168 {
2169  if (isDelete)
2171  else
2173  return true;
2174 };
2175 
2176 
2177 
2178 //
2180 {
2181  QString str;
2182  double dT=0.0;
2184 
2185  dD = dR = 0.0;
2186 
2188  dT = session_->tRefer() - t0;
2189  else
2190  dT = *this - t0;
2191 
2192  Sg3dVector dR1_ea(stn_1_->getR_ea() + stn_1_->getV_ea()*dT);
2193  Sg3dVector dR2_ea(stn_2_->getR_ea() + stn_2_->getV_ea()*dT);
2194  Sg3dVector dR1 = stn_1_->getR() - dR1_ea;
2195  Sg3dVector dR2 = stn_2_->getR() - dR2_ea;
2196 
2197  // the signs for the first station are already reverted:
2198  dD = getDdel_dR_1()*dR1 + getDdel_dR_2()*dR2;
2199  dR = getDrat_dR_1()*dR1 + getDrat_dR_2()*dR2;
2200 
2201 #ifdef DBG_MODE_2_
2203  {
2204  str.sprintf("Epoch : %s", qPrintable(toString()));
2205  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2206  str.sprintf("T0 : %s", qPrintable(t0.toString()));
2207  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2208  str.sprintf("difference: %14.8f (days)", dT);
2209  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2210 
2211  // stn #1
2212  str.sprintf("St_1, database positions: %13.4f %13.4f %13.4f",
2213  stn_1_->getR().at(X_AXIS),
2214  stn_1_->getR().at(Y_AXIS),
2215  stn_1_->getR().at(Z_AXIS));
2216  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2217  str.sprintf("St_1, e.a.file positions: %13.4f %13.4f %13.4f",
2218  stn_1_->getR_ea().at(X_AXIS),
2219  stn_1_->getR_ea().at(Y_AXIS),
2220  stn_1_->getR_ea().at(Z_AXIS));
2221  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2222  str.sprintf("St_1, e.a.file velocity : %13.10f %13.10f %13.10f (mm/yr)",
2223  stn_1_->getV_ea().at(X_AXIS)*1000.0*365.25,
2224  stn_1_->getV_ea().at(Y_AXIS)*1000.0*365.25,
2225  stn_1_->getV_ea().at(Z_AXIS)*1000.0*365.25);
2226  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2227  str.sprintf("St_1, e.a.file velocity : %13.10f %13.10f %13.10f (m/d)",
2228  stn_1_->getV_ea().at(X_AXIS),
2229  stn_1_->getV_ea().at(Y_AXIS),
2230  stn_1_->getV_ea().at(Z_AXIS));
2231  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2232  str.sprintf("St_1, e.a.position at t : %13.4f %13.4f %13.4f",
2233  dR1_ea.at(X_AXIS), dR1_ea.at(Y_AXIS), dR1_ea.at(Z_AXIS));
2234  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2235  str.sprintf("St_1, difference db-e.a : %10.7f %10.7f %10.7f",
2236  dR1.at(X_AXIS), dR1.at(Y_AXIS), dR1.at(Z_AXIS));
2237  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2238 
2239  // stn #2
2240  str.sprintf("St_2, database positions: %13.4f %13.4f %13.4f",
2241  stn_2_->getR().at(X_AXIS),
2242  stn_2_->getR().at(Y_AXIS),
2243  stn_2_->getR().at(Z_AXIS));
2244  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2245  str.sprintf("St_2, e.a.file positions: %13.4f %13.4f %13.4f",
2246  stn_2_->getR_ea().at(X_AXIS),
2247  stn_2_->getR_ea().at(Y_AXIS),
2248  stn_2_->getR_ea().at(Z_AXIS));
2249  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2250  str.sprintf("St_2, e.a.file velocity : %13.10f %13.10f %13.10f (mm/yr)",
2251  stn_2_->getV_ea().at(X_AXIS)*1000.0*365.25,
2252  stn_2_->getV_ea().at(Y_AXIS)*1000.0*365.25,
2253  stn_2_->getV_ea().at(Z_AXIS)*1000.0*365.25);
2254  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2255  str.sprintf("St_2, e.a.file velocity : %13.10f %13.10f %13.10f (m/d)",
2256  stn_2_->getV_ea().at(X_AXIS),
2257  stn_2_->getV_ea().at(Y_AXIS),
2258  stn_2_->getV_ea().at(Z_AXIS));
2259  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2260 
2261  str.sprintf("St_2, e.a.position at t : %13.4f %13.4f %13.4f",
2262  dR2_ea.at(X_AXIS), dR2_ea.at(Y_AXIS), dR2_ea.at(Z_AXIS));
2263  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2264 
2265  str.sprintf("St_2, difference db-e.a : %10.7f %10.7f %10.7f",
2266  dR2.at(X_AXIS), dR2.at(Y_AXIS), dR2.at(Z_AXIS));
2267  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2268 
2269  str.sprintf("Partials, dTau/dSt_1_i: %20.12g %20.12g %20.12g",
2270  getDdel_dR_1().at(X_AXIS),
2271  getDdel_dR_1().at(Y_AXIS),
2272  getDdel_dR_1().at(Z_AXIS));
2273  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2274 
2275  str.sprintf("Partials, dTau/dSt_2_i: %20.12g %20.12g %20.12g",
2276  getDdel_dR_2().at(X_AXIS),
2277  getDdel_dR_2().at(Y_AXIS),
2278  getDdel_dR_2().at(Z_AXIS));
2279  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2280 
2281  str.sprintf("Resulted correction (ps): %8.4f", dD*1.0e12);
2282  logger->write(SgLogger::DBG, SgLogger::DELAY, className() + ": site position mapping: " + str);
2283  };
2284 #endif
2285 
2286  return;
2287 };
2288 
2289 
2290 
2291 //
2292 void SgVlbiObservation::evalExtApriori_SrcPos(double& dD, double& dR)
2293 {
2294  dD = getDdel_dRA()*(src_->getRA() - src_->getRA_ea()) +
2295  getDdel_dDN()*(src_->getDN() - src_->getDN_ea()) ;
2296  dR = getDrat_dRA()*(src_->getRA() - src_->getRA_ea()) +
2297  getDrat_dDN()*(src_->getDN() - src_->getDN_ea()) ;
2298 };
2299 
2300 
2301 
2302 //
2303 void SgVlbiObservation::evalExtApriori_AxsOfs(double& dD, double& dR)
2304 {
2305  dD = dR = 0.0;
2306  if (auxObs_1_ && auxObs_2_)
2307  {
2312  };
2313 };
2314 
2315 
2316 
2317 //
2319 {
2320  dD = dR = 0.0;
2321  if (session_->hasGradPartials())
2322  {
2327  dD /= -1.0*vLight;
2332  dD /= -1.0*vLight;
2333  }
2334  else
2335  {
2336 // c = (stn_2_->getGradientDelay() - stn_1_->getGradientDelay());
2337  };
2338  //
2340 // return -c/vLight;
2341 };
2342 
2343 
2344 
2345 //
2347 {
2348  for (QMap<QString, SgVlbiObservable*>::iterator it=observableByKey_.begin();
2349  it!=observableByKey_.end(); ++it)
2350  it.value()->zerofyIono();
2351 };
2352 
2353 
2354 
2355 //
2357 {
2358  if (observableByKey_.size()!=2)
2359  {
2360  if (!cfg && observableByKey_.size()>2)
2362  ": calcIonoCorrections(): cannot calculate, number of bands (" +
2363  QString("").setNum(observableByKey_.size()) + ") is not equal 2; " +
2364  baseline_->getKey() + " on " + src_->getKey());
2365  return;
2366  };
2367 
2368  bool isSimpleMode=(cfg?false:true);
2369  bool hasEffFreqs=true;
2370  double coeff4SB = 0.0;
2371  double coeff4GR = 0.0;
2372  double coeff4GRp= 0.0;
2373  double coeff4PH = 0.0;
2374  double coeff4RT = 0.0;
2375  double sbdQ=0.0, grdQ=0.0, phrQ=0.0;
2376  SgVlbiObservable *o[2];
2377  double corr4SB[2];
2378  double corr4GR[2];
2379  double dClB4GR[2];
2380  double corr4PH[2];
2381  double corr4RT[2];
2382  double sigma4SB[2];
2383  double sigma4GR[2];
2384  double sigma4PH[2];
2385  double sigma4RT[2];
2386  int idx;
2387  double sDif, xDif, rDif, pDif;
2388 
2389  for (int i=0; i<2; i++)
2390  {
2391  o[i] = NULL;
2392  corr4SB[i] = corr4GR[i] = corr4PH[i] = corr4RT[i] = sigma4SB[i] = sigma4GR[i] =
2393  sigma4PH[i] = sigma4RT[i] = 0.0;
2394  dClB4GR[i] = (stn_2_->clockBreaks().value(*this) - stn_1_->clockBreaks().value(*this))*1.0e-09;
2395 
2396  /*
2397  if (o[i]->grDelay().getEffFreq() <= 0.0)
2398  {
2399  hasEffFreqs = false;
2400  logger->write(SgLogger::WRN, SgLogger::IONO, className() +
2401  ": calcIonoCorrections(): cannot calculate, the group delay ionosphere effective frequency is "
2402  "zero on " + o[i]->strId());
2403  }
2404  if (o[i]->phDelay().getEffFreq() <= 0.0)
2405  {
2406  hasEffFreqs = false;
2407  logger->write(SgLogger::WRN, SgLogger::IONO, className() +
2408  ": calcIonoCorrections(): cannot calculate, the phase delay ionosphere effective frequency is "
2409  "zero on " + o[i]->strId());
2410  }
2411  if (o[i]->phDRate().getEffFreq() <= 0.0)
2412  {
2413  hasEffFreqs = false;
2414  logger->write(SgLogger::WRN, SgLogger::IONO, className() +
2415  ": calcIonoCorrections(): cannot calculate, the phase rate ionosphere effective frequency is "
2416  "zero on " + o[i]->strId());
2417  }
2418  */
2419  };
2420  //
2421 
2422 
2423  QMap<double, SgVlbiObservable*>
2424  observableByFrq;
2425  QMap<QString, SgVlbiObservable*>::iterator
2426  it_name;
2427  idx = 0;
2428  for (it_name=observableByKey_.begin(); it_name!=observableByKey_.end() && idx<2; ++it_name, idx++)
2429  {
2430  SgVlbiObservable* oo=it_name.value();
2431  if (observableByFrq.contains(oo->getReferenceFrequency()))
2432  {
2434  ": calcIonoCorrections(): cannot calculate, the reference frequency is the same for two bands "
2435  " on " + oo->strId());
2436  return;
2437  }
2438  else
2439  observableByFrq.insert(oo->getReferenceFrequency(), oo);
2440 
2441  if (oo->grDelay().getEffFreq() <= 0.0)
2442  {
2443  hasEffFreqs = false;
2445  ": calcIonoCorrections(): cannot calculate, the group delay ionosphere effective frequency is "
2446  "zero on " + oo->strId());
2447  }
2448  if (oo->phDelay().getEffFreq() <= 0.0)
2449  {
2450  hasEffFreqs = false;
2452  ": calcIonoCorrections(): cannot calculate, the phase delay ionosphere effective frequency is "
2453  "zero on " + oo->strId());
2454  }
2455  if (oo->phDRate().getEffFreq() <= 0.0)
2456  {
2457  hasEffFreqs = false;
2459  ": calcIonoCorrections(): cannot calculate, the phase rate ionosphere effective frequency is "
2460  "zero on " + oo->strId());
2461  }
2462  };
2463  if (!hasEffFreqs)
2464  return;
2465 
2466 
2467  idx = 0;
2468  QMap<double, SgVlbiObservable*>::iterator it_frq;
2469  for (it_frq=observableByFrq.begin(); it_frq!=observableByFrq.end() && idx<2; ++it_frq, idx++)
2470  {
2471  SgVlbiObservable *obs=it_frq.value();
2472  o[idx] = obs;
2473  SgVlbiStationInfo *stn1=obs->stn_1();
2474  SgVlbiStationInfo *stn2=obs->stn_2();
2475  if (stn1 && stn2)
2476  dClB4GR[idx] += (stn2->clockBreaks().value(*this) - stn1->clockBreaks().value(*this))*1.0e-09;
2477  };
2478 
2479  // 0 -> S
2480  // 1 -> X
2481  /*
2482  if (false)
2483  {
2484  coeff4GR = o[0]->getReferenceFrequency()*o[0]->getReferenceFrequency()/
2485  (o[1]->getReferenceFrequency()*o[1]->getReferenceFrequency() -
2486  o[0]->getReferenceFrequency()*o[0]->getReferenceFrequency());
2487  }
2488  else
2489  {
2490  coeff4GR = o[0]->grDelay().getEffFreq()*o[0]->grDelay().getEffFreq()/
2491  (o[1]->grDelay().getEffFreq()*o[1]->grDelay().getEffFreq() -
2492  o[0]->grDelay().getEffFreq()*o[0]->grDelay().getEffFreq());
2493  };
2494  */
2495 
2496  coeff4GR = o[0]->grDelay().getEffFreq()*o[0]->grDelay().getEffFreq()/
2497  (o[1]->grDelay().getEffFreq()*o[1]->grDelay().getEffFreq() -
2498  o[0]->grDelay().getEffFreq()*o[0]->grDelay().getEffFreq());
2499  coeff4PH = o[0]->phDelay().getEffFreq()*o[0]->phDelay().getEffFreq()/
2500  (o[1]->phDelay().getEffFreq()*o[1]->phDelay().getEffFreq() -
2501  o[0]->phDelay().getEffFreq()*o[0]->phDelay().getEffFreq());
2502  coeff4RT = o[0]->phDRate().getEffFreq()*o[0]->phDRate().getEffFreq()/
2503  (o[1]->phDRate().getEffFreq()*o[1]->phDRate().getEffFreq() -
2504  o[0]->phDRate().getEffFreq()*o[0]->phDRate().getEffFreq());
2505  coeff4GRp= (1.0 + coeff4GR)/coeff4GR;
2506  coeff4SB = coeff4GR;
2507 
2508  sDif = o[1]->sbDelay().getValue() - o[0]->sbDelay().getValue();
2509  xDif = o[1]->grDelay().getValue() + o[1]->grDelay().ambiguity() -
2510  (o[0]->grDelay().getValue() + o[0]->grDelay().ambiguity()) - (dClB4GR[1] - dClB4GR[0]);
2511  pDif = o[1]->phDelay().getValue() + o[1]->phDelay().ambiguity() -
2512  (o[0]->phDelay().getValue() + o[0]->phDelay().ambiguity());
2513  rDif = o[1]->phDRate().getValue() - o[0]->phDRate().getValue();
2514 
2515  o[1]->grDelay().setQ2(coeff4GR);
2516  o[0]->grDelay().setQ2(o[1]->grDelay().getEffFreq()*o[1]->grDelay().getEffFreq()/
2517  (o[0]->grDelay().getEffFreq()*o[0]->grDelay().getEffFreq() -
2518  o[1]->grDelay().getEffFreq()*o[1]->grDelay().getEffFreq()));
2519  o[1]->setSbdDiffBand(-sDif); // opposite band with respect to this one
2520  o[0]->setSbdDiffBand( sDif);
2521  o[1]->setGrdDiffBand(-xDif);
2522  o[0]->setGrdDiffBand( xDif);
2523  o[1]->setPhrDiffBand(-rDif);
2524  o[0]->setPhrDiffBand( rDif);
2525 
2526  sbdQ = o[1]->phDelay().getEffFreq()*o[1]->phDelay().getEffFreq()*
2527  o[0]->phDelay().getEffFreq()*o[0]->phDelay().getEffFreq()/
2528  (o[1]->phDelay().getEffFreq()*o[1]->phDelay().getEffFreq() -
2529  o[0]->phDelay().getEffFreq()*o[0]->phDelay().getEffFreq())*sDif;
2530 /*
2531  if (false)
2532  {
2533  grdQ = o[1]->getReferenceFrequency()*o[1]->getReferenceFrequency()*
2534  o[0]->getReferenceFrequency()*o[0]->getReferenceFrequency()/
2535  (o[1]->getReferenceFrequency()*o[1]->getReferenceFrequency() -
2536  o[0]->getReferenceFrequency()*o[0]->getReferenceFrequency())*xDif;
2537  }
2538  else
2539  {
2540  grdQ = o[1]->grDelay().getEffFreq()*o[1]->grDelay().getEffFreq()*
2541  o[0]->grDelay().getEffFreq()*o[0]->grDelay().getEffFreq()/
2542  (o[1]->grDelay().getEffFreq()*o[1]->grDelay().getEffFreq() -
2543  o[0]->grDelay().getEffFreq()*o[0]->grDelay().getEffFreq())*xDif;
2544  };
2545 */
2546  grdQ = o[1]->grDelay().getEffFreq()*o[1]->grDelay().getEffFreq()*
2547  o[0]->grDelay().getEffFreq()*o[0]->grDelay().getEffFreq()/
2548  (o[1]->grDelay().getEffFreq()*o[1]->grDelay().getEffFreq() -
2549  o[0]->grDelay().getEffFreq()*o[0]->grDelay().getEffFreq())*xDif;
2550  phrQ = o[1]->phDRate().getEffFreq()*o[1]->phDRate().getEffFreq()*
2551  o[0]->phDRate().getEffFreq()*o[0]->phDRate().getEffFreq()/
2552  (o[1]->phDRate().getEffFreq()*o[1]->phDRate().getEffFreq() -
2553  o[0]->phDRate().getEffFreq()*o[0]->phDRate().getEffFreq())*rDif;
2554 
2555  o[1]->setSbdQ(sbdQ);
2556  o[0]->setSbdQ(sbdQ);
2557  o[1]->setGrdQ(grdQ);
2558  o[0]->setGrdQ(grdQ);
2559  o[1]->setPhrQ(phrQ);
2560  o[0]->setPhrQ(phrQ);
2561 
2562  if (!isSimpleMode)
2563  {
2564  corr4GR[1] = - coeff4GR*xDif;
2565  corr4RT[1] = - coeff4RT*rDif;
2566  corr4PH[1] = - coeff4PH*pDif;
2567  corr4GR[0] = - (1.0 + coeff4GR)*xDif;
2568  corr4RT[0] = - (1.0 + coeff4RT)*rDif;
2569  corr4PH[0] = - (1.0 + coeff4PH)*pDif;
2570 
2571 // sigma4GR[1] = coeff4GR*sqrt(o[1]->getSigmaGroupDelay()*o[1]->getSigmaGroupDelay() +
2572 // o[0]->getSigmaGroupDelay()*o[0]->getSigmaGroupDelay());
2573 
2574  sigma4GR[1] = coeff4GR*sqrt(
2575  o[1]->grDelay().getSigma()*o[1]->grDelay().getSigma()*(coeff4GR + 2.0)/coeff4GR +
2576  o[0]->grDelay().getSigma()*o[0]->grDelay().getSigma());
2577 
2578 // sigma4GR[1] = coeff4GR*sqrt(
2579 // o[1]->getSigmaGroupDelay()*o[1]->getSigmaGroupDelay() +
2580 // o[0]->getSigmaGroupDelay()*o[0]->getSigmaGroupDelay() +
2581 // 2.0*o[1]->getSigmaGroupDelay()*o[1]->getSigmaGroupDelay()/coeff4GR
2582 // );
2583 
2584  sigma4RT[1] = coeff4GR*sqrt(o[1]->phDRate().getSigma()*o[1]->phDRate().getSigma() +
2585  o[0]->phDRate().getSigma()*o[0]->phDRate().getSigma());
2586  sigma4PH[1] = coeff4PH*sqrt(o[1]->phDelay().getSigma()*o[1]->phDelay().getSigma() +
2587  o[0]->phDelay().getSigma()*o[0]->phDelay().getSigma());
2588  sigma4GR[0] = coeff4GRp*sigma4GR[1];
2589  sigma4RT[0] = coeff4GRp*sigma4RT[1];
2590  sigma4PH[0] = coeff4GRp*sigma4PH[1];
2591  };
2592 
2593  corr4SB[1] = - coeff4SB*sDif;
2594  corr4SB[0] = - (1.0 + coeff4SB)*sDif;
2595  sigma4SB[1] = coeff4SB*sqrt(o[1]->sbDelay().getSigma()*o[1]->sbDelay().getSigma() +
2596  o[0]->sbDelay().getSigma()*o[0]->sbDelay().getSigma());
2597  sigma4SB[0] = (1.0 + coeff4SB)/coeff4SB*sigma4SB[1];
2598 
2599  o[1]->sbDelay().setIonoValue(corr4SB[1]);
2600  o[1]->sbDelay().setIonoSigma(sigma4SB[1]);
2601  o[0]->sbDelay().setIonoValue(corr4SB[0]);
2602  o[0]->sbDelay().setIonoSigma(sigma4SB[0]);
2603 
2604  if (!isSimpleMode)
2605  {
2606  o[1]->grDelay().setIonoValue(corr4GR[1]);
2607  o[1]->grDelay().setIonoSigma(sigma4GR[1]);
2608  o[0]->grDelay().setIonoValue(corr4GR[0]);
2609  o[0]->grDelay().setIonoSigma(sigma4GR[0]);
2610 
2611  o[1]->phDRate().setIonoValue(corr4RT[1]);
2612  o[1]->phDRate().setIonoSigma(sigma4RT[1]);
2613  o[0]->phDRate().setIonoValue(corr4RT[0]);
2614  o[0]->phDRate().setIonoSigma(sigma4RT[0]);
2615 
2616  o[1]->phDelay().setIonoValue(corr4PH[1]);
2617  o[1]->phDelay().setIonoSigma(sigma4PH[1]);
2618  o[0]->phDelay().setIonoValue(corr4PH[0]);
2619  o[0]->phDelay().setIonoSigma(sigma4PH[0]);
2620  };
2621  //
2622  return;
2623 };
2624 
2625 
2626 
2627 //
2629 {
2631  // delAttr(Attr_PROCESSED);
2636  for (QMap<QString, SgVlbiObservable*>::iterator it=observableByKey_.begin();
2637  it!=observableByKey_.end(); ++it)
2638  it.value()->resetAllEditings();
2639 };
2640 
2641 
2642 
2643 //
2645 {
2646  s << key_ << getAttributes() << observableByKey_.size();
2647  for (QMap<QString, SgVlbiObservable*>::const_iterator it=observableByKey_.begin();
2648  it!=observableByKey_.end(); ++it)
2649  if (s.status() == QDataStream::Ok)
2650  it.value()->saveIntermediateResults(s);
2651  else
2652  return false;
2653 
2654  return s.status() == QDataStream::Ok;
2655 };
2656 
2657 
2658 
2659 //
2661 {
2662  QString key;
2663  int num;
2664  unsigned int attributes;
2665  s >> key >> attributes >> num;
2666  if (s.status() != QDataStream::Ok)
2667  {
2669  ": loadIntermediateResults(): error reading data: " +
2670  (s.status()==QDataStream::ReadPastEnd?"read past end of the file":"read corrupt data"));
2671  return false;
2672  };
2673  if (key_ != key)
2674  {
2676  ": loadIntermediateResults(): error reading data: bandKey mismatch: got [" + key +
2677  "], expected [" + key_ + "]");
2678  return false;
2679  };
2680  setAttributes(attributes);
2681  if (num != observableByKey_.size())
2682  {
2684  ": loadIntermediateResults(): error reading data: observableByKey_ size mismatch: got [" +
2685  QString("").setNum(num) + "], expected [" + QString("").setNum(observableByKey_.size()) + "]");
2686  return false;
2687  };
2688  for (QMap<QString, SgVlbiObservable*>::iterator it=observableByKey_.begin();
2689  it!=observableByKey_.end(); ++it)
2690  {
2691  if (s.status() == QDataStream::Ok)
2692  it.value()->loadIntermediateResults(s);
2693  else
2694  {
2696  ": loadIntermediateResults(): error reading data for the " + it.value()->getBandKey() +
2697  "-band of " + key_);
2698  return false;
2699  };
2700  };
2701  return s.status()==QDataStream::Ok;
2702 };
2703 
2704 
2705 
2706 //
2708 {
2709  int bits;
2710  bits = 0;
2711 
2712  if (!primeObs_)
2713  {
2715  ": calculateIonoBits(): the prime band obs is NULL");
2716  return bits;
2717  };
2718  if (observableByKey_.size()!=2)
2719  {
2720  if (2 < observableByKey_.size())
2722  ": calculateIonoBits(): cannot calculate, number of bands (" +
2723  QString("").setNum(observableByKey_.size()) + ") is not equal 2; " +
2724  baseline_->getKey() + " on " + src_->getKey());
2725  return bits;
2726  };
2727  SgVlbiObservable *secObs=NULL;
2728  for (QMap<QString, SgVlbiObservable*>::iterator it=observableByKey_.begin();
2729  it!=observableByKey_.end(); ++it)
2730  {
2731  if (it.value()->getBandKey() != primeObs_->getBandKey())
2732  secObs = it.value();
2733  };
2734  //
2735  // ! Apply to corrections using group delay:
2736  // ! 0001 1 Matching obs has quality code of
2737  // ! 8 or 9, but was unweighted by SOLVE
2738  // ! 0002 2 No matching group data for GION
2739  // ! 0004 3 Matching obs has quality code of
2740  // ! 1 to 7 (not used after 2001.01.17)
2741  // ! 0010 4 GION correction available
2742  // ! 0020 5 Downweight flag for GION (replaces IUNW=8)
2743  // ! (can be reset by other programs only if
2744  // ! bits 2 and 6 are not turned on)
2745  // ! ( not used after 2001.01.17 )
2746  // ! 0040 6 Matching obs has quality code of
2747  // ! 0 ("no fringes")
2748  // !
2749  // ! Apply to corrections using phase delay:
2750  // ! 0100 7 Matching obs has quality code of
2751  // ! 8 or 9, but was unweighted by SOLVE
2752  // ! 0200 8 No matching phase data for PHION
2753  // ! 0400 9 Matching obs has quality code of
2754  // ! 1 to 7
2755  // ! 1000 10 PHION correction available
2756  // ! 2000 11 Downweight flag for PHION (replaces IUNW=8)
2757  // ! (can be reset by other programs only if
2758  // ! bits 8 and 12 are not turned on)
2759  // ! 4000 12 Matching obs has quality code of
2760  // ! 0 ("no fringes")
2761 
2762  // currently, only group delays are reported:
2763  if (0.0 < primeObs_->grDelay().getIonoSigma())
2764  bits |= 1<<3;
2765 
2766  if (!secObs)
2767  bits |= 1<<1;
2768  else
2769  {
2770  int qCode4MatchedObs=secObs->getQualityFactor();
2771  if (7<qCode4MatchedObs && isAttr(Attr_NOT_VALID))
2772  bits |= 1<<0;
2773  else if (qCode4MatchedObs <= 0)
2774  bits |= 1<<5;
2775  };
2776  return bits;
2777 };
2778 
2779 
2780 
2781 
2782 
2783 /*=====================================================================================================*/
2784 
2785 
2786 
2787 
2788 /*=====================================================================================================*/
2789 //
2790 // FRIENDS:
2791 //
2792 /*=====================================================================================================*/
2793 //
2794 
2795 
2796 /*=====================================================================================================*/
2797 //
2798 // aux functions:
2799 //
2800 /*=====================================================================================================*/
2801 
2802 
2803 /*=====================================================================================================*/
2804 //
2805 // statics:
2806 //
2809 /*=====================================================================================================*/
2810 
2811 
2812 
2813 
2814 /*=====================================================================================================*/
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:35
SgLogger * logger
Definition: SgLogger.cpp:231
#define DAY2SEC
radians to mas:
Definition: SgMathSupport.h:69
@ Z_AXIS
Definition: SgMathSupport.h:81
@ X_AXIS
Definition: SgMathSupport.h:81
@ Y_AXIS
Definition: SgMathSupport.h:81
@ 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
@ REFRACTION
Definition: SgLogger.h:82
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:1008
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:386
bool getIsTesting() const
bool getHave2ApplyOldPoleTideContrib() const
Definition: SgTaskConfig.h:393
bool getUseExtAPrioriHiFyErp() const
bool getUseExtAPrioriSitesPositions() const
bool getUseExtAPrioriErp() const
bool getIsSolveCompatible() const
Definition: SgTaskConfig.h:913
bool getDoDownWeight() const
Definition: SgTaskConfig.h:961
VlbiDelayType getUseDelayType() const
Definition: SgTaskConfig.h:873
bool getDoWeightCorrection() const
Definition: SgTaskConfig.h:905
bool getUseExtAPrioriMeanGradients() const
bool getHave2ApplyEarthTideContrib() const
Definition: SgTaskConfig.h:379
WeightCorrectionMode getWcMode() const
Definition: SgTaskConfig.h:945
bool getHave2ApplyPyContrib() const
Definition: SgTaskConfig.h:378
VlbiDataType getDataType() const
Definition: SgTaskConfig.h:199
bool getHave2ApplyOceanTideContrib() const
Definition: SgTaskConfig.h:380
bool getUseExtAPrioriSourcesPositions() const
bool getHave2ApplyNdryContrib() const
Definition: SgTaskConfig.h:397
VlbiRateType getUseRateType() const
Definition: SgTaskConfig.h:881
bool getHave2ApplyUt1OceanTideHFContrib() const
Definition: SgTaskConfig.h:384
bool getHave2ApplyPxyOceanTideHFContrib() const
Definition: SgTaskConfig.h:385
bool getHave2ApplyOldOceanTideContrib() const
Definition: SgTaskConfig.h:392
bool getHave2ApplyPoleTideContrib() const
Definition: SgTaskConfig.h:381
bool getUseExtAPrioriAxisOffsets() const
bool getHave2ApplyGpsIonoContrib() const
Definition: SgTaskConfig.h:382
bool getHave2ApplyPxyLibrationContrib() const
Definition: SgTaskConfig.h:388
void setDataType(VlbiDataType t)
Definition: SgTaskConfig.h:432
bool getHave2ApplyTiltRemvrContrib() const
Definition: SgTaskConfig.h:391
TropZenithMap getFlybyTropZenithMap() const
Definition: SgTaskConfig.h:400
bool getHave2ApplySourceSsm() const
Definition: SgTaskConfig.h:383
bool getHave2ApplyPxContrib() const
Definition: SgTaskConfig.h:377
bool getHave2ApplyOceanPoleTideContrib() const
Definition: SgTaskConfig.h:389
bool getHave2ApplyFeedCorrContrib() const
Definition: SgTaskConfig.h:390
bool getHave2ApplyNwetContrib() const
Definition: SgTaskConfig.h:398
bool getHave2ApplyUt1LibrationContrib() const
Definition: SgTaskConfig.h:387
bool getHave2ApplyUnPhaseCalContrib() const
Definition: SgTaskConfig.h:396
bool getHave2ApplyAxisOffsetContrib() const
Definition: SgTaskConfig.h:395
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 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 effectiveCableCalValue(CableCorrectionType idx) 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
SgVlbiAuxObservation::CableCorrectionType cccIdx() 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