General Purpose Geodetic Library
SgVlbiSessionIoVdbInput.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 <SgVlbiSession.h>
28 
29 #include <SgConstants.h>
30 #include <SgEccRec.h>
31 #include <SgLogger.h>
32 #include <SgVgosDb.h>
33 #include <SgVlbiBand.h>
34 #include <SgVlbiObservation.h>
35 
36 
37 
38 // to do: add ACM
39 
40 
41 
42 
43 
44 /*=======================================================================================================
45 *
46 * Auxiliary data structures
47 *
48 *======================================================================================================*/
49 
50 
51 /*=======================================================================================================
52 *
53 * I/O utilities:
54 *
55 *======================================================================================================*/
56 //
57 bool SgVlbiSession::getDataFromVgosDb(SgVgosDb* vgosDb, bool have2LoadImmatureSession, bool guiExpected)
58 {
59  SgMJD startEpoch(SgMJD::currentMJD());
60  bool isOk(false);
61  QString kind("");
62  //
63  const QString sMntTypes[]={"AZEL", "EQUA", "X_YN", "X_YE", "RICHMOND", "UNKN"};
64  int numOfObs;
65  int numOfUserCorrections;
66  // 4 cleaning:
67  QList<SgVector*> vectors2del;
68  QList<SgMatrix*> matrices2del;
69  //
70  QList<SgMJD> epochs4Scans;
71  QList<SgMJD> epochs4Obs;
72  QList<QString> stations_1, stations_2, sources;
73  SgVector *calcDelays=NULL, *calcRates=NULL, *fractC=NULL;
74 
75  SgVector *dTec, *dTecStdDev;
76 
77  QMap<QString, SgMatrix*> singleBandDelaysByBand, groupDelaysByBand, ratesByBand, phasesByBand,
78  uvByBand, calFeedCorrByBand, effFreqsByBand,
79  ionCalsByBand, ionSigmasByBand,
80  phaseCals_1ByBand, phaseCals_2ByBand;
81  QMap<QString, SgMatrix*> phaseCalFreqs_1ByBand, phaseCalAmps_1ByBand,
82  phaseCalPhases_1ByBand, phaseCalOffsets_1ByBand,
83  phaseCalFreqs_2ByBand, phaseCalAmps_2ByBand,
84  phaseCalPhases_2ByBand, phaseCalOffsets_2ByBand;
85 
86  QMap<QString, SgVector*> ambigsByBand, refFreqsByBand, correlationByBand, snrByBand,
87  phaseCalRates_1ByBand, phaseCalRates_2ByBand;
88  QMap<QString, QVector<QString> >
89  qCodesByBand;
90  QMap<QString, QVector<int> > numAmbigsByBand, numSubAmbigsByBand, numPhsAmbigsByBand,
91  ionDataFlagByBand, dataFlagByBand;
92  //
93  // correlator info stuff:
94  QMap<QString, QVector<QString> >
95  fourfitOutputFNameByBand, fourfitErrorCodesByBand,
96  baselineCodesByBand,
97  tapeQualityCodesByBand, vlb1FileNamesByBand, tapeIds_1ByBand,
98  tapeIds_2ByBand;
99  QMap<QString, QVector<int> > startOffsetsByBand, stopOffsetsByBand,
100  hopsRevisionNumbersByBand;
101  QMap<QString, QVector< QVector<int> > >
102  fourfitVersionsByBand, epochsOfCorrelationsByBand,
103  epochsOfCentralsByBand, epochsOfFourfitingsByBand,
104  epochsOfNominalScanTimeByBand;
105  QMap<QString, SgVector*> deltaEpochsByBand, smplRateByBand, sbdResidsByBand, rateResidsByBand,
106  effDurationsByBand, startSecondsByBand, stopSecondsByBand,
107  percentOfDiscardsByBand, uniformityFactorsByBand,
108  geocenterPhaseResidsByBand, geocenterPhaseTotalsByBand,
109  geocenterSbDelaysByBand, geocenterGrDelaysByBand,
110  geocenterDelayRatesByBand, probOfFalsesByBand, corrAprioriDelaysByBand,
111  corrAprioriRatesByBand, corrAprioriAccsByBand, incohAmpsByBand,
112  incohAmps2ByBand, delayResidsByBand;
113  QMap<QString, SgMatrix*> urvrsByBand, instrDelaysByBand, searchParamsByBand, corrClocksByBand,
114  mDlysByBand, mAuxByBand, starElevByBand, zenithDelaysByBand;
115  // eocis
116  //
117  QMap<QString, QVector<QString> >
118  fourfitControlFileByBand, fourfitCommandByBand;
119  QMap<QString, QVector<int> > numLagsByBand;
120  QMap<QString, QVector<double> >
121  apLengthByBand;
122 
123  // channel infos:
124  QMap<QString, QVector<QString> >
125  channelIdsByBand, polarizationsByBand;
126  QMap<QString, QVector<int> > numOfChannelsByBand, bitsPerSamplesByBand;
127 
128  QMap<QString, QVector< QVector<int> > >
129  errorRates_1ByBand, errorRates_2ByBand, bbcIdxs_1ByBand, bbcIdxs_2ByBand,
130  corelIdxNumbersUsbByBand, corelIdxNumbersLsbByBand;
131  QMap<QString, SgVector* > sampleRateByBand;
132  QMap<QString, SgMatrix* > residFringeAmplByChanByBand, residFringePhseByChanByBand,
133  refFreqByChanByBand,
134  numOfSamplesByChan_USBByBand, numOfSamplesByChan_LSBByBand,
135  numOfAccPeriodsByChan_USBByBand, numOfAccPeriodsByChan_LSBByBand,
136  loFreqs_1ByBand, loFreqs_2ByBand;
137  // eoci
138 
139  QList<QString> listOfBands;
140 
142 
143  dTec = dTecStdDev = NULL;
144 
145  setName(vgosDb->getSessionName());
146  setSessionCode(vgosDb->getSessionCode());
147  setInputDriver(vgosDb);
148 
149  //
150  networkSuffix_ = name_.mid(8, 1); // need to make proper name handling..
151 
152  listOfBands = vgosDb->getListOfBands();
153 
154  // fix it later:
155  if (vgosDb->hasBand("X"))
157  "::getDataFromVgosDb(): found data for X-band");
158  else
160  "::getDataFromVgosDb(): no data for X-band have been found: " + name_);
161  if (vgosDb->hasBand("S"))
163  "::getDataFromVgosDb(): found data for S-band");
164  else
166  "::getDataFromVgosDb(): no data for S-band have been found: " + name_);
167  //
168  for (int i=0; i<listOfBands.size(); i++)
169  {
170  const QString &bandKey=listOfBands.at(i);
171  singleBandDelaysByBand .insert(bandKey, NULL);
172  groupDelaysByBand .insert(bandKey, NULL);
173  ratesByBand .insert(bandKey, NULL);
174  phasesByBand .insert(bandKey, NULL);
175  ionCalsByBand .insert(bandKey, NULL);
176  ionSigmasByBand .insert(bandKey, NULL);
177  phaseCals_1ByBand .insert(bandKey, NULL);
178  phaseCals_2ByBand .insert(bandKey, NULL);
179  phaseCalFreqs_1ByBand .insert(bandKey, NULL);
180  phaseCalFreqs_2ByBand .insert(bandKey, NULL);
181  phaseCalAmps_1ByBand .insert(bandKey, NULL);
182  phaseCalAmps_2ByBand .insert(bandKey, NULL);
183  phaseCalPhases_1ByBand .insert(bandKey, NULL);
184  phaseCalPhases_2ByBand .insert(bandKey, NULL);
185  phaseCalOffsets_1ByBand .insert(bandKey, NULL);
186  phaseCalOffsets_2ByBand .insert(bandKey, NULL);
187  phaseCalRates_1ByBand .insert(bandKey, NULL);
188  phaseCalRates_2ByBand .insert(bandKey, NULL);
189 
190  effFreqsByBand .insert(bandKey, NULL);
191  refFreqsByBand .insert(bandKey, NULL);
192  correlationByBand .insert(bandKey, NULL);
193  uvByBand .insert(bandKey, NULL);
194  calFeedCorrByBand .insert(bandKey, NULL);
195  snrByBand .insert(bandKey, NULL);
196  ambigsByBand .insert(bandKey, NULL);
197 
198  qCodesByBand .insert(bandKey, QVector<QString>());
199  // correlator info stuff:
200  fourfitOutputFNameByBand .insert(bandKey, QVector<QString>());
201  fourfitErrorCodesByBand .insert(bandKey, QVector<QString>());
202  baselineCodesByBand .insert(bandKey, QVector<QString>());
203  tapeQualityCodesByBand .insert(bandKey, QVector<QString>());
204  vlb1FileNamesByBand .insert(bandKey, QVector<QString>());
205  tapeIds_1ByBand .insert(bandKey, QVector<QString>());
206  tapeIds_2ByBand .insert(bandKey, QVector<QString>());
207 // corelVersionsByBand .insert(bandKey, QVector<int>());
208  startOffsetsByBand .insert(bandKey, QVector<int>());
209  stopOffsetsByBand .insert(bandKey, QVector<int>());
210  hopsRevisionNumbersByBand .insert(bandKey, QVector<int>());
211  fourfitVersionsByBand .insert(bandKey, QVector< QVector<int> >());
212 // dbeditVersionByBand .insert(bandKey, QVector< QVector<int> >());
213  epochsOfCorrelationsByBand .insert(bandKey, QVector< QVector<int> >());
214  epochsOfCentralsByBand .insert(bandKey, QVector< QVector<int> >());
215  epochsOfFourfitingsByBand .insert(bandKey, QVector< QVector<int> >());
216  epochsOfNominalScanTimeByBand .insert(bandKey, QVector< QVector<int> >());
217  deltaEpochsByBand .insert(bandKey, NULL);
218  smplRateByBand .insert(bandKey, NULL);
219  sbdResidsByBand .insert(bandKey, NULL);
220  rateResidsByBand .insert(bandKey, NULL);
221  effDurationsByBand .insert(bandKey, NULL);
222  startSecondsByBand .insert(bandKey, NULL);
223  stopSecondsByBand .insert(bandKey, NULL);
224  percentOfDiscardsByBand .insert(bandKey, NULL);
225  uniformityFactorsByBand .insert(bandKey, NULL);
226  geocenterPhaseResidsByBand .insert(bandKey, NULL);
227  geocenterPhaseTotalsByBand .insert(bandKey, NULL);
228  geocenterSbDelaysByBand .insert(bandKey, NULL);
229  geocenterGrDelaysByBand .insert(bandKey, NULL);
230  geocenterDelayRatesByBand .insert(bandKey, NULL);
231  probOfFalsesByBand .insert(bandKey, NULL);
232  corrAprioriDelaysByBand .insert(bandKey, NULL);
233  corrAprioriRatesByBand .insert(bandKey, NULL);
234  corrAprioriAccsByBand .insert(bandKey, NULL);
235  incohAmpsByBand .insert(bandKey, NULL);
236  incohAmps2ByBand .insert(bandKey, NULL);
237  delayResidsByBand .insert(bandKey, NULL);
238  urvrsByBand .insert(bandKey, NULL);
239  instrDelaysByBand .insert(bandKey, NULL);
240  starElevByBand .insert(bandKey, NULL);
241  zenithDelaysByBand .insert(bandKey, NULL);
242  searchParamsByBand .insert(bandKey, NULL);
243  corrClocksByBand .insert(bandKey, NULL);
244  mDlysByBand .insert(bandKey, NULL);
245  mAuxByBand .insert(bandKey, NULL);
246  // EoCIS
247 
248  fourfitControlFileByBand .insert(bandKey, QVector<QString>());
249  fourfitCommandByBand .insert(bandKey, QVector<QString>());
250  numLagsByBand .insert(bandKey, QVector<int>());
251  apLengthByBand .insert(bandKey, QVector<double>());
252 
253  numAmbigsByBand .insert(bandKey, QVector<int>());
254  numSubAmbigsByBand .insert(bandKey, QVector<int>());
255  numPhsAmbigsByBand .insert(bandKey, QVector<int>());
256  dataFlagByBand .insert(bandKey, QVector<int>());
257  ionDataFlagByBand .insert(bandKey, QVector<int>());
258 
259  // channel infos:
260  channelIdsByBand .insert(bandKey, QVector<QString>());
261  polarizationsByBand .insert(bandKey, QVector<QString>());
262  numOfChannelsByBand .insert(bandKey, QVector<int>());
263  bitsPerSamplesByBand .insert(bandKey, QVector<int>());
264 
265  errorRates_1ByBand .insert(bandKey, QVector< QVector<int> >());
266  errorRates_2ByBand .insert(bandKey, QVector< QVector<int> >());
267  bbcIdxs_1ByBand .insert(bandKey, QVector< QVector<int> >());
268  bbcIdxs_2ByBand .insert(bandKey, QVector< QVector<int> >());
269  corelIdxNumbersUsbByBand .insert(bandKey, QVector< QVector<int> >());
270  corelIdxNumbersLsbByBand .insert(bandKey, QVector< QVector<int> >());
271 
272  sampleRateByBand .insert(bandKey, NULL);
273  residFringeAmplByChanByBand .insert(bandKey, NULL);
274  residFringePhseByChanByBand .insert(bandKey, NULL);
275  refFreqByChanByBand .insert(bandKey, NULL);
276  numOfSamplesByChan_USBByBand .insert(bandKey, NULL);
277  numOfSamplesByChan_LSBByBand .insert(bandKey, NULL);
278  numOfAccPeriodsByChan_USBByBand .insert(bandKey, NULL);
279  numOfAccPeriodsByChan_LSBByBand .insert(bandKey, NULL);
280  loFreqs_1ByBand .insert(bandKey, NULL);
281  loFreqs_2ByBand .insert(bandKey, NULL);
282 
283  };
284 
285  if (!vgosDb->loadEpochs4Scans(epochs4Scans))
286  return false;
287  if (!vgosDb->loadEpochs4Obs(epochs4Obs))
288  return false;
289 
290  numOfObs = epochs4Obs.size();
291 
292  // get general info:
293  if (!vgosDb->loadObsObjectNames(stations_1, stations_2, sources))
294  return false;
295  if (!vgosDb->loadObsTheoreticals(calcDelays, calcRates))
296  {
298  "::getDataFromVgosDb(): cannot find precalculated delays and rates");
300  }
301  else
303 
304  //
305  if (!vgosDb->loadObsFractC(fractC))
306  {
308  "::getDataFromVgosDb(): cannot find fractC");
309  };
310  //
311 
312  vectors2del << calcDelays << calcRates << fractC;
313 
314  isOk = true;
315 
316  //
317  //
318  //
319  // deal with Header:
320  QString correlatorType(""), correlatorName(""), piName(""), experimentName(""),
321  experimentDescription(""), recordingMode("");
322  QList<QString> declStations, declSources;
323  SgMJD tStart, tFinis;
324  int sftIdx(-1), experimentSerialNumber(-1);
325  if (!vgosDb->loadSessionHead(correlatorType, correlatorName, piName, experimentName,
326  experimentSerialNumber, experimentDescription, recordingMode, declStations, declSources,
327  tStart, tFinis, sftIdx))
328  {
330  "::getDataFromVgosDb(): cannot use the data because of missed info: Head");
331  isOk = false;
332  };
333  setCorrelatorType(correlatorType);
334  setCorrelatorName(correlatorName);
335  setPiAgencyName(piName);
336  setDescription(experimentDescription);
337  if (0 < experimentSerialNumber)
338  setExperimentSerialNumber(experimentSerialNumber);
339  setRecordingMode(recordingMode);
340  declStations.clear();
341  declSources.clear();
342  if (0 <= sftIdx)
344  // end of Header
345 
346 
347  // "Obs" dir:
348  for (int i=0; i<listOfBands.size(); i++)
349  {
350  const QString &bandKey=listOfBands.at(i);
351  if (!vgosDb->loadObsSingleBandDelays(bandKey, singleBandDelaysByBand[bandKey]))
352  {
354  "::getDataFromVgosDb(): the data are hardly usable because of missed info: SB Delays for " +
355  bandKey + "-band");
356  /*
357  if (vgosDb->getCorrelatorType() != SgVgosDb::CT_Unknown)
358  isOk = false;
359  */
360  };
361  if (!vgosDb->loadObsGroupDelays(bandKey, groupDelaysByBand[bandKey]))
362  {
364  "::getDataFromVgosDb(): cannot use data because of missed info: Group Delays for " +
365  bandKey + "-band");
366  isOk = false;
367  };
368  if (!vgosDb->loadObsRates(bandKey, ratesByBand[bandKey]))
369  {
371  "::getDataFromVgosDb(): cannot use data because of missed info: Rates for " +
372  bandKey + "-band");
373  // isOk = false;
374  };
375  vgosDb->loadObsPhase(bandKey, phasesByBand[bandKey]);
376  if (!vgosDb->loadObsRefFreqs(bandKey, refFreqsByBand[bandKey]))
377  {
379  "::getDataFromVgosDb(): cannot use data because of missed info: Ref Freqs for " +
380  bandKey + "-band");
381  isOk = false;
382  };
383  vgosDb->loadObsEffFreqs(bandKey, effFreqsByBand[bandKey]);
384 
385  if (!vgosDb->loadObsAmbigSpacing(bandKey, ambigsByBand[bandKey]))
386  {
388  "::getDataFromVgosDb(): cannot use data because of missed info: Ambig Spacing for " +
389  bandKey + "-band");
390  // isOk = false;
391  };
392  if (!vgosDb->loadObsQualityCodes(bandKey, qCodesByBand[bandKey]))
393  {
395  "::getDataFromVgosDb(): cannot use data because of missed info: Quality Codes for " +
396  bandKey + "-band");
397  // isOk = false;
398  };
399  if (!vgosDb->loadObsCorrelation(bandKey, correlationByBand[bandKey]) && !have2LoadImmatureSession)
400  {
402  "::getDataFromVgosDb(): cannot use data because of missed info: Correlation Coeffs for " +
403  bandKey + "-band");
404  };
405  if (!vgosDb->loadObsUVFperAsec(bandKey, uvByBand[bandKey]))
406  {
408  "::getDataFromVgosDb(): cannot use data because of missed info: UV for " +
409  bandKey + "-band");
410  };
411  if (!vgosDb->loadObsCalFeedCorr(bandKey, calFeedCorrByBand[bandKey]))
412  {
414  "::getDataFromVgosDb(): cannot use data because of missed info: FeedCorr for " +
415  bandKey + "-band");
416  }
417  else
418  hasFeedCorrContrib_= true;
419  if (!vgosDb->loadObsSNR(bandKey, snrByBand[bandKey]) && !have2LoadImmatureSession)
420  {
422  "::getDataFromVgosDb(): cannot use data because of missed info: SNR for " +
423  bandKey + "-band");
424  // isOk = false;
425  };
426 
427  if (!vgosDb->loadObsCorrelatorInfo(bandKey,
428  fourfitOutputFNameByBand[bandKey],
429  fourfitErrorCodesByBand[bandKey],
430 // corelVersionsByBand[bandKey],
431  startOffsetsByBand[bandKey],
432  fourfitVersionsByBand[bandKey],
433 // dbeditVersionByBand[bandKey],
434  deltaEpochsByBand[bandKey],
435  urvrsByBand[bandKey],
436  instrDelaysByBand[bandKey],
437  starElevByBand[bandKey],
438  zenithDelaysByBand[bandKey],
439  searchParamsByBand[bandKey],
440  baselineCodesByBand[bandKey],
441  tapeQualityCodesByBand[bandKey],
442  stopOffsetsByBand[bandKey],
443  hopsRevisionNumbersByBand[bandKey],
444  smplRateByBand[bandKey],
445  sbdResidsByBand[bandKey],
446  rateResidsByBand[bandKey],
447  effDurationsByBand[bandKey],
448  startSecondsByBand[bandKey],
449  stopSecondsByBand[bandKey],
450  percentOfDiscardsByBand[bandKey],
451  uniformityFactorsByBand[bandKey],
452  geocenterPhaseResidsByBand[bandKey],
453  geocenterPhaseTotalsByBand[bandKey],
454  geocenterSbDelaysByBand[bandKey],
455  geocenterGrDelaysByBand[bandKey],
456  geocenterDelayRatesByBand[bandKey],
457  probOfFalsesByBand[bandKey],
458  corrAprioriDelaysByBand[bandKey],
459  corrAprioriRatesByBand[bandKey],
460  corrAprioriAccsByBand[bandKey],
461  incohAmpsByBand[bandKey],
462  incohAmps2ByBand[bandKey],
463  delayResidsByBand[bandKey],
464  vlb1FileNamesByBand[bandKey],
465  tapeIds_1ByBand[bandKey],
466  tapeIds_2ByBand[bandKey],
467  epochsOfCorrelationsByBand[bandKey],
468  epochsOfCentralsByBand[bandKey],
469  epochsOfFourfitingsByBand[bandKey],
470  epochsOfNominalScanTimeByBand[bandKey],
471  corrClocksByBand[bandKey],
472  mDlysByBand[bandKey],
473  mAuxByBand[bandKey]))
475  "::getDataFromVgosDb(): reading Correlator Info for the " + bandKey + "-band has failed");
476 
477 
478  if (!vgosDb->loadMiscFourFit(bandKey,
479  fourfitControlFileByBand[bandKey], fourfitCommandByBand[bandKey],
480  numLagsByBand[bandKey], apLengthByBand[bandKey]))
482  "::getDataFromVgosDb(): reading Fourfit Info for the " + bandKey + "-band has failed");
483 
484  vgosDb->loadObsNumGroupAmbigs(bandKey, numAmbigsByBand[bandKey], numSubAmbigsByBand[bandKey]);
485  vgosDb->loadObsNumPhaseAmbigs(bandKey, numPhsAmbigsByBand[bandKey]);
486  vgosDb->loadObsDataFlag(bandKey, dataFlagByBand[bandKey]);
487  vgosDb->loadObsCalIonGroup(bandKey, ionCalsByBand[bandKey], ionSigmasByBand[bandKey],
488  ionDataFlagByBand[bandKey]);
489 
490  //
491  vgosDb->loadObsCalUnphase(bandKey, phaseCals_1ByBand[bandKey], phaseCals_2ByBand[bandKey]);
492  //
493  // channels setup:
494  if (!vgosDb->loadObsChannelInfo(bandKey,
495  channelIdsByBand[bandKey],
496  polarizationsByBand[bandKey],
497  numOfChannelsByBand[bandKey],
498  bitsPerSamplesByBand[bandKey],
499  errorRates_1ByBand[bandKey],
500  errorRates_2ByBand[bandKey],
501  bbcIdxs_1ByBand[bandKey],
502  bbcIdxs_2ByBand[bandKey],
503  corelIdxNumbersUsbByBand[bandKey],
504  corelIdxNumbersLsbByBand[bandKey],
505  sampleRateByBand[bandKey],
506  residFringeAmplByChanByBand[bandKey],
507  residFringePhseByChanByBand[bandKey],
508  refFreqByChanByBand[bandKey],
509  numOfSamplesByChan_USBByBand[bandKey],
510  numOfSamplesByChan_LSBByBand[bandKey],
511  numOfAccPeriodsByChan_USBByBand[bandKey],
512  numOfAccPeriodsByChan_LSBByBand[bandKey],
513  loFreqs_1ByBand[bandKey],
514  loFreqs_2ByBand[bandKey]))
515  {
517  "::getDataFromVgosDb(): missed info: channel info for " + bandKey + "-band");
518  };
519  //
520  // phase cal data:
521  if (!vgosDb->loadObsPhaseCalInfo(bandKey,
522  phaseCalFreqs_1ByBand[bandKey], phaseCalAmps_1ByBand[bandKey],
523  phaseCalPhases_1ByBand[bandKey], phaseCalOffsets_1ByBand[bandKey],
524  phaseCalRates_1ByBand[bandKey],
525  phaseCalFreqs_2ByBand[bandKey], phaseCalAmps_2ByBand[bandKey],
526  phaseCalPhases_2ByBand[bandKey], phaseCalOffsets_2ByBand[bandKey],
527  phaseCalRates_2ByBand[bandKey]))
529  "::getDataFromVgosDb(): missed info: phase calibration data for " + bandKey + "-band");
530  };
531 
532  // VGOS:
533  if (!vgosDb->loadObsDtec(dTec, dTecStdDev))
534  {
536  "::getDataFromVgosDb(): no dTec data found"); // it is ok
537  };
538 
539  // "Cals" dir:
540  SgMatrix *calEarthTide, *calEopHiFiUt;
541  SgMatrix *calPlxRev;
542  SgMatrix *calBend, *calBendSun, *calBendSunHigher;
543  SgMatrix *calEopHiFiXY, *calOcean, *calOceanOld;
544  SgMatrix *calOceanPoleTideLd;
545  SgMatrix *calPoleTide, *calPoleTideOldRestore, *calTiltRmvr;
546  SgMatrix *calWobbleX, *calWobbleY;
547  SgMatrix *calWobNut, *calHiFreqLibrationPm, *calHiFreqLibrationUt;
548  SgMatrix *valNutNro, *valNutNro_rates;
549  SgMatrix *valNutEqx, *valNutEqx_rates;
550  SgMatrix *valNutEqxWahr, *valNutEqxWahr_rates;
551  SgMatrix *rSun, *rMoon, *rEarth, *vSun, *vMoon, *vEarth, *aEarth;
552  SgMatrix *t2c_val, *t2c_rat, *t2c_acc, *pmXy;
553  SgVector *ut1_tai;
554 
555  calEarthTide = calEopHiFiUt = calEopHiFiXY = calOcean = calOceanOld = calPlxRev = calBend
556  = calBendSun = calBendSunHigher = calPoleTide = calPoleTideOldRestore = calTiltRmvr
557  = calWobNut = calWobbleX = calWobbleY = calOceanPoleTideLd
558  = calHiFreqLibrationPm = calHiFreqLibrationUt = valNutNro = valNutNro_rates
559  = valNutEqxWahr = valNutEqxWahr_rates = valNutEqx = valNutEqx_rates
560  = rSun = rMoon = rEarth = vSun = vMoon = vEarth = aEarth
561  = t2c_val = t2c_rat = t2c_acc = pmXy
562  = NULL;
563  ut1_tai = NULL;
564 
565  if (!vgosDb->loadObsCalEarthTide(calEarthTide, kind))
566  {
568  "::getDataFromVgosDb(): limited use data, missed info: Earth Tides");
569  }
570  else if (!kind.isEmpty() && kind.toUpper() != "IERS2003")
572  "::getDataFromVgosDb(): got an unknown, (" + kind + "), kind of Earth tide calibration");
573  //
574  if (!vgosDb->loadObsCalHiFyErp(calEopHiFiUt, calEopHiFiXY, kind))
575  {
577  "::getDataFromVgosDb(): limited use data, missed info: HiFq EOP");
578  }
579  else if (!kind.isEmpty() && kind.toUpper() != "IERS2003")
581  "::getDataFromVgosDb(): got an unknown, (" + kind + "), kind of high frequency ERP calibration");
582  //
583  if (!vgosDb->loadObsCalOcean(calOcean))
584  {
586  "::getDataFromVgosDb(): limited use data, missed info: Ocean Load");
587  };
588  vgosDb->loadObsCalOceanOld(calOceanOld);
589  //
590  vgosDb->loadObsCalOceanPoleTideLoad(calOceanPoleTideLd);
591 
592  if (!vgosDb->loadObsCalPoleTide(calPoleTide, kind))
593  {
595  "::getDataFromVgosDb(): limited use data, missed info: Pole Tide");
596  }
597  else if (!kind.isEmpty() && kind.toUpper() != "IERS2003")
599  "::getDataFromVgosDb(): got an unknown, (" + kind + "), kind of pole tide calibration");
600  vgosDb->loadObsCalPoleTideOldRestore(calPoleTideOldRestore);
601 
602  if (!vgosDb->loadObsCalTiltRmvr(calTiltRmvr))
603  {
605  "::getDataFromVgosDb(): limited use data, missed info: TiltRemover");
606  };
607  //
608  if (!vgosDb->loadObsCalHiFyLibration(calHiFreqLibrationPm, calHiFreqLibrationUt, kind))
609  {
610  if (!vgosDb->loadObsCalHiFyLibration(calWobNut, kind))
611  {
613  "::getDataFromVgosDb(): limited use data, missed info: Libration");
614  };
615  }
616  else if (!kind.isEmpty() && kind.toUpper() != "IERS2010")
618  "::getDataFromVgosDb(): got an unknown, (" + kind + "), kind of high frequency libration "
619  "calibration");
620  //
621  if (!vgosDb->loadObsCalWobble(calWobbleX, calWobbleY))
622  {
624  "::getDataFromVgosDb(): limited use data, missed info: Pole Wobble");
625  };
626  if (!vgosDb->loadObsCalParallax(calPlxRev))
627  {
629  "::getDataFromVgosDb(): limited use data, missed info: Parallax");
630  };
631  if (!vgosDb->loadObsCalBend(calBend))
632  {
634  "::getDataFromVgosDb(): limited use data, missed info: Bending");
635  };
636  if (!vgosDb->loadObsCalBendSun(calBendSun))
637  {
639  "::getDataFromVgosDb(): limited use data, missed info: Bending II");
640  };
641  if (!vgosDb->loadObsCalBendSunHigher(calBendSunHigher))
642  {
644  "::getDataFromVgosDb(): limited use data, missed info: Bending III");
645  };
646 
647  QVector<int> delUFlags, phsUFlags, ratUFlags, uAcSups,
648  ionsBits, obs2Scan;
649  QVector<QString> scanNames, scanFullNames;
650  QVector<QString> corrRootFnames;
651  SgMatrix *dV_dPx, *dV_dPy, *dV_dUT1, *dV_dCipX, *dV_dCipY, *dV_dRA, *dV_dDN;
652  SgMatrix *dTau_dR_1,*dRat_dR_1;
653  SgMatrix *dV_dBend, *dV_dGamma, *dV_dParallax, *dV_dPtdX, *dV_dPtdY;
654  SgMatrix *userCorrections;
655 
656  dV_dRA = dV_dDN = dV_dCipX = dV_dCipY = dV_dPx = dV_dPy = dV_dUT1 = dTau_dR_1
657  = dRat_dR_1 = dV_dBend = dV_dGamma = dV_dParallax = dV_dPtdX = dV_dPtdY = NULL;
658  userCorrections = NULL;
659  numOfUserCorrections = vgosDb->getNumOfUserCorrections();
660  if (numOfUserCorrections)
661  {
662  QString str("");
663  userCorrections = new SgMatrix(numOfObs, numOfUserCorrections);
664  userCorrectionsUse_.resize(numOfUserCorrections);
665  userCorrectionsName_.resize(numOfUserCorrections);
666  for (int i=0; i<vgosDb->getNumOfUserCorrections(); i++)
667  {
668  vgosDb->loadObsUserCorrections(i, userCorrections, str);
669  userCorrectionsUse_[i] = false; // true;
670  userCorrectionsName_[i] = str;
671  };
672  };
673  //
674  //
675  // edit's dir:
676  vgosDb->loadObsEditData(delUFlags, phsUFlags, ratUFlags, uAcSups);
677 
678  // partial's dir:
679  if (!vgosDb->loadObsPartEOP(dV_dPx, dV_dPy, dV_dUT1))
681  "::getDataFromVgosDb(): limited use data, missed info: Partials: EOP");
682 
683  if (!vgosDb->loadObsPartBend(dV_dBend))
685  "::getDataFromVgosDb(): limited use data, missed info: Partials: bend");
686 
687  if (!vgosDb->loadObsPartGamma(dV_dGamma))
689  "::getDataFromVgosDb(): limited use data, missed info: Partials: gamma");
690 
691  if (!vgosDb->loadObsPartParallax(dV_dParallax))
693  "::getDataFromVgosDb(): limited use data, missed info: Partials: parallax");
694 
695  if (!vgosDb->loadObsPartPoleTides(dV_dPtdX, dV_dPtdY, kind))
697  "::getDataFromVgosDb(): limited use data, missed info: Partials: pole tide");
698  else if (!kind.isEmpty() && kind.toUpper() != "IERS2006")
700  "::getDataFromVgosDb(): got an unknown, (" + kind + "), kind of pole tide partials");
701 
702  //
703  if (!vgosDb->loadObsPartNut2KXY(dV_dCipX, dV_dCipY, kind))
704  {
706  "::getDataFromVgosDb(): limited use data, missed info: Partials: CIP/Nutation");
707 // isOk = false;
708  }
709  else if (!kind.isEmpty() && kind.toUpper() != "IAU2006")
711  "::getDataFromVgosDb(): got an unknown, (" + kind + "), kind of Nutation partials");
712  //
713  if (!vgosDb->loadObsPartRaDec(dV_dRA, dV_dDN))
714  {
716  "::getDataFromVgosDb(): limited use data, missed info: Partials: source position");
717 // isOk = false;
718  };
719  if (!vgosDb->loadObsPartXYZ(dTau_dR_1, dRat_dR_1)) //, here dTau_dR_2 = -dTau_dR_1
720  {
722  "::getDataFromVgosDb(): limited use data, missed info: Partials: station coordinates");
723 // isOk = false;
724  };
725  //
726  // observation-to-scan mapping:
727  if (!vgosDb->loadObsCrossRefs(obs2Scan))
728  {
730  "::getDataFromVgosDb(): cannot use data because of missed info: CrossRefers");
731  isOk = false;
732  };
733  //
734  // scans:
735  if (!vgosDb->loadScanName(scanNames, scanFullNames))
737  "::getDataFromVgosDb(): missed info: Scan Names");
738 
739  if (!vgosDb->loadScanCrootFname(corrRootFnames))
740  logger->write(
743  "::getDataFromVgosDb(): missed info: correlator root file names");
744  //
745  vgosDb->loadScanNutationEqxWahr(valNutEqxWahr, valNutEqxWahr_rates);
746  vgosDb->loadScanNutationEqx(valNutEqx, valNutEqx_rates, kind);
747  if (!kind.isEmpty() && kind.toUpper() != "IAU2006")
749  "::getDataFromVgosDb(): got an unknown, (" + kind + "), kind of Nutation contribution, "
750  "Equinox mode");
751  vgosDb->loadScanNutationNro(valNutNro, valNutNro_rates, kind);
752  if (!kind.isEmpty() && kind.toUpper() != "IAU2006")
754  "::getDataFromVgosDb(): got an unknown, (" + kind + "), kind of Nutation contribution, "
755  "NRO mode");
756 
757  vgosDb->loadScanEphemeris(rSun, rMoon, rEarth, vSun, vMoon, vEarth, aEarth);
758  vgosDb->loadScanTrf2crf(t2c_val, t2c_rat, t2c_acc);
759  vgosDb->loadErpApriori(ut1_tai, pmXy);
760 
761  // collect pointers on vectors:
762  vectors2del << dTec << dTecStdDev << ut1_tai
763  ;
764 
765  // collect pointers on matrices:
766  matrices2del << calEarthTide << calEopHiFiUt << calEopHiFiXY << calOcean << calOceanOld
767  << calPlxRev << calBend
768  << calBendSun << calBendSunHigher << calPoleTide << calPoleTideOldRestore
769  << calTiltRmvr << calWobNut
770  << valNutEqxWahr << valNutEqxWahr_rates
771  << valNutNro << valNutNro_rates
772  << valNutEqx << valNutEqx_rates
773  << rSun << rMoon << rEarth << vSun << vMoon << vEarth << aEarth
774  << t2c_val << t2c_rat << t2c_acc << pmXy
775  << calWobbleX << calWobbleY
776  << calOceanPoleTideLd << calHiFreqLibrationPm << calHiFreqLibrationUt
777  << dTau_dR_1 << dRat_dR_1
778  << dV_dPx << dV_dPy << dV_dUT1 << dV_dCipX << dV_dCipY << dV_dRA << dV_dDN
779  << dV_dBend << dV_dGamma << dV_dParallax << dV_dPtdX << dV_dPtdY
780  ;
781  if (userCorrections)
782  matrices2del << userCorrections;
783 
784  // phase 1:
785  //
786  // parse load info:
787  QString station1Name, station2Name, sourceName, baselineName;
788  QString obsKey, scanName, scanId;
789  SgVlbiStationInfo *station1Info, *station2Info;
790  SgVlbiSourceInfo *sourceInfo;
791  SgVlbiBaselineInfo *baselineInfo;
792  SgVlbiObservation *obs=NULL;
793  SgMJD epoch;
794  QMap<QString, SgVlbiAuxObservation*> *auxObsByScan=NULL;
795  int obs2ScanIdx;
796  //
797  // first, read observation, set up identities
799  "::getDataFromVgosDb(): processing observations of the session " + vgosDb->getSessionName());
800  for (int obsIdx=0; obsIdx<numOfObs; obsIdx++)
801  {
802  obs = NULL;
803  // stations and source names:
804  station1Name = stations_1.at(obsIdx);
805  station2Name = stations_2.at(obsIdx);
806  sourceName = sources.at(obsIdx);
807  baselineName = station1Name + ":" + station2Name;
808  epoch = epochs4Obs.at(obsIdx);
809  obsKey.sprintf("%s",
810  qPrintable(epoch.toString(SgMJD::F_INTERNAL) + "-" + baselineName + "@" + sourceName));
811  // scanId and scanName:
812  scanId = epoch.toString(SgMJD::F_INTERNAL) + "@" + sourceName;
813  obs2ScanIdx = obs2Scan.at(obsIdx) - 1;
814  if (scanNames.size())
815  scanName = scanNames.at(obs2ScanIdx);
816  else if (scanFullNames.size())
817  scanName = scanFullNames.at(obs2ScanIdx);
818  else
819  scanName.sprintf("%03d-%02d:%02d:%04.1f@%s",
820  epoch.calcDayOfYear(), epoch.calcHour(), epoch.calcMin(), epoch.calcSec(),
821  qPrintable(sourceName));
822  //
823  if (observationByKey_.contains(obsKey))
824  {
826  "::getDataFromVgosDb(): the observation #" + QString("").setNum(obsIdx) + " at " +
827  epoch.toString() + " with a key \'" + obsKey + "\' already exists in the container");
828  obs = observationByKey_.value(obsKey); // just to prevent the segfault
829  }
830  else
831  {
832  obs = new SgVlbiObservation(this);
833  obs->setMJD(epoch);
834  obs->setScanName(scanName);
835  obs->setScanId(scanId);
836  obs->setKey(obsKey);
837  obs->setMediaIdx(obsIdx);
838  if (scanFullNames.size() && scanFullNames.at(obs2ScanIdx).size())
839  obs->setScanFullName(scanFullNames.at(obs2ScanIdx));
840  if (corrRootFnames.size() && corrRootFnames.at(obs2ScanIdx).size())
841  obs->setCorrRootFileName(corrRootFnames.at(obs2ScanIdx));
842  observations_.append(obs);
843  observationByKey_.insert(obsKey, obs);
844  };
845  //
846  // station #1:
847  if (stationsByName_.contains(station1Name))
848  station1Info = stationsByName_.value(station1Name);
849  else // new station, add it to the container and register its index:
850  {
851  station1Info = new SgVlbiStationInfo(stationsByName_.size(), station1Name);
852  stationsByName_.insert(station1Info->getKey(), station1Info);
853  stationsByIdx_.insert(station1Info->getIdx(), station1Info);
854  };
855  // station #2:
856  if (stationsByName_.contains(station2Name))
857  station2Info = stationsByName_.value(station2Name);
858  else // new station, add it to the container and register its index:
859  {
860  station2Info = new SgVlbiStationInfo(stationsByName_.size(), station2Name);
861  stationsByName_.insert(station2Info->getKey(), station2Info);
862  stationsByIdx_.insert(station2Info->getIdx(), station2Info);
863  };
864  // source:
865  if (sourcesByName_.contains(sourceName))
866  sourceInfo = sourcesByName_.value(sourceName);
867  else // new source, add it to the container and register its index:
868  {
869  sourceInfo = new SgVlbiSourceInfo(sourcesByName_.size(), sourceName);
870  sourcesByName_.insert(sourceInfo->getKey(), sourceInfo);
871  sourcesByIdx_.insert(sourceInfo->getIdx(), sourceInfo);
872  };
873  // baseline:
874  if (baselinesByName_.contains(baselineName))
875  baselineInfo = baselinesByName_.value(baselineName);
876  else // new baseline, add it to the container and register its index:
877  {
878  baselineInfo = new SgVlbiBaselineInfo(baselinesByName_.size(), baselineName);
879  baselinesByName_.insert(baselineInfo->getKey(), baselineInfo);
880  baselinesByIdx_.insert(baselineInfo->getIdx(), baselineInfo);
881  };
882  obs->setStation1Idx(station1Info->getIdx());
883  obs->setStation2Idx(station2Info->getIdx());
884  obs->setSourceIdx (sourceInfo ->getIdx());
885  obs->setBaselineIdx(baselineInfo->getIdx());
886  //
887  // collect data:
888  // VGOS:
889  if (dTec && dTecStdDev)
890  {
891  obs->setDTec (dTec ->getElement(obsIdx));
892  obs->setDTecStdDev(dTecStdDev ->getElement(obsIdx));
893  };
894  // theo consensus delay:
895  if (calcDelays)
896  obs->setCalcConsensusDelay (calcDelays->getElement(obsIdx));
897  if (calcRates)
898  obs->setCalcConsensusRate (calcRates->getElement(obsIdx));
899  if (fractC)
900  obs->setFractC(fractC->getElement(obsIdx));
901 
902  if (calPlxRev)
903  {
904  obs->setDdel_dParallaxRev(calPlxRev->getElement(obsIdx, 0));
905  obs->setDrat_dParallaxRev(calPlxRev->getElement(obsIdx, 1));
906  };
907  if (calBend)
908  {
909  obs->setCalcConsBendingDelay(calBend->getElement(obsIdx, 0));
910  obs->setCalcConsBendingRate (calBend->getElement(obsIdx, 1));
911  };
912  if (calBendSun)
913  {
914  obs->setCalcConsBendingSunDelay(calBendSun->getElement(obsIdx, 0));
915  obs->setCalcConsBendingSunRate (calBendSun->getElement(obsIdx, 1));
916  };
917  if (calBendSunHigher)
918  {
919  obs->setCalcConsBendingSunHigherDelay(calBendSunHigher->getElement(obsIdx, 0));
920  obs->setCalcConsBendingSunHigherRate (calBendSunHigher->getElement(obsIdx, 1));
921  };
922  //
923  // contributions:
924  if (calOcean)
925  {
926  obs->setCalcOceanTideDelay(calOcean->getElement(obsIdx, 0));
927  obs->setCalcOceanTideRate (calOcean->getElement(obsIdx, 1));
928  };
929  if (calEopHiFiUt)
930  {
931  obs->setCalcHiFyUt1Delay(calEopHiFiUt->getElement(obsIdx, 0));
932  obs->setCalcHiFyUt1Rate (calEopHiFiUt->getElement(obsIdx, 1));
933  };
934  if (calEopHiFiXY)
935  {
936  obs->setCalcHiFyPxyDelay(calEopHiFiXY->getElement(obsIdx, 0));
937  obs->setCalcHiFyPxyRate (calEopHiFiXY->getElement(obsIdx, 1));
938  };
939  if (calPoleTide)
940  {
941  obs->setCalcPoleTideDelay(calPoleTide->getElement(obsIdx, 0));
942  obs->setCalcPoleTideRate (calPoleTide->getElement(obsIdx, 1));
943  };
944  if (calEarthTide)
945  {
946  obs->setCalcEarthTideDelay(calEarthTide->getElement(obsIdx, 0));
947  obs->setCalcEarthTideRate (calEarthTide->getElement(obsIdx, 1));
948  };
949  if (calOceanPoleTideLd)
950  {
951  obs->setCalcOceanPoleTideLdDelay(calOceanPoleTideLd->getElement(obsIdx, 0));
952  obs->setCalcOceanPoleTideLdRate (calOceanPoleTideLd->getElement(obsIdx, 1));
953  };
954  if (calWobbleX)
955  {
956  obs->setCalcPxDelay(calWobbleX->getElement(obsIdx, 0));
957  obs->setCalcPxRate (calWobbleX->getElement(obsIdx, 1));
958  };
959  if (calWobbleY)
960  {
961  obs->setCalcPyDelay(calWobbleY->getElement(obsIdx, 0));
962  obs->setCalcPyRate (calWobbleY->getElement(obsIdx, 1));
963  };
964  if (calWobNut)
965  {
966  obs->setCalcWobNutatContrib(calWobNut->getElement(obsIdx, 0));
967  //obs->setCalcWobNutatContrib(calWobNut->getElement(obsIdx, 1));
968  };
969  if (calHiFreqLibrationPm)
970  {
971  obs->setCalcHiFyPxyLibrationDelay(calHiFreqLibrationPm->getElement(obsIdx, 0));
972  obs->setCalcHiFyPxyLibrationRate (calHiFreqLibrationPm->getElement(obsIdx, 1));
973  };
974  if (calHiFreqLibrationUt)
975  {
976  obs->setCalcHiFyUt1LibrationDelay(calHiFreqLibrationUt->getElement(obsIdx, 0));
977  obs->setCalcHiFyUt1LibrationRate (calHiFreqLibrationUt->getElement(obsIdx, 1));
978  };
979 
980  if (rSun)
981  obs->setRsun(Sg3dVector(rSun->getElement(obs2ScanIdx, 0),
982  rSun->getElement(obs2ScanIdx, 1),
983  rSun->getElement(obs2ScanIdx, 2)));
984  if (vSun)
985  obs->setVsun(Sg3dVector(vSun->getElement(obs2ScanIdx, 0),
986  vSun->getElement(obs2ScanIdx, 1),
987  vSun->getElement(obs2ScanIdx, 2)));
988  if (rMoon)
989  obs->setRmoon(Sg3dVector(rMoon->getElement(obs2ScanIdx, 0),
990  rMoon->getElement(obs2ScanIdx, 1),
991  rMoon->getElement(obs2ScanIdx, 2)));
992  if (vMoon)
993  obs->setVmoon(Sg3dVector(vMoon->getElement(obs2ScanIdx, 0),
994  vMoon->getElement(obs2ScanIdx, 1),
995  vMoon->getElement(obs2ScanIdx, 2)));
996 
997  if (rEarth)
998  obs->setRearth(Sg3dVector(rEarth->getElement(obs2ScanIdx, 0),
999  rEarth->getElement(obs2ScanIdx, 1),
1000  rEarth->getElement(obs2ScanIdx, 2)));
1001  if (vEarth)
1002  obs->setVearth(Sg3dVector(vEarth->getElement(obs2ScanIdx, 0),
1003  vEarth->getElement(obs2ScanIdx, 1),
1004  vEarth->getElement(obs2ScanIdx, 2)));
1005  if (aEarth)
1006  obs->setAearth(Sg3dVector(aEarth->getElement(obs2ScanIdx, 0),
1007  aEarth->getElement(obs2ScanIdx, 1),
1008  aEarth->getElement(obs2ScanIdx, 2)));
1009  if (t2c_val)
1010  for (int k=0; k<3; k++)
1011  for (int l=0; l<3; l++)
1012  obs->trf2crfVal()((DIRECTION)k, (DIRECTION)l) = t2c_val->getElement(obs2ScanIdx, 3*k+l);
1013  if (t2c_rat)
1014  for (int k=0; k<3; k++)
1015  for (int l=0; l<3; l++)
1016  obs->trf2crfRat()((DIRECTION)k, (DIRECTION)l) = t2c_rat->getElement(obs2ScanIdx, 3*k+l);
1017  if (t2c_acc)
1018  for (int k=0; k<3; k++)
1019  for (int l=0; l<3; l++)
1020  obs->trf2crfAcc()((DIRECTION)k, (DIRECTION)l) = t2c_acc->getElement(obs2ScanIdx, 3*k+l);
1021 
1022  if (ut1_tai)
1023  obs->setCalcUt1_Tai(ut1_tai->getElement(obs2ScanIdx));
1024 
1025  if (pmXy)
1026  {
1027  obs->setCalcPmX(pmXy->getElement(obs2ScanIdx, 0));
1028  obs->setCalcPmY(pmXy->getElement(obs2ScanIdx, 1));
1029  };
1030 
1031  if (valNutNro)
1032  {
1033  obs->setCalcCipXv(valNutNro->getElement(obs2ScanIdx, 0));
1034  obs->setCalcCipYv(valNutNro->getElement(obs2ScanIdx, 1));
1035  obs->setCalcCipSv(valNutNro->getElement(obs2ScanIdx, 2));
1036  };
1037  if (valNutNro_rates)
1038  {
1039  obs->setCalcCipXr(valNutNro_rates->getElement(obs2ScanIdx, 0));
1040  obs->setCalcCipYr(valNutNro_rates->getElement(obs2ScanIdx, 1));
1041  obs->setCalcCipSr(valNutNro_rates->getElement(obs2ScanIdx, 2));
1042  };
1043  if (valNutEqxWahr)
1044  {
1045  obs->setCalcNutWahr_dPsiV(valNutEqxWahr->getElement(obs2ScanIdx, 0));
1046  obs->setCalcNutWahr_dEpsV(valNutEqxWahr->getElement(obs2ScanIdx, 1));
1047  };
1048  if (valNutEqxWahr_rates)
1049  {
1050  obs->setCalcNutWahr_dPsiR(valNutEqxWahr_rates->getElement(obs2ScanIdx, 0));
1051  obs->setCalcNutWahr_dEpsR(valNutEqxWahr_rates->getElement(obs2ScanIdx, 1));
1052  };
1053  if (valNutEqx)
1054  {
1055  obs->setCalcNut2006_dPsiV(valNutEqx->getElement(obs2ScanIdx, 0));
1056  obs->setCalcNut2006_dEpsV(valNutEqx->getElement(obs2ScanIdx, 1));
1057  };
1058  if (valNutEqx_rates)
1059  {
1060  obs->setCalcNut2006_dPsiR(valNutEqx_rates->getElement(obs2ScanIdx, 0));
1061  obs->setCalcNut2006_dEpsR(valNutEqx_rates->getElement(obs2ScanIdx, 1));
1062  };
1063  if (calOceanOld)
1064  {
1065  obs->setCalcOceanTideOldDelay(calOceanOld->getElement(obsIdx, 0));
1066  obs->setCalcOceanTideOldRate (calOceanOld->getElement(obsIdx, 1));
1067  };
1068  if (calPoleTideOldRestore)
1069  {
1070  obs->setCalcPoleTideOldDelay(calPoleTideOldRestore->getElement(obsIdx, 0));
1071  obs->setCalcPoleTideOldRate (calPoleTideOldRestore->getElement(obsIdx, 1));
1072  };
1073  if (calTiltRmvr)
1074  {
1075  obs->setCalcTiltRemvrDelay(calTiltRmvr->getElement(obsIdx, 0));
1076  obs->setCalcTiltRemvrRate (calTiltRmvr->getElement(obsIdx, 1));
1077  };
1078  //
1079  // partials:
1080  // stations:
1081  if (dTau_dR_1)
1082  {
1083  Sg3dVector r(dTau_dR_1->getElement(obsIdx, 0),
1084  dTau_dR_1->getElement(obsIdx, 1),
1085  dTau_dR_1->getElement(obsIdx, 2));
1086  obs->setDdel_dR_1( r);
1087  obs->setDdel_dR_2(-r);
1088  };
1089  if (dRat_dR_1)
1090  {
1091  Sg3dVector r(dRat_dR_1->getElement(obsIdx, 0),
1092  dRat_dR_1->getElement(obsIdx, 1),
1093  dRat_dR_1->getElement(obsIdx, 2));
1094  obs->setDrat_dR_1( r);
1095  obs->setDrat_dR_2(-r);
1096  };
1097  // sources:
1098  if (dV_dRA && dV_dDN)
1099  {
1100  obs->setDdel_dRA( dV_dRA->getElement(obsIdx, 0) );
1101  obs->setDdel_dDN( dV_dDN->getElement(obsIdx, 0) );
1102  obs->setDrat_dRA( dV_dRA->getElement(obsIdx, 1) );
1103  obs->setDrat_dDN( dV_dDN->getElement(obsIdx, 1) );
1104  };
1105  // dUT1:
1106  if (dV_dUT1)
1107  {
1108  obs->setDdel_dUT1( dV_dUT1->getElement(obsIdx, 0)*86400.0 ); // the sign has been already inverted
1109  obs->setDrat_dUT1( dV_dUT1->getElement(obsIdx, 1)*86400.0 ); // the sign has been already inverted
1110  obs->setD2del_dUT12(dV_dUT1->getElement(obsIdx, 2));
1111  obs->setD2rat_dUT12(dV_dUT1->getElement(obsIdx, 3));
1112  };
1113  // Polar motion:
1114  if (dV_dPx && dV_dPy)
1115  {
1116  obs->setDdel_dPx(dV_dPx->getElement(obsIdx, 0));
1117  obs->setDdel_dPy(dV_dPy->getElement(obsIdx, 0));
1118  obs->setDrat_dPx(dV_dPx->getElement(obsIdx, 1));
1119  obs->setDrat_dPy(dV_dPy->getElement(obsIdx, 1));
1120  };
1121  // Angles of nutation:
1122  if (dV_dCipX && dV_dCipY)
1123  {
1124  obs->setDdel_dCipX( dV_dCipX->getElement(obsIdx, 0) );
1125  obs->setDdel_dCipY( dV_dCipY->getElement(obsIdx, 0) );
1126  obs->setDrat_dCipX( dV_dCipX->getElement(obsIdx, 1) );
1127  obs->setDrat_dCipY( dV_dCipY->getElement(obsIdx, 1) );
1128  };
1129  if (dV_dBend)
1130  {
1131  obs->setDdel_dBend(dV_dBend->getElement(obsIdx, 0));
1132  obs->setDrat_dBend(dV_dBend->getElement(obsIdx, 1));
1133  };
1134  if (dV_dGamma)
1135  {
1136  obs->setDdel_dGamma(dV_dGamma->getElement(obsIdx, 0));
1137  obs->setDrat_dGamma(dV_dGamma->getElement(obsIdx, 1));
1138  };
1139  if (dV_dParallax)
1140  {
1141  obs->setDdel_dParallax(dV_dParallax->getElement(obsIdx, 0));
1142  obs->setDrat_dParallax(dV_dParallax->getElement(obsIdx, 1));
1143  };
1144  if (dV_dPtdX && dV_dPtdY)
1145  {
1146  obs->setDdel_dPolTideX(dV_dPtdX->getElement(obsIdx, 0));
1147  obs->setDrat_dPolTideX(dV_dPtdX->getElement(obsIdx, 1));
1148  obs->setDdel_dPolTideY(dV_dPtdY->getElement(obsIdx, 0));
1149  obs->setDrat_dPolTideY(dV_dPtdY->getElement(obsIdx, 1));
1150  };
1151  //
1152  //
1153  //
1154  // auxObs: just create entries:
1155  // the first station:
1156  auxObsByScan = station1Info->auxObservationByScanId();
1157  if (!auxObsByScan->contains(scanId)) // new scan, insert data:
1158  {
1160  auxObs->setMJD(*obs);
1161  auxObsByScan->insert(scanId, auxObs);
1162  obs->setAuxObs_1(auxObs);
1163 // if (calUnphaseCal_1)
1164 // auxObs->setCalcUnPhaseCal(calUnphaseCal_1->getElement(obsIdx, 0));
1165  }
1166  else
1167  obs->setAuxObs_1(auxObsByScan->value(scanId));
1168  // the second station:
1169  auxObsByScan = station2Info->auxObservationByScanId();
1170  if (!auxObsByScan->contains(scanId)) // new scan, insert data:
1171  {
1173  auxObs->setMJD(*obs);
1174  auxObsByScan->insert(scanId, auxObs);
1175  obs->setAuxObs_2(auxObs);
1176 // if (calUnphaseCal_2)
1177 // auxObs->setCalcUnPhaseCal(calUnphaseCal_2->getElement(obsIdx, 0));
1178  }
1179  else
1180  obs->setAuxObs_2(auxObsByScan->value(scanId));
1181  // cumulative statistics (do we need it?):
1182  station1Info->incNumTotal(DT_DELAY);
1183  station2Info->incNumTotal(DT_DELAY);
1184  sourceInfo ->incNumTotal(DT_DELAY);
1185  baselineInfo->incNumTotal(DT_DELAY);
1186 
1187  station1Info->incNumTotal(DT_RATE);
1188  station2Info->incNumTotal(DT_RATE);
1189  sourceInfo ->incNumTotal(DT_RATE);
1190  baselineInfo->incNumTotal(DT_RATE);
1191  //
1192  // user corrections:
1193  if (numOfUserCorrections)
1194  {
1195  obs->userCorrections().resize(numOfUserCorrections);
1196  for (int i=0; i<numOfUserCorrections; i++)
1197  obs->userCorrections()[i] = userCorrections->getElement(obsIdx, i);
1198  };
1199  };
1200  //
1201  //
1202  // collect observables:
1203  SgVlbiStationInfo *bandStation1Info, *bandStation2Info;
1204  SgVlbiSourceInfo *bandSourceInfo;
1205  SgVlbiBaselineInfo *bandBaselineInfo;
1206  SgVlbiObservable *o=NULL;
1207  // for calculation of effective frequencies:
1208  double effFreq4GR=0.0, effFreq4PH=0.0, effFreq4RT=0.0;
1209  //
1210  skyFreqByIfId_.clear();
1211  //
1212  for (int bandIdx=0; bandIdx<listOfBands.size(); bandIdx++)
1213  {
1214  const QString &bandKey=listOfBands.at(bandIdx);
1215  SgVlbiBand *band=new SgVlbiBand;
1216  band->setKey(bandKey);
1217  bands_.append(band);
1218  bandByKey_.insert(bandKey, band);
1219  //
1220  SgMatrix *singleBandDelays = singleBandDelaysByBand[bandKey];
1221  SgMatrix *groupDelays = groupDelaysByBand[bandKey];
1222  SgMatrix *rates = ratesByBand[bandKey];
1223  SgMatrix *phases = phasesByBand[bandKey];
1224  SgMatrix *ionCals = ionCalsByBand[bandKey];
1225  SgMatrix *ionSigmas = ionSigmasByBand[bandKey];
1226  SgMatrix *phaseCals_1 = phaseCals_1ByBand[bandKey];
1227  SgMatrix *phaseCals_2 = phaseCals_2ByBand[bandKey];
1228  SgMatrix *phaseCalFreqs_1 = phaseCalFreqs_1ByBand[bandKey];
1229  SgMatrix *phaseCalFreqs_2 = phaseCalFreqs_2ByBand[bandKey];
1230  SgMatrix *phaseCalAmps_1 = phaseCalAmps_1ByBand[bandKey];
1231  SgMatrix *phaseCalAmps_2 = phaseCalAmps_2ByBand[bandKey];
1232  SgMatrix *phaseCalPhases_1 = phaseCalPhases_1ByBand[bandKey];
1233  SgMatrix *phaseCalPhases_2 = phaseCalPhases_2ByBand[bandKey];
1234  SgMatrix *phaseCalOffsets_1 = phaseCalOffsets_1ByBand[bandKey];
1235  SgMatrix *phaseCalOffsets_2 = phaseCalOffsets_2ByBand[bandKey];
1236  SgMatrix *effFreqs = effFreqsByBand[bandKey];
1237  SgMatrix *uv = uvByBand[bandKey];
1238  SgMatrix *calFeedCorr = calFeedCorrByBand[bandKey];
1239 
1240  SgVector *refFreqs = refFreqsByBand[bandKey];
1241  SgVector *correlation = correlationByBand[bandKey];
1242  SgVector *snr = snrByBand[bandKey];
1243  SgVector *ambigs = ambigsByBand[bandKey];
1244 
1245  const QVector<QString> &qCodes=qCodesByBand[bandKey];
1246  const QVector<int> &numAmbigs=numAmbigsByBand[bandKey];
1247  const QVector<int> &numSubAmbigs=numSubAmbigsByBand[bandKey];
1248  const QVector<int> &numPhsAmbigs=numPhsAmbigsByBand[bandKey];
1249  const QVector<int> &dataFlag=dataFlagByBand[bandKey];
1250 
1251  // correlator info stuff:
1252  const QVector<QString> &fourfitOutputFName=fourfitOutputFNameByBand[bandKey];
1253  const QVector<QString> &fourfitErrorCodes=fourfitErrorCodesByBand[bandKey];
1254  const QVector<QString> &baselineCodes=baselineCodesByBand[bandKey];
1255  const QVector<QString> &tapeQualityCodes=tapeQualityCodesByBand[bandKey];
1256  const QVector<QString> &vlb1FileNames=vlb1FileNamesByBand[bandKey];
1257  const QVector<QString> &tapeIds_1=tapeIds_1ByBand[bandKey];
1258  const QVector<QString> &tapeIds_2=tapeIds_2ByBand[bandKey];
1259 // const QVector<int> &corelVersions=corelVersionsByBand[bandKey];
1260  const QVector<int> &startOffsets=startOffsetsByBand[bandKey];
1261  const QVector<int> &stopOffsets=stopOffsetsByBand[bandKey];
1262  const QVector<int> &hopsRevisionNumbers=hopsRevisionNumbersByBand[bandKey];
1263  const QVector< QVector<int> >
1264  &fourfitVersions=fourfitVersionsByBand[bandKey];
1265 // const QVector< QVector<int> >
1266 // &dbeditVersion=dbeditVersionByBand[bandKey];
1267  const QVector< QVector<int> >
1268  &epochsOfCorrelations=epochsOfCorrelationsByBand[bandKey];
1269  const QVector< QVector<int> >
1270  &epochsOfCentrals=epochsOfCentralsByBand[bandKey];
1271  const QVector< QVector<int> >
1272  &epochsOfFourfitings=epochsOfFourfitingsByBand[bandKey];
1273  const QVector< QVector<int> >
1274  &epochsOfNominalScanTime=epochsOfNominalScanTimeByBand[bandKey];
1275  SgVector *deltaEpochs=deltaEpochsByBand[bandKey];
1276  SgVector *smplRate=smplRateByBand[bandKey];
1277  SgVector *sbdResids=sbdResidsByBand[bandKey];
1278  SgVector *rateResids=rateResidsByBand[bandKey];
1279  SgVector *effDurations=effDurationsByBand[bandKey];
1280  SgVector *startSeconds=startSecondsByBand[bandKey];
1281  SgVector *stopSeconds=stopSecondsByBand[bandKey];
1282  SgVector *percentOfDiscards=percentOfDiscardsByBand[bandKey];
1283  SgVector *uniformityFactors=uniformityFactorsByBand[bandKey];
1284  SgVector *geocenterPhaseResids=geocenterPhaseResidsByBand[bandKey];
1285  SgVector *geocenterPhaseTotals=geocenterPhaseTotalsByBand[bandKey];
1286  SgVector *geocenterSbDelays=geocenterSbDelaysByBand[bandKey];
1287  SgVector *geocenterGrDelays=geocenterGrDelaysByBand[bandKey];
1288  SgVector *geocenterDelayRates=geocenterDelayRatesByBand[bandKey];
1289  SgVector *probOfFalses=probOfFalsesByBand[bandKey];
1290  SgVector *corrAprioriDelays=corrAprioriDelaysByBand[bandKey];
1291  SgVector *corrAprioriRates=corrAprioriRatesByBand[bandKey];
1292  SgVector *corrAprioriAccs=corrAprioriAccsByBand[bandKey];
1293  SgVector *incohAmps=incohAmpsByBand[bandKey];
1294  SgVector *incohAmps2=incohAmps2ByBand[bandKey];
1295  SgVector *delayResids=delayResidsByBand[bandKey];
1296  SgMatrix *urvrs=urvrsByBand[bandKey];
1297  SgMatrix *instrDelays=instrDelaysByBand[bandKey];
1298  SgMatrix *starElev=starElevByBand[bandKey];
1299  SgMatrix *zenithDelays=zenithDelaysByBand[bandKey];
1300  SgMatrix *searchParams=searchParamsByBand[bandKey];
1301  SgMatrix *corrClocks=corrClocksByBand[bandKey];
1302  SgMatrix *mDlys=mDlysByBand[bandKey];
1303  SgMatrix *mAux=mAuxByBand[bandKey];
1304  // EoCIS
1305  const QVector<QString> &fourfitControlFile=fourfitControlFileByBand[bandKey];
1306  const QVector<QString> &fourfitCommand =fourfitCommandByBand[bandKey];
1307  const QVector<int> &numLags =numLagsByBand[bandKey];
1308  const QVector<double> &apLength =apLengthByBand[bandKey];
1309  // channel info stuff:
1310  const QVector<QString> &channelIds=channelIdsByBand[bandKey];
1311  const QVector<QString> &polarizations=polarizationsByBand[bandKey];
1312 
1313  const QVector<int> &numOfChannels=numOfChannelsByBand[bandKey];
1314  const QVector<int> &bitsPerSamples=bitsPerSamplesByBand[bandKey];
1315 
1316  const QVector< QVector<int> >
1317  &errorRates_1=errorRates_1ByBand[bandKey],
1318  &errorRates_2=errorRates_2ByBand[bandKey],
1319  &bbcIdxs_1=bbcIdxs_1ByBand[bandKey],
1320  &bbcIdxs_2=bbcIdxs_2ByBand[bandKey],
1321  &corelIdxNumbersUsb=corelIdxNumbersUsbByBand[bandKey],
1322  &corelIdxNumbersLsb=corelIdxNumbersLsbByBand[bandKey];
1323  const SgVector *sampleRate=sampleRateByBand[bandKey];
1324  const SgMatrix *residFringeAmplByChan=residFringeAmplByChanByBand[bandKey],
1325  *residFringePhseByChan=residFringePhseByChanByBand[bandKey],
1326  *refFreqByChan=refFreqByChanByBand[bandKey],
1327  *numOfSamplesByChan_USB=numOfSamplesByChan_USBByBand[bandKey],
1328  *numOfSamplesByChan_LSB=numOfSamplesByChan_LSBByBand[bandKey],
1329  *numOfAccPeriodsByChan_USB=numOfAccPeriodsByChan_USBByBand[bandKey],
1330  *numOfAccPeriodsByChan_LSB=numOfAccPeriodsByChan_LSBByBand[bandKey],
1331  *loFreqs_1=loFreqs_1ByBand[bandKey],
1332  *loFreqs_2=loFreqs_2ByBand[bandKey];
1333 
1334  //
1335  // complain:
1336  //
1337  if (numOfAccPeriodsByChan_USB == NULL || numOfAccPeriodsByChan_LSB == NULL)
1339  "::getDataFromVgosDb(): numsOfAccPeriodsByChan_* == NULL");
1340  if (refFreqByChan == NULL)
1342  "::getDataFromVgosDb(): refFreqsByChan == NULL");
1343  if (residFringeAmplByChan == NULL)
1345  "::getDataFromVgosDb(): residFringeAmplByChan == NULL");
1346  //
1347  if (numOfChannels.size())
1348  {
1351  "::getDataFromVgosDb(): channel info is missing");
1352  };
1353  //
1354 
1355 
1356 // QVector<int> &ionDataFlags = ionDataFlagByBand[bandKey];
1357  // import observations:
1359  "::getDataFromVgosDb(): processing " + bandKey +
1360  "-band of the session " + vgosDb->getSessionName());
1361  int nYr, nMo, nDy, nHr, nMi;
1362  double dSec;
1363  SgMJD tStart(tZero), tStop(tZero);
1364 
1365  for (int obsIdx=0; obsIdx<numOfObs; obsIdx++)
1366  {
1367  bool hasPhaseCal;
1368  o = NULL;
1369  if ((dataFlag.size()>0 && dataFlag.at(obsIdx) != -1) ||
1370  ( ambigs && 0.0<ambigs->getElement(obsIdx) &&
1371  //snr && 0.0<snr->getElement(obsIdx) && // SNR is missing in early databases
1372  groupDelays)
1373  )
1374  {
1375  station1Name = stations_1.at(obsIdx);
1376  station2Name = stations_2.at(obsIdx);
1377  sourceName = sources.at(obsIdx);
1378  epoch = epochs4Obs.at(obsIdx);
1379  baselineName = station1Name + ":" + station2Name;
1380  obsKey.sprintf("%s",
1381  qPrintable(epoch.toString(SgMJD::F_INTERNAL) + "-" + baselineName + "@" + sourceName));
1382  // it have to be inserted already:
1383  if (observationByKey_.contains(obsKey))
1384  obs = observationByKey_.value(obsKey);
1385  else
1386  {
1388  "::getDataFromVgosDb(): the observation #" + QString("").setNum(obsIdx) + ", " +
1389  obsKey + ", does not exist in the container");
1390  return false;
1391  };
1392  //
1393  // need more robust checking for missed observables here
1394  o = new SgVlbiObservable(obs, band);
1395  o->setMediaIdx(obsIdx);
1396  obs->addObservable(bandKey, o);
1397  //
1398  // band's station #1:
1399  if (band->stationsByName().contains(station1Name))
1400  bandStation1Info = band->stationsByName().value(station1Name);
1401  else // new station, add it to the container:
1402  {
1403  bandStation1Info = new SgVlbiStationInfo(obs->getStation1Idx(), station1Name);
1404  band->stationsByName().insert(bandStation1Info->getKey(), bandStation1Info);
1405  band->stationsByIdx().insert(bandStation1Info->getIdx(), bandStation1Info);
1406  };
1407  // band's station #2:
1408  if (band->stationsByName().contains(station2Name))
1409  bandStation2Info = band->stationsByName().value(station2Name);
1410  else // new station, add it to the container:
1411  {
1412  bandStation2Info = new SgVlbiStationInfo(obs->getStation2Idx(), station2Name);
1413  band->stationsByName().insert(bandStation2Info->getKey(), bandStation2Info);
1414  band->stationsByIdx().insert(bandStation2Info->getIdx(), bandStation2Info);
1415  };
1416  // band's source:
1417  if (band->sourcesByName().contains(sourceName))
1418  bandSourceInfo = band->sourcesByName().value(sourceName);
1419  else // new source, add it to the container:
1420  {
1421  bandSourceInfo = new SgVlbiSourceInfo(obs->getSourceIdx(), sourceName);
1422  band->sourcesByName().insert(bandSourceInfo->getKey(), bandSourceInfo);
1423  band->sourcesByIdx().insert(bandSourceInfo->getIdx(), bandSourceInfo);
1424  };
1425  // band's baselines:
1426  if (band->baselinesByName().contains(baselineName))
1427  bandBaselineInfo = band->baselinesByName().value(baselineName);
1428  else // new baseline, add it to the container and register its index:
1429  {
1430  bandBaselineInfo = new SgVlbiBaselineInfo(obs->getBaselineIdx(), baselineName);
1431  band->baselinesByName().insert(bandBaselineInfo->getKey(), bandBaselineInfo);
1432  band->baselinesByIdx().insert(bandBaselineInfo->getIdx(), bandBaselineInfo);
1433  };
1434  // collect data:
1435  // single band delay:
1436  if (singleBandDelays)
1437  {
1438  o->sbDelay().setValue(singleBandDelays->getElement(obsIdx, 0));
1439  o->sbDelay().setSigma(singleBandDelays->getElement(obsIdx, 1));
1440  if (o->sbDelay().getSigma() < 5.0e-12)
1442  };
1443  // group delay:
1444  if (groupDelays)
1445  {
1446  o->grDelay().setValue(groupDelays->getElement(obsIdx, 0));
1447  o->grDelay().setSigma(groupDelays->getElement(obsIdx, 1));
1448  if (o->grDelay().getSigma() < 1.0e-15)
1450  };
1451  // delay rate:
1452  if (rates)
1453  {
1454  o->phDRate().setValue(rates->getElement(obsIdx, 0));
1455  o->phDRate().setSigma(rates->getElement(obsIdx, 1));
1456  };
1457  // ambiguity spacing:
1458  if (ambigs)
1459  o->grDelay().setAmbiguitySpacing(ambigs->getElement(obsIdx));
1460  // number of ambiguities:
1461  if (numAmbigs.size())
1462  o->grDelay().setNumOfAmbiguities(numAmbigs.at(obsIdx));
1463  // number of ambiguities:
1464  if (numSubAmbigs.size())
1465  o->grDelay().setNumOfSubAmbigs(numSubAmbigs.at(obsIdx));
1466  // number of ambiguities, phase delays:
1467  if (numPhsAmbigs.size())
1468  o->phDelay().setNumOfAmbiguities(numPhsAmbigs.at(obsIdx));
1469  // quality code:
1470  if (qCodes.size())
1471  {
1472  int d;
1473  bool isTmp;
1474  d = qCodes.at(obsIdx).toInt(&isTmp);
1475  if (!isTmp)
1476  d = -1;
1477  o->setQualityFactor(d);
1478  }
1479  else // old data, no quality code:
1480  o->setQualityFactor(9);
1481  // frequencies:
1482  if (refFreqs)
1483  o->setReferenceFrequency(refFreqs->getElement(obsIdx));
1484  if (effFreqs)
1485  {
1486  o->grDelay().setEffFreq(effFreqs->getElement(obsIdx, 0));
1487  o->phDelay().setEffFreq(effFreqs->getElement(obsIdx, 1));
1488  o->phDRate().setEffFreq(effFreqs->getElement(obsIdx, 2));
1489  };
1490  // correlation and SNR:
1491  if (correlation)
1492  o->setCorrCoeff(correlation->getElement(obsIdx));
1493  if (uv)
1494  {
1495  o->setUvFrPerAsec(0, uv->getElement(obsIdx, 0));
1496  o->setUvFrPerAsec(1, uv->getElement(obsIdx, 1));
1497  };
1498  if (calFeedCorr)
1499  {
1500  o->setCalcFeedCorrDelay(calFeedCorr->getElement(obsIdx, 0));
1501  o->setCalcFeedCorrRate (calFeedCorr->getElement(obsIdx, 1));
1502  };
1503  if (snr)
1504  o->setSnr(snr->getElement(obsIdx));
1505  // total phase:
1506  if (phases)
1507  o->setTotalPhase(phases->getElement(obsIdx, 0));
1508  //
1509  // Edits:
1510  // check for ionospheric correction, if it is already calculated, get it:
1511  if (ionCals && ionSigmas)
1512  {
1513  o->grDelay().setIonoValue(ionCals -> getElement(obsIdx, 0));
1514  o->phDRate().setIonoValue(ionCals -> getElement(obsIdx, 1));
1515  o->grDelay().setIonoSigma(ionSigmas->getElement(obsIdx, 0));
1516  o->phDRate().setIonoSigma(ionSigmas->getElement(obsIdx, 1));
1517  };
1518  if (phaseCals_1 && phaseCals_2)
1519  {
1520  o->setPhaseCalGrDelays(0, phaseCals_1->getElement(obsIdx, 0));
1521  o->setPhaseCalGrDelays(1, phaseCals_2->getElement(obsIdx, 0));
1522  o->setPhaseCalRates (0, phaseCals_1->getElement(obsIdx, 1));
1523  o->setPhaseCalRates (1, phaseCals_2->getElement(obsIdx, 1));
1524  };
1525  //
1526  // channel set up:
1527  if (bitsPerSamples.size())
1528  o->setBitsPerSample(bitsPerSamples.at(obsIdx));
1529  //
1530  // channel dependent stuff:
1531  //
1532  int nOfC=numOfChannels.size()?numOfChannels.at(obsIdx):0;
1533  if (nOfC>0)
1534  {
1536  int numOfActualChannels=0;
1537  // set up data:
1538  for (int j=0; j<nOfC; j++)
1539  {
1540  // channel setup:
1542  numOfAccPeriodsByChan_USB?numOfAccPeriodsByChan_USB->getElement(obsIdx, j):0.0);
1544  numOfAccPeriodsByChan_LSB?numOfAccPeriodsByChan_LSB->getElement(obsIdx, j):0.0);
1546  numOfSamplesByChan_USB?numOfSamplesByChan_USB->getElement(obsIdx, j):0.0);
1548  numOfSamplesByChan_LSB?numOfSamplesByChan_LSB->getElement(obsIdx, j):0.0);
1549  o->refFreqByChan()->setElement (j,
1550  refFreqByChan?refFreqByChan->getElement(obsIdx, j):0.0);
1551  if (0.0001 < o->refFreqByChan()->getElement(j))
1552  numOfActualChannels++;
1554  residFringeAmplByChan?residFringeAmplByChan->getElement(obsIdx, j):0.0);
1555  o->fringePhaseByChan()->setElement (j,
1556  residFringePhseByChan?residFringePhseByChan->getElement(obsIdx, j)/RAD2DEG:0.0);
1557  if (loFreqs_1 && loFreqs_1->nRow()>0 && loFreqs_1->nCol()>0)
1558  o->loFreqByChan_1()->setElement(j, loFreqs_1->getElement(obsIdx, j));
1559  if (loFreqs_2 && loFreqs_2->nRow()>0 && loFreqs_2->nCol()>0)
1560  o->loFreqByChan_2()->setElement(j, loFreqs_2->getElement(obsIdx, j));
1561 
1562  (*o->chanIdByChan())[j] = channelIds.size()?channelIds.at(obsIdx).at(2*j).toLatin1():' ';
1563  (*o->polarization_1ByChan())[j] = polarizations.size()?
1564  polarizations.at(obsIdx).at(4*j ).toLatin1():' ';
1565  (*o->polarization_2ByChan())[j] = polarizations.size()?
1566  polarizations.at(obsIdx).at(4*j + 2).toLatin1():' ';
1567  (*o->corelIndexNumUSB())[j] = corelIdxNumbersUsb.size()?corelIdxNumbersUsb.at(obsIdx).at(j):0;
1568  (*o->corelIndexNumLSB())[j] = corelIdxNumbersLsb.size()?corelIdxNumbersLsb.at(obsIdx).at(j):0;
1569  (*o->bbcIdxByChan_1())[j] = bbcIdxs_1.size()?bbcIdxs_1.at(obsIdx).at(j):0;
1570  (*o->bbcIdxByChan_2())[j] = bbcIdxs_2.size()?bbcIdxs_2.at(obsIdx).at(j):0;
1571  //
1572  //
1573  // phase calibration data:
1574  if (phaseCalAmps_1 && phaseCalAmps_2 && phaseCalPhases_1 && phaseCalPhases_2 &&
1575  phaseCalFreqs_1 && phaseCalFreqs_2 && phaseCalOffsets_1 && phaseCalOffsets_2)
1576  {
1578  phaseCalAmps_1->getElement(obsIdx, j));
1580  phaseCalAmps_2->getElement(obsIdx, j));
1582  phaseCalPhases_1->getElement(obsIdx, j)*DEG2RAD/100.0);
1584  phaseCalPhases_2->getElement(obsIdx, j)*DEG2RAD/100.0);
1586  phaseCalFreqs_1->getElement(obsIdx, j));
1588  phaseCalFreqs_2->getElement(obsIdx, j));
1590  phaseCalOffsets_1->getElement(obsIdx, j)*DEG2RAD/100.0);
1592  phaseCalOffsets_2->getElement(obsIdx, j)*DEG2RAD/100.0);
1593  hasPhaseCal = true;
1594  }
1595  else
1596  hasPhaseCal = false;
1597  //
1598  //
1599  if (errorRates_1.size())
1600  o->phaseCalData_1ByChan()->setElement (4,j, errorRates_1.at(obsIdx).at(j));
1601  if (errorRates_2.size())
1602  o->phaseCalData_2ByChan()->setElement (4,j, errorRates_2.at(obsIdx).at(j));
1603  //
1604  //
1605  QString ifId((*o->chanIdByChan())[j]);
1606  if (ifId.size() && ifId!=QString(" "))
1607  {
1608  if (skyFreqByIfId_.contains(ifId) &&
1609  skyFreqByIfId_.value(ifId) != o->refFreqByChan()->getElement(j))
1611  "::getDataFromVgosDb(): the IF \"" + ifId + "\" got new sky frequency " +
1612  QString("").sprintf("%.4f (old=%.4f) obs:",
1613  o->refFreqByChan()->getElement(j), skyFreqByIfId_.value(ifId)) +
1614  o->strId());
1615  skyFreqByIfId_[ifId] = o->refFreqByChan()->getElement(j);
1616  };
1617  };
1618  //
1619  if (cppsSoft_ != CPPS_PIMA && hasPhaseCal)
1620  o->calcPhaseCalDelay();
1621  //
1622  if (sampleRate && numOfActualChannels &&
1623  cppsSoft_ != CPPS_PIMA &&
1624  vgosDb->getCorrelatorType() != SgVgosDb::CT_S2)
1625  {
1626  o->setSampleRate(sampleRate->getElement(obsIdx));
1627  // calculate the effective frequencies:
1629  *o->refFreqByChan(), *o->fringeAmplitudeByChan(),
1631  sampleRate->getElement(obsIdx), o->getReferenceFrequency(),
1632  nOfC, effFreq4GR, effFreq4PH, effFreq4RT, correlatorType, o->strId());
1633  o->grDelay().setEffFreq(effFreq4GR);
1634  o->phDelay().setEffFreq(effFreq4PH);
1635  o->phDRate().setEffFreq(effFreq4RT);
1636  // calculate the effective frequencies with equal weights:
1638  *o->refFreqByChan(), *o->fringeAmplitudeByChan(),
1640  sampleRate->getElement(obsIdx), o->getReferenceFrequency(),
1641  nOfC, effFreq4GR, effFreq4PH, effFreq4RT, correlatorType, o->strId(), true);
1642  o->grDelay().setEffFreqEqWgt(effFreq4GR);
1643  o->phDelay().setEffFreqEqWgt(effFreq4PH);
1644  o->phDRate().setEffFreqEqWgt(effFreq4RT);
1645  };
1646  }
1647  else if (numOfChannels.size())
1649  "::getDataFromVgosDb(): get zero number of channels: " + o->strId());
1650  //
1651  //
1652  //
1653  // correlator info stuff:
1654  if (fourfitOutputFName.size())
1655  o->setFourfitOutputFName(fourfitOutputFName.at(obsIdx));
1656  if (fourfitErrorCodes.size())
1657  o->setErrorCode(fourfitErrorCodes.at(obsIdx));
1658  //
1659  if (baselineCodes.size() && cppsSoft_ != CPPS_PIMA)
1660  {
1661  char cid;
1662  cid = baselineCodes.at(obsIdx).at(0).toLatin1();
1663  station1Info = stationsByName_.value(station1Name);
1664  if (station1Info->getCid() == ' ')
1665  {
1666  station1Info->setCid(cid);
1668  "::getDataFromVgosDb(): station#1 " + station1Info->getKey() + " set station CID to \"" +
1669  cid + "\" at " + o->strId());
1670  }
1671  else if (station1Info->getCid() != cid)
1672  {
1674  "::getDataFromVgosDb(): station#1 " + station1Info->getKey() +
1675  " station CID missmatch: \"" + station2Info->getCid() + "\" vs \"" + cid +
1676  "\" at " + o->strId());
1677  };
1678  cid = baselineCodes.at(obsIdx).at(1).toLatin1();
1679  station2Info = stationsByName_.value(station2Name);
1680  if (station2Info->getCid() == ' ')
1681  {
1682  station2Info->setCid(cid);
1684  "::getDataFromVgosDb(): station#2 " + station2Info->getKey() + " set station CID to \"" +
1685  cid + "\" at " + o->strId());
1686  }
1687  else if (station2Info->getCid() != cid)
1688  {
1690  "::getDataFromVgosDb(): station#2 " + station2Info->getKey() +
1691  " station CID missmatch: \"" + station2Info->getCid() + "\" vs \"" + cid +
1692  "\" at " + o->strId());
1693  };
1694  };
1695  //
1696  if (tapeQualityCodes.size())
1697  o->setTapeQualityCode(tapeQualityCodes.at(obsIdx));
1698  if (vlb1FileNames.size())
1699  obs->setCorrRootFileName(vlb1FileNames.at(obsIdx));
1700  if (tapeIds_1.size() && obs->auxObs_1())
1701  obs->auxObs_1()->setTapeId(tapeIds_1.at(obsIdx));
1702  if (tapeIds_2.size() && obs->auxObs_2())
1703  obs->auxObs_2()->setTapeId(tapeIds_2.at(obsIdx));
1704  if (startOffsets.size())
1705  o->setStartOffset(startOffsets.at(obsIdx));
1706  if (stopOffsets.size())
1707  o->setStopOffset(stopOffsets.at(obsIdx));
1708  if (hopsRevisionNumbers.size())
1709  o->setHopsRevisionNumber(hopsRevisionNumbers.at(obsIdx));
1710  if (fourfitVersions.size() && 2<=fourfitVersions.at(obsIdx).size())
1711  {
1712  o->setFourfitVersion(0, fourfitVersions.at(obsIdx).at(0));
1713  o->setFourfitVersion(1, fourfitVersions.at(obsIdx).at(1));
1714  };
1715  //
1716  // epochs:
1717  if (epochsOfCorrelations.size() && 6<=epochsOfCorrelations.at(obsIdx).size())
1718  {
1719  epoch.setUpEpoch(epochsOfCorrelations.at(obsIdx).at(0), epochsOfCorrelations.at(obsIdx).at(1),
1720  epochsOfCorrelations.at(obsIdx).at(2), epochsOfCorrelations.at(obsIdx).at(3),
1721  epochsOfCorrelations.at(obsIdx).at(4), (double)epochsOfCorrelations.at(obsIdx).at(5));
1722  o->setEpochOfCorrelation(epoch);
1723  };
1724  if (epochsOfCentrals.size() && 6<=epochsOfCentrals.at(obsIdx).size())
1725  {
1726  epoch.setUpEpoch(epochsOfCentrals.at(obsIdx).at(0), epochsOfCentrals.at(obsIdx).at(1),
1727  epochsOfCentrals.at(obsIdx).at(2), epochsOfCentrals.at(obsIdx).at(3),
1728  epochsOfCentrals.at(obsIdx).at(4), (double)epochsOfCentrals.at(obsIdx).at(5));
1729  o->setEpochCentral(epoch);
1730  };
1731  if (epochsOfFourfitings.size() && 6<=epochsOfFourfitings.at(obsIdx).size())
1732  {
1733  epoch.setUpEpoch(epochsOfFourfitings.at(obsIdx).at(0), epochsOfFourfitings.at(obsIdx).at(1),
1734  epochsOfFourfitings.at(obsIdx).at(2), epochsOfFourfitings.at(obsIdx).at(3),
1735  epochsOfFourfitings.at(obsIdx).at(4), (double)epochsOfFourfitings.at(obsIdx).at(5));
1736  o->setEpochOfFourfitting(epoch);
1737  };
1738  if (epochsOfNominalScanTime.size() && 6<=epochsOfNominalScanTime.at(obsIdx).size())
1739  {
1740  epoch.setUpEpoch(epochsOfNominalScanTime.at(obsIdx).at(0),
1741  epochsOfNominalScanTime.at(obsIdx).at(1),
1742  epochsOfNominalScanTime.at(obsIdx).at(2), epochsOfNominalScanTime.at(obsIdx).at(3),
1743  epochsOfNominalScanTime.at(obsIdx).at(4), (double)epochsOfNominalScanTime.at(obsIdx).at(5));
1744  o->setEpochOfScan(epoch);
1745  };
1746  //
1747  if (deltaEpochs)
1748  o->setCentrOffset(deltaEpochs->getElement(obsIdx));
1749  if (smplRate)
1750  o->setSampleRate(smplRate->getElement(obsIdx));
1751  if (sbdResids)
1752  o->sbDelay().setResidualFringeFitting(sbdResids->getElement(obsIdx));
1753  if (rateResids)
1754  o->phDRate().setResidualFringeFitting(rateResids->getElement(obsIdx));
1755  if (effDurations)
1756  o->setEffIntegrationTime(effDurations->getElement(obsIdx));
1757  //
1758  if (startSeconds && stopSeconds)
1759  {
1760  SgMJD::MJD_reverse(o->owner()->getDate(), o->owner()->getTime(),
1761  nYr, nMo, nDy, nHr, nMi, dSec);
1762  tStart = SgMJD(nYr, nMo, nDy, nHr, 0, startSeconds->getElement(obsIdx));
1763  tStop = SgMJD(nYr, nMo, nDy, nHr, 0, stopSeconds->getElement(obsIdx));
1764  if (tStart - *o->owner() > 40.0/24.0/60.0)
1765  tStart -= 1.0/24.0;
1766  if (*o->owner() - tStart > 40.0/24.0/60.0)
1767  tStart += 1.0/24.0;
1768  if (*o->owner() - tStop > 40.0/24.0/60.0)
1769  tStop += 1.0/24.0;
1770  if (tStop - *o->owner() > 40.0/24.0/60.0)
1771  tStop -= 1.0/24.0;
1772  if (tStart < tStop)
1773  {
1774  o->setTstart(tStart);
1775  o->setTstop (tStop);
1776  }
1777  else
1778  {
1779  o->setTstart(tStop);
1780  o->setTstop (tStart);
1781  };
1782  };
1783  //
1784  if (percentOfDiscards)
1785  o->setDiscardRatio(percentOfDiscards->getElement(obsIdx));
1786  if (uniformityFactors)
1787  o->setAcceptedRatio(uniformityFactors->getElement(obsIdx));
1788  if (geocenterPhaseResids)
1789  o->setGeocenterResidPhase(geocenterPhaseResids->getElement(obsIdx)/RAD2DEG);
1790  if (geocenterPhaseTotals)
1791  o->setGeocenterTotalPhase(geocenterPhaseTotals->getElement(obsIdx)/RAD2DEG);
1792  if (geocenterSbDelays)
1793  o->sbDelay().setGeocenterValue(geocenterSbDelays->getElement(obsIdx));
1794  if (geocenterGrDelays)
1795  o->grDelay().setGeocenterValue(geocenterGrDelays->getElement(obsIdx));
1796  if (geocenterDelayRates)
1797  o->phDRate().setGeocenterValue(geocenterDelayRates->getElement(obsIdx));
1798  if (delayResids)
1799  o->grDelay().setResidualFringeFitting(delayResids->getElement(obsIdx));
1800  if (probOfFalses)
1801  o->setProbabOfFalseDetection(probOfFalses->getElement(obsIdx));
1802  if (corrAprioriDelays)
1803  o->setAprioriDra(0, corrAprioriDelays->getElement(obsIdx));
1804  if (corrAprioriRates)
1805  o->setAprioriDra(1, corrAprioriRates->getElement(obsIdx));
1806  if (corrAprioriAccs)
1807  o->setAprioriDra(2, corrAprioriAccs->getElement(obsIdx));
1808  if (incohAmps)
1809  o->setIncohChanAddAmp(incohAmps->getElement(obsIdx));
1810  if (incohAmps2)
1811  o->setIncohSegmAddAmp(incohAmps2->getElement(obsIdx));
1812 
1813  // matrices:
1814  if (urvrs)
1815  {
1816  o->setUrVr(0, urvrs->getElement(obsIdx,0));
1817  o->setUrVr(1, urvrs->getElement(obsIdx,1));
1818  };
1819  if (instrDelays)
1820  {
1821  o->setInstrDelay(0, instrDelays->getElement(obsIdx,0));
1822  o->setInstrDelay(1, instrDelays->getElement(obsIdx,1));
1823  };
1824  //
1825  if (starElev)
1826  {
1827  o->setCorrelStarElev_1(starElev->getElement(obsIdx, 0)/RAD2DEG);
1828  o->setCorrelStarElev_2(starElev->getElement(obsIdx, 1)/RAD2DEG);
1829  };
1830  if (zenithDelays)
1831  {
1832  o->setCorrelZdelay_1(zenithDelays->getElement(obsIdx, 0));
1833  o->setCorrelZdelay_2(zenithDelays->getElement(obsIdx, 1));
1834  };
1835  //
1836  if (searchParams)
1837  for (int j=0; j<6; j++)
1838  o->setFourfitSearchParameters(j, searchParams->getElement(obsIdx,j));
1839  if (corrClocks)
1840  {
1841  o->setCorrClocks(0, 0, corrClocks->getElement(obsIdx,0));
1842  o->setCorrClocks(0, 1, corrClocks->getElement(obsIdx,1));
1843  o->setCorrClocks(1, 0, corrClocks->getElement(obsIdx,2));
1844  o->setCorrClocks(1, 1, corrClocks->getElement(obsIdx,3));
1845  };
1846  if (mDlys)
1847  {
1848  o->vDlys()->setElement(0, mDlys->getElement(obsIdx,0));
1849  o->vDlys()->setElement(1, mDlys->getElement(obsIdx,1));
1850  o->vDlys()->setElement(2, mDlys->getElement(obsIdx,2));
1851  };
1852  if (mAux)
1853  {
1854  o->vAuxData()->setElement(0, mAux->getElement(obsIdx,0));
1855  o->vAuxData()->setElement(1, mAux->getElement(obsIdx,1)/RAD2DEG);
1856  o->vAuxData()->setElement(2, mAux->getElement(obsIdx,2));
1857  o->vAuxData()->setElement(3, mAux->getElement(obsIdx,3));
1858  };
1859  // EoCIS
1860  //
1861  if (fourfitControlFile.size())
1862  o->setFourfitControlFile(fourfitControlFile.at(obsIdx));
1863  if (fourfitCommand.size())
1864  o->setFourfitCommandOverride(fourfitCommand.at(obsIdx));
1865  if (numLags.size())
1866  o->setNlags(numLags.at(obsIdx));
1867  if (apLength.size())
1868  obs->setApLength(apLength.at(obsIdx));
1869 
1870  if (delUFlags.size())
1871  o->grDelay().setUnweightFlag(delUFlags.at(obsIdx));
1872  // config_ can be NULL:
1874  (o->grDelay().getUnweightFlag()==1 || o->grDelay().getUnweightFlag()==2))
1876  if (ratUFlags.size())
1877  o->phDRate().setUnweightFlag(ratUFlags.at(obsIdx));
1878  if (phsUFlags.size())
1879  o->phDelay().setUnweightFlag(phsUFlags.at(obsIdx));
1880  // + uAcSup, where to put it?
1881  //
1882  if (ambigs && ambigs->getElement(obsIdx)<=0.0 && // no ambigs for
1883  groupDelays && groupDelays->getElement(obsIdx, 1) > 0.0) // good observation
1884  {
1885  o->setErrorCode("Z");
1886  if (vgosDb->getCorrelatorType()!=SgVgosDb::CT_Unknown || ambigs->getElement(obsIdx)<0.0)
1888  "::getDataFromVgosDb(): wrong ambiguity spacing (" +
1889  QString("").setNum(ambigs->getElement(obsIdx)) + ") for the observable #" +
1890  QString("").setNum(obsIdx) + " at the " + bandKey + "-band of " + obs->getKey() +
1891  " on " + name_);
1892  };
1893  if (qCodes.size() &&
1894  qCodes.at(obsIdx).simplified().size() == 0 && // it is ok, nothing to complain
1895  o->getErrorCode().simplified().size() == 0)
1896  o->setErrorCode("Y");
1897  //
1898  // per band statistics:
1899  band ->incNumTotal(DT_DELAY);
1900  bandStation1Info->incNumTotal(DT_DELAY);
1901  bandStation2Info->incNumTotal(DT_DELAY);
1902  bandSourceInfo ->incNumTotal(DT_DELAY);
1903  bandBaselineInfo->incNumTotal(DT_DELAY);
1904 
1905  band ->incNumTotal(DT_RATE);
1906  bandStation1Info->incNumTotal(DT_RATE);
1907  bandStation2Info->incNumTotal(DT_RATE);
1908  bandSourceInfo ->incNumTotal(DT_RATE);
1909  bandBaselineInfo->incNumTotal(DT_RATE);
1910  }
1911  else
1913  "::getDataFromVgosDb(): skipped observable #" + QString("").setNum(obsIdx) +
1914  " at the " + bandKey + "-band: missed data");
1915  };
1916  //
1917  // set up band's attributes:
1918  band->setTCreation(vgosDb->getDateOfCreation());
1919  band->setInputFileName(vgosDb->getWrapperFileName());
1920 /*
1921  if (hasCorrelatorType_)
1922  band->setCorrelatorType(image->getStr(dCorrelatorType_, 0,0));
1923 */
1924 
1925  if ((ionCals && ionSigmas) || (dTec && dTecStdDev))
1926  {
1929  };
1930  //
1931  // quick'n'dirty:
1932  int idx(0);
1933  o = observations_.at(idx)->observable(bandKey);
1934  while (!o && idx<observations_.size())
1935  o = observations_.at(idx++)->observable(bandKey);
1936  if (o)
1937  band->setFrequency(o->getReferenceFrequency());
1938  };
1939  //
1940  //
1942  "::getDataFromVgosDb(): collected " + QString().setNum(skyFreqByIfId_.size()) +
1943  " ifId<->skyFrq pairs");
1944 
1945  //
1946  // check for fourfit info:
1947  if (fourfitControlFileByBand.size() && fourfitControlFileByBand.begin().value().size()==0)
1948  {
1950  "::getDataFromVgosDb(): no fourfit info found for each band, trying to check the data for the "
1951  "X-band only");
1952 
1953  QVector<QString> fourfitControlFile, fourfitCommand;
1954  QVector<int> numLags;
1955  QVector<double> apL;
1956 
1957  if (!vgosDb->loadMiscFourFit("", fourfitControlFile, fourfitCommand, numLags, apL))
1959  "::getDataFromVgosDb(): reading Fourfit Info has failed");
1960  else
1961  {
1962  for (int i=0; i<numOfObs; i++)
1963  {
1964  SgVlbiObservation *obs=observations_.at(i);
1965  for (QMap<QString, SgVlbiObservable*>::iterator it=obs->observableByKey().begin();
1966  it!=obs->observableByKey().end(); ++it)
1967  {
1968 // SgVlbiObservable *o=obs->observable("X");
1969  SgVlbiObservable *o=it.value();
1970  if (o)
1971  {
1972  o->setFourfitControlFile(fourfitControlFile.at(i));
1973  o->setFourfitCommandOverride(fourfitCommand.at(i));
1974  o->setNlags(numLags.at(i));
1975  };
1976  };
1977  obs->setApLength(apL.at(i));
1978  };
1979  };
1980  fourfitControlFile.clear();
1981  fourfitCommand.clear();
1982  numLags.clear();
1983  apL.clear();
1984  };
1985  //
1986  //
1987  //
1988  if (dTec && dTecStdDev)
1990  //
1991  //
1992  //
1993  // end of phase 1
1994  //
1995  //
1996  //
1997  // checks for available "contributions":
1998  if (calOcean)
1999  hasOceanTideContrib_ = true;
2000  if (calPoleTide)
2001  hasPoleTideContrib_= true;
2002  if (calEarthTide)
2003  hasEarthTideContrib_= true;
2004  if (calWobbleX)
2005  hasWobblePxContrib_= true;
2006  if (calWobbleY)
2007  hasWobblePyContrib_= true;
2008  if (calWobNut)
2009  hasWobbleNutContrib_= true;
2010  if (calEopHiFiXY)
2012  if (calEopHiFiUt)
2013  hasUt1HighFreqContrib_ = true;
2014  if (calTiltRmvr)
2015  hasTiltRemvrContrib_= true;
2016  if (calHiFreqLibrationPm)
2017  hasPxyLibrationContrib_ = true;
2018  if (calHiFreqLibrationUt)
2019  hasUt1LibrationContrib_ = true;
2020  if (calOceanPoleTideLd)
2021  hasOceanPoleTideContrib_ = true;
2022  if (calPoleTideOldRestore)
2023  hasPoleTideOldContrib_= true;
2024  if (calOceanOld)
2025  hasOceanTideOldContrib_ = true;
2026  hasUnPhaseCalContrib_= true;
2027  for (int i=0; i<listOfBands.size(); i++)
2028  {
2029  const QString &bandKey=listOfBands.at(i);
2031  phaseCals_1ByBand[bandKey]!=NULL && phaseCals_2ByBand[bandKey]!=NULL;
2032  };
2033  if (dV_dCipX && dV_dCipY)
2034  hasCipPartials_ = true;
2035  else
2036  hasCipPartials_ = false;
2037  //
2038  //
2039  // clear temporary storages:
2040  for (int i=0; i<vectors2del.size(); i++)
2041  if (vectors2del.at(i))
2042  delete vectors2del.at(i);
2043 
2044  for (int i=0; i<matrices2del.size(); i++)
2045  if (matrices2del.at(i))
2046  delete matrices2del.at(i);
2047  //
2048  scanNames.clear();
2049  scanFullNames.clear();
2050  ionsBits.clear();
2051  obs2Scan.clear();
2052  delUFlags.clear();
2053  phsUFlags.clear();
2054  ratUFlags.clear();
2055  uAcSups.clear();
2056 
2057  for (int i=0; i<listOfBands.size(); i++)
2058  {
2059  const QString &bandKey=listOfBands.at(i);
2060  qCodesByBand[bandKey].clear();
2061 
2062  // correlator info stuff:
2063  fourfitOutputFNameByBand[bandKey].clear();
2064  fourfitErrorCodesByBand[bandKey].clear();
2065  baselineCodesByBand[bandKey].clear();
2066  tapeQualityCodesByBand[bandKey].clear();
2067  vlb1FileNamesByBand[bandKey].clear();
2068  tapeIds_1ByBand[bandKey].clear();
2069  tapeIds_2ByBand[bandKey].clear();
2070 // corelVersionsByBand[bandKey].clear();
2071  startOffsetsByBand[bandKey].clear();
2072  stopOffsetsByBand[bandKey].clear();
2073  hopsRevisionNumbersByBand[bandKey].clear();
2074  fourfitVersionsByBand[bandKey].clear();
2075 // dbeditVersionByBand[bandKey].clear();
2076  epochsOfCorrelationsByBand[bandKey].clear();
2077  epochsOfCentralsByBand[bandKey].clear();
2078  epochsOfFourfitingsByBand[bandKey].clear();
2079  epochsOfNominalScanTimeByBand[bandKey].clear();
2080  if (deltaEpochsByBand[bandKey])
2081  delete deltaEpochsByBand[bandKey];
2082  if (smplRateByBand[bandKey])
2083  delete smplRateByBand[bandKey];
2084  if (sbdResidsByBand[bandKey])
2085  delete sbdResidsByBand[bandKey];
2086  if (rateResidsByBand[bandKey])
2087  delete rateResidsByBand[bandKey];
2088  if (effDurationsByBand[bandKey])
2089  delete effDurationsByBand[bandKey];
2090  if (startSecondsByBand[bandKey])
2091  delete startSecondsByBand[bandKey];
2092  if (stopSecondsByBand[bandKey])
2093  delete stopSecondsByBand[bandKey];
2094  if (percentOfDiscardsByBand[bandKey])
2095  delete percentOfDiscardsByBand[bandKey];
2096 
2097  if (uniformityFactorsByBand[bandKey])
2098  delete uniformityFactorsByBand[bandKey];
2099  if (geocenterPhaseResidsByBand[bandKey])
2100  delete geocenterPhaseResidsByBand[bandKey];
2101  if (geocenterPhaseTotalsByBand[bandKey])
2102  delete geocenterPhaseTotalsByBand[bandKey];
2103  if (geocenterSbDelaysByBand[bandKey])
2104  delete geocenterSbDelaysByBand[bandKey];
2105  if (geocenterGrDelaysByBand[bandKey])
2106  delete geocenterGrDelaysByBand[bandKey];
2107  if (geocenterDelayRatesByBand[bandKey])
2108  delete geocenterDelayRatesByBand[bandKey];
2109  if (probOfFalsesByBand[bandKey])
2110  delete probOfFalsesByBand[bandKey];
2111  if (corrAprioriDelaysByBand[bandKey])
2112  delete corrAprioriDelaysByBand[bandKey];
2113  if (corrAprioriRatesByBand[bandKey])
2114  delete corrAprioriRatesByBand[bandKey];
2115  if (corrAprioriAccsByBand[bandKey])
2116  delete corrAprioriAccsByBand[bandKey];
2117  if (incohAmpsByBand[bandKey])
2118  delete incohAmpsByBand[bandKey];
2119  if (incohAmps2ByBand[bandKey])
2120  delete incohAmps2ByBand[bandKey];
2121  if (delayResidsByBand[bandKey])
2122  delete delayResidsByBand[bandKey];
2123  if (urvrsByBand[bandKey])
2124  delete urvrsByBand[bandKey];
2125  if (instrDelaysByBand[bandKey])
2126  delete instrDelaysByBand[bandKey];
2127  if (starElevByBand[bandKey])
2128  delete starElevByBand[bandKey];
2129  if (zenithDelaysByBand[bandKey])
2130  delete zenithDelaysByBand[bandKey];
2131  if (searchParamsByBand[bandKey])
2132  delete searchParamsByBand[bandKey];
2133  if (corrClocksByBand[bandKey])
2134  delete corrClocksByBand[bandKey];
2135  if (mDlysByBand[bandKey])
2136  delete mDlysByBand[bandKey];
2137  if (mAuxByBand[bandKey])
2138  delete mAuxByBand[bandKey];
2139  // EoCIS
2140 
2141  fourfitControlFileByBand[bandKey].clear();
2142  fourfitCommandByBand[bandKey].clear();
2143  numLagsByBand[bandKey].clear();
2144  apLengthByBand[bandKey].clear();
2145 
2146  numAmbigsByBand[bandKey].clear();
2147  numSubAmbigsByBand[bandKey].clear();
2148  numPhsAmbigsByBand[bandKey].clear();
2149  dataFlagByBand[bandKey].clear();
2150  ionDataFlagByBand[bandKey].clear();
2151  if (ambigsByBand[bandKey])
2152  delete ambigsByBand[bandKey];
2153  if (correlationByBand[bandKey])
2154  delete correlationByBand[bandKey];
2155  if (uvByBand[bandKey])
2156  delete uvByBand[bandKey];
2157  if (calFeedCorrByBand[bandKey])
2158  delete calFeedCorrByBand[bandKey];
2159  if (snrByBand[bandKey])
2160  delete snrByBand[bandKey];
2161  if (sampleRateByBand[bandKey])
2162  delete sampleRateByBand[bandKey];
2163  if (residFringeAmplByChanByBand[bandKey])
2164  delete residFringeAmplByChanByBand[bandKey];
2165  if (residFringePhseByChanByBand[bandKey])
2166  delete residFringePhseByChanByBand[bandKey];
2167  if (refFreqByChanByBand[bandKey])
2168  delete refFreqByChanByBand[bandKey];
2169  if (numOfSamplesByChan_USBByBand[bandKey])
2170  delete numOfSamplesByChan_USBByBand[bandKey];
2171  if (numOfSamplesByChan_LSBByBand[bandKey])
2172  delete numOfSamplesByChan_LSBByBand[bandKey];
2173  if (numOfAccPeriodsByChan_USBByBand[bandKey])
2174  delete numOfAccPeriodsByChan_USBByBand[bandKey];
2175  if (numOfAccPeriodsByChan_LSBByBand[bandKey])
2176  delete numOfAccPeriodsByChan_LSBByBand[bandKey];
2177  if (loFreqs_1ByBand[bandKey])
2178  delete loFreqs_1ByBand[bandKey];
2179  if (loFreqs_2ByBand[bandKey])
2180  delete loFreqs_2ByBand[bandKey];
2181 
2182  if (refFreqsByBand[bandKey])
2183  delete refFreqsByBand[bandKey];
2184  if (phasesByBand[bandKey])
2185  delete phasesByBand[bandKey];
2186  if (ionCalsByBand[bandKey])
2187  delete ionCalsByBand[bandKey];
2188  if (ionSigmasByBand[bandKey])
2189  delete ionSigmasByBand[bandKey];
2190  if (phaseCals_1ByBand[bandKey])
2191  delete phaseCals_1ByBand[bandKey];
2192  if (phaseCals_2ByBand[bandKey])
2193  delete phaseCals_2ByBand[bandKey];
2194  if (ratesByBand[bandKey])
2195  delete ratesByBand[bandKey];
2196  if (groupDelaysByBand[bandKey])
2197  delete groupDelaysByBand[bandKey];
2198  if (singleBandDelaysByBand[bandKey])
2199  delete singleBandDelaysByBand[bandKey];
2200  if (phaseCalFreqs_1ByBand[bandKey])
2201  delete phaseCalFreqs_1ByBand[bandKey];
2202  if (phaseCalAmps_1ByBand[bandKey])
2203  delete phaseCalAmps_1ByBand[bandKey];
2204  if (phaseCalPhases_1ByBand[bandKey])
2205  delete phaseCalPhases_1ByBand[bandKey];
2206  if (phaseCalOffsets_1ByBand[bandKey])
2207  delete phaseCalOffsets_1ByBand[bandKey];
2208  if (phaseCalRates_1ByBand[bandKey])
2209  delete phaseCalRates_1ByBand[bandKey];
2210  if (phaseCalFreqs_2ByBand[bandKey])
2211  delete phaseCalFreqs_2ByBand[bandKey];
2212  if (phaseCalAmps_2ByBand[bandKey])
2213  delete phaseCalAmps_2ByBand[bandKey];
2214  if (phaseCalPhases_2ByBand[bandKey])
2215  delete phaseCalPhases_2ByBand[bandKey];
2216  if (phaseCalOffsets_2ByBand[bandKey])
2217  delete phaseCalOffsets_2ByBand[bandKey];
2218  if (phaseCalRates_2ByBand[bandKey])
2219  delete phaseCalRates_2ByBand[bandKey];
2220  };
2221  listOfBands.clear();
2222  epochs4Scans.clear();
2223  epochs4Obs.clear();
2224  stations_1.clear();
2225  stations_2.clear();
2226  sources.clear();
2227  //
2228  //
2229  //
2230  //
2231  // Phase two. Collecting station infos:
2232  bool isCalced=isAttr(Attr_HAS_CALC_DATA);
2233  bool hasAuxObs=false;
2234  for (StationsByName_it it=stationsByName_.begin(); it!=stationsByName_.end(); ++it)
2235  {
2236  SgVlbiStationInfo *stInfo = it.value();
2237  QString origin("");
2238  //
2239  if (parametersDescriptor_) // can be NULL
2240  {
2243  };
2244  //
2245  const QString stnName(stInfo->getKey());
2246  QList<SgMJD> stEpochs;
2247  if (vgosDb->loadStationEpochs(stnName, stEpochs) && stEpochs.size())
2248  {
2249  int numOfPts=stEpochs.size();
2250  int numOfTsysIFs=0;
2251 // QMap<SgMJD, int> idxByMjd;
2252  QMap<QString, int> idxByMjd;
2253  for (int i=0; i<numOfPts; i++)
2254  idxByMjd.insert(stEpochs.at(i).toString(SgMJD::F_YYYYMMDDHHMMSSSS), i);
2255 
2256  SgVector *parAngle=NULL, *refClockOffset=NULL;
2257  SgMatrix *azTheo=NULL, *elTheo=NULL;
2258  SgMatrix *calAxisOffset=NULL;
2259  SgMatrix *calCable=NULL;
2260  SgMatrix *calNmfDry=NULL;
2261  SgMatrix *calNmfWet=NULL;
2262  SgMatrix *calHorzOLoad=NULL, *calVertOLoad=NULL;
2263  SgVector *metAtmPres=NULL, *metAtmRH=NULL, *metAtmTemp=NULL;
2264  SgMatrix *partAxisOffset=NULL;
2265  SgMatrix *partTropZenithDry=NULL, *partTropZenithWet=NULL, *partTropGrad=NULL;
2266  SgMatrix *ocnLdR=NULL, *ocnLdV=NULL;
2267  SgMatrix *tSyses=NULL;
2268  //
2269  QVector<double> tsysFreqs;
2270  QVector<QString> tsysIds, tsysSbs, tsysPzs;
2271 
2272  // KOMB:
2273  if (!vgosDb->loadStationRefClockOffset(stnName, refClockOffset))
2275  "::getDataFromVgosDb(): no reference station clock offset data found for the station " +
2276  stnName); // it is ok
2277  // data from CALC:
2278  if (isCalced && !vgosDb->loadStationAzEl(stnName, azTheo, elTheo))
2280  "::getDataFromVgosDb(): reading of azimuth-elevation file failed for the station " + stnName);
2281  if (isCalced && !vgosDb->loadStationParAngle(stnName, parAngle))
2283  "::getDataFromVgosDb(): reading of parallactic angle file failed for the station " + stnName);
2284  if (isCalced && !vgosDb->loadStationOceanLdDisp(stnName, ocnLdR, ocnLdV))
2286  "::getDataFromVgosDb(): reading of Ocean Loading displacements file failed for the station " +
2287  stnName);
2288  if (isCalced && !vgosDb->loadStationCalAxisOffset(stnName, calAxisOffset))
2290  "::getDataFromVgosDb(): reading of axis offset calibrations file failed for the station " +
2291  stnName);
2292  //
2293  if (isCalced && !vgosDb->loadStationCalSlantPathTropDry(stnName, calNmfDry, kind))
2295  "::getDataFromVgosDb(): reading of hydrostatic troposphere calibrations file failed for the "
2296  "station " + stnName);
2297  else if (!kind.isEmpty() && kind.toUpper() != "NMF")
2299  "::getDataFromVgosDb(): got an unknown, (" + kind + "), kind of hydrostatic troposphere "
2300  "calibrations for the station " + stnName);
2301  //
2302  if (isCalced && !vgosDb->loadStationCalSlantPathTropWet(stnName, calNmfWet, kind))
2304  "::getDataFromVgosDb(): reading of wet troposphere calibrations file failed for the "
2305  "station " + stnName);
2306  else if (!kind.isEmpty() && kind.toUpper() != "NMF")
2308  "::getDataFromVgosDb(): got an unknown, (" + kind + "), kind of wet troposphere "
2309  "calibrations for the station " + stnName);
2310  //
2311  if (isCalced && !vgosDb->loadStationCalOceanLoad(stnName, calHorzOLoad, calVertOLoad))
2313  "::getDataFromVgosDb(): reading of ocean loading calibrations file failed for the station " +
2314  stnName);
2315  if (isCalced && !vgosDb->loadStationPartAxisOffset(stnName, partAxisOffset))
2317  "::getDataFromVgosDb(): reading of axis offset partials file failed for the station " +
2318  stnName);
2319  //
2320  if (isCalced && !vgosDb->loadStationPartZenithDelayDry(stnName, partTropZenithDry, kind))
2322  "::getDataFromVgosDb(): reading of troposheric zenith delay (hydrostatic component) partials "
2323  "file failed for the station " + stnName);
2324  else if (!kind.isEmpty() && kind.toUpper() != "NMF")
2326  "::getDataFromVgosDb(): got an unknown, (" + kind + "), kind of troposheric zenith delay "
2327  "(hydrostatic component) partials for the station " + stnName);
2328  //
2329  if (isCalced && !vgosDb->loadStationPartZenithDelayWet(stnName, partTropZenithWet, kind))
2331  "::getDataFromVgosDb(): reading of troposheric zenith delay (wet component) partials "
2332  "file failed for the station " + stnName);
2333  else if (!kind.isEmpty() && kind.toUpper() != "NMF")
2335  "::getDataFromVgosDb(): got an unknown, (" + kind + "), kind of troposheric zenith delay "
2336  "(wet component) partials for the station " + stnName);
2337  //
2338  if (isCalced && !vgosDb->loadStationPartHorizonGrad(stnName, partTropGrad, kind))
2340  "::getDataFromVgosDb(): reading of troposheric horizontal gradients partials "
2341  "file failed for the station " + stnName);
2342  else if (!kind.isEmpty() && kind.toUpper() != "NMF")
2344  "::getDataFromVgosDb(): got an unknown, (" + kind + "), kind of troposheric horizontal "
2345  "gradients partials for the station " + stnName);
2346  //
2347  //
2348  if (calNmfDry)
2349  hasNdryContrib_= true;
2350  if (calNmfWet)
2351  hasNwetContrib_= true;
2352  if (partTropGrad)
2353  hasGradPartials_ = true;
2354  //
2355  // from logs:
2356  // cable calibration corrections:
2357  if (vgosDb->loadStationCalCable(stnName, calCable, origin, kind))
2358  {
2359  stInfo->setCableCalsOriginTxt(origin);
2361  if (kind.isEmpty())
2363  else if (kind.toUpper() == "CDMS")
2365  else if (kind.toUpper() == "PCMT")
2367  else
2368  {
2370  "::getDataFromVgosDb(): the station " + stnName +
2371  " has an unknown kind of cable calibration data");
2373  };
2374  }
2375  else
2376  {
2380  "::getDataFromVgosDb(): reading of cable calibrations file failed for the station " + stnName);
2381  };
2382  //
2383  // meteo data:
2384  if (vgosDb->loadStationMet(stnName, metAtmPres, metAtmRH, metAtmTemp, origin, kind))
2385  {
2386  stInfo->setMeteoDataOriginTxt(origin);
2388  if (kind.isEmpty())
2390  else if (kind.toUpper() == "EXTERNAL")
2392  else
2393  {
2395  "::getDataFromVgosDb(): the station " + stnName +
2396  " has an unknown kind of meteorological data");
2398  };
2399  }
2400  else
2401  {
2404  "::getDataFromVgosDb(): reading of Meteo file failed for the station " + stnName);
2405  };
2406  // tsyses:
2407  if (vgosDb->loadStationTsys(stnName, tSyses, tsysFreqs, tsysIds, tsysSbs, tsysPzs))
2408  {
2409  numOfTsysIFs = tSyses->nCol();
2410  if (numOfPts != (int)tSyses->nRow())
2411  {
2413  "::getDataFromVgosDb(): tsys data dimension mismatch for the station " + stnName);
2414  numOfTsysIFs = 0;
2415  };
2416  if (numOfTsysIFs != tsysFreqs.size())
2417  {
2419  "::getDataFromVgosDb(): tsys freqs dimension mismatch for the station " + stnName);
2420  numOfTsysIFs = 0;
2421  };
2422  if (numOfTsysIFs != tsysIds.size())
2423  {
2425  "::getDataFromVgosDb(): tsys ids dimension mismatch for the station " + stnName);
2426  numOfTsysIFs = 0;
2427  };
2428  if (numOfTsysIFs != tsysSbs.size())
2429  {
2431  "::getDataFromVgosDb(): tsys isbs dimension mismatch for the station " + stnName);
2432  numOfTsysIFs = 0;
2433  };
2434  if (numOfTsysIFs != tsysPzs.size())
2435  {
2437  "::getDataFromVgosDb(): tsys pzs dimension mismatch for the station " + stnName);
2438  numOfTsysIFs = 0;
2439  };
2440  if (numOfTsysIFs)
2441  {
2442  stInfo->tsysIfFreqs().resize(numOfTsysIFs);
2443  stInfo->tsysIfIds().resize(numOfTsysIFs);
2444  stInfo->tsysIfSideBands().resize(numOfTsysIFs);
2445  stInfo->tsysIfPolarizations().resize(numOfTsysIFs);
2446  for (int j=0; j<numOfTsysIFs; j++)
2447  {
2448  stInfo->tsysIfFreqs()[j] = tsysFreqs[j];
2449  stInfo->tsysIfIds()[j] = tsysIds[j];
2450  stInfo->tsysIfSideBands()[j] = tsysSbs[j];
2451  stInfo->tsysIfPolarizations()[j] = tsysPzs[j];
2452  }
2454  };
2455  }
2456  else
2457  {
2460  "::getDataFromVgosDb(): reading of tsys file failed for the station " + stnName);
2461  };
2462  //
2463  // clear this attributes:
2467  //
2468  QMap<QString, SgVlbiAuxObservation*>
2469  *auxObsByScan=stInfo->auxObservationByScanId();
2470  QMap<QString, SgVlbiAuxObservation*>::iterator
2471  jt=auxObsByScan->begin();
2472  for (; jt!=auxObsByScan->end(); ++jt)
2473  {
2474  SgVlbiAuxObservation *auxObs = jt.value();
2475 // if (idxByMjd.contains(*auxObs))
2476  if (idxByMjd.contains(auxObs->toString(SgMJD::F_YYYYMMDDHHMMSSSS)))
2477  {
2478 // int idx=idxByMjd.value(*auxObs);
2479  int idx=idxByMjd.value(auxObs->toString(SgMJD::F_YYYYMMDDHHMMSSSS));
2480  if (azTheo && elTheo)
2481  {
2482  auxObs->setAzimuthAngle (azTheo->getElement(idx, 0));
2483  auxObs->setAzimuthAngleRate (azTheo->getElement(idx, 1));
2484  auxObs->setElevationAngle (elTheo->getElement(idx, 0));
2485  auxObs->setElevationAngleRate (elTheo->getElement(idx, 1));
2486  };
2487  if (parAngle)
2488  auxObs->setParallacticAngle(parAngle->getElement(idx));
2489  if (refClockOffset)
2490  auxObs->setRefClockOffset(refClockOffset->getElement(idx));
2491  if (calAxisOffset)
2492  {
2493  auxObs->setCalcAxisOffset4Delay(calAxisOffset->getElement(idx, 0));
2494  auxObs->setCalcAxisOffset4Rate (calAxisOffset->getElement(idx, 1));
2495  };
2496  if (calNmfDry)
2497  {
2498  auxObs->setCalcNdryCont4Delay(calNmfDry->getElement(idx, 0));
2499  auxObs->setCalcNdryCont4Rate (calNmfDry->getElement(idx, 1));
2500  };
2501  if (calNmfWet)
2502  {
2503  auxObs->setCalcNwetCont4Delay(calNmfWet->getElement(idx, 0));
2504  auxObs->setCalcNwetCont4Rate (calNmfWet->getElement(idx, 1));
2505  };
2506  if (calHorzOLoad && calVertOLoad)
2507  {
2508  auxObs->setCalcOLoadHorz4Delay(calHorzOLoad->getElement(idx, 0));
2509  auxObs->setCalcOLoadHorz4Rate (calHorzOLoad->getElement(idx, 1));
2510  auxObs->setCalcOLoadVert4Delay(calVertOLoad->getElement(idx, 0));
2511  auxObs->setCalcOLoadVert4Rate (calVertOLoad->getElement(idx, 1));
2512  };
2513  if (partAxisOffset)
2514  {
2515  auxObs->setDdel_dAxsOfs(partAxisOffset->getElement(idx, 0));
2516  auxObs->setDrat_dAxsOfs(partAxisOffset->getElement(idx, 1));
2517  };
2518  if (partTropZenithDry)
2519  {
2520  auxObs->setDdel_dTzdDry(partTropZenithDry->getElement(idx, 0));
2521  auxObs->setDrat_dTzdDry(partTropZenithDry->getElement(idx, 1));
2522  };
2523  if (partTropZenithWet)
2524  {
2525  auxObs->setDdel_dTzdWet(partTropZenithWet->getElement(idx, 0));
2526  auxObs->setDrat_dTzdWet(partTropZenithWet->getElement(idx, 1));
2527  };
2528  if (partTropGrad)
2529  {
2530  auxObs->setDdel_dTzdGrdN (partTropGrad->getElement(idx, 0));
2531  auxObs->setDdel_dTzdGrdE (partTropGrad->getElement(idx, 1));
2532  auxObs->setDrat_dTzdGrdN (partTropGrad->getElement(idx, 2));
2533  auxObs->setDrat_dTzdGrdE (partTropGrad->getElement(idx, 3));
2534  };
2535  //
2536  if (calCable)
2537  {
2538  auxObs->setCableCalibration(calCable->getElement(idx, 0));
2539  hasAuxObs = true;
2540  }
2541  else
2543  if (metAtmPres && metAtmRH && metAtmTemp)
2544  {
2545  auxObs->setMeteoData(SgMeteoData(metAtmTemp->getElement(idx),
2546  metAtmPres->getElement(idx), metAtmRH->getElement(idx)));
2548  hasAuxObs = true;
2549  };
2550  if (tSyses && numOfTsysIFs)
2551  {
2552  auxObs->setTsysesSize(numOfTsysIFs);
2553  for (int j=0; j<numOfTsysIFs; j++)
2554  auxObs->tSyses()->setElement(j, tSyses->getElement(idx, j));
2555  };
2556  if (ocnLdR && ocnLdV)
2557  {
2558  auxObs->setOcnLdR( Sg3dVector(ocnLdR->getElement(idx,0),
2559  ocnLdR->getElement(idx,1),
2560  ocnLdR->getElement(idx,2)));
2561  auxObs->setOcnLdV( Sg3dVector(ocnLdV->getElement(idx,0),
2562  ocnLdV->getElement(idx,1),
2563  ocnLdV->getElement(idx,2)));
2564  };
2565  //
2566  }
2567  else
2569  "::getDataFromVgosDb(): cannot find epoch " + auxObs->toString() +
2570  " in the block of station info for the station " + stnName);
2571  };
2572  // free allocated spaces:
2573  if (azTheo)
2574  delete azTheo;
2575  if (elTheo)
2576  delete elTheo;
2577  if (parAngle)
2578  delete parAngle;
2579  if (refClockOffset)
2580  delete refClockOffset;
2581  if (calAxisOffset)
2582  delete calAxisOffset;
2583  if (calCable)
2584  delete calCable;
2585  if (calNmfDry)
2586  delete calNmfDry;
2587  if (calNmfWet)
2588  delete calNmfWet;
2589  if (calHorzOLoad)
2590  delete calHorzOLoad;
2591  if (calVertOLoad)
2592  delete calVertOLoad;
2593  if (metAtmPres)
2594  delete metAtmPres;
2595  if (metAtmRH)
2596  delete metAtmRH;
2597  if (metAtmTemp)
2598  delete metAtmTemp;
2599  if (partAxisOffset)
2600  delete partAxisOffset;
2601  if (ocnLdR)
2602  delete ocnLdR;
2603  if (ocnLdV)
2604  delete ocnLdV;
2605  if (partTropZenithDry)
2606  delete partTropZenithDry;
2607  if (partTropZenithWet)
2608  delete partTropZenithWet;
2609  if (partTropGrad)
2610  delete partTropGrad;
2611  }
2612  else
2614  "::getDataFromVgosDb(): cannot load time table for the station " + stnName + ", skipped");
2615  };
2616  if (hasAuxObs)
2618  //
2619  //
2620  //
2621  //
2622  // Phase three. Collecting a priori for sourses, stations:
2623  QVector<QString> sourcesNames, sourcesApRefs, eccTypes, eccNums;
2624  QVector<QString> stationsNames4Coo, stationsNames4Ant, stationsNames4Ecc,
2625  stationsNames4AprioriClocks, tectonicPlateNames;
2626  QVector<int> axisTypes;
2627  SgVector *axisOffsets=NULL;
2628  SgMatrix *srcCoo=NULL, *axisTilts=NULL, *eccVals=NULL, *stnCoo=NULL,
2629  *offsets_n_rates=NULL;
2630 
2631 
2632  if (!vgosDb->loadSourcesApriories(sourcesNames, srcCoo, sourcesApRefs))
2633  {
2635  "::getDataFromVgosDb(): limited use data, missed info: a priori: sources");
2636 // isOk = false;
2637  };
2638  if (!vgosDb->loadStationsApriories(stationsNames4Coo, stnCoo, tectonicPlateNames))
2639  {
2641  "::getDataFromVgosDb(): limited use data, missed info: a priori: stations");
2642 // isOk = false;
2643  };
2644  if (!vgosDb->loadAntennaApriories(stationsNames4Ant, axisTypes, axisOffsets, axisTilts))
2645  {
2647  "::getDataFromVgosDb(): limited use data, missed info: a priori: antennae");
2648 // isOk = false;
2649  };
2650  vgosDb->loadEccentricities(stationsNames4Ecc, eccTypes, eccNums, eccVals);
2651  vgosDb->loadClockApriories(stationsNames4AprioriClocks, offsets_n_rates);
2652 
2653 
2654  //
2655  // sources:
2656  //
2657  if (sourcesNames.size() && srcCoo)
2658  {
2659  if (sourcesNames.size()!=sourcesByName_.size())
2661  "::getDataFromVgosDb(): the number of a priori source positions " +
2662  QString().sprintf("(%d) is not equal to the actual number of sources (%d)",
2663  sourcesNames.size(), sourcesByName_.size()));
2664  for (int i=0; i<sourcesNames.size(); i++)
2665  {
2666  sourceName = sourcesNames.at(i);
2667  if (sourcesByName_.contains(sourceName))
2668  {
2669  sourceInfo = sourcesByName_.value(sourceName);
2670  double ra=srcCoo->getElement(i, 0);
2671  double dn=srcCoo->getElement(i, 1);
2672  sourceInfo->setRA(ra);
2673  sourceInfo->setDN(dn);
2674  if (sourcesApRefs.size() == sourcesNames.size())
2675  sourceInfo->setAprioriReference(sourcesApRefs.at(i));
2676  }
2677  else // complain:
2679  "::getDataFromVgosDb(): cannot find a priori entry '" + sourceName +
2680  "' in the list of session sources");
2681  };
2682  }
2683  else
2685  "::getDataFromVgosDb(): cannot find sources a priori coordinates in the vgosDb tree");
2686  //
2687  // stations:
2688  // here we have three lists and the order of stations could be different
2689  // first, coordinates:
2690  if (stationsNames4Coo.size() && stnCoo && tectonicPlateNames.size())
2691  {
2692  if (stationsNames4Coo.size()!=stationsByName_.size())
2694  "::getDataFromVgosDb(): the number of a priori stations positions " +
2695  QString().sprintf("(%d) is not equal to the actual number of stations (%d)",
2696  stationsNames4Coo.size(), stationsByName_.size()));
2697  calcInfo_.stations().clear();
2698  for (int i=0; i<stationsNames4Coo.size(); i++)
2699  {
2700  station1Name = stationsNames4Coo.at(i);
2701  if (stationsByName_.contains(station1Name))
2702  {
2703  station1Info = stationsByName_.value(station1Name);
2704  Sg3dVector r(v3Zero);
2705  r(X_AXIS) = stnCoo->getElement(i, 0);
2706  r(Y_AXIS) = stnCoo->getElement(i, 1);
2707  r(Z_AXIS) = stnCoo->getElement(i, 2);
2708  station1Info->setR(r);
2709  station1Info->setTectonicPlateName(tectonicPlateNames.at(i));
2710  // set up the order:
2711  calcInfo_.stations().append(station1Info);
2712  }
2713  else // complain:
2715  "::getDataFromVgosDb(): cannot find station '" + station1Name + "' in the list of stations");
2716  };
2717  }
2718  else
2720  "::getDataFromVgosDb(): cannot find stations a priori coordinates in the vgosDb tree");
2721  //
2722  // then, antenna parameters:
2723  if (stationsNames4Ant.size() && axisTypes.size() && axisOffsets)
2724  {
2725  if (stationsNames4Ant.size()!=stationsByName_.size())
2727  "::getDataFromVgosDb(): the number of a priori antenna parameters " +
2728  QString().sprintf("(%d) is not equal to the actual number of stations (%d)",
2729  stationsNames4Ant.size(), stationsByName_.size()));
2730  for (int i=0; i<stationsNames4Ant.size(); i++)
2731  {
2732  station1Name = stationsNames4Ant.at(i);
2733  if (stationsByName_.contains(station1Name))
2734  {
2735  station1Info = stationsByName_.value(station1Name);
2737  Sg3dVector r(v3Zero);
2738  //
2739  // axis offset type:
2740  if (axisTypes.size())
2741  {
2742  mnt = SgVlbiStationInfo::int2mntType(axisTypes.at(i));
2743  if (mnt != SgVlbiStationInfo::MT_UNKN)
2744  {
2745  station1Info->setMntType(mnt);
2747  "::getDataFromVgosDb(): set up mounting type [" + sMntTypes[mnt] + "] for the antenna " +
2748  station1Info->getKey());
2749  };
2750  };
2751  // axis offset:
2752  if (axisOffsets)
2753  {
2754  station1Info->setAxisOffset(axisOffsets->getElement(i));
2756  "::getDataFromVgosDb(): the value of axis offset for the antenna " +
2757  station1Info->getKey() + " has been set to " +
2758  QString("").setNum(station1Info->getAxisOffset()));
2759  };
2760  }
2761  else // complain:
2763  "::getDataFromVgosDb(): cannot find station '" + station1Name + "' in the list of stations");
2764  };
2765  }
2766  else
2768  "::getDataFromVgosDb(): cannot find antenna a priori parameters in the vgosDb tree");
2769  //
2770  //
2771  // and eccentricities:
2772  if (stationsNames4Ecc.size() && eccTypes.size() && eccNums.size() && eccVals)
2773  {
2774  for (int i=0; i<stationsNames4Ecc.size(); i++)
2775  {
2776  station1Name = stationsNames4Ecc.at(i);
2777  if (stationsByName_.contains(station1Name))
2778  {
2779  station1Info = stationsByName_.value(station1Name);
2780  if (station1Info)
2781  {
2782  station1Info->eccRec() = new SgEccRec();
2783  if (eccTypes.at(i) == "XY")
2784  station1Info->eccRec()->setEccType(SgEccRec::ET_XYZ);
2785  else if (eccTypes.at(i) == "NE")
2786  station1Info->eccRec()->setEccType(SgEccRec::ET_NEU);
2787  else
2788  {
2789  station1Info->eccRec()->setEccType(SgEccRec::ET_N_A);
2791  "::getDataFromVgosDb(): cannot figure out Ecc type from the string \"" +
2792  eccTypes.at(i) + "\" for the station \"" + station1Info->getKey() + "\"");
2793  };
2794  //
2795  station1Info->eccRec()->setDR(
2796  Sg3dVector(eccVals->getElement(i, 0), eccVals->getElement(i, 1), eccVals->getElement(i, 2)));
2797  station1Info->eccRec()->setCdpNumber(eccNums.at(i));
2798  }
2799  else
2801  "::getDataFromVgosDb(): parsing ecc: the station # " + QString("").setNum(i) + " is NULL");
2802  }
2803  else
2805  "::getDataFromVgosDb(): cannot find a station \"" + station1Name + "\" in the map");
2806  };
2807  }
2808  else
2810  "::getDataFromVgosDb(): cannot find eccentricities in the vgosDb tree");
2811  //
2812  // a priori clocks:
2813  if (stationsNames4AprioriClocks.size() && offsets_n_rates)
2814  {
2815  for (int i=0; i<stationsNames4AprioriClocks.size(); i++)
2816  {
2817  station1Name = stationsNames4AprioriClocks.at(i);
2818  if (stationsByName_.contains(station1Name))
2819  {
2820  station1Info = stationsByName_.value(station1Name);
2821  station1Info->setAPrioriClockTerm_0(offsets_n_rates->getElement(i, 0));
2822  station1Info->setAPrioriClockTerm_1(offsets_n_rates->getElement(i, 1));
2823  station1Info->setNeed2useAPrioriClocks(true);
2824  }
2825  else // complain:
2827  "::getDataFromVgosDb(): cannot find station \"" + station1Name +
2828  "\" in the list of stations for a priori clocks");
2829  };
2830  };
2831 
2832 
2833  bool hasTidalUt1;
2834 //int tidalUt1(0);
2835 //hasTidalUt1 = vgosDb->loadCalcInfo(tidalUt1, calcVersionValue);
2836 //calcInfo_.setDversion(calcVersionValue);
2837  hasTidalUt1 = vgosDb->loadCalcInfo(calcInfo_);
2838  //
2839  //
2840  //
2841  eccTypes.clear();
2842  eccNums.clear();
2843  axisTypes.clear();
2844  stationsNames4AprioriClocks.clear();
2845  if (axisOffsets)
2846  delete axisOffsets;
2847  if (srcCoo)
2848  delete srcCoo;
2849  if (axisTilts)
2850  delete axisTilts;
2851  if (eccVals)
2852  delete eccVals;
2853  if (stnCoo)
2854  delete stnCoo;
2855  if (offsets_n_rates)
2856  delete offsets_n_rates;
2857  //
2858  //
2859  //
2860  //
2861  // Phase four. Solve-related parameters:
2862  // atm setup:
2863  SgVector *atmInterval=NULL, *atmRateConstraint=NULL;
2864  QVector<QString> atmStationsNames;
2865  // clock setup:
2866  SgVector *clkInterval=NULL, *clkRateConstraint=NULL;
2867  QList<QString> refClocks;
2868  QVector<QString> clockStationsNames;
2869  // EOP:
2870  SgVector *pmArrayInfo=NULL, *utArrayInfo=NULL, *utValues=NULL;
2871  SgMatrix *pmValues=NULL;
2872  QString sUtMode, sUtModule, sUtOrigin, sPmMode, sPmModule, sPmOrigin;
2873  // calibrations:
2874  int obsCalFlags(31);
2875  QVector<int> statCalFlags;
2876  QVector< QVector<int> > flybyFlags;
2877  QVector<QString> statCalNames, flybyNames, calSiteNames, obsCalNames, blwNames;
2878  // selection status:
2879  QVector<int> sourcesSelection;
2880  QVector< QVector<int> > baselinesSelection;
2881  // additional weights:
2882  SgMatrix *groupBlWeights=NULL;
2883  // calc info:
2884  int leapSecond=0;
2885  // clock breaks:
2886  QVector<QString> cbNames;
2887  QVector<SgMJD> cbEpochs;
2888  QVector<int> cbFlags;
2889  // cable signs:
2890  QMap<QString, QString> cableSignByKey;
2891  bool hasLeapSecond;
2892  //
2893  // load data:
2894  //
2895  vgosDb->loadAtmSetup(atmInterval, atmRateConstraint, atmStationsNames);
2896  vgosDb->loadClockSetup(refClocks, clkInterval, clkRateConstraint, clockStationsNames);
2897  vgosDb->loadCalcEop(pmArrayInfo, utArrayInfo, pmValues, utValues, sUtMode, sUtModule, sUtOrigin,
2898  sPmMode, sPmModule, sPmOrigin);
2899  vgosDb->loadCalibrations(obsCalFlags, statCalFlags, flybyFlags, statCalNames, flybyNames,
2900  calSiteNames, obsCalNames);
2901  vgosDb->loadSelectionStatus(sourcesSelection, baselinesSelection);
2902  vgosDb->loadSolveWeights(blwNames, groupBlWeights);
2903  vgosDb->loadClockBreaks(cbNames, cbEpochs, cbFlags);
2904  hasLeapSecond = vgosDb->loadLeapSecond(leapSecond);
2905  vgosDb->loadMiscCable(cableSignByKey);
2906 
2907 
2908  if (atmInterval && atmRateConstraint)
2910 
2911  //
2912  // update the session:
2913  //
2915  {
2916  QString siteName("");
2917  //
2918  // clocks:
2919  if (clkInterval && clkRateConstraint)
2920  {
2922  if (clkInterval->n()==1)
2923  {
2924  pCfg.setPwlStep(clkInterval->getElement(0)/24.0); // hr->day
2926  }
2927  else
2928  for (int i=0; i<clockStationsNames.size(); i++)
2929  {
2930  siteName = clockStationsNames.at(i);
2931  if (siteName.size() < 8)
2932  siteName.sprintf("%-8s", qPrintable(siteName));
2933  if (stationsByName_.contains(siteName))
2934  {
2935  SgVlbiStationInfo *si=stationsByName_.value(siteName);
2936  si->pcClocks()->setPwlStep(clkInterval->getElement(i)/24.0); // hr->day
2937  if (fabs(parametersDescriptor_->getClock0().getPwlStep() -
2938  si->pcClocks()->getPwlStep()) > 1.0e-3)
2940  }
2941  else
2943  "::getDataFromVgosDb(): cannot find siteName \"" + siteName +
2944  "\" in the map of stations");
2945  };
2946  //
2947  if (clkRateConstraint->n()==1)
2948  {
2949  pCfg.setPwlAPriori(clkRateConstraint->getElement(0)*864.0);
2951  }
2952  else
2953  for (int i=0; i<clockStationsNames.size(); i++)
2954  {
2955  siteName = clockStationsNames.at(i);
2956  if (siteName.size() < 8)
2957  siteName.sprintf("%-8s", qPrintable(siteName));
2958  if (stationsByName_.contains(siteName))
2959  {
2960  SgVlbiStationInfo *si=stationsByName_.value(siteName);
2961  si->pcClocks()->setPwlAPriori(clkRateConstraint->getElement(i)*864.0);
2963  si->pcClocks()->getPwlAPriori()) > 1.0e-3)
2965  }
2966  else
2968  "::getDataFromVgosDb(): cannot find siteName \"" + siteName +
2969  "\" in the map of stations");
2970  };
2971  }
2972  else
2974  "::getDataFromVgosDb(): no clock interval or clock rate constraint found");
2975  //
2976  // zenith:
2977  if (atmInterval && atmRateConstraint)
2978  {
2980  if (atmInterval->n()==1)
2981  {
2982  pCfg.setPwlStep(atmInterval->getElement(0)/24.0); // hr->day
2984  }
2985  else
2986  for (int i=0; i<atmStationsNames.size(); i++)
2987  {
2988  siteName = atmStationsNames.at(i);
2989  if (siteName.size() < 8)
2990  siteName.sprintf("%-8s", qPrintable(siteName));
2991  if (stationsByName_.contains(siteName))
2992  {
2993  SgVlbiStationInfo *si=stationsByName_.value(siteName);
2994  si->pcZenith()->setPwlStep(atmInterval->getElement(i)/24.0); // hr->day
2995  if (fabs(parametersDescriptor_->getZenith().getPwlStep() -
2996  si->pcZenith()->getPwlStep()) > 1.0e-3)
2998  }
2999  else
3001  "::getDataFromVgosDb(): cannot find siteName \"" + siteName +
3002  "\" in the map of stations");
3003  };
3004  //
3005  if (atmRateConstraint->n()==1)
3006  {
3007  pCfg.setPwlAPriori(atmRateConstraint->getElement(0)*1.0e-12*24.0*vLight*100.0);
3009  }
3010  else
3011  for (int i=0; i<atmStationsNames.size(); i++)
3012  {
3013  siteName = atmStationsNames.at(i);
3014  if (siteName.size() < 8)
3015  siteName.sprintf("%-8s", qPrintable(siteName));
3016  if (stationsByName_.contains(siteName))
3017  {
3018  SgVlbiStationInfo *si=stationsByName_.value(siteName);
3019  si->pcZenith()->setPwlAPriori(atmRateConstraint->getElement(i)*1.0e-12*24.0*vLight*100.0);
3021  si->pcZenith()->getPwlAPriori()) > 1.0e-3)
3023  }
3024  else
3026  "::getDataFromVgosDb(): cannot find siteName \"" + siteName +
3027  "\" in the map of stations");
3028  };
3029  }
3030  else
3032  "::getDataFromVgosDb(): no atm interval or atm rate constraint found");
3033  };
3034 
3035 
3036 /*
3037  if (atmInterval && atmRateConstraint && atmInterval->n()==atmRateConstraint->n()
3038  && atmInterval->n()==1)
3039  {
3040  if (parametersDescriptor_)
3041  {
3042  SgParameterCfg pCfg=parametersDescriptor_->getZenith();
3043  pCfg.setPwlAPriori(atmRateConstraint->getElement(0)*(1.0e-12*24.0*vLight*100.0));
3044  pCfg.setPwlStep(atmInterval->getElement(0)/24.0); // hr->day
3045  parametersDescriptor_->setZenith(pCfg);
3046  };
3047  };
3048 */
3049 /*
3050  if (parametersDescriptor_ &&
3051  clkInterval && clkRateConstraint &&
3052  clkInterval->n()==clkRateConstraint->n() &&
3053  clkInterval->n()==1)
3054  {
3055  SgParameterCfg pCfg=parametersDescriptor_->getClock0();
3056  pCfg.setPwlAPriori(clkRateConstraint->getElement(0)*864.0);
3057  pCfg.setPwlStep(clkInterval->getElement(0)/24.0); // hr->day
3058  parametersDescriptor_->setClock0(pCfg);
3059  };
3060 */
3061 
3062  //
3063  // set up a reference clock site, if available:
3064  bool hasRC(false);
3065  if (refClocks.size())
3066  {
3067  for (int i=0; i<refClocks.size(); i++)
3068  {
3069  QString clockSiteName(refClocks.at(i));
3070  if (clockSiteName.size()<8)
3071  clockSiteName.sprintf("%-8s", qPrintable(refClocks.at(i)));
3072  if (stationsByName_.contains(clockSiteName))
3073  {
3074  stationsByName_.value(clockSiteName)->addAttr(SgVlbiStationInfo::Attr_REFERENCE_CLOCKS);
3075  hasRC = true;
3077  "::getDataFromVgosDb(): Reference Clock attribute has been assigned to the station " +
3078  stationsByName_.value(clockSiteName)->getKey());
3079  };
3080  };
3081  };
3082  if (!hasRC)
3084  "::getDataFromVgosDb(): no Reference Clock attribute has been found for the session");
3085  // reference clock site finished.
3086  //
3087  // EOP, UT1:
3088  if (utArrayInfo && utValues)
3089  {
3090  double t0=utArrayInfo->getElement(0);
3091  double dt=utArrayInfo->getElement(1);
3092  unsigned int numOfPts=round(utArrayInfo->getElement(2));
3093  if (t0 > 2390000.0)
3094  t0 -= 2400000.5;
3095  if (utValues->n() < numOfPts)
3096  numOfPts = utValues->n();
3097  allocUt1InterpolEpochs(t0, dt, numOfPts);
3098  *utValues *= -1.0;
3099  allocUt1InterpolValues(utValues);
3100  hasUt1Interpolation_ = true;
3103  calcInfo_.ut1Interpolation().setOrigin(sUtOrigin);
3105  "::getDataFromVgosDb(): loaded " + QString().setNum(numOfPts) +
3106  " records for UT1 interpolation");
3107  }
3108  else
3109  {
3111  {
3112  delete args4Ut1Interpolation_;
3113  args4Ut1Interpolation_ = NULL;
3114  };
3116  {
3117  delete tabs4Ut1Interpolation_;
3118  tabs4Ut1Interpolation_ = NULL;
3119  };
3120  hasUt1Interpolation_ = false;
3121  };
3122  // EOP, PM:
3123  if (pmArrayInfo && pmValues)
3124  {
3125  double t0=pmArrayInfo->getElement(0);
3126  double dt=pmArrayInfo->getElement(1);
3127  unsigned int numOfPts=round(pmArrayInfo->getElement(2));
3128  if (t0 > 2390000.0)
3129  t0 -= 2400000.5;
3130  if (pmValues->nRow() < numOfPts)
3131  numOfPts = pmValues->nRow();
3132  allocPxyInterpolEpochs(t0, dt, numOfPts);
3133  allocPxyInterpolValues(pmValues);
3134  hasPxyInterpolation_ = true;
3136  "::getDataFromVgosDb(): loaded " + QString().setNum(numOfPts) +
3137  " records for polar motion interpolation");
3138 
3142  }
3143  else
3144  {
3146  {
3147  delete args4PxyInterpolation_;
3148  args4PxyInterpolation_ = NULL;
3149  };
3151  {
3152  delete tabs4PxyInterpolation_;
3153  tabs4PxyInterpolation_ = NULL;
3154  };
3155  hasPxyInterpolation_ = false;
3156  };
3157 
3158  if (hasTidalUt1)
3159  {
3160  QString ut1Type("");
3161  switch (calcInfo_.getFlagTidalUt1())
3162  {
3163  case 1:
3165  ut1Type = "Seriesfull of tides";
3166  break;
3167  case -1: // UT1R
3169  ut1Type = "Only short period tidal terms are removed";
3170  break;
3171  case -2: // UT1S
3173  ut1Type = "All tidal terms are removed";
3174  break;
3175  default:
3177  "::getDataFromVgosDb(): got undocumented value for the TIDALUT1 value: " +
3178  QString().setNum(calcInfo_.getFlagTidalUt1()) + "; the UT1 type has been reverted to default");
3179  break;
3180  };
3182  "::getDataFromVgosDb(): the type of the UT1 inner series has been set to " + ut1Type);
3183  };
3184  //
3185  // calibrations:
3186  if (obsCalNames.size() && config_)
3187  {
3188  QList<QString> calList;
3189  for (int i=0; i<obsCalNames.size(); i++)
3190  calList << obsCalNames.at(i);
3191  applyObsCalibrationSetup(obsCalFlags, calList);
3192  calList.clear();
3193  }
3194  else
3196  "::getDataFromVgosDb(): the observation calibration list is empty");
3197  //
3198  // flags for cable calibrations (is available):
3199  if (statCalNames.size() && calSiteNames.size() && statCalFlags.size())
3200  {
3201  bool isCableCalMatched(false);
3202  int cableCalFlagIdx(-1);
3203  for (int i=0; i<statCalNames.size(); i++)
3204  if (statCalNames.at(i) == "CABL DEL")
3205  {
3206  isCableCalMatched = true;
3207  cableCalFlagIdx = i;
3208  };
3209  if (isCableCalMatched)
3210  {
3211  QString str;
3212  // use order of stations from calSiteNames list:
3213  for (int i=0; i<calSiteNames.size(); i++)
3214  {
3215  str = calSiteNames.at(i);
3216  if (stationsByName_.contains(str))
3217  {
3218  SgVlbiStationInfo *si=stationsByName_.value(str);
3219  // just alternate cable cal flag:
3220  int nFlag=statCalFlags.at(i);
3221  if (nFlag & 1<<cableCalFlagIdx)
3223  else
3225  }
3226  else
3228  "::getDataFromVgosDb(): cannot find " + str +
3229  " (an entry from CalSiteName variable) in the list of stations");
3230  };
3231  }
3232  else
3234  "::getDataFromVgosDb(): there is no \"CABL DEL\" flag in the list of calibrations");
3235  };
3236  //
3237  //
3238  // sources selection status:
3239  if (sourcesSelection.size() && sourcesNames.size())
3240  {
3241  if (sourcesSelection.size() == sourcesNames.size())
3242  {
3243  int bitArray;
3244  SgVlbiSourceInfo *si;
3245  for (int i=0; i<sourcesNames.size(); i++)
3246  {
3247  sourceName = sourcesNames.at(i);
3248  if (sourcesByName_.contains(sourceName))
3249  {
3250  si = sourcesByName_.value(sourceName);
3251  bitArray = sourcesSelection.at(i);
3252  si->applyStatusBits(bitArray);
3253  };
3254  };
3255  }
3256  else
3258  "::getDataFromVgosDb(): sourcesSelection and sourcesNames size mismatch");
3259  };
3260  //
3261  // baselines selection status:
3262  if (baselinesSelection.size() && stationsNames4Coo.size())
3263  {
3264  if (baselinesSelection.size() == stationsNames4Coo.size())
3265  {
3266  int bitArray;
3267  SgVlbiBaselineInfo *bi, *biR;
3268  for (int i=0; i<stationsNames4Coo.size(); i++)
3269  {
3270  station1Name = stationsNames4Coo.at(i);
3271  if (stationsByName_.contains(station1Name))
3272  {
3273  for (int j=0; j<stationsNames4Coo.size(); j++)
3274  {
3275  station2Name = stationsNames4Coo.at(j);
3276  if (stationsByName_.contains(station2Name))
3277  {
3278 // ???????????
3279 // bitArray = baselinesSelection.at(j).at(i);
3280  bitArray = baselinesSelection.at(i).at(j);
3281  // image->getI2(dBaselinesSelStatus_, dSiteNames_->dim2()*j + i,0,0);
3282  if (baselinesByName_.contains(station1Name + ":" + station2Name))
3283  bi = baselinesByName_.value(station1Name + ":" + station2Name);
3284  else
3285  bi = NULL;
3286  if (baselinesByName_.contains (station2Name + ":" + station1Name))
3287  biR = baselinesByName_.value(station2Name + ":" + station1Name);
3288  else
3289  biR = NULL;
3290  // check for deselect flag:
3291  if (!(bitArray & (1<<1)))
3292  {
3294  {
3297  "::getDataFromVgosDb(): the baseline " + bi->getKey() + " has been deselected");
3298  };
3299  if (biR && !biR->isAttr(SgVlbiBaselineInfo::Attr_NOT_VALID))
3300  {
3303  "::getDataFromVgosDb(): the baseline " + biR->getKey() + " has been deselected");
3304  };
3305  };
3306  // check for baseline clocks flag:
3307  if ((bitArray & (1<<3)))
3308  {
3309  if (bi)
3310  {
3313  "::getDataFromVgosDb(): clock estimation has been assigned to the baseline " +
3314  bi->getKey());
3315  };
3316  if (biR)
3317  {
3320  "::getDataFromVgosDb(): clock estimation has been assigned to the baseline " +
3321  biR->getKey());
3322  };
3323  };
3324  };
3325  };
3326  };
3327  };
3328  }
3329  else
3331  "::getDataFromVgosDb(): baselinesSelection and stationsNames size mismatch");
3332  };
3333  //
3334  // weight corrections:
3335  if (groupBlWeights && blwNames.size() && groupBlWeights->nCol()==(unsigned)blwNames.size())
3336  {
3337  SgVlbiBaselineInfo *bi;
3338  for (int i=0; i<blwNames.size(); i++)
3339  {
3340  const QString &st=blwNames.at(i);
3341  int idx=st.indexOf(':');
3342  if (idx>0)
3343  {
3344  QString st1 = st.left(idx);
3345  QString st2 = st.mid(idx + 1);
3346  if (baselinesByName_.contains(blwNames.at(i)))
3347  {
3348  bi = baselinesByName_.value(blwNames.at(i));
3349  bi->setSigma2add(DT_DELAY, groupBlWeights->getElement(0, i));
3350  bi->setSigma2add(DT_RATE, groupBlWeights->getElement(1, i));
3351  }
3352  else if (baselinesByName_.contains(st2 + ":" + st1)) // reverted?
3353  {
3354  bi = baselinesByName_.value(st2 + ":" + st1);
3355  bi->setSigma2add(DT_DELAY, groupBlWeights->getElement(0, i));
3356  bi->setSigma2add(DT_RATE, groupBlWeights->getElement(1, i));
3358  "::getDataFromVgosDb(): the list of baseline weights contains a reverted name: [" +
3359  blwNames.at(i) + "]");
3360  }
3361  else
3362  {
3364  "::getDataFromVgosDb(): cannot find baseline [" + blwNames.at(i) +
3365  "] in the map of baselines; supposed weight corrections are " +
3366  QString("").sprintf("%.1fps and %.1fE-14s/s",
3367  groupBlWeights->getElement(0, i)*1.0e12, groupBlWeights->getElement(1, i)*1.0e14));
3368  }
3369  }
3370  else
3372  "::getDataFromVgosDb(): malformed name of a baseline: \"" + st + "\", skipped");
3373  };
3375  }
3376  else if (config_)
3377  {
3378  for (BaselinesByName_it ij=baselinesByName_.begin(); ij!=baselinesByName_.end(); ++ij)
3379  {
3380  ij.value()->setSigma2add(DT_DELAY, config_->getInitAuxSigma4Delay());
3381  ij.value()->setSigma2add(DT_RATE, config_->getInitAuxSigma4Rate());
3382  };
3383  };
3384  //
3385  // clock breaks:
3386  if (cbNames.size() && cbEpochs.size() && cbFlags.size())
3387  {
3388  int numOfClockBreaks;
3389  numOfClockBreaks = cbNames.size();
3390  if (numOfClockBreaks != cbEpochs.size())
3391  {
3393  "::getDataFromVgosDb(): the number of clock breaks sites (" +
3394  QString("").setNum(numOfClockBreaks) + ") is not equal to the number of clock break epochs " +
3395  QString("").setNum(cbEpochs.size()));
3396  numOfClockBreaks = std::min(numOfClockBreaks, cbEpochs.size());
3397  };
3398  QString stnName("");
3399  for (int i=0; i<numOfClockBreaks; i++)
3400  {
3401  const SgMJD &tBreak=cbEpochs.at(i);
3402  SgVlbiStationInfo *stn2Correct=NULL;
3403  stnName = cbNames.at(i);
3404  if (stnName.size() < 8)
3405  {
3406  stnName = cbNames.at(i).leftJustified(8, ' ');
3408  "::getDataFromVgosDb(): a name of station \"" + cbNames.at(i) +
3409  "\" from the ClockBreak file has been adjusted to \"" + stnName + "\"");
3410  };
3411  // add a clock break, set it to estimate in a common solution:
3412  if (stationsByName_.contains(stnName))
3413  {
3414  stn2Correct = stationsByName_.value(stnName);
3415  SgParameterBreak *clockBreak=new SgParameterBreak(tBreak, 0.0);
3417  if (stn2Correct->clockBreaks().addBreak(clockBreak))
3419  "::getDataFromVgosDb(): a clock break at station " + stn2Correct->getKey() +
3420  " that occurred on " + tBreak.toString() + " has been added");
3421  else
3423  "::getDataFromVgosDb(): adding new clock break at " + stn2Correct->getKey() +
3424  " station on " + tBreak.toString() + " has failed");
3425  }
3426  else
3428  "::getDataFromVgosDb(): cannot find station \"" + stnName +
3429  "\" in the map of stations, adding a clock break has failed");
3430  /*
3431  // ok, we add a clock break to each band:
3432  SgVlbiBand *band=NULL;
3433  for (int iBand=0; iBand<bands_.size(); iBand++)
3434  {
3435  band = bands_.at(iBand);
3436  if (band->stationsByName().contains(stnName))
3437  {
3438  stn2Correct = band->stationsByName().value(stnName);
3439  SgParameterBreak *clockBreak=new SgParameterBreak(tBreak, 0.0);
3440  if (stn2Correct->clockBreaks().addBreak(clockBreak))
3441  logger->write(SgLogger::INF, SgLogger::IO_NCDF, className() +
3442  "::getDataFromVgosDb(): a clock break at station " + stn2Correct->getKey() +
3443  " that occurred on " + tBreak.toString() + " has been added to the " +
3444  band->getKey() + "-band");
3445  else
3446  logger->write(SgLogger::WRN, SgLogger::IO_NCDF, className() +
3447  "::getDataFromVgosDb(): adding new clock break at " + stn2Correct->getKey() +
3448  " station on " + tBreak.toString() + " has failed");
3449  };
3450  };
3451  */
3452  };
3454  }
3455  else
3457  "::getDataFromVgosDb(): no clock breaks found");
3458  // end of clock breaks.
3459  //
3460  // check for leap seconds:
3461  if (hasLeapSecond)
3462  {
3463  setLeapSeconds(leapSecond);
3465  "::getDataFromVgosDb(): a number of leap seconds has been found; " + QString().setNum(leapSecond) +
3466  " leap seconds were assigned");
3467  };
3468  //
3469  // check for the applied cable cal signs:
3470  if (cableSignByKey.size())
3471  {
3472  for (QMap<QString, QString>::const_iterator it=cableSignByKey.begin();
3473  it!=cableSignByKey.end(); ++it)
3474  {
3475  const QString &stnNme=it.key();
3476  const QString &stnSgn=it.value();
3477  if (stationsByName_.contains(stnNme))
3478  {
3479  double d;
3480  if (stnSgn.contains("-"))
3481  d = -1.0;
3482  else if (stnSgn.contains("+"))
3483  d = 1.0;
3484  else
3485  d = 0.0;
3486  stationsByName_[stnNme]->setCableCalMultiplierDBCal(d);
3488  "::getDataFromVgosDb(): an applied cable calibration sign " + QString().sprintf("%+g", d) +
3489  " has been set for the station [" + stnNme + "] on the basis of string: \"" + stnSgn +
3490  "\"");
3491  }
3492  else
3494  "::getDataFromVgosDb(): got cable cal sign for a station that is not in the session: " +
3495  stnNme);
3496  };
3498  "::getDataFromVgosDb(): " + QString().setNum(cableSignByKey.size()) +
3499  " cable calibration signs were applied to stations");
3500  };
3501 
3502  if (cppsSoft_ == CPPS_UNKNOWN)
3503  cppsSoft_ = CPPS_HOPS;
3504 
3505  //
3506  //
3507  // clear temporary storages:
3508  if (atmInterval)
3509  delete atmInterval;
3510  if (atmRateConstraint)
3511  delete atmRateConstraint;
3512  if (clkInterval)
3513  delete clkInterval;
3514  if (clkRateConstraint)
3515  delete clkRateConstraint;
3516 
3517  if (pmArrayInfo)
3518  delete pmArrayInfo;
3519  if (utArrayInfo)
3520  delete utArrayInfo;
3521  if (utValues)
3522  delete utValues;
3523  if (pmValues)
3524  delete pmValues;
3525  if (groupBlWeights)
3526  delete groupBlWeights;
3527 
3528  sourcesNames.clear();
3529  stationsNames4Coo.clear();
3530  tectonicPlateNames.clear();
3531  stationsNames4Ant.clear();
3532  stationsNames4Ecc.clear();
3533 
3534  cbNames.clear();
3535  cbEpochs.clear();
3536  cbFlags.clear();
3537  cableSignByKey.clear();
3538 
3539  // pick up history, put it in every band:
3540  for (int iBand=0; iBand<numberOfBands(); iBand++)
3541  {
3542  SgVlbiBand *band=bands_.at(iBand);
3543  vgosDb->loadHistory(band->history());
3544  band->setInputFileVersion(vgosDb->getCurrentVersion());
3545  band->setCorrelatorType(correlatorType);
3546  };
3547  //
3549  //
3550  //
3551  isOk = isOk && selfCheck(guiExpected);
3552  //
3553  SgMJD finisEpoch(SgMJD::currentMJD());
3555  ": getDataFromVgosDb(): the session " + getName() + " has been read from vgosDb data set" +
3556  ", elapsed time: " + QString("").sprintf("%.2f", (finisEpoch - startEpoch)*86400000.0) + " ms");
3557 
3558 
3559  //
3560  return isOk;
3561 };
3562 
3563 /*=====================================================================================================*/
3564 
3565 
3566 
3567 
3568 
3569 /*=====================================================================================================*/
3570 //
3571 // constants:
3572 //
3573 
3574 
3575 
3576 /*=====================================================================================================*/
3577 
3578 /*=====================================================================================================*/
const Sg3dVector v3Zero(0.0, 0.0, 0.0)
const double vLight
Definition: SgConstants.cpp:33
SgLogger * logger
Definition: SgLogger.cpp:231
const SgMJD tZero(1957, 10, 4)
DIRECTION
Definition: SgMathSupport.h:68
@ Z_AXIS
Definition: SgMathSupport.h:68
@ X_AXIS
Definition: SgMathSupport.h:68
@ Y_AXIS
Definition: SgMathSupport.h:68
#define RAD2DEG
< radians to degrees:
Definition: SgMathSupport.h:32
#define DEG2RAD
hours to radians:
Definition: SgMathSupport.h:40
QMap< QString, SgVlbiBaselineInfo * >::iterator BaselinesByName_it
const QString sMntTypes[]
void evaluateEffectiveFreqs(const SgVector &numOfAccPeriodsByChan_USB, const SgVector &numOfAccPeriodsByChan_LSB, const SgVector &refFreqByChan, const SgVector &fringeAmplitudeByChan, const SgVector &numOfSamplesByChan_USB, const SgVector &numOfSamplesByChan_LSB, double sampleRate, double refFreq, int numOfChannels, double &effFreq4GR, double &effFreq4PH, double &effFreq4RT, const QString &correlatorType, const QString &oId, bool useEqualWeights=false)
QMap< QString, SgVlbiStationInfo * >::iterator StationsByName_it
@ DT_DELAY
Definition: SgWrmsable.h:44
@ DT_RATE
Definition: SgWrmsable.h:45
bool isAttr(uint a) const
Definition: SgAttribute.h:226
void delAttr(uint a)
Definition: SgAttribute.h:210
void addAttr(uint a)
Definition: SgAttribute.h:202
bool addBreak(const SgMJD &t, double a0=0.0, double a1=0.0, double a2=0.0, bool isDynamic=false)
void setDR(const Sg3dVector &)
Definition: SgEccRec.h:299
@ ET_NEU
Definition: SgEccRec.h:51
@ ET_N_A
Definition: SgEccRec.h:50
@ ET_XYZ
Definition: SgEccRec.h:52
void setEccType(EccType)
Definition: SgEccRec.h:307
void setCdpNumber(const QString &)
Definition: SgEccRec.h:267
const SgMJD & getDateOfCreation() const
Definition: SgIoDriver.h:100
virtual void write(LogLevel, quint32, const QString &, bool=false)
Definition: SgLogger.cpp:88
@ IO_NCDF
Definition: SgLogger.h:66
@ IO_TXT
Definition: SgLogger.h:65
Definition: SgMJD.h:59
double getTime() const
Definition: SgMJD.h:457
@ F_YYYYMMDDHHMMSSSS
Long verbose: Fri, the 2nd of Apr, 2010; 17hr 02min 43.6400sec.
Definition: SgMJD.h:67
@ F_INTERNAL
Digits, date and time: 20100402.71.
Definition: SgMJD.h:72
QString toString(Format format=F_Verbose) const
Definition: SgMJD.cpp:1007
int getDate() const
Definition: SgMJD.h:449
int calcHour() const
Definition: SgMJD.h:495
int calcDayOfYear() const
Definition: SgMJD.cpp:237
static SgMJD currentMJD()
Definition: SgMJD.cpp:118
void setUpEpoch(int year, int month, int day, int hour, int min, double sec)
Definition: SgMJD.cpp:254
int calcMin() const
Definition: SgMJD.h:502
static void MJD_reverse(int date, double time, int &nYear, int &nMonth, int &nDay, int &nHour, int &nMin, double &dSec)
Definition: SgMJD.cpp:74
double calcSec() const
Definition: SgMJD.h:509
void clear()
Definition: SgMatrix.h:425
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
@ Attr_ARTIFICIAL_DATA
data are artificial (mean values or some model);
Definition: SgMeteoData.h:52
void setDefinition(const QString &def)
Definition: SgModelsInfo.h:73
void setOrigin(const QString &orig)
Definition: SgModelsInfo.h:74
void setControlFlag(const QString &flag)
Definition: SgModelsInfo.h:72
QList< SgVlbiStationInfo * > & stations()
Definition: SgModelsInfo.h:155
DasModel & ut1Interpolation()
Definition: SgModelsInfo.h:140
short getFlagTidalUt1() const
Definition: SgModelsInfo.h:116
DasModel & polarMotionInterpolation()
Definition: SgModelsInfo.h:138
void setKey(const QString &key)
Definition: SgObjectInfo.h:447
int getIdx() const
Definition: SgObjectInfo.h:335
void incNumTotal(DataType, int=1)
Definition: SgObjectInfo.h:519
const QString & getKey() const
Definition: SgObjectInfo.h:319
void setSigma2add(DataType dType, double d)
Definition: SgObjectInfo.h:471
virtual void setMediaIdx(int idx)
virtual void setMJD(const SgMJD &)
@ Attr_NOT_VALID
omit the observation;
Definition: SgObservation.h:78
@ Attr_DYNAMIC
parameters supposed to be estimated during the common solution;
Definition: SgBreakModel.h:60
double getPwlStep() const
double getPwlAPriori() const
void setPwlStep(double s)
void setPwlAPriori(double)
const SgParameterCfg & getZenith() const
void setClock0(const SgParameterCfg &p)
void setZenith(const SgParameterCfg &p)
const SgParameterCfg & getClock0() const
double getInitAuxSigma4Delay() const
Definition: SgTaskConfig.h:231
bool getUseSolveObsSuppresionFlags() const
Definition: SgTaskConfig.h:913
double getInitAuxSigma4Rate() const
Definition: SgTaskConfig.h:232
@ CT_ALL_TERMS_REMOVED
Definition: SgTidalUt1.h:53
@ CT_SHORT_TERMS_REMOVED
Definition: SgTidalUt1.h:52
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 loadObsSNR(const QString &band, SgVector *&snrs)
bool loadObsCrossRefs(QVector< int > &obs2Scan)
bool loadClockSetup(QList< QString > &refClocks, SgVector *&interval, SgVector *&rateConstraint, QVector< QString > &stationsNames)
bool loadStationCalOceanLoad(const QString &stnName, SgMatrix *&calHorzOLoad, SgMatrix *&calVertOLoad)
bool loadHistory(QList< SgVlbiHistoryRecord * > &)
bool loadStationCalSlantPathTropDry(const QString &stnName, SgMatrix *&calNmfDry, QString &kind)
bool loadObsAmbigSpacing(const QString &band, SgVector *&)
bool loadObsPartNut2KXY(SgMatrix *&dV_dCipX, SgMatrix *&dV_dCipY, QString &kind)
bool loadObsNumPhaseAmbigs(const QString &band, QVector< int > &numAmbigs)
bool loadObsCorrelatorInfo(const QString &band, QList< QString > &fourfitOutputFName, QList< QString > &fourfitErrorCodes, SgVector *&scanStartSec, SgVector *&scanStopSec)
bool loadObsSingleBandDelays(const QString &band, SgMatrix *&)
bool loadCalibrations(int &obsCalFlags, QVector< int > &statCalFlags, QVector< QVector< int > > &flybyFlags, QVector< QString > &statCalNames, QVector< QString > &flybyNames, QVector< QString > &calSiteNames, QVector< QString > &obsCalNames)
bool loadSelectionStatus(QVector< int > &sourcesSelection, QVector< QVector< int > > &baselinesSelection)
bool loadAtmSetup(SgVector *&interval, SgVector *&rateConstraint, QVector< QString > &stationsNames)
bool loadObsCalTiltRmvr(SgMatrix *&cals)
bool loadScanNutationEqx(SgMatrix *&pPsiEps, SgMatrix *&pPsiEps_rates, QString &kind)
bool loadLeapSecond(int &leapSecond)
bool loadObsEffFreqs(const QString &band, SgMatrix *&)
bool loadSolveWeights(QVector< QString > &baselineNames, SgMatrix *&groupBlWeights)
bool loadObsCalHiFyLibration(SgMatrix *&, QString &kind)
bool loadObsCalUnphase(const QString &band, SgMatrix *&unPhaseCal_1, SgMatrix *&unPhaseCal_2)
bool loadObsNumGroupAmbigs(const QString &band, QVector< int > &numAmbigs, QVector< int > &numSubAmbigs)
bool loadObsPartGamma(SgMatrix *&part)
bool loadObsRefFreqs(const QString &band, SgVector *&)
bool loadObsCalBendSunHigher(SgMatrix *&cals)
bool loadObsUserCorrections(int idx, SgMatrix *m, QString &name)
bool loadObsCalOceanOld(SgMatrix *&)
bool loadStationsApriories(QVector< QString > &stationsNames, SgMatrix *&cooXYZ, QVector< QString > &tectonicPlateNames)
bool loadObsGroupDelays(const QString &band, SgMatrix *&)
bool loadObsCalFeedCorr(SgMatrix *&)
bool loadScanNutationEqxWahr(SgMatrix *&pPsiEps, SgMatrix *&pPsiEps_rates)
@ CT_GSI
Definition: SgVgosDb.h:192
@ CT_Unknown
Definition: SgVgosDb.h:188
@ CT_CRL
Definition: SgVgosDb.h:191
int getNumOfUserCorrections() const
Definition: SgVgosDb.h:302
bool loadObsCalOceanPoleTideLoad(SgMatrix *&)
bool loadObsPartBend(SgMatrix *&partBend)
int getCurrentVersion() const
Definition: SgVgosDb.h:280
bool loadScanName(QVector< QString > &scanNames, QVector< QString > &scanFullNames)
bool loadObsPartParallax(SgMatrix *&part)
bool loadStationCalSlantPathTropWet(const QString &stnName, SgMatrix *&calNmfWet, QString &kind)
bool loadObsCalHiFyErp(SgMatrix *&, SgMatrix *&, QString &kind)
bool loadObsCalBend(SgMatrix *&cals)
bool loadStationCalAxisOffset(const QString &stnName, SgMatrix *&cal)
bool loadObsDtec(SgVector *&dTec, SgVector *&dTecStdDev)
bool loadStationOceanLdDisp(const QString &stnName, SgMatrix *&dis, SgMatrix *&vel)
bool loadStationMet(const QString &stnName, SgVector *&metAtmPres, SgVector *&metAtmRH, SgVector *&metAtmTemp, QString &origin, QString &kind)
bool loadSessionHead(QString &corrType, QString &corrName, QString &piName, QString &experimentName, int &experimentSerialNumber, QString &experimentDescription, QString &recordingMode, QList< QString > &stations, QList< QString > &sources, SgMJD &tStart, SgMJD &tFinis, int &cppsIdx)
bool hasBand(const QString &band) const
Definition: SgVgosDb.h:383
bool loadStationRefClockOffset(const QString &stnName, SgVector *&refClockOffset)
bool loadObsPartRaDec(SgMatrix *&dV_dRA, SgMatrix *&dV_dDN)
QList< QString > getListOfBands() const
Definition: SgVgosDb.h:379
bool loadObsCalWobble(SgMatrix *&, SgMatrix *&)
bool loadObsCalPoleTide(SgMatrix *&, QString &kind)
bool loadObsCorrelation(const QString &band, SgVector *&correlations)
bool loadScanTrf2crf(SgMatrix *&val, SgMatrix *&rat, SgMatrix *&acc)
bool loadClockBreaks(QVector< QString > &cbNames, QVector< SgMJD > &cbEpochs, QVector< int > &cbFlags)
bool loadEccentricities(QVector< QString > &stationsNames, QVector< QString > &eccTypes, QVector< QString > &eccNums, SgMatrix *&eccVals)
bool loadStationCalCable(const QString &stnName, SgMatrix *&cal, QString &origin, QString &kind)
bool loadStationPartZenithDelayDry(const QString &stnName, SgMatrix *&part, QString &kind)
bool loadObsDataFlag(const QString &band, QVector< int > &delUFlag)
bool loadMiscFourFit(const QString &band, QVector< QString > &fourfitControlFile, QVector< QString > &fourfitCommand, QVector< int > &numLags, QVector< double > &apLength)
bool loadObsPhase(const QString &band, SgMatrix *&)
bool loadObsCalParallax(SgMatrix *&cals)
bool loadObsChannelInfo(const QString &band, QVector< QString > &channelIds, QVector< QString > &polarizations, QVector< int > &numOfChannels, QVector< int > &bitsPerSamples, QVector< QVector< int > > &errorRates_1, QVector< QVector< int > > &errorRates_2, QVector< QVector< int > > &bbcIdxs_1, QVector< QVector< int > > &bbcIdxs_2, QVector< QVector< int > > &corelIdxNumbersUsb, QVector< QVector< int > > &corelIdxNumbersLsb, SgVector *&sampleRate, SgMatrix *&residFringeAmplByChan, SgMatrix *&residFringePhseByChan, SgMatrix *&refFreqByChan, SgMatrix *&numOfSamplesByChan_USB, SgMatrix *&numOfSamplesByChan_LSB, SgMatrix *&numOfAccPeriodsByChan_USB, SgMatrix *&numOfAccPeriodsByChan_LSB, SgMatrix *&loFreqs_1, SgMatrix *&loFreqs_2)
bool loadCalcEop(SgVector *&pmArrayInfo, SgVector *&utArrayInfo, SgMatrix *&pmValues, SgVector *&utValues, QString &sUtMode, QString &sUtModule, QString &sUtOrigin, QString &sPmMode, QString &sPmModule, QString &sPmOrigin)
bool loadObsPartEOP(SgMatrix *&dV_dPx, SgMatrix *&dV_dPy, SgMatrix *&dV_dUT1)
bool loadStationParAngle(const QString &stnName, SgVector *&parAngle)
bool loadObsFractC(SgVector *&v)
const QString & getSessionCode() const
Definition: SgVgosDb.h:264
bool loadStationTsys(const QString &stnName, SgMatrix *&tsyses, QVector< double > &frqs, QVector< QString > &ids, QVector< QString > &sbs, QVector< QString > &polzs)
bool loadSourcesApriories(QVector< QString > &sourcesNames, SgMatrix *&cooRaDe, QVector< QString > &sourcesApRefs)
bool loadStationPartHorizonGrad(const QString &stnName, SgMatrix *&part, QString &kind)
const QString & getSessionName() const
Definition: SgVgosDb.h:268
bool loadObsPhaseCalInfo(const QString &band, SgMatrix *&phaseCalFreqs_1, SgMatrix *&phaseCalAmps_1, SgMatrix *&phaseCalPhases_1, SgMatrix *&phaseCalOffsets_1, SgVector *&phaseCalRates_1, SgMatrix *&phaseCalFreqs_2, SgMatrix *&phaseCalAmps_2, SgMatrix *&phaseCalPhases_2, SgMatrix *&phaseCalOffsets_2, SgVector *&phaseCalRates_2)
bool loadMiscCable(QMap< QString, QString > &cableSignByKey)
bool loadObsEditData(QVector< int > &delUFlag, QVector< int > &phsUFlag, QVector< int > &ratUFlag, QVector< int > &uAcSup)
bool loadCalcInfo(int &tidalUt1, double &calcVersionValue)
const QString & getWrapperFileName() const
Definition: SgVgosDb.h:276
bool loadObsCalOcean(SgMatrix *&)
bool loadObsCalIonGroup(const QString &band, SgMatrix *&ionCals, SgMatrix *&ionSigmas, QVector< int > &ionDataFlag)
bool loadStationEpochs(const QString &stnName, QList< SgMJD > &epochs)
bool loadAntennaApriories(QVector< QString > &stationsNames, QVector< int > &axisTypes, SgVector *&axisOffsets, SgMatrix *&axisTilts)
bool loadObsCalPoleTideOldRestore(SgMatrix *&cals)
bool loadScanNutationNro(SgMatrix *&pXys, SgMatrix *&pXys_rates, QString &kind)
bool loadObsUVFperAsec(const QString &band, SgMatrix *&uvfPerAsec)
bool loadObsCalBendSun(SgMatrix *&cals)
bool loadObsRates(const QString &band, SgMatrix *&)
bool loadScanCrootFname(QVector< QString > &corrRootFnames)
bool loadEpochs4Scans(QList< SgMJD > &)
CorrelatorType getCorrelatorType() const
Definition: SgVgosDb.h:296
bool loadEpochs4Obs(QList< SgMJD > &)
bool loadObsQualityCodes(const QString &band, QVector< QString > &qualityCodes)
bool loadScanEphemeris(SgMatrix *&rSun, SgMatrix *&rMoon, SgMatrix *&rEarth, SgMatrix *&vSun, SgMatrix *&vMoon, SgMatrix *&vEarth, SgMatrix *&aEarth)
bool loadObsPartPoleTides(SgMatrix *&partX, SgMatrix *&partY, QString &kind)
bool loadObsPartXYZ(SgMatrix *&dTau_dR_1, SgMatrix *&dRat_dR_1)
bool loadStationPartZenithDelayWet(const QString &stnName, SgMatrix *&part, QString &kind)
bool loadClockApriories(QVector< QString > &stationNames, SgMatrix *&offsets_n_rates)
bool loadStationAzEl(const QString &stnName, SgMatrix *&azTheo, SgMatrix *&elTheo)
bool loadObsCalEarthTide(SgMatrix *&, QString &kind)
bool loadErpApriori(SgVector *&ut1_tai, SgMatrix *&pm)
bool loadObsTheoreticals(SgVector *&delays, SgVector *&rates)
bool loadObsObjectNames(QList< QString > &, QList< QString > &, QList< QString > &)
bool loadStationPartAxisOffset(const QString &stnName, SgMatrix *&partAxisOffset)
void setOcnLdV(const Sg3dVector &v)
void setCableCalibration(double cable)
void setMeteoData(const SgMeteoData &meteo)
void setAzimuthAngle(double angle)
void setDdel_dTzdDry(double v)
@ Attr_CABLE_CAL_BAD
clock break occured at the station
void setCalcNwetCont4Delay(double v)
void setCalcNdryCont4Delay(double v)
void setDrat_dTzdWet(double v)
void setCalcOLoadHorz4Delay(double v)
void setCalcOLoadHorz4Rate(double v)
void setDdel_dTzdGrdE(double v)
void setAzimuthAngleRate(double rate)
void setCalcOLoadVert4Rate(double v)
void setDrat_dTzdGrdE(double v)
void setParallacticAngle(double angle)
void setDdel_dTzdGrdN(double v)
void setCalcOLoadVert4Delay(double v)
void setCalcAxisOffset4Delay(double v)
void setDrat_dTzdGrdN(double v)
void setOcnLdR(const Sg3dVector &r)
void setCalcNwetCont4Rate(double v)
void setElevationAngle(double angle)
void setElevationAngleRate(double rate)
void setCalcNdryCont4Rate(double v)
void setDdel_dTzdWet(double v)
void setDrat_dTzdDry(double v)
void setRefClockOffset(double d)
void setTapeId(const QString id)
void setCalcAxisOffset4Rate(double v)
void setFrequency(double f)
Definition: SgVlbiBand.h:402
void setTCreation(const SgMJD &t)
Definition: SgVlbiBand.h:410
void setCorrelatorType(const QString &name)
Definition: SgVlbiBand.h:434
QMap< QString, SgVlbiBaselineInfo * > & baselinesByName()
Definition: SgVlbiBand.h:376
QMap< QString, SgVlbiStationInfo * > & stationsByName()
Definition: SgVlbiBand.h:368
void setInputFileName(const QString &fileName)
Definition: SgVlbiBand.h:418
void setInputFileVersion(int version)
Definition: SgVlbiBand.h:426
QMap< int, SgVlbiBaselineInfo * > & baselinesByIdx()
Definition: SgVlbiBand.h:304
QMap< QString, SgVlbiSourceInfo * > & sourcesByName()
Definition: SgVlbiBand.h:384
QMap< int, SgVlbiSourceInfo * > & sourcesByIdx()
Definition: SgVlbiBand.h:312
SgVlbiHistory & history()
Definition: SgVlbiBand.h:360
QMap< int, SgVlbiStationInfo * > & stationsByIdx()
Definition: SgVlbiBand.h:296
@ Attr_HAS_IONO_SOLUTION
the band contains ionospheric corrections;
Definition: SgVlbiBand.h:61
@ Attr_MISSING_CHANNEL_INFO
the band lacks info on channel setup;
Definition: SgVlbiBand.h:63
@ Attr_ESTIMATE_CLOCKS
estimate baseline clocks;
@ Attr_NOT_VALID
omit the baseline;
void setAmbiguitySpacing(double)
void setEffFreqEqWgt(double)
short int getUnweightFlag() const
void setIonoSigma(double)
void setNumOfSubAmbigs(int n)
void setEffFreq(double)
void setNumOfAmbiguities(int)
void setIonoValue(double)
double getSigma() const
void setResidualFringeFitting(double r)
void setGeocenterValue(double)
void setUnweightFlag(short int)
QVector< int > * corelIndexNumLSB()
void setEpochOfCorrelation(const SgMJD &)
void setEpochCentral(const SgMJD &)
void setBitsPerSample(int bps)
void setTstart(const SgMJD &t)
void setCorrClocks(int i, int j, double d)
void setTotalPhase(double)
void setHopsRevisionNumber(int num)
void setPhaseCalGrDelays(int i, double d)
QVector< char > * polarization_1ByChan()
SgVector * loFreqByChan_1()
QVector< char > * chanIdByChan()
void setIncohSegmAddAmp(double d)
QVector< int > * corelIndexNumUSB()
SgMatrix * phaseCalData_2ByChan()
void setAcceptedRatio(double d)
const QString & getErrorCode() const
void setTstop(const SgMJD &t)
void setEpochOfFourfitting(const SgMJD &)
SgVlbiObservation * owner()
SgVector * numOfAccPeriodsByChan_LSB()
void setIncohChanAddAmp(double d)
void setCentrOffset(double offset)
void setEffIntegrationTime(double d)
void setFourfitOutputFName(const QString &)
QVector< char > * polarization_2ByChan()
SgVector * numOfAccPeriodsByChan_USB()
QVector< int > * bbcIdxByChan_1()
void setFourfitControlFile(const QString &cf)
SgVlbiMeasurement & phDRate()
void setGeocenterResidPhase(double d)
void setCorrelStarElev_2(double v)
void setSnr(double)
void setProbabOfFalseDetection(double d)
void setQualityFactor(int)
QString strId() const
void setNlags(int n)
void setGeocenterTotalPhase(double d)
void setDiscardRatio(double d)
SgVector * fringeAmplitudeByChan()
void setCorrCoeff(double)
SgVector * vAuxData()
void setEpochOfScan(const SgMJD &)
void setUrVr(int i, double d)
void setCorrelZdelay_1(double v)
SgVector * numOfSamplesByChan_LSB()
void setAprioriDra(int i, double d)
void setInstrDelay(int i, double d)
void setPhaseCalRates(int i, double d)
void setStopOffset(int offset)
SgVector * vDlys()
void setUvFrPerAsec(int i, double d)
void setErrorCode(const QString &)
SgMatrix * phaseCalData_1ByChan()
SgVector * numOfSamplesByChan_USB()
void setFourfitCommandOverride(const QString &co)
void setReferenceFrequency(double)
void setCorrelZdelay_2(double v)
double getReferenceFrequency() const
void allocateChannelsSetupStorages(int numOfChans)
SgVlbiMeasurement & phDelay()
void setTapeQualityCode(const QString &code)
void setCalcFeedCorrDelay(double v)
SgVector * loFreqByChan_2()
SgVlbiMeasurement & grDelay()
void setStartOffset(int offset)
SgVlbiMeasurement & sbDelay()
SgVector * fringePhaseByChan()
SgVector * refFreqByChan()
void setFourfitSearchParameters(int i, double d)
void setSampleRate(double sr)
void setCorrelStarElev_1(double v)
void setCalcFeedCorrRate(double v)
QVector< int > * bbcIdxByChan_2()
void setFourfitVersion(int idx, int ver)
void setCalcOceanTideDelay(double v)
void setCalcHiFyPxyRate(double v)
void setCalcNut2006_dPsiV(double v)
void setStation1Idx(short int idx)
void setRearth(const Sg3dVector &r)
void setScanId(const QString &sId)
void setCalcConsBendingRate(double d)
@ Attr_SBD_NOT_VALID
omit the observation if single band delay is analysed;
void setCalcHiFyPxyDelay(double v)
void setDdel_dRA(double d)
void setDrat_dPolTideY(double d)
void setCalcOceanPoleTideLdDelay(double v)
void setDrat_dR_1(const Sg3dVector &r)
void setCalcHiFyUt1Rate(double v)
void setCalcPxDelay(double v)
void setSourceIdx(short int idx)
void setCalcNut2006_dEpsV(double v)
void setCalcPoleTideDelay(double v)
void setDdel_dGamma(double d)
void setApLength(double d)
void setCalcTiltRemvrRate(double v)
SgVlbiAuxObservation * auxObs_2()
void setCalcConsBendingSunRate(double d)
bool addObservable(const QString &, const SgVlbiObservable &)
void setRsun(const Sg3dVector &r)
void setCalcEarthTideDelay(double v)
void setCalcConsensusDelay(double tau)
void setDTecStdDev(double e)
void setCalcNut2006_dPsiR(double v)
void setAuxObs_2(SgVlbiAuxObservation *aux)
void setCalcNut2006_dEpsR(double v)
void setVsun(const Sg3dVector &v)
void setCalcHiFyPxyLibrationRate(double v)
void setAuxObs_1(SgVlbiAuxObservation *aux)
void setCalcPyDelay(double v)
void setScanName(const QString &sName)
void setCalcCipSr(double v)
void setCalcPoleTideOldDelay(double v)
short int getStation1Idx() const
void setDrat_dPolTideX(double d)
void setCalcPoleTideRate(double v)
void setCalcHiFyUt1LibrationDelay(double v)
void setCalcPmY(double d)
void setDTec(double d)
void setVmoon(const Sg3dVector &v)
void setCalcConsBendingSunHigherDelay(double d)
void setCalcConsensusRate(double r)
void setCalcUt1_Tai(double d)
void setCalcNutWahr_dEpsV(double v)
void setCalcNutWahr_dPsiV(double v)
void setDrat_dParallaxRev(double d)
void setDrat_dCipY(double d)
void setCalcCipYv(double v)
short int getSourceIdx() const
void setDrat_dGamma(double d)
Sg3dMatrix & trf2crfRat()
void setCalcOceanTideOldRate(double v)
void setDrat_dRA(double d)
void setCorrRootFileName(const QString &sName)
void setD2rat_dUT12(double d)
void setCalcHiFyPxyLibrationDelay(double v)
void setCalcPmX(double d)
void setCalcOceanTideOldDelay(double v)
void setDdel_dR_1(const Sg3dVector &r)
void setDdel_dUT1(double d)
void setDrat_dBend(double d)
void setVearth(const Sg3dVector &v)
void setDdel_dPolTideX(double d)
void setCalcCipXr(double v)
void setCalcCipSv(double v)
void setCalcConsBendingSunHigherRate(double d)
void setDdel_dCipY(double d)
void setStation2Idx(short int idx)
void setCalcCipXv(double v)
void setDrat_dParallax(double d)
void setCalcNutWahr_dEpsR(double v)
QVector< double > & userCorrections()
void setDdel_dParallax(double d)
void setCalcEarthTideRate(double v)
void setDdel_dPy(double d)
void setD2del_dUT12(double d)
short int getStation2Idx() const
void setDdel_dPx(double d)
QMap< QString, SgVlbiObservable * > & observableByKey()
void setCalcTiltRemvrDelay(double v)
void setDdel_dCipX(double d)
void setRmoon(const Sg3dVector &r)
void setCalcOceanPoleTideLdRate(double v)
void setCalcConsBendingDelay(double d)
void setDdel_dBend(double d)
void setCalcOceanTideRate(double v)
Sg3dMatrix & trf2crfAcc()
SgVlbiAuxObservation * auxObs_1()
void setDrat_dCipX(double d)
void setCalcHiFyUt1LibrationRate(double v)
void setCalcHiFyUt1Delay(double v)
void setDrat_dPx(double d)
void setDdel_dParallaxRev(double d)
void setAearth(const Sg3dVector &a)
const QString & getKey()
void setCalcPyRate(double v)
void setDrat_dDN(double d)
void setBaselineIdx(short int idx)
void setCalcPxRate(double v)
void setDdel_dR_2(const Sg3dVector &r)
void setCalcNutWahr_dPsiR(double v)
void setScanFullName(const QString &sId)
void setCalcPoleTideOldRate(double v)
void setCalcConsBendingSunDelay(double d)
short int getBaselineIdx() const
void setDrat_dUT1(double d)
void setFractC(double d)
void setDrat_dR_2(const Sg3dVector &r)
void setCalcWobNutatContrib(double v)
void setDrat_dPy(double d)
void setKey(const QString &)
void setCalcCipYr(double v)
Sg3dMatrix & trf2crfVal()
void setDdel_dPolTideY(double d)
void setDdel_dDN(double d)
const QString & getName() const
void setRecordingMode(const QString &mode)
void setSessionCode(const QString &code)
void setDescription(const QString &description)
void setName(const QString &name)
void setCorrelatorType(const QString &name)
CorrelatorPostProcSoftware cppsSoft_
@ Attr_PRE_PROCESSED
the observations has been prepared for analysis;
@ Attr_HAS_CALC_DATA
the theoretical values are available;
@ Attr_HAS_DTEC
the session contains diffTec values;
@ Attr_HAS_AUX_OBS
session contains aux.observations (e.g.: meteo data, cables);
@ Attr_HAS_IONO_CORR
the theoretical values are available;
@ Attr_HAS_WEIGHTS
the theoretical values are available;
@ Attr_HAS_CLOCK_BREAKS
there is at least one clock break at one of stations;
@ CPPS_UNKNOWN
unknown (=all others);
QString networkSuffix_
a char that specifies network (e.g., A, E, U, etc.);
void setExperimentSerialNumber(int sn)
void setCorrelatorName(const QString &name)
void setPiAgencyName(const QString &name)
QString name_
name of the session (e.g., 10JUL22XE);
int numberOfBands() const
StationsByName stationsByName_
bool hasOceanPoleTideContrib_
bool hasWobbleNutContrib_
bool getDataFromVgosDb(SgVgosDb *vgosDb, bool have2LoadImmatureSession, bool guiExpected)
void allocPxyInterpolValues(const SgMatrix *vals)
void setLeapSeconds(double s)
bool hasUt1LibrationContrib_
QMap< QString, SgVlbiObservation * > observationByKey_
QList< SgVlbiBand * > bands_
QVector< bool > userCorrectionsUse_
SgTidalUt1::UT1TideContentType tabsUt1Type_
SgVector * args4PxyInterpolation_
bool selfCheck(bool guiExpected)
QMap< QString, SgVlbiBand * > bandByKey_
void applyObsCalibrationSetup(int bitFlags, const QList< QString > &calList)
bool hasOceanTideContrib_
QList< SgVlbiObservation * > observations_
void allocPxyInterpolEpochs(double t0, double dt, unsigned int numOfPts)
bool hasPoleTideOldContrib_
bool hasWobblePxContrib_
void allocUt1InterpolEpochs(double t0, double dt, unsigned int numOfPts)
bool hasWobbleHighFreqContrib_
bool hasUnPhaseCalContrib_
QMap< int, SgVlbiStationInfo * > stationsByIdx_
SgModelsInfo calcInfo_
bool hasUt1HighFreqContrib_
void allocUt1InterpolValues(const SgVector *vals)
bool hasPxyInterpolation_
QMap< QString, double > skyFreqByIfId_
bool hasWobblePyContrib_
QVector< QString > userCorrectionsName_
BaselinesByName baselinesByName_
bool hasUt1Interpolation_
SgParametersDescriptor * parametersDescriptor_
bool hasPoleTideContrib_
void setInputDriver(SgIoDriver *drv)
bool hasEarthTideContrib_
static QString className()
SgVector * args4Ut1Interpolation_
bool hasPxyLibrationContrib_
SgMatrix * tabs4Ut1Interpolation_
bool hasFeedCorrContrib_
QMap< int, SgVlbiBaselineInfo * > baselinesByIdx_
SourcesByName sourcesByName_
SgTaskConfig * config_
bool hasTiltRemvrContrib_
bool hasOceanTideOldContrib_
SgMatrix * tabs4PxyInterpolation_
QMap< int, SgVlbiSourceInfo * > sourcesByIdx_
void applyStatusBits(short bitArray)
void setDN(double dn)
void setRA(double ra)
void setAprioriReference(const QString &ref)
void setNeed2useAPrioriClocks(bool)
QMap< QString, SgVlbiAuxObservation * > * auxObservationByScanId()
void setR(const Sg3dVector &r)
QVector< QString > & tsysIfSideBands()
QVector< double > & tsysIfFreqs()
double getAxisOffset() const
QVector< QString > & tsysIfIds()
void setMeteoDataOriginTxt(const QString &origin)
void setMntType(MountingType m)
@ Attr_REFERENCE_CLOCKS
the clocks are the reference ones;
@ Attr_HAS_CABLE_CAL
a station has cable calibration readings;
@ Attr_IGNORE_CABLE_CAL
do not apply cable calibration;
@ Attr_METEO_MODIFIED
a station has meteo parameters;
@ 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;
@ Attr_CABLE_CAL_MODIFIED
a station has cable calibration readings;
@ Attr_HAS_METEO
a station has meteo parameters;
SgParameterCfg * pcZenith()
void setMeteoDataOrigin(MeteoDataOrigin origin)
void setAPrioriClockTerm_1(double)
void setTectonicPlateName(const QString &name)
SgParameterCfg * pcClocks()
static MountingType int2mntType(int)
void setCableCalsOriginTxt(const QString &origin)
void setAxisOffset(double v)
void setCableCalsOrigin(CableCalsOrigin origin)
SgBreakModel & clockBreaks()
void setAPrioriClockTerm_0(double)
QVector< QString > & tsysIfPolarizations()
void setPcClocks(const SgParameterCfg &pc)
void setPcZenith(const SgParameterCfg &pc)