General Purpose Geodetic Library
SgVlbiSession.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 
29 #if QT_VERSION >= 0x050000
30 # include <QtWidgets/QMessageBox>
31 #else
32 # include <QtGui/QMessageBox>
33 #endif
34 
35 
36 
37 #include <SgVlbiSession.h>
38 
39 #include <SgAPrioriData.h>
40 #include <SgCubicSpline.h>
41 #include <SgEccDat.h>
42 #include <SgEccRec.h>
43 #include <SgLogger.h>
44 #include <SgMasterRecord.h>
45 #include <SgTaskConfig.h>
46 #include <SgVector.h>
47 #include <SgVersion.h>
48 #include <SgVlbiBand.h>
49 #include <SgVlbiNetworkId.h>
50 #include <SgVlbiObservation.h>
51 
52 
53 
54 // aux functions:
58 
59 
60 
61 const QString SgVlbiSession::sSkipCode_("---");
62 
63 
64 
65 /*=======================================================================================================
66 *
67 * METHODS:
68 *
69 *======================================================================================================*/
70 //
71 // static first:
73 {
74  return "SgVlbiSession";
75 };
76 
77 
78 
79 // CONSTRUCTORS:
80 //
81 // A constructor:
84  bands_(),
85  bandByKey_(),
86  observations_(),
87  scanEpochs_(),
88  observationByKey_(),
89  stationsByName_(),
90  baselinesByName_(),
91  sourcesByName_(),
92  tRefer_(tZero),
93  storedConfig_(),
94  lastProcessedConfig_(),
95  stationsByIdx_(),
96  baselinesByIdx_(),
97  sourcesByIdx_(),
98  calcInfo_(),
99  path2Masterfile_("./"),
100  path2APrioriFiles_("./"),
101  apStationPositions_(SgAPriories::DT_STN_POS),
102  apStationVelocities_(SgAPriories::DT_STN_VEL),
103  apSourcePositions_(SgAPriories::DT_SRC_POS),
104  apSourceStrModel_(SgAPriories::DT_SRC_SSM),
105  apAxisOffsets_(SgAPriories::DT_AXS_OFS),
106  apHiFyEop_(),
107  apStationGradients_(SgAPriories::DT_STN_GRD),
108  externalWeights_(),
109  externalErpFile_(),
110  contemporaryHistory_(),
111  skyFreqByIfId_(),
112  userCorrectionsUse_(),
113  userCorrectionsName_()
114 {
115  hasOceanTideContrib_ = false;
116  hasPoleTideContrib_= false;
117  hasEarthTideContrib_= false;
118  hasWobblePxContrib_= false;
119  hasWobblePyContrib_= false;
120  hasWobbleNutContrib_= false;
122  hasUt1HighFreqContrib_ = false;
123  hasFeedCorrContrib_= false;
124  hasTiltRemvrContrib_= false;
125  hasPxyLibrationContrib_ = false;
126  hasUt1LibrationContrib_ = false;
127  hasOceanPoleTideContrib_ = false;
128  hasGpsIonoContrib_ = false;
129  hasPoleTideOldContrib_ = false;
130  hasOceanTideOldContrib_ = false;
131  hasNdryContrib_= false;
132  hasNwetContrib_= false;
133  hasUnPhaseCalContrib_= false;
134  hasGradPartials_ = false;
135  hasCipPartials_ = false;
136 // calcVersionValue_ = 0.0;
137  primaryBand_ = NULL;
138 
139  // config & descriptor of parameters:
140  config_ = NULL;
141  parametersDescriptor_ = NULL;
142 
143  leapSeconds_ = 0.0;
144 
145  // parameters:
146  pPolusX_ = NULL;
147  pPolusY_ = NULL;
148  pUT1_ = NULL;
149  pUT1Rate_ = NULL;
150  pPolusXRate_ = NULL;
151  pPolusYRate_ = NULL;
152  pNutX_ = NULL;
153  pNutY_ = NULL;
154  pNutXRate_ = NULL;
155  pNutYRate_ = NULL;
156 
157  reporter_ = NULL;
158  numOfParameters_ = 0;
160  numOfDOF_= 0;
161 
163  hasOutlierRestoratioRun_ = false;
164 
165  have2InteractWithGui_ = false;
166  longOperationStart_ = NULL;
167  longOperationProgress_ = NULL;
168  longOperationStop_ = NULL;
169  longOperationMessage_ = NULL;
171 
173 
174  args4Ut1Interpolation_ = NULL;
175  tabs4Ut1Interpolation_ = NULL;
176  hasUt1Interpolation_ = false;
177  args4PxyInterpolation_ = NULL;
178  tabs4PxyInterpolation_ = NULL;
179  hasPxyInterpolation_ = false;
181  innerUt1Interpolator_ = NULL;
182  innerPxyInterpolator_ = NULL;
184  isAble2InterpolateErp_ = false;
185 
186  inputDriver_ = NULL;
187 };
188 
189 
190 
191 // A destructor:
193 {
195  stationsByIdx_.clear();
196  baselinesByIdx_.clear();
197  sourcesByIdx_.clear();
198 
199  primaryBand_ = NULL;
200  for (StationsByName_it i=stationsByName_.begin(); i!=stationsByName_.end(); ++i)
201  delete i.value();
202  stationsByName_.clear();
203 
204  for (BaselinesByName_it i=baselinesByName_.begin(); i!=baselinesByName_.end(); ++i)
205  delete i.value();
206  baselinesByName_.clear();
207 
208  for (SourcesByName_it i=sourcesByName_.begin(); i!=sourcesByName_.end(); ++i)
209  delete i.value();
210  sourcesByName_.clear();
211 
212  // not an onwer:
213  config_ = NULL;
214  parametersDescriptor_ = NULL;
215  inputDriver_ = NULL;
216 
217  // free bands:
218  for (int i=0; i<bands_.size(); i++)
219  delete bands_.at(i);
220  bands_.clear();
221  bandByKey_.clear();
222 
223  // free observations:
224  observationByKey_.clear();
225  for (int i=0; i<observations_.size(); i++)
226  delete observations_.at(i);
227  observations_.clear();
228 
229  for (int i=0; i<scanEpochs_.size(); i++)
230  delete scanEpochs_.at(i);
231  scanEpochs_.clear();
232 
234  {
235  delete args4Ut1Interpolation_;
236  args4Ut1Interpolation_ = NULL;
237  };
239  {
240  delete tabs4Ut1Interpolation_;
241  tabs4Ut1Interpolation_ = NULL;
242  };
244  {
245  delete args4PxyInterpolation_;
246  args4PxyInterpolation_ = NULL;
247  };
249  {
250  delete tabs4PxyInterpolation_;
251  tabs4PxyInterpolation_ = NULL;
252  };
254  {
255  delete innerUt1Interpolator_;
256  innerUt1Interpolator_ = NULL;
257  };
259  {
260  delete innerPxyInterpolator_;
261  innerPxyInterpolator_ = NULL;
262  };
264  {
267  };
268  skyFreqByIfId_.clear();
269  userCorrectionsUse_.clear();
270  userCorrectionsName_.clear();
271 };
272 
273 
274 
275 // FUNCTIONS:
276 //
277 //
279 {
280  tMean_ = (tStart_.toDouble() + tFinis_.toDouble())/2.0;
281 };
282 
283 
284 
285 //
287 {
288  return bands_.size();
289 };
290 
291 
292 
293 //
295 {
296  QString eopPrefix = "EOP: ";
298  pPolusX_ = new SgParameter(eopPrefix + "P_x, mas");
299  pPolusY_ = new SgParameter(eopPrefix + "P_y, mas");
300  pUT1_ = new SgParameter(eopPrefix + "dUT1, ms");
301  pUT1Rate_ = new SgParameter(eopPrefix + "dUT1Rate, ms/day");
302  pPolusXRate_ = new SgParameter(eopPrefix + "dPxRate, mas/day");
303  pPolusYRate_ = new SgParameter(eopPrefix + "dPyRate, mas/day");
304  pNutX_ = new SgParameter(eopPrefix + "dX, mas");
305  pNutY_ = new SgParameter(eopPrefix + "dY, mas");
306  pNutXRate_ = new SgParameter(eopPrefix + "dXRate, mas/day");
307  pNutYRate_ = new SgParameter(eopPrefix + "dYRate, mas/day");
308 
309  for (StationsByName_it i=stationsByName_.begin(); i!=stationsByName_.end(); ++i)
310  {
311  i.value()->createParameters();
312  i.value()->clockBreaks().setT0(tRefer_);
313  };
314  for (BaselinesByName_it i=baselinesByName_.begin(); i!=baselinesByName_.end(); ++i)
315  i.value()->createParameters();
316  // The sky is a neighborhood
317  for (SourcesByName_it i=sourcesByName_.begin(); i!=sourcesByName_.end(); ++i)
318  i.value()->createParameters();
319  // So keep it down
320 
321 /*
322  // later, remove this part:
323  for (int i=0; i<bands_.size(); i++)
324  {
325  SgVlbiBand *band=bands_.at(i);
326  for (StationsByName_it it=band->stationsByName().begin(); it!=band->stationsByName().end(); ++it)
327  it.value()->createParameters();
328  };
329  //
330 */
331 };
332 
333 
334 
335 //
337 {
338  for (StationsByName_it i=stationsByName_.begin(); i!=stationsByName_.end(); ++i)
339  i.value()->releaseParameters();
340  for (BaselinesByName_it i=baselinesByName_.begin(); i!=baselinesByName_.end(); ++i)
341  i.value()->releaseParameters();
342  for (SourcesByName_it i=sourcesByName_.begin(); i!=sourcesByName_.end(); ++i)
343  i.value()->releaseParameters();
344 /*
345  // later, remove this part:
346  for (int i=0; i<bands_.size(); i++)
347  {
348  SgVlbiBand *band=bands_.at(i);
349  for (StationsByName_it it=band->stationsByName().begin(); it!=band->stationsByName().end(); ++it)
350  it.value()->releaseParameters();
351  };
352  //
353 */
354  if (pPolusX_)
355  {
356  delete pPolusX_;
357  pPolusX_ = NULL;
358  };
359  if (pPolusY_)
360  {
361  delete pPolusY_;
362  pPolusY_ = NULL;
363  };
364  if (pUT1_)
365  {
366  delete pUT1_;
367  pUT1_ = NULL;
368  };
369  if (pUT1Rate_)
370  {
371  delete pUT1Rate_;
372  pUT1Rate_ = NULL;
373  };
374  if (pPolusXRate_)
375  {
376  delete pPolusXRate_;
377  pPolusXRate_ = NULL;
378  };
379  if (pPolusYRate_)
380  {
381  delete pPolusYRate_;
382  pPolusYRate_ = NULL;
383  };
384  if (pNutX_)
385  {
386  delete pNutX_;
387  pNutX_ = NULL;
388  };
389  if (pNutY_)
390  {
391  delete pNutY_;
392  pNutY_ = NULL;
393  };
394 
395  if (pNutXRate_)
396  {
397  delete pNutXRate_;
398  pNutXRate_ = NULL;
399  };
400  if (pNutYRate_)
401  {
402  delete pNutYRate_;
403  pNutYRate_ = NULL;
404  };
405 };
406 
407 
408 
409 //
410 bool SgVlbiSession::checkChannelSetup(bool guiExpected)
411 {
412  //
413  QMap<QString, QList<QString> >
414  strLstByBand;
415  int num=0;
416  QString str("");
417  //
418  // collect info:
419  for (int i=0; i<bands_.size(); i++)
420  {
421  SgVlbiBand *band=bands_.at(i);
422  for (BaselinesByName_it it=band->baselinesByName().begin(); it!=band->baselinesByName().end(); ++it)
423  {
424  SgVlbiBaselineInfo *bi=it.value();
425  if (!bi->numOfChanByCount().size())
427  "::checkChannelSetup(): cannot check channels for baseline " + bi->getKey() +
428  ", the numOfChanByCount map is empty");
429  else if (bi->numOfChanByCount().size() > 1)
430  {
431  num = bi->observables().size();
432  str = bi->getKey() + ": ";
433  for (QMap<int, int>::const_iterator jt=bi->numOfChanByCount().begin();
434  jt!=bi->numOfChanByCount().end(); ++jt)
435  str += QString("").sprintf("%d (%.1f%%), ", jt.key(), jt.value()*100.0/num);
436  str = str.left(str.size() - 2);
437  strLstByBand[band->getKey()] << str;
438  };
439  };
440  };
441  //
442  // make a report:
443  if (strLstByBand.size())
444  {
445  QString str("");
447  "::checkChannelSetup(): the session has a mixed channel setup:");
448  for (QMap<QString, QList<QString> >::iterator it=strLstByBand.begin(); it!=strLstByBand.end(); ++it)
449  {
450  const QList<QString>& strLst=it.value();
451  QString key=it.key();
452  str += "Numbers of channels at the " + key + "-band: \n";
453  for (int i=0; i<strLst.size(); i++)
454  {
455  str += "\t" + strLst.at(i) + "\n";
457  "::checkChannelSetup(): " + key + "-band: " + strLst.at(i));
458  };
459  str += "\n";
460  };
461  //
462  if (guiExpected)
463  QMessageBox::warning(NULL, "Warning: mixed channels setup",
464  "The session contains mixed channels setup for the following baseline(s):\n\n" + str +
465  "\nSometimes this happens by mistake, you may need to report it to the correlator.");
466  }
467  else
469  "::checkChannelSetup(): the session is ok");
470  //
471  strLstByBand.clear();
472  return true;
473 };
474 
475 
476 
477 //
478 bool SgVlbiSession::selfCheck(bool guiExpected)
479 {
480  QVector<QChar> abetka;
481  QString str("");
482  double dTmp;
483  bool isOk=true;
484  SgMJD t(tZero);
485  int numBands(bands().size());
486  abetka.resize(14);
487  abetka[ 0] = 'a';
488  abetka[ 1] = 'b';
489  abetka[ 2] = 'c';
490  abetka[ 3] = 'd';
491  abetka[ 4] = 'e';
492  abetka[ 5] = 'f';
493  abetka[ 6] = 'g';
494  abetka[ 7] = 'h';
495  abetka[ 8] = 'i';
496  abetka[ 9] = 'j';
497  abetka[10] = 'k';
498  abetka[11] = 'l';
499  abetka[12] = 'm';
500  abetka[13] = 'n';
502  "::selfCheck(): the operation started", true);
503 
504  // make selfcheck here:
505  if (!observations_.size()) // there is no observations at all
506  {
508  "::selfCheck(): the session [" + name_ + "] does not contain any observations");
509  return false;
510  };
511  // sort in wavelength order:
512  qSort(bands_.begin(), bands_.end(), wavelengthSortingOrderLessThan);
513 
514 
515  //
516  // check for deselected stations (the info is in baselines)
518 
519  //
520  // set up a primary band:
521  if (!primaryBand_)
523  QString pBandKey(primaryBand_->getKey());
525  "::selfCheck(): the " + pBandKey + "-band is set as the primary one");
526  //
527  QMap<QString, QMap<QString, QString> >
528  scanNameByIdByStn;
529  QMap<QString, QMap<QString, int> >
530  numByScanIdBySrc;
531  int iObs;
532  dTmp = 0.0;
533  iObs = 0;
534  //
535  // process the data in time order:
536  for (QMap<QString, SgVlbiObservation*>::iterator it=observationByKey_.begin();
537  it!=observationByKey_.end(); ++it, iObs++)
538  {
539  SgVlbiObservation *obs=it.value();
540  if (obs->getMediaIdx() == -1)
541  obs->setMediaIdx(iObs);
542  // mark unmatched observables:
543  if (obs->observableByKey().size() != numBands)
545  // set up identities:
546  obs->setupIdentities();
547  obs->setupActiveObservable(pBandKey);
548  obs->selfCheck();
549  scanNameByIdByStn[obs->stn_1()->getKey()][obs->getScanId()] = obs->getScanName();
550  scanNameByIdByStn[obs->stn_2()->getKey()][obs->getScanId()] = obs->getScanName();
551  numByScanIdBySrc[obs->src()->getKey()][obs->getScanId()]++;
552  dTmp += obs->getDTecStdDev();
553  /*
554  SgVlbiObservable *pbObs=obs->primeObs();
555  if (pbObs)
556  {
557 
558  };
559  */
560  };
562  "::selfCheck(): the identities of observations were set up", true);
563  //
564  if (dTmp > 0.0)
565  {
568  "::selfCheck(): found dTec values");
569  };
570  //
571  // and sort it:
572  //
573 //-> if (originType_==OT_MK4 || originType_==OT_KOMB)
575 //-> else
576 //-> qSort(observations_.begin(), observations_.end(), observationSortingOrderLessThan);
577 
579  "::selfCheck(): the observations were sorted", true);
580 
581  //
582  // collect scan epochs and check scan names:
583  // This is a new session, check and adjust scan names:
584  QMap<QString, QString> scanIdByName;
585  QMap<QString, QMap<QString, QString> >
586  duplicateByName;
587  for (int i=0; i<observations_.size(); i++)
588  {
589  SgVlbiObservation *obs=observations_.at(i);
590  if (t != obs->getMJD())
591  {
592  t = obs->getMJD();
593  scanEpochs_.append(new SgMJD(t));
594  };
595  // collect scan names:
596  if (!scanIdByName.contains(obs->getScanName()))
597  scanIdByName.insert(obs->getScanName(), obs->getScanId());
598  else if (scanIdByName[obs->getScanName()] != obs->getScanId())
599  {
600  if (!duplicateByName.contains(obs->getScanName()))
601  duplicateByName[obs->getScanName()].insert(scanIdByName[obs->getScanName()], obs->getScanName());
602  duplicateByName[obs->getScanName()].insert(obs->getScanId(), obs->getScanName());
603  };
604  };
606  "::selfCheck(): " + QString("").setNum(scanEpochs_.size()) +
607  " scans have been found in the session", true);
608  //
609  // Check for duplicate scan names:
610  if (duplicateByName.size())
611  {
613  "::selfCheck(): found " + QString("").setNum(duplicateByName.size()) +
614  " duplicate scan names:", true);
615  for (QMap<QString, QMap<QString, QString> >::iterator it=duplicateByName.begin();
616  it!=duplicateByName.end(); ++it)
617  {
618  int idx=0;
619  for (QMap<QString, QString>::iterator jt=it.value().begin(); jt!=it.value().end(); ++jt, idx++)
620  {
622  "::selfCheck(): the scan ID " + jt.key() + " has a scan name \"" + jt.value() + "\"");
623  // alter the scan name:
624  if (originType_==OT_KOMB)
625  {
626  str = jt.value().simplified() + abetka[idx];
627  jt.value() = str;
628  };
629  };
630  };
631  // correct scan names:
632  if (originType_==OT_KOMB)
633  {
634  QString oldScanName("");
635  for (int i=0; i<observations_.size(); i++)
636  {
637  SgVlbiObservation *obs=observations_.at(i);
638  if (duplicateByName.contains(obs->getScanName()))
639  {
640  oldScanName = obs->getScanName();
641  if (!duplicateByName.value(obs->getScanName()).contains(obs->getScanId()))
643  "::selfCheck(): cannot find the corrected scan name for scan ID " + obs->getScanId() +
644  " and scan name \"" + oldScanName + "\"");
645  else
646  {
647  str = duplicateByName.value(obs->getScanName())[obs->getScanId()];
648  if (str.size())
649  {
650  obs->setScanName(str);
652  "::selfCheck(): the scan name of " + obs->getScanId() +
653  " scan has been changed from \"" + oldScanName + "\" to \"" + str + "\"");
654  }
655  else
657  "::selfCheck(): the corrected scan name is empty for scan ID " + obs->getScanId() +
658  " and scan name \"" + oldScanName + "\"");
659  };
660  }
661  };
662  };
663  };
664  scanIdByName.clear();
665  duplicateByName.clear();
666  //
667  //
668  //
669  // set up band-dependent stuff:
670  int numChan=0, bitsPerSample=0;
671  double rbw=0.0;
672  for (int i=0; i<numBands; i++)
673  {
674  bands_.at(i)->selfCheck();
675  numChan += bands_.at(i)->getMaxNumOfChannels();
676  rbw += bands_.at(i)->getMaxNumOfChannels()*bands_.at(i)->sampleRate();
677  if (bitsPerSample == 0)
678  bitsPerSample = bands_.at(i)->bitsPerSample();
679  else if (bitsPerSample != bands_.at(i)->bitsPerSample())
681  "::selfCheck(): at the " + bands_.at(i)->getKey() +
682  "-band there is a different value for bits per sample: " +
683  QString("").sprintf("%d vs %d", bitsPerSample, bands_.at(i)->bitsPerSample()));
684  };
686  "::selfCheck(): the selfcheck procedure for the bands was done", true);
687  // set up the recording mode:
688  recordingMode_.sprintf("NChan:%d Rbw:%.1f Bps:%d", numChan, rbw*1.0e-6, bitsPerSample);
690  "::selfCheck(): the record mode has been set to \"" + recordingMode_ + "\"");
691 
692 
693  //
694  // calculate baseline length:
696  for (BaselinesByName_it i=baselinesByName_.begin(); i!=baselinesByName_.end(); ++i)
697  {
698  SgVlbiBaselineInfo *bi=i.value();
699  SgVlbiStationInfo *si1=NULL, *si2=NULL;
700  str = bi->getKey().left(8);
701  if (stationsByName_.contains(str))
702  si1 = stationsByName_.value(str);
703  else
705  "::selfCheck(): cannot find the station \"" + str + "\" in the map", true);
706  str = bi->getKey().right(8);
707  if (stationsByName_.contains(str))
708  si2 = stationsByName_.value(str);
709  else
711  "::selfCheck(): cannot find the station \"" + str + "\" in the map", true);
712  if (si1 && si2)
713  {
714  bi->setLength((si2->getR() - si1->getR()).module());
716  "::selfCheck(): set the length of the baseline \"" + bi->getKey() + "\" to " +
717  QString("").sprintf("%.3f (m)", bi->getLength()));
718  };
719  };
720  //
721  // set up a clock reference attribute for the session:
722  SgVlbiStationInfo *bandRC=NULL;
723  for (StationsByName_it it=stationsByName_.begin(); it!=stationsByName_.end(); ++it)
724  if (it.value()->isAttr(SgVlbiStationInfo::Attr_REFERENCE_CLOCKS))
725  bandRC = it.value();
726  if (!bandRC) // there is no presetupped RC staion on a session level, pick one:
727  {
728  for (int i=0; i<numBands; i++)
729  {
730  SgVlbiBand *band=bands_.at(i);
731  for (StationsByName_it it=band->stationsByName().begin(); it!=band->stationsByName().end(); ++it)
732  if (it.value()->isAttr(SgVlbiStationInfo::Attr_REFERENCE_CLOCKS))
733  bandRC = it.value();
734  };
735  if (bandRC) // one of bands has one of stations with RC-flag
737  };
738  if (bandRC && config_ && config_->getIsSolveCompatible())
739  stationsByName_[bandRC->getKey()]->setClocksModelOrder(0);
741  "::selfCheck(): a reference clock station has been set up", true);
742 
743 
744  // set up proper time of creation:
745  t = tZero;
746  for (int i=0; i<numBands; i++)
747  {
748  if (!bands_.at(i)->observables().size()) // there is no observations at some band
749  {
751  "::selfCheck(): the band " + bands_.at(i)->getKey() +
752  " at the session " + name_ + " does not contain any observations");
753  return false;
754  };
755  if (t<bands_.at(i)->getTCreation())
756  t = bands_.at(i)->getTCreation();
757  };
758  //
759  // set up correct tStart and tFinis:
760  tStart_ = observations_.at(0)->getMJD();
761  tFinis_ = observations_.at(observations_.size() - 1)->getMJD();
762  setTCreation(t); // set up "creation time" to the oldest from the bands
763  calcTMean();
764  setupTimeRefer();
766  "::selfCheck(): epochs of start/finish were established", true);
767  //
768  //
769  // check masterfile:
770  SgMasterRecord mr;
772  {
773  // if user explicitly specified the nickname:
774  if (name_ != "unnamed" && nickName().size()==9)
775  {
777  "::selfCheck(): trying to check the provided by user the database name " + name_);
779  {
780  sessionCode_ = mr.getCode();
781  officialName_ = mr.getName();
782  if (correlatorName_.size() == 0)
787  "::selfCheck(): a masterfile record was found");
788  }
789  else
791  "::selfCheck(): cannot find a masterfile record for the database \"" + nickName() + "\"");
792  }
793  else
794  {
795  QString sYear;
796  int year(tStart_.calcYear());
797  sYear.sprintf("%02d", year - (year>=2000?2000:1900));
799  {
801  "::selfCheck(): a masterfile record was found");
802  name_ = sYear + mr.getDate() + mr.getDbcCode();
803  networkSuffix_ = mr.getDbcCode().at(1);
804  officialName_ = mr.getName();
805  if (correlatorName_.size() == 0)
809  }
810  else
812  "::selfCheck(): cannot find a masterfile record for the session code \"" + sessionCode_ + "\"");
813  };
815  "::selfCheck(): for the session code: " + sessionCode_ +
816  ", the following attributes were assigned:");
818  "::selfCheck(): name: " + name_);
820  "::selfCheck(): official name: " + officialName_);
822  "::selfCheck(): scheduler/correlator/submitter: " +
824  }
825  else
826  {
828  {
829  sessionCode_ = mr.getCode();
830  officialName_ = mr.getName();
831  if (correlatorName_.size() == 0)
836  "::selfCheck(): a masterfile record was found");
837  }
838  else
839  {
841  "::selfCheck(): cannot find a masterfile record for the session [" + nickName() + "] ");
842  };
844  "::selfCheck(): for the session name: " + name_ +
845  ", the following attributes were assigned:");
847  "::selfCheck(): code: " + sessionCode_);
849  "::selfCheck(): official name: " + officialName_);
851  "::selfCheck(): scheduler/correlator/submitter: " +
852  schedulerName_ + "/" + correlatorName_ + "/" + submitterName_, true);
853  };
854  //
855  //
856  //
857  // check for Eccs:
859  {
861  "::selfCheck(): skipping the eccentricities set up: incomplete data set ", true);
862  }
863  else if (config_)
864  {
866  if (config_->getEccentricitiesFileName().size() > 0)
867  {
869  if (config_->getEccentricitiesFileName().at(0) == '/')
870  eccDat.setPath2File("");
871  };
872  eccDat.importEccFile();
874  "::selfCheck(): the eccentricity file was read", true);
875  for (StationsByName_it it=stationsByName_.begin(); it!=stationsByName_.end(); ++it)
876  {
877  SgVlbiStationInfo *si=it.value();
878  if (!si->eccRec())
879  {
880  SgEccRec *eccRec=eccDat.lookupRecord(si->getKey(), tRefer_);
881  if (eccRec) // setup eccentricity:
882  {
883  si->eccRec() = new SgEccRec(*eccRec);
884  si->setCdpNumber(eccRec->getNCdp());
885  if (eccRec->getDR().module() > 0.0)
886  si->adjustEccVector();
889  "::selfCheck(): set up the eccentricity for the station " + si->getKey());
890  }
891  else
892  {
893  si->eccRec() = new SgEccRec();
895  "::selfCheck(): cannot find the eccentricity record for the station " + si->getKey());
896  };
897  };
898  };
900  "::selfCheck(): the eccentricities of stations were set up", true);
901  };
902  //
903  //
904  //
905  //
906  // check for the external a priori data:
908  {
909  //
910  }
911  else if (config_)
912  {
915  "::selfCheck(): the external a priori were collected", true);
916 
917  // lookup a file with external weights:
921  "::selfCheck(): the file with external weights was read", true);
922  };
923  //
924  //
925  // perform station set up:
926  // check for different observations of a station at the same epoch (a rare case, just for curiosity),
927  for (StationsByName_it it=stationsByName_.begin(); it!=stationsByName_.end(); ++it)
928  {
929  SgVlbiStationInfo *si=it.value();
930  si->checkAuxObs(scanNameByIdByStn[si->getKey()]);
931 // if (parametersDescriptor_)
932 // {
933 // si->pcClocks()->setPMode(parametersDescriptor_->getClock0Mode());
934 // si->pcZenith()->setPMode(parametersDescriptor_->getZenithMode());
935 // };
936  };
938  "::selfCheck(): the auxiliary observations were checked", true);
939  //
940  // sources:
941  //
942  //for (QMap<QString, QMap<QString, int> >::iterator it=numByScanIdBySrc.begin();
943  // it!=numByScanIdBySrc.end(); ++it)
944  //{
945  // std::cout << " +++ source " << qPrintable(it.key()) << ":\n";
946  // for (QMap<QString, int>::iterator jt=it.value().begin(); jt!=it.value().end(); ++jt)
947  // std::cout << " " << qPrintable(jt.key()) << " => " << jt.value() << "\n";
948  //};
949  for (SourcesByName_it it=sourcesByName_.begin(); it!=sourcesByName_.end(); ++it)
950  {
951  SgVlbiSourceInfo *si=it.value();
952  if (numByScanIdBySrc.contains(si->getKey()))
953  si->setTotalScanNum(numByScanIdBySrc.value(si->getKey()).size());
954  else
955  {
956  str = si->getKey();
957  // the source have no any observations on the primary band, remove it from the maps:
958  --it;
959  sourcesByName_.remove(str);
960  delete si;
962  "::selfCheck(): the source \"" + str + "\" has no any good observations in the primary band"
963  ", it was removed from the whole session");
964  };
965  };
967  "::selfCheck(): numbers of scans per a source were calculated", true);
968 
969  //
970  //
971  if (calcInfo_.stations().size()==0)
972  {
973  calcInfo_.stations() = stationsByName_.values();
975  "::selfCheck(): the calcInfo's list of stations is empty; set it up: " +
976  QString("").setNum(calcInfo_.stations().size()) + " stations in the list");
977  };
978  //
979  // guess the network ID:
980  guessNetworkId();
982  "::selfCheck(): the network ID was set up", true);
983  //
984  checkChannelSetup(guiExpected);
986  "::selfCheck(): the session selfcheck has been completed", true);
987  //
988  return isOk;
989 };
990 
991 
992 
993 //
995 {
996  if (tStart_ == tFinis_) // trivial case
997  tRefer_ = tStart_;
998  else if (tStart_.getDate() != tFinis_.getDate()) // set tRefer to midnight:
999  {
1000  tRefer_ = tFinis_;
1001  tRefer_.setTime(0); // 0hr
1002  }
1003  else
1004  {
1005  int nYr_s, nMon_s, nDay_s, nHr_s, nMi_s;
1006  int nYr_f, nMon_f, nDay_f, nHr_f, nMi_f;
1007  double dSec_s, dSec_f;
1008 
1009  tStart_.toYMDHMS_tr(nYr_s, nMon_s, nDay_s, nHr_s, nMi_s, dSec_s);
1010  tFinis_.toYMDHMS_tr(nYr_f, nMon_f, nDay_f, nHr_f, nMi_f, dSec_f);
1011  //
1012  if (nHr_s == nHr_f)
1013  {
1014  if (20 < nMi_f-nMi_s)
1015  nMi_s = 10*round(double(nMi_s + nMi_f)/20.0);
1016  else
1017  nMi_s = round(double(nMi_s + nMi_f)/2.0);
1018  }
1019  else if (nHr_s+1 == nHr_f)
1020  {
1021  if (nMi_s > 20)
1022  {
1023  nHr_s++;
1024  nMi_s = 0;
1025  }
1026  else
1027  nMi_s = 30;
1028  }
1029  else
1030  {
1031  nHr_s = round(double(nHr_s + nHr_f)/2.0);
1032  nMi_s = 0;
1033  };
1034 
1035  tRefer_.setUpEpoch(nYr_s, nMon_s, nDay_s, nHr_s, nMi_s, 0.0);
1036  };
1038  "::setupTimeRefer(): the reference epoch was set to " + tRefer_.toString());
1039 };
1040 
1041 
1042 
1043 //
1045 {
1046  if (!bands_.size())
1047  return;
1048  if (idx<0 || bands_.size()<=idx)
1049  return;
1050  for (int i=0; i<bands_.size(); i++)
1051  {
1052  if (i==idx)
1053  {
1054  primaryBand_ = bands_.at(i);
1056  }
1057  else
1058  if (bands_.at(i)->isAttr(SgVlbiBand::Attr_PRIMARY))
1059  bands_.at(i)->delAttr(SgVlbiBand::Attr_PRIMARY);
1060  };
1061 };
1062 
1063 
1064 
1065 //
1067 {
1068  // there is no any band:
1069  if (!bands_.size())
1070  return;
1071 
1072  // one band, trivia:
1073  if (bands_.size()==1)
1074  {
1075  primaryBand_ = bands_.at(0);
1077  return;
1078  };
1079  int numOfPrimaryBands=0;
1080  for (int i=0; i<bands_.size(); i++)
1081  if (bands_.at(i)->isAttr(SgVlbiBand::Attr_PRIMARY))
1082  {
1083  primaryBand_ = bands_.at(i);
1084  numOfPrimaryBands++;
1085  };
1086  if (numOfPrimaryBands==1) // ok, there is one pband, just return;
1087  return;
1088 
1089  if (numOfPrimaryBands>1) // something get wrong, clear flags and set up pband
1090  for (int i=0; i<bands_.size(); i++)
1091  bands_.at(i)->delAttr(SgVlbiBand::Attr_PRIMARY);
1092  primaryBand_ = NULL;
1093  for (int i=0; i<bands_.size(); i++)
1094  {
1095  if (bands_.at(i)->getKey() == "X")
1096  {
1097  primaryBand_ = bands_.at(i);
1099  };
1100  };
1101  if (!primaryBand_) // "X"-band was not found
1102  {
1103  primaryBand_ = bands_.at(0); // first element, highest freq
1105  };
1106 };
1107 
1108 
1109 
1110 //
1112 {
1113  // clear statistics:
1114  // common observations:
1115  for (StationsByName_it i=stationsByName_.begin(); i!=stationsByName_.end(); ++i)
1116  {
1117  i.value()->clearWrms();
1118  QMap<QString, SgVlbiAuxObservation*>::iterator auxObsIt=i.value()->auxObservationByScanId()->begin();
1119  for (; auxObsIt!=i.value()->auxObservationByScanId()->end(); ++auxObsIt)
1120  {
1121  SgVlbiAuxObservation *auxObs=auxObsIt.value();
1122  auxObs->setEstClocks(0.0);
1123  auxObs->setEstClocksSigma(0.0);
1124  auxObs->setEstZenithDelay(0.0);
1125  auxObs->setEstZenithDelaySigma(0.0);
1126  auxObs->setEstAtmGradN(0.0);
1127  auxObs->setEstAtmGradNSigma(0.0);
1128  auxObs->setEstAtmGradE(0.0);
1129  auxObs->setEstAtmGradESigma(0.0);
1131  };
1132  };
1133  for (BaselinesByName_it i=baselinesByName_.begin(); i!=baselinesByName_.end(); ++i)
1134  i.value()->clearWrms();
1135  for (SourcesByName_it i=sourcesByName_.begin(); i!=sourcesByName_.end(); ++i)
1136  i.value()->clearWrms();
1137  // per band observations:
1138  for (int iBand=0; iBand<bands_.size(); iBand++)
1139  {
1140  SgVlbiBand *band=bands_.at(iBand);
1141  band->clearWrms();
1142  for (StationsByName_it i=band->stationsByName().begin(); i!=band->stationsByName().end(); ++i)
1143  i.value()->clearWrms();
1144  for (BaselinesByName_it i=band->baselinesByName().begin(); i!=band->baselinesByName().end(); ++i)
1145  i.value()->clearWrms();
1146  for (SourcesByName_it i=band->sourcesByName().begin(); i!=band->sourcesByName().end(); ++i)
1147  i.value()->clearWrms();
1148  };
1149 };
1150 
1151 
1152 
1153 //
1155 {
1156  if (!observations_.size())
1157  return;
1158  for (int i=0; i<observations_.size(); i++)
1159  observations_.at(i)->calcIonoCorrections(cfg);
1160  if (cfg)
1161  {
1164  addAttr(Attr_FF_AMBIGS_RESOLVED); // assume ambigs are ok so set the flag on.
1165  };
1166 };
1167 
1168 
1169 
1170 //
1172 {
1173  for (int i=0; i<observations_.size(); i++)
1174  observations_.at(i)->zerofyIono();
1177 };
1178 
1179 
1180 
1181 //
1183 {
1184  for (int iBand=0; iBand<bands_.size(); iBand++)
1185  {
1186  SgVlbiBand *band=bands_.at(iBand);
1187  QMap<QString, SgVlbiBaselineInfo*>::iterator itBaselineInfo=band->baselinesByName().begin();
1188  for (int iBaseline=0; itBaselineInfo!=band->baselinesByName().end(); ++itBaselineInfo, iBaseline++)
1189  {
1190  SgVlbiBaselineInfo *baselineInfo=itBaselineInfo.value();
1191  if (baselineInfo && !baselineInfo->isAttr(SgVlbiBaselineInfo::Attr_NOT_VALID))
1192  baselineInfo->calculateClockF1(config_);
1193  };
1194  };
1195 };
1196 
1197 
1198 
1199 //
1201 {
1202  double sig4bln4del=0.0, sig4bln4rat=0.0, sig4bnd4del=0.0, sig4bnd4rat=0.0;
1204  {
1205  sig4bnd4del = config_->getInitAuxSigma4Delay();
1206  sig4bnd4rat = config_->getInitAuxSigma4Rate();
1207  }
1209  {
1210  sig4bln4del = config_->getInitAuxSigma4Delay();
1211  sig4bln4rat = config_->getInitAuxSigma4Rate();
1212  }
1213  else
1214  {
1215  //
1216  };
1217  for (int iBand=0; iBand<bands_.size(); iBand++)
1218  {
1219  bands_.at(iBand)->setSigma2add(DT_DELAY, sig4bnd4del);
1220  bands_.at(iBand)->setSigma2add(DT_RATE, sig4bnd4rat);
1221  for (BaselinesByName_it jt=bands_.at(iBand)->baselinesByName().begin();
1222  jt!=bands_.at(iBand)->baselinesByName().end(); ++jt)
1223  {
1224  jt.value()->setSigma2add(DT_DELAY, sig4bln4del);
1225  jt.value()->setSigma2add(DT_RATE, sig4bln4rat);
1226  };
1227  };
1228  for (BaselinesByName_it i=baselinesByName_.begin(); i!=baselinesByName_.end(); ++i)
1229  {
1230  i.value()->setSigma2add(DT_DELAY, sig4bln4del);
1231  i.value()->setSigma2add(DT_RATE, sig4bln4rat);
1232  };
1233 };
1234 
1235 
1236 
1237 //
1239 {
1240  QString str(name_);
1241  //
1242  if (name_.at(0) == '$')
1243  str.remove(0, 1);
1244  //
1245  if (bands_.size() == 2)
1246  {
1247  str = str.mid(0, 7);
1248  str += primaryBand_->getKey() + networkSuffix_;
1249  };
1250  //
1251  return str;
1252 };
1253 
1254 
1255 
1256 //
1258 {
1259  // Attributes:
1269 
1270 
1271  // bands:
1272  for (int i=0; i<bands_.size(); i++)
1273  bands_.at(i)->resetAllEditings();
1274  //
1275  // stations:
1276  for (QMap<QString, SgVlbiStationInfo*>::const_iterator it=stationsByName_.begin();
1277  it!=stationsByName_.end(); ++it)
1278  it.value()->resetAllEditings();
1279  //
1280  // sources:
1281  for (QMap<QString, SgVlbiSourceInfo*>::const_iterator it=sourcesByName_.begin();
1282  it!=sourcesByName_.end(); ++it)
1283  it.value()->resetAllEditings();
1284  //
1285  // baselines:
1286  for (QMap<QString, SgVlbiBaselineInfo*>::const_iterator it=baselinesByName_.begin();
1287  it!=baselinesByName_.end(); ++it)
1288  it.value()->resetAllEditings();
1289  //
1290  // observations:
1291  for (int i=0; i<observations_.size(); i++)
1292  observations_.at(i)->resetAllEditings();
1293  //
1294  // config:
1295  *config_ = storedConfig_; // ? do we need to reset the config at all?
1296  //
1297  // parameterization:
1299  //
1301  //
1303  *ap=(config_->apByNetId().contains(networkID_)?
1304  &config_->apByNetId()[networkID_] :
1306  if (ap->doSessionSetup_)
1307  {
1311  };
1312  //
1313  numOfParameters_ = 0;
1314  numOfConstraints_= 0;
1315  numOfDOF_= 0;
1316  //
1318  "::resetAllEditings(): all editings have been cleared");
1319 };
1320 
1321 
1322 
1323 //
1324 QString SgVlbiSession::name4SirFile(bool isThroughCatalog)
1325 {
1326  QString str(nickName());
1327  QString altName(config_->getName());
1328  if (altName.size() > 0)
1329  altName += ".";
1330  str += QString("").sprintf("_V%03d_M%02d_C%c.%ssir",
1331  primaryBand_->getInputFileVersion(), (int)originType_, isThroughCatalog?'Y':'N',
1332  qPrintable(altName));
1333  return str;
1334 };
1335 
1336 
1337 
1338 //
1340 {
1341  s << name_ << getAttributes();
1342  if (s.status() != QDataStream::Ok)
1343  {
1345  "::saveIntermediateResults(): error writting data");
1346  return false;
1347  };
1348  // store the current version too:
1350  {
1352  "::saveIntermediateResults(): error writting data for the version");
1353  return false;
1354  };
1355  //
1356  // bands:
1357  for (int i=0; i<bands_.size(); i++)
1358  {
1359  if (!bands_.at(i)->saveIntermediateResults(s))
1360  {
1362  "::saveIntermediateResults(): error writting data for " + bands_.at(i)->getKey() + "-band: " +
1363  (s.status()==QDataStream::ReadPastEnd?"read past end of the file":"read corrupt data"));
1364  return false;
1365  };
1366  }
1367  //
1368  // stations:
1369  for (QMap<QString, SgVlbiStationInfo*>::const_iterator it=stationsByName_.begin();
1370  it!=stationsByName_.end(); ++it)
1371  if (!it.value()->saveIntermediateResults(s))
1372  {
1374  "::saveIntermediateResults(): error writting data for station " + it.value()->getKey() + ": " +
1375  (s.status()==QDataStream::ReadPastEnd?"read past end of the file":"read corrupt data"));
1376  return false;
1377  };
1378  //
1379  // sources:
1380  for (QMap<QString, SgVlbiSourceInfo*>::const_iterator it=sourcesByName_.begin();
1381  it!=sourcesByName_.end(); ++it)
1382  if (!it.value()->saveIntermediateResults(s))
1383  {
1385  "::saveIntermediateResults(): error writting data for source " + it.value()->getKey() + ": " +
1386  (s.status()==QDataStream::ReadPastEnd?"read past end of the file":"read corrupt data"));
1387  return false;
1388  };
1389  //
1390  // baselines:
1391  for (QMap<QString, SgVlbiBaselineInfo*>::const_iterator it=baselinesByName_.begin();
1392  it!=baselinesByName_.end(); ++it)
1393  if (!it.value()->saveIntermediateResults(s))
1394  {
1396  "::saveIntermediateResults(): error writting data for baseline " + it.value()->getKey() + ": " +
1397  (s.status()==QDataStream::ReadPastEnd?"read past end of the file":"read corrupt data"));
1398  return false;
1399  };
1400  //
1401  // observations:
1402  for (int i=0; i<observations_.size(); i++)
1403  if (!observations_.at(i)->saveIntermediateResults(s))
1404  {
1406  "::saveIntermediateResults(): error writting data for observation " +
1407  observations_.at(i)->getKey() + ": " +
1408  (s.status()==QDataStream::ReadPastEnd?"read past end of the file":"read corrupt data"));
1409  return false;
1410  };
1411  //
1412  // config:
1414  {
1416  "::saveIntermediateResults(): error writting data for config: " +
1417  (s.status()==QDataStream::ReadPastEnd?"read past end of the file":"read corrupt data"));
1418  return false;
1419  };
1420  //
1421  // parameterization:
1423  {
1425  "::saveIntermediateResults(): error writting data for parameters setup: " +
1426  (s.status()==QDataStream::ReadPastEnd?"read past end of the file":"read corrupt data"));
1427  return false;
1428  };
1429 
1430  return s.status() == QDataStream::Ok;
1431 };
1432 
1433 
1434 
1435 //
1437 {
1438  QString name;
1439  unsigned int attributes;
1440  SgVersion version(libraryVersion);
1441  s >> name >> attributes;
1442  if (s.status() != QDataStream::Ok)
1443  {
1445  "::loadIntermediateResults(): error reading data: " +
1446  (s.status()==QDataStream::ReadPastEnd?"read past end of the file":"read corrupt data"));
1447  return false;
1448  };
1449  if (getName() != name)
1450  {
1452  "::loadIntermediateResults(): error reading data: wrong session, names mismatch: got [" + name +
1453  "], expected [" + getName() + "]");
1454  return false;
1455  };
1456  if (!version.loadIntermediateResults(s))
1457  {
1459  "::loadIntermediateResults(): error reading data for version: " +
1460  (s.status()==QDataStream::ReadPastEnd?"read past end of the file":"read corrupt data"));
1461  return false;
1462  };
1463 /*
1464  if (version != libraryVersion)
1465  {
1466  logger->write(SgLogger::ERR, SgLogger::IO_BIN, className() +
1467  "::loadIntermediateResults(): version mismatch, wouldn't dare to read that file");
1468  return false;
1469  };
1470 */
1471  if (version != libraryVersion)
1472  {
1474  "::loadIntermediateResults(): version mismatch, could get a problem");
1475 // return false;
1476  };
1477  //
1478  // bands:
1479  for (int i=0; i<bands_.size(); i++)
1480  if (!bands_.at(i)->loadIntermediateResults(s))
1481  {
1483  "::loadIntermediateResults(): error writting data for " + bands_.at(i)->getKey() + "-band: " +
1484  (s.status()==QDataStream::ReadPastEnd?"read past end of the file":"read corrupt data"));
1485  return false;
1486  };
1487  //
1488  // stations:
1489  for (QMap<QString, SgVlbiStationInfo*>::const_iterator it=stationsByName_.begin();
1490  it!=stationsByName_.end(); ++it)
1491  if (!it.value()->loadIntermediateResults(s))
1492  {
1494  "::loadIntermediateResults(): error writting data for station " + it.value()->getKey() + ": " +
1495  (s.status()==QDataStream::ReadPastEnd?"read past end of the file":"read corrupt data"));
1496  return false;
1497  };
1498  //
1499  // sources:
1500  for (QMap<QString, SgVlbiSourceInfo*>::const_iterator it=sourcesByName_.begin();
1501  it!=sourcesByName_.end(); ++it)
1502  if (!it.value()->loadIntermediateResults(s))
1503  {
1505  "::loadIntermediateResults(): error writting data for source " + it.value()->getKey() + ": " +
1506  (s.status()==QDataStream::ReadPastEnd?"read past end of the file":"read corrupt data"));
1507  return false;
1508  };
1509  //
1510  // baselines:
1511  for (QMap<QString, SgVlbiBaselineInfo*>::const_iterator it=baselinesByName_.begin();
1512  it!=baselinesByName_.end(); ++it)
1513  if (!it.value()->loadIntermediateResults(s))
1514  {
1516  "::loadIntermediateResults(): error writting data for baseline " + it.value()->getKey() + ": " +
1517  (s.status()==QDataStream::ReadPastEnd?"read past end of the file":"read corrupt data"));
1518  return false;
1519  };
1520  //
1521  // observations:
1522  for (int i=0; i<observations_.size(); i++)
1523  if (!observations_.at(i)->loadIntermediateResults(s))
1524  {
1526  "::loadIntermediateResults(): error writting data for observation " +
1527  observations_.at(i)->getKey() + ": " +
1528  (s.status()==QDataStream::ReadPastEnd?"read past end of the file":"read corrupt data"));
1529  return false;
1530  };
1531  //
1532  // config:
1534  {
1536  "::loadIntermediateResults(): error writting data for config: " +
1537  (s.status()==QDataStream::ReadPastEnd?"read past end of the file":"read corrupt data"));
1538  return false;
1539  };
1540  //
1541  // parameterization:
1543  {
1545  "::loadIntermediateResults(): error writting data for parameters setup: " +
1546  (s.status()==QDataStream::ReadPastEnd?"read past end of the file":"read corrupt data"));
1547  return false;
1548  };
1549  //
1550  setAttributes(attributes);
1551  //
1552  return s.status()==QDataStream::Ok;
1553 };
1554 
1555 
1556 
1557 //
1559 {
1560  if (!bi)
1561  return false;
1562  if (baselinesByName_.contains(bi->getKey()))
1563  return !baselinesByName_.value(bi->getKey())->isAttr(SgVlbiBaselineInfo::Attr_NOT_VALID);
1564  else
1565  return false;
1566 };
1567 
1568 
1569 
1570 //
1572 {
1573  if (!si)
1574  return false;
1575  if (stationsByName_.contains(si->getKey()))
1576  return !stationsByName_.value(si->getKey())->isAttr(SgVlbiStationInfo::Attr_NOT_VALID);
1577  else
1578  return false;
1579 };
1580 
1581 
1582 
1583 //
1584 void SgVlbiSession::allocUt1InterpolEpochs(double t0, double dt, unsigned int numOfPts)
1585 {
1586  if (args4Ut1Interpolation_ && args4Ut1Interpolation_->n() != numOfPts)
1587  {
1588  delete args4Ut1Interpolation_;
1589  args4Ut1Interpolation_ = NULL;
1591  "::allocUt1InterpolEpochs(): the vector of UT1 arguments has been deleted");
1592  };
1594  {
1595  args4Ut1Interpolation_ = new SgVector(numOfPts);
1597  "::allocUt1InterpolEpochs(): the vector of UT1 arguments has been created");
1598  };
1599  for (unsigned int i=0; i<numOfPts; i++)
1600  args4Ut1Interpolation_->setElement(i, t0 + dt*i);
1602  "::allocUt1InterpolEpochs(): the vector of UT1 arguments has been filled");
1603 };
1604 
1605 
1606 
1607 //
1608 void SgVlbiSession::allocPxyInterpolEpochs(double t0, double dt, unsigned int numOfPts)
1609 {
1610  if (args4PxyInterpolation_ && args4PxyInterpolation_->n() != numOfPts)
1611  {
1612  delete args4PxyInterpolation_;
1613  args4PxyInterpolation_ = NULL;
1615  "::allocPxyInterpolEpochs(): the vector of Pxy arguments has been deleted");
1616  };
1618  {
1619  args4PxyInterpolation_ = new SgVector(numOfPts);
1621  "::allocPxyInterpolEpochs(): the vector of Pxy arguments has been created");
1622  };
1623  for (unsigned int i=0; i<numOfPts; i++)
1624  args4PxyInterpolation_->setElement(i, t0 + dt*i);
1626  "::allocPxyInterpolEpochs(): the vector of Pxy arguments has been filled");
1627 };
1628 
1629 
1630 
1631 //
1633 {
1634  if (!vals)
1635  {
1637  "::allocUt1InterpolValues(): the input vector is NULL");
1638  return;
1639  };
1640  if (vals->n() == 0)
1641  {
1643  "::allocUt1InterpolValues(): the size of the input vector is zero");
1644  return;
1645  };
1646 
1647  if (tabs4Ut1Interpolation_ && tabs4Ut1Interpolation_->nRow() != vals->n())
1648  {
1649  delete tabs4Ut1Interpolation_;
1650  tabs4Ut1Interpolation_ = NULL;
1652  "::allocUt1InterpolValues(): the matrix of UT1 values has been deleted");
1653  };
1655  {
1656  tabs4Ut1Interpolation_ = new SgMatrix(vals->n(), 1);
1658  "::allocUt1InterpolValues(): the matrix of UT1 values has been created");
1659  };
1660  for (unsigned int i=0; i<vals->n(); i++)
1661  tabs4Ut1Interpolation_->setElement(i, 0, vals->getElement(i));
1663  "::allocUt1InterpolValues(): the matrix of UT1 values has been filled");
1664 };
1665 
1666 
1667 
1668 //
1670 {
1671  if (!vals)
1672  {
1674  "::allocPxyInterpolValues(): the input matrix is NULL");
1675  return;
1676  };
1677  if (vals->nRow()==0 || vals->nCol()!=2)
1678  {
1680  "::allocPxyInterpolValues(): the size of the input matrix is wrong");
1681  return;
1682  };
1684  {
1685  delete tabs4PxyInterpolation_;
1686  tabs4PxyInterpolation_ = NULL;
1688  "::allocPxyInterpolValues(): the matrix of Pxy values has been deleted");
1689  };
1691  {
1692  tabs4PxyInterpolation_ = new SgMatrix(vals->nRow(), 2);
1694  "::allocPxyInterpolValues(): the matrix of Pxy values has been created");
1695  };
1696  for (unsigned int i=0; i<vals->nRow(); i++)
1697  {
1698  tabs4PxyInterpolation_->setElement(i, 0, vals->getElement(i, 0));
1699  tabs4PxyInterpolation_->setElement(i, 1, vals->getElement(i, 1));
1700  };
1702  "::allocPxyInterpolValues(): the matrix of Pxy values has been filled");
1703 };
1704 
1705 
1706 
1707 
1708 
1709 /*=====================================================================================================*/
1710 
1711 
1712 
1713 
1714 
1715 
1716 /*=====================================================================================================*/
1717 //
1718 // AUX Functions:
1719 //
1720 /*=====================================================================================================*/
1721 // sorts bands by frequency:
1723 {
1724  return b1->getFrequency() > b2->getFrequency();
1725 };
1726 
1727 
1728 
1729 //
1731 {
1732  SgVlbiObservable *o1, *o2;
1733  o1 = obs1->primeObs();
1734  o2 = obs2->primeObs();
1735  if (obs1->getMJD() == obs2->getMJD())
1736  {
1737  if (o1 && o2)
1738  return o1->getMediaIdx() < o2->getMediaIdx();
1739  else
1740  return obs1->getMediaIdx() < obs2->getMediaIdx();
1741  };
1742  return obs1->getMJD() < obs2->getMJD();
1743 };
1744 
1745 
1746 
1747 //
1749 {
1750  if (obs1->getMJD() == obs2->getMJD())
1751  {
1752  if (obs1->src()->getKey() == obs2->src()->getKey())
1753  {
1754  if (obs1->stn_1()->getKey() == obs2->stn_1()->getKey())
1755  return obs1->stn_2()->getKey() < obs2->stn_2()->getKey();
1756  else
1757  return obs1->stn_1()->getKey() < obs2->stn_1()->getKey();
1758  }
1759  else
1760  return obs1->src()->getKey() < obs2->src()->getKey();
1761  };
1762  return obs1->getMJD() < obs2->getMJD();
1763 };
1764 /*=====================================================================================================*/
1765 
1766 /*=====================================================================================================*/
SgLogger * logger
Definition: SgLogger.cpp:231
const SgMJD tZero(1957, 10, 4)
SgVersion libraryVersion("SgLib", 0, 7, 5, "Tuscarora (rc1)", SgMJD(2022, 2, 18, 17, 34))
QMap< QString, SgVlbiBaselineInfo * >::iterator BaselinesByName_it
const QString defaultNetIdName
bool wavelengthSortingOrderLessThan(SgVlbiBand *, SgVlbiBand *)
bool observationSortingOrderLessThan4newSession(SgVlbiObservation *, SgVlbiObservation *)
bool observationSortingOrderLessThan(SgVlbiObservation *, SgVlbiObservation *)
QMap< QString, SgVlbiSourceInfo * >::iterator SourcesByName_it
QMap< QString, SgVlbiStationInfo * >::iterator StationsByName_it
@ DT_DELAY
Definition: SgWrmsable.h:44
@ DT_RATE
Definition: SgWrmsable.h:45
double module() const
Definition: Sg3dVector.h:99
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
SgEccRec * lookupRecord(const QString &, const SgMJD &)
Definition: SgEccDat.cpp:119
void setPath2File(const QString &)
Definition: SgEccDat.h:142
void setFileName(const QString &)
Definition: SgEccDat.h:150
void importEccFile()
Definition: SgEccDat.cpp:61
int getNCdp() const
Definition: SgEccRec.h:219
const Sg3dVector & getDR() const
Definition: SgEccRec.h:243
void setSessionName(const QString &)
virtual void write(LogLevel, quint32, const QString &, bool=false)
Definition: SgLogger.cpp:88
@ IO_BIN
Definition: SgLogger.h:64
@ IO_DBH
Definition: SgLogger.h:67
@ DATA
Definition: SgLogger.h:78
@ PREPROC
Definition: SgLogger.h:98
Definition: SgMJD.h:59
void setTime(double dTime)
Definition: SgMJD.cpp:165
QString toString(Format format=F_Verbose) const
Definition: SgMJD.cpp:1007
double toDouble() const
Definition: SgMJD.h:533
void toYMDHMS_tr(int &nYear, int &nMonth, int &nDay, int &nHour, int &nMin, double &dSec) const
Definition: SgMJD.cpp:1305
int getDate() const
Definition: SgMJD.h:449
void setUpEpoch(int year, int month, int day, int hour, int min, double sec)
Definition: SgMJD.cpp:254
int calcYear() const
Definition: SgMJD.cpp:204
const QString & getCorrelatedBy() const
const QString & getDate() const
bool lookupRecordByCode(const QString &sessionCode, const QString &sYear, const QString &path)
const QString & getScheduledBy() const
const QString & getName() const
const QString & getCode() const
const QString & getDbcCode() const
const QString & getSubmittedBy() const
bool lookupRecordByName(const QString &nickName, const QString &path)
unsigned int nRow() const
Definition: SgMatrix.h:352
void setElement(unsigned int i, unsigned int j, double d)
Definition: SgMatrix.h:402
double getElement(unsigned int i, unsigned int j) const
Definition: SgMatrix.h:385
unsigned int nCol() const
Definition: SgMatrix.h:360
QList< SgVlbiStationInfo * > & stations()
Definition: SgModelsInfo.h:155
void clearWrms()
Definition: SgObjectInfo.h:550
const QString & getKey() const
Definition: SgObjectInfo.h:319
virtual int getMediaIdx() const
virtual void setMediaIdx(int idx)
@ Attr_PROCESSED
the observation has been processed;
Definition: SgObservation.h:79
virtual const SgMJD & getMJD() const
bool saveIntermediateResults(QDataStream &) const
bool loadIntermediateResults(QDataStream &)
const QString & getEccentricitiesFileName() const
bool saveIntermediateResults(QDataStream &) const
bool getIsSolveCompatible() const
Definition: SgTaskConfig.h:897
WeightCorrectionMode getWcMode() const
Definition: SgTaskConfig.h:929
QMap< QString, AutomaticProcessing > & apByNetId()
Definition: SgTaskConfig.h:623
double getInitAuxSigma4Delay() const
Definition: SgTaskConfig.h:231
const QString & getName() const
Definition: SgTaskConfig.h:809
double getInitAuxSigma4Rate() const
Definition: SgTaskConfig.h:232
bool loadIntermediateResults(QDataStream &)
unsigned int n() const
Definition: SgVector.h:327
void setElement(unsigned int i, double d)
Definition: SgVector.h:348
double getElement(unsigned int i) const
Definition: SgVector.h:362
bool loadIntermediateResults(QDataStream &)
Definition: SgVersion.cpp:99
bool saveIntermediateResults(QDataStream &) const
Definition: SgVersion.cpp:78
void setEstAtmGradESigma(double s)
void setEstClocksSigma(double e)
void setEstAtmGradNSigma(double s)
void setEstZenithDelaySigma(double e)
void setEstZenithDelay(double d)
QMap< QString, SgVlbiBaselineInfo * > & baselinesByName()
Definition: SgVlbiBand.h:376
QMap< QString, SgVlbiStationInfo * > & stationsByName()
Definition: SgVlbiBand.h:368
int getInputFileVersion() const
Definition: SgVlbiBand.h:344
QMap< QString, SgVlbiSourceInfo * > & sourcesByName()
Definition: SgVlbiBand.h:384
double getFrequency() const
Definition: SgVlbiBand.h:320
@ Attr_PRIMARY
the band is a primary band;
Definition: SgVlbiBand.h:60
void setLength(double l)
@ Attr_NOT_VALID
omit the baseline;
QList< SgVlbiObservable * > & observables()
void calculateClockF1(SgTaskConfig *)
const QMap< int, int > & numOfChanByCount() const
double getLength() const
int getMediaIdx() const
@ Attr_NOT_MATCHED
there is no match at another band(s)
SgVlbiStationInfo * stn_1()
SgVlbiSourceInfo * src()
void setScanName(const QString &sName)
double getDTecStdDev() const
virtual bool selfCheck()
void setupActiveObservable(const QString &)
SgVlbiStationInfo * stn_2()
SgVlbiObservable * primeObs()
const QString & getScanName() const
QMap< QString, SgVlbiObservable * > & observableByKey()
const QString & getScanId() const
const QString & getName() const
@ OT_MK4
observations are from Mk4-compatible correlator output;
@ OT_KOMB
observations are from KOMB output (generated by NICT, Japan);
QString officialName_
Official Name (from MasterFile)
@ Attr_FF_EDIT_INFO_MODIFIED
edit info has been modified by user;
@ Attr_FF_WEIGHTS_CORRECTED
weights have been corrected;
@ Attr_PRE_PROCESSED
the observations has been prepared for analysis;
@ Attr_FF_ION_C_CALCULATED
ionospheric corrections have been calculated;
@ Attr_FF_OUTLIERS_PROCESSED
outliers have been processed;
@ Attr_HAS_CALC_DATA
the theoretical values are available;
@ Attr_HAS_DTEC
the session contains diffTec values;
@ Attr_FF_AMBIGS_RESOLVED
ambiguities have been resolved;
@ Attr_FF_ECC_UPDATED
eccentricity data for one of stations were updated;
@ Attr_HAS_IONO_CORR
the theoretical values are available;
@ Attr_HAS_CLOCK_BREAKS
there is at least one clock break at one of stations;
void setTCreation(const SgMJD &t)
SgMJD tFinis_
last epoch of the observations;
QString networkID_
Network ID (a key);.
QString networkSuffix_
a char that specifies network (e.g., A, E, U, etc.);
QString sessionCode_
official session code (from Masterfile);
SgMJD tMean_
mean epoch of the observations;
QString schedulerName_
Name of resposible organization (from MasterFile)
QString correlatorName_
Correlator Name (from MasterFile)
OriginType originType_
type of origin of the imported file(s);
QString submitterName_
Name of resposible organization (from MasterFile)
QString name_
name of the session (e.g., 10JUL22XE);
SgMJD tStart_
first epoch of the observations;
QList< SgMJD * > scanEpochs_
void(* longOperationStart_)(int minStep, int maxStep, const QString &message)
int numberOfBands() const
StationsByName stationsByName_
bool hasOceanPoleTideContrib_
bool hasWobbleNutContrib_
SgParameter * pPolusYRate_
void allocPxyInterpolValues(const SgMatrix *vals)
QString path2Masterfile_
bool hasUt1LibrationContrib_
QMap< QString, SgVlbiObservation * > observationByKey_
SgParameter * pPolusX_
SgParameter * pNutYRate_
QList< SgVlbiBand * > & bands()
QList< SgVlbiBand * > bands_
QVector< bool > userCorrectionsUse_
void setPrimaryBandByIdx(int)
SgTidalUt1::UT1TideContentType tabsUt1Type_
void calculateIonoCorrections(const SgTaskConfig *)
SgVector * args4PxyInterpolation_
double leapSeconds_
void(* longOperationProgress_)(int step)
bool hasGpsIonoContrib_
bool selfCheck(bool guiExpected)
virtual ~SgVlbiSession()
QMap< QString, SgVlbiBand * > bandByKey_
SgParameter * pPolusXRate_
bool hasOceanTideContrib_
QList< SgVlbiObservation * > observations_
void allocPxyInterpolEpochs(double t0, double dt, unsigned int numOfPts)
bool hasPoleTideOldContrib_
SgParameter * pNutY_
SgParameter * pPolusY_
bool hasWobblePxContrib_
void allocUt1InterpolEpochs(double t0, double dt, unsigned int numOfPts)
bool hasWobbleHighFreqContrib_
SgSolutionReporter * reporter_
bool saveIntermediateResults(QDataStream &) const
bool hasUnPhaseCalContrib_
void(* longOperationStop_)()
bool hasOutlierRestoratioRun_
QMap< int, SgVlbiStationInfo * > stationsByIdx_
virtual void setUpPrimaryBand()
QString name4SirFile(bool)
SgCubicSpline * externalErpInterpolator_
bool isInUse(SgVlbiBaselineInfo *)
SgParameter * pUT1Rate_
SgModelsInfo calcInfo_
SgParametersDescriptor storedParametersDescriptor_
SgExternalWeights externalWeights_
void(* longOperationMessage_)(const QString &message)
bool hasUt1HighFreqContrib_
void allocUt1InterpolValues(const SgVector *vals)
bool hasPxyInterpolation_
QMap< QString, double > skyFreqByIfId_
void zerofyIonoCorrections(const SgTaskConfig *)
SgCubicSpline * innerUt1Interpolator_
bool hasWobblePyContrib_
QVector< QString > userCorrectionsName_
static const QString sSkipCode_
BaselinesByName baselinesByName_
bool hasUt1Interpolation_
SgParametersDescriptor * parametersDescriptor_
void createParameters()
QString path2APrioriFiles_
SgVlbiBand * primaryBand_
bool hasPoleTideContrib_
SgIoDriver * inputDriver_
SgParameter * pUT1_
bool hasEarthTideContrib_
bool hasOutlierEliminationRun_
static QString className()
SgTaskConfig storedConfig_
virtual void calcTMean()
bool loadIntermediateResults(QDataStream &)
SgVector * args4Ut1Interpolation_
bool hasPxyLibrationContrib_
SgMatrix * tabs4Ut1Interpolation_
SgParameter * pNutX_
void(* longOperationShowStats_)(const QString &label, int numTot, int numPrc, double wrms, double chi2)
bool have2InteractWithGui_
SgParameter * pNutXRate_
int numOfPts4ErpInterpolation_
bool hasFeedCorrContrib_
QMap< int, SgVlbiBaselineInfo * > baselinesByIdx_
SourcesByName sourcesByName_
bool isAble2InterpolateErp_
SgCubicSpline * innerPxyInterpolator_
void releaseParameters()
void calculateBaselineClock_F1()
QString nickName()
SgTaskConfig * config_
bool hasTiltRemvrContrib_
bool hasOceanTideOldContrib_
SgMatrix * tabs4PxyInterpolation_
QMap< int, SgVlbiSourceInfo * > sourcesByIdx_
bool checkChannelSetup(bool guiExpected)
void setTotalScanNum(int n)
@ Attr_NOT_VALID
omit the station;
@ Attr_REFERENCE_CLOCKS
the clocks are the reference ones;
const Sg3dVector & getR()
void setCdpNumber(int cdp)
void checkAuxObs(const QMap< QString, QString > &scanNameById)