General Purpose Geodetic Library
SgTaskManager.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 
24 #include <SgTaskManager.h>
25 
26 #include <SgEstimator.h>
27 #include <SgLogger.h>
28 #include <SgPwlStorage.h>
29 #include <SgRefraction.h>
30 #include <SgVlbiBand.h>
31 
32 
33 
34 
35 /*=======================================================================================================
36 *
37 * METHODS:
38 *
39 *======================================================================================================*/
40 //
41 // static first:
42 const QString SgTaskManager::className()
43 {
44  return "SgTaskManager";
45 };
46 
47 
48 
49 // A destructor:
51 {
52  if (isTaskOwner_ && task_)
53  {
54  delete task_;
55  task_ = NULL;
56  };
57 /*
58  if (estimator_)
59  {
60  delete estimator_;
61  estimator_ = NULL;
62  };
63 */
64  if (estimator_)
65  {
66  delete estimator_;
67  estimator_ = NULL;
68  };
70  observations_->clear();
72  {
73  delete globalParameters_;
74  globalParameters_ = NULL;
75  };
76  if (arcParameters_)
77  {
78  delete arcParameters_;
79  arcParameters_ = NULL;
80  };
81  if (localParameters_)
82  {
83  delete localParameters_;
84  localParameters_ = NULL;
85  };
86  if (pwlParameters_)
87  {
88  delete pwlParameters_;
89  pwlParameters_ = NULL;
90  };
92  {
93  delete stochasticParameters_;
94  stochasticParameters_ = NULL;
95  };
96  if (refraction_)
97  {
98  delete refraction_;
99  refraction_ = NULL;
100  };
101 };
102 
103 
104 
105 //
107 {
109  ": preparing to run the task");
110 
111  // estimator_ = new SgEstimator(this);
113 
114  // create the list of parameters:
115  // [...]
116 
117  // create a list of VLBI sessions:
118  for (SessionInfosByName_it i=task_->sessionsByName().begin(); i!=task_->sessionsByName().end(); ++i)
119  {
120  SgVlbiSessionInfo *si = i.value();
122  sessions_.append(si);
123  };
124  // ... and sort them in a chronological order:
126  // clear the cache:
127  if (observations_ && observations_->size())
128  observations_->clear();
129 
130  // create CALCable objects:
132 
133  // set up tStart and tFinis:
134  tStart_ = **observations_->begin();
135  tFinis_ = **observations_->end();
136  if (currentSession_)
138  else
139  tRefer_ = tStart_ + (tFinis_ - tStart_)/2.0;
140 
141 // estimator_->prepare4Run();
142  return true;
143 };
144 
145 
146 
147 //
149 {
150  SgMJD startDate(SgMJD::currentMJD());
151  int obsIdx=0;
152  const SgTaskConfig *cfg=task_->config();
154  "::run(): data analysis procerure initiated");
155 
156  bool useDelays=cfg->getUseDelayType()!=SgTaskConfig::VD_NONE;
157  bool useRates=cfg->getUseRateType()!=SgTaskConfig::VR_NONE;
158  int nDataTypes(useDelays && useRates?2:1);
159 
160  estimator_->prepare2Run(nDataTypes*observations_->size(), tStart_, tFinis_, tRefer_);
161  for (obsIdx=0; obsIdx<observations_->size(); obsIdx++)
162  {
163  SgObservation *obs=observations_->at(obsIdx);
164  if (obs->isEligible(cfg))
165  obs->prepare4Analysis(this);
166  estimator_->processObs(obs->getMJD(), obs->o_c(), obs->sigma());
167 
168  };
169  estimator_->finisRun();
170 
171  // the executions is finished
172  SgMJD finisDate(SgMJD::currentMJD());
174  ": data analysis procerure finished");
176  ": elapsed time for the task " + " is: " + interval2Str(finisDate - startDate) +
177  " (" + QString("").sprintf("%.2f", finisDate - startDate) + " sec)");
178 };
179 
180 
181 
182 //
184 {
185 // estimator_->finisRun();
186 
187  // destroy calcable objects:
188  if (refraction_)
189  {
190  delete refraction_;
191  refraction_ = NULL;
192  };
193 
195  ": the task is finished");
196 };
197 
198 
199 
200 //
201 void SgTaskManager::loadVlbiSession(const QString&)
202 {
203 
204 };
205 
206 
207 
208 //
210 {
211 
212 };
213 
214 
215 
216 //
218 {
219  // lists of gloabal parameters:
220  if (globalParameters_)
221  {
223  if (globalParameters_->size())
225  ": the list of global parameters (" + QString("_").setNum(globalParameters_->size()) +
226  ") has been created");
227  };
228  // lists of arc parameters:
229  if (arcParameters_)
230  {
232  if (arcParameters_->size())
234  ": the list of arc parameters (" + QString("_").setNum(arcParameters_->size()) +
235  ") has been created");
236  };
237 
238  // lists of local parameters:
239  if (localParameters_)
240  {
242  if (localParameters_->size())
244  ": the list of local parameters (" + QString("_").setNum(localParameters_->size()) +
245  ") has been created");
246  };
247 
248  // lists of PWL parameters:
249  if (pwlParameters_)
250  {
252  if (pwlParameters_->size())
254  ": the list of `picewise linear' parameters (" + QString("_").setNum(pwlParameters_->size()) +
255  ") has been created");
256  };
257 
258  // lists of stochastic parameters:
260  {
262  if (stochasticParameters_->size())
264  ": the list of stochastic parameters (" + QString("_").setNum(stochasticParameters_->size()) +
265  ") has been created");
266  };
267 };
268 
269 
270 
271 //
273 {
274  // remove `in run' flag:
275  for (int i=0; i<list->size(); i++)
276  list->at(i)->delAttr(SgPartial::Attr_IS_IN_RUN);
277  // clear the list:
278  list->clear();
279 
280 /*
281  SgTaskConfig *cfg=task_->config();
282  SgVlbiBand *band=currentSession_->bands().at(cfg->getActiveBandIdx());
283 */
284  // Stations:
286  it!=currentSession_->stationsByName().end(); ++it)
287  {
288  SgVlbiStationInfo *si=it.value();
289 /*
290  SgVlbiStationInfo *bsi=NULL;
291  if (band && band->stationsByName().contains(si->getKey()))
292  bsi = band->stationsByName().value(si->getKey());
293 */
295  {
296  // clocks:
297  if (task_->parameters()->getClock0Mode()==mode &&
298  si->getClocksModelOrder()>0 &&
300  (mode==SgParameterCfg::PM_ARC/* || mode==SgParameterCfg::PM_PWL*/)) )
301  {
303  si->pClock0()->tune(si->getPcClocks());
304  else
305  si->pClock0()->tune(task_->parameters()->getClock0());
306  // adjust a num of polinomials:
308  //
309  list->append(si->pClock0());
310  };
311  if (task_->parameters()->getClock1Mode()==mode &&
313  {
314  if (si->getClocksModelOrder()>1)
315  for (int i=1; i<si->getClocksModelOrder(); i++)
316  {
317  si->pClocks(i)->tune(task_->parameters()->getClock1());
318  list->append(si->pClocks(i));
319  };
320  };
321  // add dynamic clock break parameters:
322  if (mode==SgParameterCfg::PM_LOC)
323  {
324  for (int i=0; i<si->clockBreaks().size(); i++)
325  {
326  SgParameterBreak *pb=si->clockBreaks().at(i);
328  {
329  if (si->getClocksModelOrder()>0)
330  {
332  list->append(pb->pA0());
333  }
334  else
336  "::fillParameterList: an attempt to register clock break parameter for station " +
337  si->getKey() + " with turned off clocks");
338  if (si->getClocksModelOrder()>1)
339  {
341  list->append(pb->pA1());
342  };
343  if (si->getClocksModelOrder()>2)
344  {
346  list->append(pb->pA2());
347  };
348  };
349  };
350  };
351  // tropospheric parameters:
352  if (task_->parameters()->getZenithMode() == mode &&
354  {
356  si->pZenithDelay()->tune(si->getPcZenith());
357  else
359  list->append(si->pZenithDelay());
360  };
361  if (task_->parameters()->getAtmGradMode() == mode &&
363  {
364  si->pAtmGradE()->tune(task_->parameters()->getAtmGrad());
365  si->pAtmGradN()->tune(task_->parameters()->getAtmGrad());
366  list->append(si->pAtmGradE());
367  list->append(si->pAtmGradN());
368  };
369  // cooridinates:
370  if (task_->parameters()->getStnCooMode() == mode &&
372  {
373  si->pRx()->tune(task_->parameters()->getStnCoo());
374  si->pRy()->tune(task_->parameters()->getStnCoo());
375  si->pRz()->tune(task_->parameters()->getStnCoo());
376  list->append(si->pRx());
377  list->append(si->pRy());
378  list->append(si->pRz());
379  };
380  // axis offset:
381  if (task_->parameters()->getAxisOffsetMode() == mode &&
383  {
385  list->append(si->pAxisOffset());
386  };
387  };
388  };
389 
390  // Sources:
392  it!=currentSession_->sourcesByName().end(); ++it)
393  {
394  SgVlbiSourceInfo *si=it.value();
397  task_->parameters()->getSrcCooMode() == mode )
398  {
399  si->pRA()->tune(task_->parameters()->getSrcCoo());
400  si->pDN()->tune(task_->parameters()->getSrcCoo());
401  list->append(si->pRA());
402  list->append(si->pDN());
403  };
404 
405  if ( task_->config()->getHave2ApplySourceSsm() &&
408  task_->parameters()->getSrcSsmMode() == mode )
409  {
410 /*
411  if (si->getSmtType() == SgVlbiSourceInfo::SMT_TWO_POINTS)
412  {
413  if (si->getEstimateRatio())
414  {
415  si->pK()->tune(task_->parameters()->getSrcSsm());
416  list->append(si->pK());
417  };
418  if (si->getEstimateSpIdx())
419  {
420  si->pB()->tune(task_->parameters()->getSrcSsm());
421  list->append(si->pB());
422  };
423  if (si->getEstimatePosition())
424  {
425  si->pX()->tune(task_->parameters()->getSrcCoo());
426  si->pY()->tune(task_->parameters()->getSrcCoo());
427  list->append(si->pX());
428  list->append(si->pY());
429  };
430  if (si->isExtSS())
431  {
432  si->pA0()->tune(task_->parameters()->getSrcCoo());
433  si->pB0()->tune(task_->parameters()->getSrcCoo());
434  si->pTheta0()->tune(task_->parameters()->getSrcSsm());
435  si->pA1()->tune(task_->parameters()->getSrcCoo());
436  si->pB1()->tune(task_->parameters()->getSrcCoo());
437  si->pTheta1()->tune(task_->parameters()->getSrcSsm());
438 
439  if (si->getEstimateA0())
440  list->append(si->pA0());
441 
442  if (si->getEstimateB0())
443  list->append(si->pB0());
444 
445  if (si->getEstimateT0())
446  list->append(si->pTheta0());
447 
448  if (si->getEstimateA1())
449  list->append(si->pA1());
450 
451  if (si->getEstimateB1())
452  list->append(si->pB1());
453 
454  if (si->getEstimateT1())
455  list->append(si->pTheta1());
456  };
457  }
458  else if (si->getSmtType() == SgVlbiSourceInfo::SMT_MULTIPLE_POINTS)
459 */
460  {
461  si->setIsSsModelEstimating(false);
462  for (int i=0; i<si->sModel().size(); i++)
463  {
464  if (si->sModel()[i].getEstimateRatio())
465  {
466  si->sModel()[i].pK()->tune(task_->parameters()->getSrcSsm());
467  list->append(si->sModel()[i].pK());
468  if (!si->getIsSsModelEstimating())
469  si->setIsSsModelEstimating(true);
470  };
471  if (si->sModel()[i].getEstimateSpIdx())
472  {
473  si->sModel()[i].pB()->tune(task_->parameters()->getSrcSsm());
474  list->append(si->sModel()[i].pB());
475  if (!si->getIsSsModelEstimating())
476  si->setIsSsModelEstimating(true);
477  };
478  if (si->sModel()[i].getEstimatePosition())
479  {
480  si->sModel()[i].pX()->tune(task_->parameters()->getSrcCoo());
481  si->sModel()[i].pY()->tune(task_->parameters()->getSrcCoo());
482  list->append(si->sModel()[i].pX());
483  list->append(si->sModel()[i].pY());
484  if (!si->getIsSsModelEstimating())
485  si->setIsSsModelEstimating(true);
486  };
487  };
488  };
489  };
490  };
491 
492  // Baselines:
494  it!=currentSession_->baselinesByName().end(); ++it)
495  {
496  SgVlbiBaselineInfo *bi = it.value();
497  // baseline clock offset:
500  task_->parameters()->getBlClockMode() == mode )
501  {
502  bi->pClock()->tune(task_->parameters()->getBlClock());
503  list->append(bi->pClock());
504  };
505  // vector of a baseline:
507  task_->parameters()->getBlLengthMode() == mode )
508  {
509  bi->pBx()->tune(task_->parameters()->getBlLength());
510  bi->pBy()->tune(task_->parameters()->getBlLength());
511  bi->pBz()->tune(task_->parameters()->getBlLength());
512  list->append(bi->pBx());
513  list->append(bi->pBy());
514  list->append(bi->pBz());
515  };
516  };
517 
518  // Session-wide:
519  if (task_->parameters()->getPolusXYMode() == mode)
520  {
523  list->append(currentSession_->pPolusX());
524  list->append(currentSession_->pPolusY());
525  };
526  if (task_->parameters()->getPolusXYRateMode() == mode)
527  {
530  list->append(currentSession_->pPolusXRate());
531  list->append(currentSession_->pPolusYRate());
532  };
533  if (task_->parameters()->getPolusUT1Mode() == mode)
534  {
536  list->append(currentSession_->pUT1());
537  };
538  if (task_->parameters()->getPolusUT1RateMode() == mode)
539  {
541  list->append(currentSession_->pUT1Rate());
542  };
543  if (task_->parameters()->getPolusNutMode() == mode)
544  {
547  list->append(currentSession_->pNutX());
548  list->append(currentSession_->pNutY());
549  };
550  if (task_->parameters()->getPolusNutRateMode() == mode)
551  {
554  list->append(currentSession_->pNutXRate());
555  list->append(currentSession_->pNutYRate());
556  };
557 
558  // rise the `in run' flag:
559  for (int i=0; i<list->size(); i++)
560  list->at(i)->addAttr(SgPartial::Attr_IS_IN_RUN);
561  // ... and sort it:
562  qSort(list->begin(), list->end(), lessThan4_ParameterByNameSortingOrder);
563 };
564 
565 
566 
567 //
569 {
570  int numOfConstrainedClocks, numOfConstrains;
571  //
572  numOfConstrainedClocks = numOfConstrains = 0;
574  it!=currentSession_->stationsByName().end(); ++it)
575  {
576  SgVlbiStationInfo *si=it.value();
577  //
580  {
582  {
583  si->pClock0()->setD(1.0);
584  estimator_->processConstraint(0.0, 1.0e-15);
585  numOfConstrains++;
586  };
587  if (si->pClock0()->getPMode() == SgParameterCfg::PM_LOC)
588  {
589  for (int i=1; i<si->getClocksModelOrder(); i++)
590  {
592  {
593  si->pClocks(i)->setD(1.0);
594  estimator_->processConstraint(0.0, 1.0e-16);
595  numOfConstrains++;
596  };
597  };
598  }
599  else if (si->pClock0()->getPMode() == SgParameterCfg::PM_PWL)
600  {
601  SgPwlStorage* pwl=NULL;
602  if (estimator_->pwlStorageByName()->contains(si->pClock0()->getName()))
603  {
604  pwl = estimator_->pwlStorageByName()->value(si->pClock0()->getName());
605  if (pwl)
606  {
607  for (int i=0; i<pwl->getNumOfPolynomials(); i++)
608  {
609  pwl->getP_Ai(i)->setD(1.0);
610  estimator_->processConstraint(0.0, 1.0e-15);
611  numOfConstrains++;
612  };
613  }
614  else
616  ": the PWL container is NULL: station " + si->getKey());
617  };
618  };
619  numOfConstrainedClocks++;
621  ": the clocks of the station " + si->getKey() + " have been constrained");
622  };
623  };
624  if (!numOfConstrainedClocks)
625  {
627  ": there is no reference clocks on the session " + currentSession_->getName() +
628  ", the solution could fail");
629  };
630  if (numOfConstrainedClocks>1)
632  ": more than one station has been used as a 'reference clocks' on the session " +
633  currentSession_->getName() + ", the solution could fail");
634  return numOfConstrains;
635 };
636 
637 
638 
639 //
641 {
642  QString key;
643  int numOfConstrains=0;
644  SgVlbiBaselineInfo *bi=NULL;
645  SgVlbiStationInfo *si_1=NULL, *si_2=NULL;
647  it!=currentSession_->baselinesByName().end(); ++it)
648  {
649  bi = it.value();
651  {
652  si_1 = si_2 = NULL;
653  key = bi->getKey().mid(0, 8);
654  if (currentSession_->stationsByName().contains(key))
655  si_1 = currentSession_->stationsByName().value(key);
656  key = bi->getKey().mid(9, 8);
657  if (currentSession_->stationsByName().contains(key))
658  si_2 = currentSession_->stationsByName().value(key);
659  if (si_1 && si_2)
660  {
662  si_2->pZenithDelay()->isAttr(SgPartial::Attr_IS_IN_RUN) )
663  {
664  si_1->pZenithDelay()->setD( 1.0);
665  si_2->pZenithDelay()->setD(-1.0);
666  estimator_->processConstraint(0.0, 1.0e-6);
667  numOfConstrains++;
669  ": the trpospheric parameters of the stations " + si_1->getKey() + " and " +
670  si_2->getKey() + " have been binded");
671  };
672  }
673  else
674  {
675  if (!si_1)
677  ": cannot find in the map the first station of the baseline " + bi->getKey());
678  if (!si_2)
680  ": cannot find in the map the second station of the baseline " + bi->getKey());
681  };
682  };
683  };
684  return numOfConstrains;
685 };
686 
687 
688 
689 //
691 {
692  int numOfConstrains=0;
693  double sigma = 1.0E-9; // meters
694  QList<SgVlbiStationInfo*> stations4constraints;
696  i!=currentSession_->stationsByName().end(); ++i)
697  {
698  SgVlbiStationInfo *si = i.value();
701  stations4constraints.append(si);
702  };
703  // check it:
704  if (!stations4constraints.size())
705  return 0;
706  //
707  // ok, the list is not empty, process constraints:
708  // No Net Translation of Position:
709  // * x-coo:
710  for (int i=0; i<stations4constraints.size(); i++)
711  {
712  SgVlbiStationInfo *si = stations4constraints.at(i);
713  si->pRx()->setD(1.0);
715  ": TRF No-Net-Translation of Positions Constraints: (X-coord) of the station [" +
716  si->getKey() + "]");
717  };
718  estimator_->processConstraint(0.0, sigma);
719  numOfConstrains++;
720  // * y-coo:
721  for (int i=0; i<stations4constraints.size(); i++)
722  {
723  SgVlbiStationInfo *si = stations4constraints.at(i);
724  si->pRy()->setD(1.0);
726  ": TRF No-Net-Translation of Positions Constraints: (Y-coord) of the station [" +
727  si->getKey() + "]");
728  };
729  estimator_->processConstraint(0.0, sigma);
730  numOfConstrains++;
731  // * z-coo:
732  for (int i=0; i<stations4constraints.size(); i++)
733  {
734  SgVlbiStationInfo *si = stations4constraints.at(i);
735  si->pRz()->setD(1.0);
737  ": TRF No-Net-Translation of Positions Constraints: (Z-coord) of the station [" +
738  si->getKey() + "]");
739  };
740  estimator_->processConstraint(0.0, sigma);
741  numOfConstrains++;
742  return numOfConstrains;
743 };
744 
745 
746 
747 //
749 {
750  double r2;
751  int numOfConstrains=0;
752  double sigma = 1.0E-8*SEC2RAD; // rotation is in radians
753  QList<SgVlbiStationInfo*> stations4constraints;
755  i!=currentSession_->stationsByName().end(); ++i)
756  {
757  SgVlbiStationInfo *si = i.value();
760  stations4constraints.append(si);
761  };
762  // check it:
763  if (!stations4constraints.size())
764  return 0;
765  //
766  // ok, the list is not empty, process constraints:
767  //
768  // No Net Rotation of Position:
769  // * x-coo:
770  for (int i=0; i<stations4constraints.size(); i++)
771  {
772  SgVlbiStationInfo *si = stations4constraints.at(i);
773  r2 = si->getR()*si->getR();
774  si->pRz()->setD( si->getR().at(Y_AXIS)/r2);
775  si->pRy()->setD(-si->getR().at(Z_AXIS)/r2);
777  ": TRF No-Net-Rotation of Positions Constraints: (X-coord) of the station [" +
778  si->getKey() + "]");
779  };
780  estimator_->processConstraint(0.0, sigma);
781  numOfConstrains++;
782  // * y-coo:
783  for (int i=0; i<stations4constraints.size(); i++)
784  {
785  SgVlbiStationInfo *si = stations4constraints.at(i);
786  r2 = si->getR()*si->getR();
787  si->pRx()->setD( si->getR().at(Z_AXIS)/r2);
788  si->pRz()->setD(-si->getR().at(X_AXIS)/r2);
790  ": TRF No-Net-Rotation of Positions Constraints: (Y-coord) of the station [" +
791  si->getKey() + "]");
792  };
793  estimator_->processConstraint(0.0, sigma);
794  numOfConstrains++;
795  // * z-coo:
796  for (int i=0; i<stations4constraints.size(); i++)
797  {
798  SgVlbiStationInfo *si = stations4constraints.at(i);
799  r2 = si->getR()*si->getR();
800  si->pRy()->setD( si->getR().at(X_AXIS)/r2);
801  si->pRx()->setD(-si->getR().at(Y_AXIS)/r2);
803  ": TRF No-Net-Rotation of Positions Constraints: (Z-coord) of the station [" +
804  si->getKey() + "]");
805  };
806  estimator_->processConstraint(0.0, sigma);
807  numOfConstrains++;
808 
809  return numOfConstrains;
810 };
811 
812 
813 /*
814 int SgTaskManager::constrainStationsPositions()
815 {
816  int numOfConstrains=0;
817  double sigma = 1.0E-7; // meters
818  QList<SgVlbiStationInfo*> stations4constraints;
819  for (StationsByName_it i=currentSession_->stationsByName().begin();
820  i!=currentSession_->stationsByName().end(); ++i)
821  {
822  SgVlbiStationInfo *si = i.value();
823  if ( !si->isAttr(SgVlbiStationInfo::Attr_NOT_VALID) &&
824  si->isAttr(SgVlbiStationInfo::Attr_CONSTRAIN_COO) )
825  stations4constraints.append(si);
826  };
827  // check it:
828  if (!stations4constraints.size())
829  return 0;
830  //
831  // ok, the list is not empty, process constraints:
832  // 1) No Net Translation of Position:
833  // * x-coo:
834  for (int i=0; i<stations4constraints.size(); i++)
835  {
836  SgVlbiStationInfo *si = stations4constraints.at(i);
837  si->pRx()->setD(1.0);
838  logger->write(SgLogger::DBG, SgLogger::RUN, className() +
839  ": TRF No Net Translation of Position Constraints: used X-coord of the station [" +
840  si->getKey() + "]");
841  };
842  estimator_->processConstraint(0.0, sigma);
843  numOfConstrains++;
844  // * y-coo:
845  for (int i=0; i<stations4constraints.size(); i++)
846  {
847  SgVlbiStationInfo *si = stations4constraints.at(i);
848  si->pRy()->setD(1.0);
849  logger->write(SgLogger::DBG, SgLogger::RUN, className() +
850  ": TRF No Net Translation Position Constraints: used Y-coord of the station [" +
851  si->getKey() + "]");
852  };
853  estimator_->processConstraint(0.0, sigma);
854  numOfConstrains++;
855  // * z-coo:
856  for (int i=0; i<stations4constraints.size(); i++)
857  {
858  SgVlbiStationInfo *si = stations4constraints.at(i);
859  si->pRz()->setD(1.0);
860  logger->write(SgLogger::DBG, SgLogger::RUN, className() +
861  ": TRF No Net Translation Position Constraints: used Y-coord of the station [" +
862  si->getKey() + "]");
863  };
864  estimator_->processConstraint(0.0, sigma);
865  numOfConstrains++;
866 
867  //
868  // 2) No Net Rotation of Position:
869  double r2, r_scale=6378136.6*6378136.6;
870  // r_scale = 1.0;
871  // * x-coo:
872  for (int i=0; i<stations4constraints.size(); i++)
873  {
874  SgVlbiStationInfo *si = stations4constraints.at(i);
875  r2 = si->getR()*si->getR()/r_scale;
876  si->pRz()->setD( si->getR().at(Y_AXIS)/r2);
877  si->pRy()->setD(-si->getR().at(Z_AXIS)/r2);
878  logger->write(SgLogger::DBG, SgLogger::RUN, className() +
879  ": TRF No Net Rotation of Position Constraints: (X-coord) used the station [" +
880  si->getKey() + "]");
881  };
882  estimator_->processConstraint(0.0, sigma);
883  numOfConstrains++;
884  // * y-coo:
885  for (int i=0; i<stations4constraints.size(); i++)
886  {
887  SgVlbiStationInfo *si = stations4constraints.at(i);
888  r2 = si->getR()*si->getR()/r_scale;
889  si->pRx()->setD( si->getR().at(Z_AXIS)/r2);
890  si->pRz()->setD(-si->getR().at(X_AXIS)/r2);
891  logger->write(SgLogger::DBG, SgLogger::RUN, className() +
892  ": TRF No Net Rotation of Position Constraints: (Y-coord) used the station [" +
893  si->getKey() + "]");
894  };
895  estimator_->processConstraint(0.0, sigma);
896  numOfConstrains++;
897  // * z-coo:
898  for (int i=0; i<stations4constraints.size(); i++)
899  {
900  SgVlbiStationInfo *si = stations4constraints.at(i);
901  r2 = si->getR()*si->getR()/r_scale;
902  si->pRy()->setD( si->getR().at(X_AXIS)/r2);
903  si->pRx()->setD(-si->getR().at(Y_AXIS)/r2);
904  logger->write(SgLogger::DBG, SgLogger::RUN, className() +
905  ": TRF No Net Rotation of Position Constraints: (Z-coord) used the station [" +
906  si->getKey() + "]");
907  };
908  estimator_->processConstraint(0.0, sigma);
909  numOfConstrains++;
910 
911  return numOfConstrains;
912 };
913 */
914 
915 
916 //
918 {
919  int numOfConstrains=0;
920  double sigma = 1.0E-8*SEC2RAD; // arc sec
921  QList<SgVlbiSourceInfo*> sources4constraints;
923  i!=currentSession_->sourcesByName().end(); ++i)
924  {
925  SgVlbiSourceInfo *si = i.value();
928  sources4constraints.append(si);
929  };
930  // check it:
931  if (!sources4constraints.size())
932  return 0;
933  // ok, the list is not empty, process constraints:
934  // 1) No Net Translation Position:
935  double s_ra=0.0, c_ra=0.0, s_dn=0.0, c_dn=0.0;
936  // * (1):
937  for (int i=0; i<sources4constraints.size(); i++)
938  {
939  SgVlbiSourceInfo *si = sources4constraints.at(i);
940  sincos(si->getRA(), &s_ra, &c_ra);
941  sincos(si->getDN(), &s_dn, &c_dn);
942  si->pDN()->setD( s_ra );
943  si->pRA()->setD(-s_dn*c_dn*c_ra);
945  ": CRF No Net Source Rotation Position Constraints (1): used the source [" +
946  si->getKey() + "]");
947  };
948  estimator_->processConstraint(0.0, sigma);
949  numOfConstrains++;
950  // * (2):
951  for (int i=0; i<sources4constraints.size(); i++)
952  {
953  SgVlbiSourceInfo *si = sources4constraints.at(i);
954 
955  sincos(si->getRA(), &s_ra, &c_ra);
956  sincos(si->getDN(), &s_dn, &c_dn);
957  si->pDN()->setD(c_ra );
958  si->pRA()->setD(s_dn*c_dn*s_ra);
959  // Source->p_RA()->setD(-s_dn*c_dn*s_ra, TZero);
961  ": CRF No Net Source Rotation Position Constraints (2): used the source [" +
962  si->getKey() + "]");
963  };
964  estimator_->processConstraint(0.0, sigma);
965  numOfConstrains++;
966  // * (3):
967  for (int i=0; i<sources4constraints.size(); i++)
968  {
969  SgVlbiSourceInfo *si = sources4constraints.at(i);
970  c_dn = cos(si->getDN());
971  si->pRA()->setD(c_dn*c_dn);
972  // Source->p_DN()->setD(c_dn*c_dn, TZero);
974  ": CRF No Net Source Rotation Position Constraints (3): used the source [" +
975  si->getKey() + "]");
976  };
977  estimator_->processConstraint(0.0, sigma);
978  numOfConstrains++;
979  return numOfConstrains;
980 };
981 
982 
983 
984 
986 {
987  int numOfConstrains=0;
988 /*
989  double sigma = 1.0E-12;
990  QList<SgVlbiSourceInfo*> sources4constraints;
991  for (SourcesByName_it i=currentSession_->sourcesByName().begin();
992  i!=currentSession_->sourcesByName().end(); ++i)
993  {
994  SgVlbiSourceInfo *si=i.value();
995  if ( !si->isAttr(SgVlbiSourceInfo::Attr_NOT_VALID) &&
996  si->isAttr(SgVlbiSourceInfo::Attr_APPLY_SSM) )
997  sources4constraints.append(si);
998  };
999  // check it:
1000  if (!sources4constraints.size())
1001  return 0;
1002  //
1003  for (int i=0; i<sources4constraints.size(); i++)
1004  {
1005  SgVlbiSourceInfo *si=sources4constraints.at(i);
1006 
1007  for (int i=0; i<si->sModel().size(); i++)
1008  {
1009  si->sModel()[i].pG()->setD(1.0);
1010  };
1011  estimator_->processConstraint(1.0, sigma);
1012  numOfConstrains++;
1013  logger->write(SgLogger::DBG, SgLogger::RUN, className() +
1014  "::constrainSourcesTmp(): processed G parameter for \"" + si->getKey() + "\"");
1015  };
1016 */
1017  return numOfConstrains;
1018 };
1019 /*=====================================================================================================*/
1020 
1021 
1022 
1023 
1024 /*=======================================================================================================
1025 *
1026 * FRIENDS:
1027 *
1028 *======================================================================================================*/
1029 //
1030 
1031 
1032 
1033 /*=====================================================================================================*/
1034 //
1035 // aux functions:
1036 //
1037 
1038 
1039 // i/o:
1040 
1041 
1042 /*=====================================================================================================*/
1043 //
1044 // constants:
1045 //
1046 
1047 
1048 /*=====================================================================================================*/
SgLogger * logger
Definition: SgLogger.cpp:231
QString interval2Str(double days)
Definition: SgMJD.cpp:1370
#define SEC2RAD
radians to arc seconds:
Definition: SgMathSupport.h:48
@ Z_AXIS
Definition: SgMathSupport.h:68
@ X_AXIS
Definition: SgMathSupport.h:68
@ Y_AXIS
Definition: SgMathSupport.h:68
bool lessThan4_ParameterByNameSortingOrder(SgParameter *p1, SgParameter *p2)
QMap< QString, SgVlbiBaselineInfo * >::iterator BaselinesByName_it
bool lessThan4_FirstEpochSortingOrder(SgVlbiSessionInfo *si1, SgVlbiSessionInfo *si2)
QMap< QString, SgVlbiSessionInfo * >::iterator SessionInfosByName_it
QMap< QString, SgVlbiSourceInfo * >::iterator SourcesByName_it
QMap< QString, SgVlbiStationInfo * >::iterator StationsByName_it
double at(DIRECTION i) const
Definition: Sg3dVector.h:91
bool isAttr(uint a) const
Definition: SgAttribute.h:226
void prepare2Run(int numOfExpectedObs, const SgMJD &, const SgMJD &, const SgMJD &)
void processConstraint(double o_c, double sigma)
void processObs(const SgMJD &t, const SgVector &o_c, const SgVector &sigma)
QMap< QString, SgPwlStorage * > * pwlStorageByName()
Definition: SgEstimator.h:412
virtual void write(LogLevel, quint32, const QString &, bool=false)
Definition: SgLogger.cpp:88
Definition: SgMJD.h:59
static SgMJD currentMJD()
Definition: SgMJD.cpp:118
const QString & getKey() const
Definition: SgObjectInfo.h:319
virtual void prepare4Analysis(SgTaskManager *)=0
virtual const SgVector & o_c()=0
virtual const SgVector & sigma()=0
virtual bool isEligible(const SgTaskConfig *)
virtual const SgMJD & getMJD() const
SgParameter * pA2()
Definition: SgBreakModel.h:164
SgParameter * pA0()
Definition: SgBreakModel.h:162
@ Attr_DYNAMIC
parameters supposed to be estimated during the common solution;
Definition: SgBreakModel.h:60
SgParameter * pA1()
Definition: SgBreakModel.h:163
void setNumOfPolynomials(int)
Definition: SgParameter.h:683
void tune(const SgParameterCfg &)
Definition: SgParameter.cpp:72
SgParameterCfg::PMode getPMode() const
Definition: SgParameter.h:459
const SgParameterCfg & getBlClock() const
SgParameterCfg::PMode getClock1Mode() const
const SgParameterCfg & getClock1() const
const SgParameterCfg & getZenith() const
const SgParameterCfg & getAxisOffset() const
const SgParameterCfg & getPolusUT1Rate() const
const SgParameterCfg & getSrcSsm() const
const SgParameterCfg & getSrcCoo() const
SgParameterCfg::PMode getPolusXYMode() const
const SgParameterCfg & getPolusNutRate() const
SgParameterCfg::PMode getPolusXYRateMode() const
const SgParameterCfg & getBlLength() const
SgParameterCfg::PMode getSrcSsmMode() const
const SgParameterCfg & getAtmGrad() const
SgParameterCfg::PMode getStnCooMode() const
SgParameterCfg::PMode getPolusNutMode() const
const SgParameterCfg & getPolusUT1() const
SgParameterCfg::PMode getClock0Mode() const
const SgParameterCfg & getPolusXY() const
SgParameterCfg::PMode getAxisOffsetMode() const
SgParameterCfg::PMode getPolusNutRateMode() const
const SgParameterCfg & getPolusNut() const
const SgParameterCfg & getClock0() const
SgParameterCfg::PMode getZenithMode() const
SgParameterCfg::PMode getBlLengthMode() const
SgParameterCfg::PMode getPolusUT1RateMode() const
SgParameterCfg::PMode getAtmGradMode() const
const SgParameterCfg & getPolusXYRate() const
SgParameterCfg::PMode getSrcCooMode() const
const SgParameterCfg & getStnCoo() const
SgParameterCfg::PMode getPolusUT1Mode() const
SgParameterCfg::PMode getBlClockMode() const
void setD(double d)
Definition: SgPartial.h:347
const QString & getName() const
Definition: SgPartial.h:283
@ Attr_IS_IN_RUN
Definition: SgPartial.h:52
int getNumOfPolynomials() const
Definition: SgPwlStorage.h:259
SgParameter * getP_Ai(int)
Definition: SgPwlStorage.h:316
VlbiDelayType getUseDelayType() const
Definition: SgTaskConfig.h:857
VlbiRateType getUseRateType() const
Definition: SgTaskConfig.h:865
bool getHave2ApplySourceSsm() const
Definition: SgTaskConfig.h:371
void updateParamaterLists()
SgTask * task_
QList< SgObservation * > * observations_
QList< SgParameter * > * localParameters_
QList< SgParameter * > * arcParameters_
SessionInfos sessions_
int constrainTroposphericParameters()
SgEstimator * estimator_
virtual ~SgTaskManager()
virtual void run(bool=true)
SgVlbiSession * currentSession_
int constrainStcPositionsNNR()
int constrainStcPositionsNNT()
void loadVlbiSession(const QString &)
QList< SgParameter * > * pwlParameters_
QList< SgParameter * > * globalParameters_
int constrainSourcesPositions()
virtual const QString className()
SgRefraction * refraction_
virtual bool prepare4Run()
void saveVlbiSession()
QList< SgParameter * > * stochasticParameters_
int constrainSourcesTmp()
virtual void finisRun()
void fillParameterList(QList< SgParameter * > *&, SgParameterCfg::PMode)
SgParametersDescriptor * parameters()
Definition: SgTask.h:211
SgTaskConfig * config()
Definition: SgTask.h:204
SessionInfosByName & sessionsByName()
Definition: SgTask.h:219
@ Attr_ESTIMATE_CLOCKS
estimate baseline clocks;
@ Attr_NOT_VALID
omit the baseline;
@ Attr_BIND_TROPOSPHERE
the troposphere parameters should be tied between the stations;
SgParameter * pClock()
const QString & getName() const
@ Attr_NOT_VALID
omit the session;
SgParameter * pUT1()
QMap< QString, SgVlbiStationInfo * > & stationsByName()
SgParameter * pPolusYRate()
const SgMJD & tRefer() const
SgParameter * pNutYRate()
SgParameter * pPolusY()
SgParameter * pUT1Rate()
SgParameter * pPolusXRate()
QMap< QString, SgVlbiSourceInfo * > & sourcesByName()
SgParameter * pNutXRate()
SgParameter * pNutY()
SgParameter * pNutX()
QMap< QString, SgVlbiBaselineInfo * > & baselinesByName()
SgParameter * pPolusX()
bool getIsSsModelEstimating() const
double getRA() const
QList< StructModelMp > & sModel()
SgParameter * pRA()
double getDN() const
SgParameter * pDN()
void setIsSsModelEstimating(bool is)
@ Attr_APPLY_SSM
apply the source structure model;
@ Attr_CONSTRAIN_COO
constrain source position in estimation;
@ Attr_NOT_VALID
omit the source;
@ Attr_ESTIMATE_COO
estimate source position;
SgParameter * pAtmGradN()
SgParameter * pRz()
SgParameter * pClock0()
SgParameter * pRx()
@ Attr_ESTIMATE_AXO
estimate axis offset;
@ Attr_NOT_VALID
omit the station;
@ Attr_CONSTRAIN_COO
constrain station position in estimation;
@ Attr_REFERENCE_CLOCKS
the clocks are the reference ones;
@ Attr_DONT_ESTIMATE_TRPS
do not estimate parameters of troposphere delay for station;
@ Attr_ESTIMATE_COO
estimate station position;
@ Attr_USE_LOCAL_ZENITH
use its own setup for the zenith delay parameter;
@ Attr_USE_LOCAL_CLOCKS
use its own setup for the clock parameter;
const SgParameterCfg & getPcClocks() const
const Sg3dVector & getR()
SgParameter * pClocks(int i)
const SgParameterCfg & getPcZenith() const
SgParameter * pAtmGradE()
SgParameter * pZenithDelay()
SgBreakModel & clockBreaks()
int getClocksModelOrder() const
SgParameter * pAxisOffset()
SgParameter * pRy()