General Purpose Geodetic Library
SgVlbiSessionIoVdbOutput.cpp
Go to the documentation of this file.
1 /*
2  *
3  * This file is a part of Space Geodetic Library. The library is used by
4  * nuSolve, a part of CALC/SOLVE system, and designed to make analysis of
5  * geodetic VLBI observations.
6  * Copyright (C) 2010-2020 Sergei Bolotin.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #include <iostream>
24 #include <stdlib.h>
25 
26 
27 #include <QtCore/QRegExp>
28 
29 
30 #include <SgVlbiSession.h>
31 
32 #include <SgConstants.h>
33 #include <SgEccRec.h>
34 #include <SgIdentities.h>
35 #include <SgLogger.h>
36 #include <SgVersion.h>
37 #include <SgVgosDb.h>
38 #include <SgVlbiBand.h>
39 #include <SgVlbiObservation.h>
40 
41 
42 
43 // to do: add ACM
44 
45 //
46 extern const QString sCalList[], sFclList[];
47 
48 
49 /*=======================================================================================================
50 *
51 * Auxiliary data structures
52 *
53 *======================================================================================================*/
54 //
56 {
57  QString str("");
58  SgMJD startEpoch(SgMJD::currentMJD());
59  bool isOk(true);
60  int numOfObs=observations_.size();
61  int numOfChans;
62 
63  if (vgosDb->getOperationMode() == SgNetCdf::OM_DRY_RUN)
64  std::cout << "\nRunning in a DRY RUN mode, no files will be created:\n\n";
65 
66 
67  // AGV specific stuff:
68  if (originType_ == OT_AGV)
69  {
70  str = getCorrelatorType();
71  if (str.contains("MK3", Qt::CaseInsensitive))
73  else if (str.contains("MK4", Qt::CaseInsensitive))
75  else if (str.contains("VLBA", Qt::CaseInsensitive))
77  else if (str.contains("CRL", Qt::CaseInsensitive))
79  else if (str.contains("GSI", Qt::CaseInsensitive))
81  else if (str.contains("S2", Qt::CaseInsensitive))
83  else if (str.contains("difx", Qt::CaseInsensitive))
85  else
86  {
89  "::putDataIntoVgosDb(): canot guess correlator type: \"" + str + "\"");
90  };
91  };
92 
93 
94 //if (getOriginType()==OT_MK4 || getOriginType()==OT_KOMB) // new session, no vgosDb tree exists yet
95  if (isAttr(Attr_FF_CREATED)) // new session, no vgosDb tree exists yet
96  {
97  QList<SgVector*> vectors2del;
98  QList<SgMatrix*> matrices2del;
99 
100  QList<SgMJD> epochs4Scans;
101  QList<SgMJD> epochs4Obs;
102  QMap<QString, SgMJD> epochByScanId;
103  QList<QString> stations_1, stations_2, sources;
104  QList<QString> scanNames, scanFullNames, crootFnames;
105  //
107  QMap<QString, SgMatrix*> sbDelaysByBand, grDelaysByBand, phRatesByBand, phasesByBand;
108  QMap<QString, SgMatrix*> grDelaysAltByBand, phRatesAltByBand;
109  QMap<QString, SgMatrix*> phaseCal_1ByBand, phaseCal_2ByBand;
110  QMap<QString, SgVector*> ambigsByBand, refFreqsByBand, correlationByBand, snrByBand;
111  QMap<QString, QVector<char> >
112  qualityCodesByBand;
113  //
114  QMap<QString, int> maxNumOfChanByBand;
115  QMap<QString, QVector<int> >
116  numOfChannelsByBand, dataFlagsByBand;
117  QMap<QString, QVector<QString> >
118  fourfitOutputFNameByBand;
119  QMap<QString, SgVector*> sampleRateByBand;
120  QMap<QString, SgMatrix*> numOfAccPeriodsByChan_USBByBand, numOfAccPeriodsByChan_LSBByBand,
121  refFreqByChanByBand,
122  phCalAmps_1ByChanByBand, phCalAmps_2ByChanByBand,
123  phCalPhss_1ByChanByBand, phCalPhss_2ByChanByBand,
124  phCalFrqs_1ByChanByBand, phCalFrqs_2ByChanByBand,
125  phCalOffs_1ByChanByBand, phCalOffs_2ByChanByBand,
126  numOfSamplesByChan_USBByBand,
127  numOfSamplesByChan_LSBByBand,
128  residualFringeAmplByChanByBand,
129  residualFringePhseByChanByBand;
130  //
131  QList<int> obs2scan, obs2stn_1, obs2stn_2;
132  QList<int> scan2src;
133  // StationCrossRef's clients:
134  QList<int> numScansPerStation;
135  QMap<QString, QList<int> > station2Scan, scan2Station;
136  //
137  QMap<QString, int> stnIdxByName;
138  QMap<QString, int> srcIdxByName;
139  int n;
140  char buff[32];
141  // correlInfo's aux stuff:
142  QMap<QString, QVector<QString> >
143  fourfitErrorCodesByBand, frqGrpCodesByBand,
144  fourfitControlFileByBand, fourfitCommandByBand;
145  QMap<QString, QVector<int> >corelVersionsByBand, startOffsetsByBand, bitsPerSamplesByBand,
146  numLagsByBand;
147  QMap<QString, QVector<double> >
148  apLengthByBand;
149  QMap<QString, QVector< QVector<int> > >
150  fourfitVersionsByBand, dbeditVersionByBand;
151 // QMap<QString, SgVector*> refClkErrByBand, deltaEpochsByBand;
152  QMap<QString, SgVector*> deltaEpochsByBand;
153  QMap<QString, SgMatrix*> urvrsByBand, instrDelaysByBand, starElevByBand, zenithDelaysByBand,
154  searchParamsByBand;
155  QMap<QString, SgMatrix*> mDlysByBand, mAuxByBand;
156  QMap<QString, QVector<QString> >
157  baselineCodesByBand, tapeQualityCodesByBand;
158  QMap<QString, QVector<int> >stopOffsetsByBand, hopsRevisionNumbersByBand;
159  QMap<QString, SgVector*> sbdResidsByBand, rateResidsByBand, effDurationsByBand,
160  startSecondsByBand, stopSecondsByBand, percentOfDiscardsByBand,
161  uniformityFactorsByBand, geocenterPhaseResidsByBand,
162  geocenterPhaseTotalsByBand, geocenterSbDelaysByBand,
163  geocenterGrDelaysByBand, geocenterDelayRatesByBand,
164  probOfFalsesByBand, corrAprioriDelaysByBand, corrAprioriRatesByBand,
165  corrAprioriAccsByBand, incohAmpsByBand, incohAmps2ByBand,
166  delayResidsByBand, phaseCalRates_1ByBand, phaseCalRates_2ByBand;
167  //
168  QMap<QString, QVector<QString> >
169  corrRootFileNamesByBand, tapeIds_1ByBand, tapeIds_2ByBand,
170  channelIdsByBand, polarizationsByBand;
171  QMap<QString, QVector< QVector<int> > >
172  epochsOfCorrelationsByBand, epochsOfCentralsByBand,
173  epochsOfFourfitingsByBand, epochsOfNominalScanTimeByBand,
174  bbcIdxs_1ByBand, bbcIdxs_2ByBand, corelIdxNumbersUsbByBand,
175  corelIdxNumbersLsbByBand, errorRates_1ByBand, errorRates_2ByBand;
176  QMap<QString, SgMatrix*> corrClocksByBand, loFreqs_1ByBand, loFreqs_2ByBand;
177  SgVector *dTec, *dTecStdDev;
178 
179 
180  // create the data structures:
181  for (int iB=0; iB<bands_.size(); iB++)
182  {
183  //
184  const QString& bandKey=bands_.at(iB)->getKey();
185  numOfChans = bands_.at(iB)->getMaxNumOfChannels();
186  sbDelaysByBand[bandKey] = new SgMatrix(numOfObs, 2);
187  grDelaysByBand[bandKey] = new SgMatrix(numOfObs, 2);
188  phRatesByBand [bandKey] = new SgMatrix(numOfObs, 2);
189  grDelaysAltByBand[bandKey] = new SgMatrix(numOfObs, 2);
190  phRatesAltByBand [bandKey] = new SgMatrix(numOfObs, 2);
191 
192  phasesByBand [bandKey] = new SgMatrix(numOfObs, 2);
193  phaseCalRates_1ByBand[bandKey]
194  = new SgVector(numOfObs);
195  phaseCalRates_2ByBand[bandKey]
196  = new SgVector(numOfObs);
197 
198  refFreqsByBand[bandKey] = new SgVector(numOfObs);
199  phaseCal_1ByBand[bandKey]
200  = new SgMatrix(numOfObs, 4);
201  phaseCal_2ByBand[bandKey]
202  = new SgMatrix(numOfObs, 4);
203  ambigsByBand [bandKey] = new SgVector(numOfObs);
204  correlationByBand[bandKey] = new SgVector(numOfObs);
205  snrByBand [bandKey] = new SgVector(numOfObs);
206 
207  qualityCodesByBand [bandKey].resize(numOfObs);
208  numOfChannelsByBand [bandKey].resize(numOfObs);
209  dataFlagsByBand [bandKey].resize(numOfObs);
210  dataFlagsByBand [bandKey].fill(-1);
211  fourfitOutputFNameByBand[bandKey].resize(numOfObs);
212  sampleRateByBand [bandKey] = new SgVector(numOfObs);
213  numOfAccPeriodsByChan_USBByBand [bandKey] = new SgMatrix(numOfObs, numOfChans);
214  numOfAccPeriodsByChan_LSBByBand [bandKey] = new SgMatrix(numOfObs, numOfChans);
215 
216  phCalAmps_1ByChanByBand[bandKey] = new SgMatrix(numOfObs, numOfChans);
217  phCalAmps_2ByChanByBand[bandKey] = new SgMatrix(numOfObs, numOfChans);
218  phCalPhss_1ByChanByBand[bandKey] = new SgMatrix(numOfObs, numOfChans);
219  phCalPhss_2ByChanByBand[bandKey] = new SgMatrix(numOfObs, numOfChans);
220  phCalFrqs_1ByChanByBand[bandKey] = new SgMatrix(numOfObs, numOfChans);
221  phCalFrqs_2ByChanByBand[bandKey] = new SgMatrix(numOfObs, numOfChans);
222  phCalOffs_1ByChanByBand[bandKey] = new SgMatrix(numOfObs, numOfChans);
223  phCalOffs_2ByChanByBand[bandKey] = new SgMatrix(numOfObs, numOfChans);
224 
225  refFreqByChanByBand [bandKey] = new SgMatrix(numOfObs, numOfChans);
226  numOfSamplesByChan_USBByBand [bandKey] = new SgMatrix(numOfObs, numOfChans);
227  numOfSamplesByChan_LSBByBand [bandKey] = new SgMatrix(numOfObs, numOfChans);
228  residualFringeAmplByChanByBand [bandKey] = new SgMatrix(numOfObs, numOfChans);
229  residualFringePhseByChanByBand [bandKey] = new SgMatrix(numOfObs, numOfChans);
230 
231  maxNumOfChanByBand[bandKey] = numOfChans;
232 
233  fourfitErrorCodesByBand [bandKey].resize(numOfObs);
234  frqGrpCodesByBand [bandKey].resize(numOfObs);
235  fourfitControlFileByBand [bandKey].resize(numOfObs);
236  fourfitCommandByBand [bandKey].resize(numOfObs);
237  corelVersionsByBand [bandKey].resize(numOfObs);
238  startOffsetsByBand [bandKey].resize(numOfObs);
239  bitsPerSamplesByBand [bandKey].resize(numOfObs);
240  numLagsByBand [bandKey].resize(numOfObs);
241  apLengthByBand [bandKey].resize(numOfObs);
242  fourfitVersionsByBand [bandKey].resize(numOfObs);
243  dbeditVersionByBand [bandKey].resize(numOfObs);
244  baselineCodesByBand [bandKey].resize(numOfObs);
245  tapeQualityCodesByBand [bandKey].resize(numOfObs);
246  stopOffsetsByBand [bandKey].resize(numOfObs);
247  hopsRevisionNumbersByBand [bandKey].resize(numOfObs);
248 // refClkErrByBand [bandKey] = new SgVector(numOfObs);
249  deltaEpochsByBand [bandKey] = new SgVector(numOfObs);
250  urvrsByBand [bandKey] = new SgMatrix(numOfObs, 2);
251  instrDelaysByBand [bandKey] = new SgMatrix(numOfObs, 2);
252  starElevByBand [bandKey] = new SgMatrix(numOfObs, 2);
253  zenithDelaysByBand [bandKey] = new SgMatrix(numOfObs, 2);
254  searchParamsByBand [bandKey] = new SgMatrix(numOfObs, 6);
255  mDlysByBand [bandKey] = new SgMatrix(numOfObs, 3);
256  mAuxByBand [bandKey] = new SgMatrix(numOfObs, 4);
257  sbdResidsByBand [bandKey] = new SgVector(numOfObs);
258  rateResidsByBand [bandKey] = new SgVector(numOfObs);
259  effDurationsByBand [bandKey] = new SgVector(numOfObs);
260  startSecondsByBand [bandKey] = new SgVector(numOfObs);
261  stopSecondsByBand [bandKey] = new SgVector(numOfObs);
262  percentOfDiscardsByBand [bandKey] = new SgVector(numOfObs);
263  uniformityFactorsByBand [bandKey] = new SgVector(numOfObs);
264  geocenterPhaseResidsByBand[bandKey] = new SgVector(numOfObs);
265  geocenterPhaseTotalsByBand[bandKey] = new SgVector(numOfObs);
266  geocenterSbDelaysByBand [bandKey] = new SgVector(numOfObs);
267  geocenterGrDelaysByBand [bandKey] = new SgVector(numOfObs);
268  geocenterDelayRatesByBand [bandKey] = new SgVector(numOfObs);
269  probOfFalsesByBand [bandKey] = new SgVector(numOfObs);
270  corrAprioriDelaysByBand [bandKey] = new SgVector(numOfObs);
271  corrAprioriRatesByBand [bandKey] = new SgVector(numOfObs);
272  corrAprioriAccsByBand [bandKey] = new SgVector(numOfObs);
273  incohAmpsByBand [bandKey] = new SgVector(numOfObs);
274  incohAmps2ByBand [bandKey] = new SgVector(numOfObs);
275  delayResidsByBand [bandKey] = new SgVector(numOfObs);
276 
277  if (originType_==OT_KOMB)
278  corrRootFileNamesByBand[bandKey].resize(numOfObs);
279 
280  tapeIds_1ByBand [bandKey].resize(numOfObs);
281  tapeIds_2ByBand [bandKey].resize(numOfObs);
282  channelIdsByBand [bandKey].resize(numOfObs);
283  polarizationsByBand [bandKey].resize(numOfObs);
284  epochsOfCorrelationsByBand[bandKey].resize(numOfObs);
285  epochsOfCentralsByBand [bandKey].resize(numOfObs);
286  epochsOfFourfitingsByBand [bandKey].resize(numOfObs);
287  epochsOfNominalScanTimeByBand[bandKey].resize(numOfObs);
288  bbcIdxs_1ByBand [bandKey].resize(numOfObs);
289  bbcIdxs_2ByBand [bandKey].resize(numOfObs);
290  corelIdxNumbersUsbByBand [bandKey].resize(numOfObs);
291  corelIdxNumbersLsbByBand [bandKey].resize(numOfObs);
292  errorRates_1ByBand [bandKey].resize(numOfObs);
293  errorRates_2ByBand [bandKey].resize(numOfObs);
294 
295  corrClocksByBand [bandKey] = new SgMatrix(numOfObs, 4);
296  loFreqs_1ByBand [bandKey] = new SgMatrix(numOfObs, numOfChans);
297  loFreqs_2ByBand [bandKey] = new SgMatrix(numOfObs, numOfChans);
298 
299  matrices2del
300  << sbDelaysByBand[bandKey] << grDelaysByBand[bandKey] << phRatesByBand [bandKey]
301  << grDelaysAltByBand[bandKey] << phRatesAltByBand [bandKey]
302  << phasesByBand[bandKey]
303  << phaseCal_1ByBand[bandKey] << phaseCal_2ByBand[bandKey]
304  << numOfAccPeriodsByChan_USBByBand[bandKey]
305  << numOfAccPeriodsByChan_LSBByBand[bandKey]
306  << refFreqByChanByBand[bandKey]
307  << phCalAmps_1ByChanByBand[bandKey]
308  << phCalAmps_2ByChanByBand[bandKey]
309  << phCalPhss_1ByChanByBand[bandKey]
310  << phCalPhss_2ByChanByBand[bandKey]
311  << phCalFrqs_1ByChanByBand[bandKey]
312  << phCalFrqs_2ByChanByBand[bandKey]
313  << phCalOffs_1ByChanByBand[bandKey]
314  << phCalOffs_2ByChanByBand[bandKey]
315  << numOfSamplesByChan_USBByBand[bandKey] << numOfSamplesByChan_LSBByBand[bandKey]
316  << residualFringeAmplByChanByBand[bandKey] << residualFringePhseByChanByBand[bandKey]
317  << urvrsByBand[bandKey] << instrDelaysByBand[bandKey]
318  << starElevByBand[bandKey] << zenithDelaysByBand[bandKey] << searchParamsByBand[bandKey]
319  << mDlysByBand[bandKey] << mAuxByBand[bandKey]
320  << corrClocksByBand[bandKey] << loFreqs_1ByBand[bandKey]
321  << loFreqs_2ByBand[bandKey]
322  ;
323 
324  vectors2del
325  << refFreqsByBand[bandKey] << ambigsByBand[bandKey] << correlationByBand[bandKey]
326  << snrByBand[bandKey] << sampleRateByBand[bandKey]
327  << deltaEpochsByBand[bandKey] << sbdResidsByBand[bandKey] << rateResidsByBand[bandKey]
328  << effDurationsByBand[bandKey] << startSecondsByBand[bandKey] << stopSecondsByBand[bandKey]
329  << percentOfDiscardsByBand[bandKey] << uniformityFactorsByBand[bandKey]
330  << geocenterPhaseResidsByBand[bandKey] << geocenterPhaseTotalsByBand[bandKey]
331  << geocenterSbDelaysByBand[bandKey] << geocenterGrDelaysByBand[bandKey]
332  << geocenterDelayRatesByBand[bandKey] << probOfFalsesByBand[bandKey]
333  << corrAprioriDelaysByBand[bandKey] << corrAprioriRatesByBand[bandKey]
334  << corrAprioriAccsByBand[bandKey] << incohAmpsByBand[bandKey] << incohAmps2ByBand[bandKey]
335  << delayResidsByBand[bandKey] << phaseCalRates_1ByBand[bandKey] << phaseCalRates_2ByBand[bandKey]
336 // << refClkErrByBand[bandKey]
337  ;
338  };
339  dTec = new SgVector(numOfObs);
340  dTecStdDev = new SgVector(numOfObs);
341  vectors2del << dTec << dTecStdDev;
342 
343  bands = bandByKey_.keys();
344 
345  //
346  QMap<QString, bool> stnsPresent;
347  QMap<QString, int> stnsIdxs4scns;
348  QMap<QString, int> idxByScan;
349  n = 1;
350  for (StationsByName_it it=stationsByName_.begin(); it!=stationsByName_.end(); ++it)
351  {
352  stnIdxByName[it.value()->getKey()] = n++;
353  stnsIdxs4scns[it.value()->getKey()] = 0;
354  };
355  n = 1;
356  for (SourcesByName_it it=sourcesByName_.begin(); it!=sourcesByName_.end(); ++it)
357  srcIdxByName[it.value()->getKey()] = n++;
358 
359  // fill the lists:
360  for (int obsIdx=0; obsIdx<numOfObs; obsIdx++)
361  {
362  int nYear, nMonth, nDay, nHour, nMin;
363  double dSec;
364  SgVlbiObservation *obs=observations_.at(obsIdx);
365  epochs4Obs << *obs;
366  stations_1 << obs->stn_1()->getKey();
367  stations_2 << obs->stn_2()->getKey();
368  sources << obs->src()->getKey();
369  //
370 //4KOMB:
371 //std::cout << " -- - - " << qPrintable(QString("").sprintf("%3d(%3d)", obsIdx, epochByScanId.size()))
372 // << qPrintable(obs->getScanId()) << " : "
373 // << qPrintable(obs->getKey()) << " : " << qPrintable(obs->getScanName())
374 // << qPrintable(obs->toString())
375 // << " \n";
376  if (!epochByScanId.contains(obs->getScanId())) // new scan:
377  {
378  epochByScanId.insert(obs->getScanId(), *obs);
379  scanNames << obs->getScanName();
380  crootFnames << obs->getCorrRootFileName();
381  idxByScan[obs->getScanId()] = idxByScan.size();
382  str.sprintf("%s %s",
383  qPrintable(obs->toString(SgMJD::F_YYYYMMDDHHMMSSSS)), qPrintable(obs->src()->getKey()));
384  if (str.at(10) == ' ')
385  str[10] = '-';
386  scanFullNames << str;
387  scan2src << srcIdxByName[obs->src()->getKey()];
388  //
389  if (stnsPresent.size())
390  for (StationsByName_it it=stationsByName_.begin(); it!=stationsByName_.end(); ++it)
391  {
392  if (stnsPresent.contains(it.key()))
393  scan2Station[it.key()] << ++stnsIdxs4scns[it.key()];
394  else
395  scan2Station[it.key()] << 0;
396  };
397  stnsPresent.clear();
398  };
399  // crossrefs:
400  obs2scan << epochByScanId.size();
401  obs2stn_1 << stnIdxByName[obs->stn_1()->getKey()];
402  obs2stn_2 << stnIdxByName[obs->stn_2()->getKey()];
403  stnsPresent[obs->stn_1()->getKey()] = true;
404  stnsPresent[obs->stn_2()->getKey()] = true;
405  //
406  //
407  for (int bandIdx=0; bandIdx<bands.size(); bandIdx++)
408  {
409  const QString& bandKey=bands.at(bandIdx);
410  SgVlbiObservable *o=obs->observable(bandKey);
411  numOfChans = maxNumOfChanByBand[bandKey];
412  epochsOfCorrelationsByBand[bandKey][obsIdx].resize(6);
413  epochsOfCentralsByBand[bandKey][obsIdx].resize(6);
414  epochsOfFourfitingsByBand[bandKey][obsIdx].resize(6);
415  epochsOfNominalScanTimeByBand[bandKey][obsIdx].resize(6);
416  bbcIdxs_1ByBand[bandKey][obsIdx].resize(numOfChans);
417  bbcIdxs_2ByBand[bandKey][obsIdx].resize(numOfChans);
418  corelIdxNumbersUsbByBand[bandKey][obsIdx].resize(numOfChans);
419  corelIdxNumbersLsbByBand[bandKey][obsIdx].resize(numOfChans);
420  errorRates_1ByBand[bandKey][obsIdx].resize(numOfChans);
421  errorRates_2ByBand[bandKey][obsIdx].resize(numOfChans);
422  fourfitVersionsByBand [bandKey][obsIdx].resize(2);
423  dbeditVersionByBand [bandKey][obsIdx].resize(3);
424 
425  if (o)
426  {
427  //
428  sbDelaysByBand[bandKey] ->setElement(obsIdx,0, o->sbDelay().getValue());
429  sbDelaysByBand[bandKey] ->setElement(obsIdx,1, o->sbDelay().getSigma());
430  //
431  grDelaysByBand[bandKey] ->setElement(obsIdx,0, o->grDelay().getValue());
432  grDelaysByBand[bandKey] ->setElement(obsIdx,1, o->grDelay().getSigma());
433  phRatesByBand [bandKey] ->setElement(obsIdx,0, o->phDRate().getValue());
434  phRatesByBand [bandKey] ->setElement(obsIdx,1, o->phDRate().getSigma());
435  //
437  {
438  grDelaysAltByBand[bandKey] ->setElement(obsIdx,0, o->grDelay().getAlternateValue());
439  grDelaysAltByBand[bandKey] ->setElement(obsIdx,1, o->grDelay().getSigma());
440  phRatesAltByBand [bandKey] ->setElement(obsIdx,0, o->phDRate().getAlternateValue());
441  phRatesAltByBand [bandKey] ->setElement(obsIdx,1, o->phDRate().getSigma());
442  };
443  //
444  phasesByBand [bandKey] ->setElement(obsIdx,0, o->getTotalPhase());
445  phasesByBand [bandKey] ->setElement(obsIdx,1, o->getSnr()==0.0?1.0:1.0/o->getSnr());
446  refFreqsByBand[bandKey] ->setElement(obsIdx, o->getReferenceFrequency());
447 
448 // effFreqsByBand[bandKey] ->setElement(obsIdx,0, o->grDelay().getEffFreq());
449 // effFreqsByBand[bandKey] ->setElement(obsIdx,1, o->phDelay().getEffFreq());
450 // effFreqsByBand[bandKey] ->setElement(obsIdx,2, o->phDRate().getEffFreq());
451 
452  phaseCal_1ByBand[bandKey]->setElement(obsIdx,0, o->getPhaseCalGrDelays(0));
453  phaseCal_2ByBand[bandKey]->setElement(obsIdx,0, o->getPhaseCalGrDelays(1));
454  phaseCal_1ByBand[bandKey]->setElement(obsIdx,1, o->getPhaseCalRates(0));
455  phaseCal_2ByBand[bandKey]->setElement(obsIdx,1, o->getPhaseCalRates(1));
456 /*
457  evaluateEffectiveFreqs(*o->numOfAccPeriodsByChan_USB(), *o->numOfAccPeriodsByChan_LSB(),
458  *o->refFreqByChan(), *o->fringeAmplitudeByChan(),
459  *o->numOfSamplesByChan_USB(), *o->numOfSamplesByChan_LSB(),
460  o->getSampleRate(), o->getReferenceFrequency(), o->getNumOfChannels(),
461  effFreqEw4GR, effFreqEw4PH, effFreqEw4RT, o->strId(), true);
462  effFreqsEqWgtByBand [bandKey]->setElement(obsIdx,0, effFreqEw4GR);
463  effFreqsEqWgtByBand [bandKey]->setElement(obsIdx,1, effFreqEw4PH);
464  effFreqsEqWgtByBand [bandKey]->setElement(obsIdx,2, effFreqEw4RT);
465 */
466  ambigsByBand [bandKey]->setElement(obsIdx, o->grDelay().getAmbiguitySpacing());
467  sprintf(buff, "%1d", o->getQualityFactor());
468  qualityCodesByBand [bandKey][obsIdx] = buff[0];
469  dataFlagsByBand [bandKey][obsIdx] = 0;
470  correlationByBand [bandKey]->setElement(obsIdx, o->getCorrCoeff());
471  snrByBand [bandKey]->setElement(obsIdx, o->getSnr());
472  numOfChannelsByBand [bandKey][obsIdx] = o->getNumOfChannels();
473  sampleRateByBand [bandKey]->setElement(obsIdx, o->getSampleRate());
474 
475  fourfitOutputFNameByBand[bandKey][obsIdx] = o->getFourfitOutputFName();
476 
477  // epochs:
478  //
479  o->getEpochOfCorrelation().toYMDHMS_tr(nYear, nMonth, nDay, nHour, nMin, dSec);
480  epochsOfCorrelationsByBand[bandKey][obsIdx][0] = nYear;
481  epochsOfCorrelationsByBand[bandKey][obsIdx][1] = nMonth;
482  epochsOfCorrelationsByBand[bandKey][obsIdx][2] = nDay;
483  epochsOfCorrelationsByBand[bandKey][obsIdx][3] = nHour;
484  epochsOfCorrelationsByBand[bandKey][obsIdx][4] = nMin;
485  epochsOfCorrelationsByBand[bandKey][obsIdx][5] = (int)round(dSec);
486  //
487  o->getEpochCentral().toYMDHMS_tr(nYear, nMonth, nDay, nHour, nMin, dSec);
488  epochsOfCentralsByBand[bandKey][obsIdx][0] = nYear;
489  epochsOfCentralsByBand[bandKey][obsIdx][1] = nMonth;
490  epochsOfCentralsByBand[bandKey][obsIdx][2] = nDay;
491  epochsOfCentralsByBand[bandKey][obsIdx][3] = nHour;
492  epochsOfCentralsByBand[bandKey][obsIdx][4] = nMin;
493  epochsOfCentralsByBand[bandKey][obsIdx][5] = (int)round(dSec);
494  //
495  o->getEpochOfFourfitting().toYMDHMS_tr(nYear, nMonth, nDay, nHour, nMin, dSec);
496  epochsOfFourfitingsByBand[bandKey][obsIdx][0] = nYear;
497  epochsOfFourfitingsByBand[bandKey][obsIdx][1] = nMonth;
498  epochsOfFourfitingsByBand[bandKey][obsIdx][2] = nDay;
499  epochsOfFourfitingsByBand[bandKey][obsIdx][3] = nHour;
500  epochsOfFourfitingsByBand[bandKey][obsIdx][4] = nMin;
501  epochsOfFourfitingsByBand[bandKey][obsIdx][5] = (int)round(dSec);
502  //
503  o->getEpochOfScan().toYMDHMS_tr(nYear, nMonth, nDay, nHour, nMin, dSec);
504  epochsOfNominalScanTimeByBand[bandKey][obsIdx][0] = nYear;
505  epochsOfNominalScanTimeByBand[bandKey][obsIdx][1] = nMonth;
506  epochsOfNominalScanTimeByBand[bandKey][obsIdx][2] = nDay;
507  epochsOfNominalScanTimeByBand[bandKey][obsIdx][3] = nHour;
508  epochsOfNominalScanTimeByBand[bandKey][obsIdx][4] = nMin;
509  epochsOfNominalScanTimeByBand[bandKey][obsIdx][5] = (int)round(dSec);
510  //
511  //
512  if (originType_==OT_KOMB)
513  corrRootFileNamesByBand[bandKey][obsIdx] = obs->getCorrRootFileName();
514  //
515  tapeIds_1ByBand[bandKey][obsIdx] = obs->auxObs_1()?obs->auxObs_1()->getTapeId():"";
516  tapeIds_2ByBand[bandKey][obsIdx] = obs->auxObs_2()?obs->auxObs_2()->getTapeId():"";
517  channelIdsByBand[bandKey][obsIdx] = "";
518  polarizationsByBand[bandKey][obsIdx] = "";
519  for (int k=0; k<o->getNumOfChannels(); k++)
520  {
521  refFreqByChanByBand[bandKey]->setElement(obsIdx,k,
522  o->refFreqByChan()->getElement(k));
523  numOfAccPeriodsByChan_USBByBand[bandKey]->setElement(obsIdx,k,
525  numOfAccPeriodsByChan_LSBByBand[bandKey]->setElement(obsIdx,k,
527 
528  phCalAmps_1ByChanByBand[bandKey]->setElement(obsIdx,k,
529  o->phaseCalData_1ByChan()->getElement(0, k));
530  phCalAmps_2ByChanByBand[bandKey]->setElement(obsIdx,k,
531  o->phaseCalData_2ByChan()->getElement(0, k));
532  phCalPhss_1ByChanByBand[bandKey]->setElement(obsIdx,k,
533  o->phaseCalData_1ByChan()->getElement(1, k)*RAD2DEG*100.0);
534  phCalPhss_2ByChanByBand[bandKey]->setElement(obsIdx,k,
535  o->phaseCalData_2ByChan()->getElement(1, k)*RAD2DEG*100.0);
536  phCalFrqs_1ByChanByBand[bandKey]->setElement(obsIdx,k,
537  o->phaseCalData_1ByChan()->getElement(2, k));
538  phCalFrqs_2ByChanByBand[bandKey]->setElement(obsIdx,k,
539  o->phaseCalData_2ByChan()->getElement(2, k));
540  phCalOffs_1ByChanByBand[bandKey]->setElement(obsIdx,k,
541  o->phaseCalData_1ByChan()->getElement(3, k)*RAD2DEG*100.0);
542  phCalOffs_2ByChanByBand[bandKey]->setElement(obsIdx,k,
543  o->phaseCalData_2ByChan()->getElement(3, k)*RAD2DEG*100.0);
544  errorRates_1ByBand[bandKey][obsIdx][k] =
545  o->phaseCalData_1ByChan()->getElement(4, k);
546  errorRates_2ByBand[bandKey][obsIdx][k] =
547  o->phaseCalData_2ByChan()->getElement(4, k);
548 
549  numOfSamplesByChan_USBByBand[bandKey]->setElement(obsIdx,k,
551  numOfSamplesByChan_LSBByBand[bandKey]->setElement(obsIdx,k,
553  residualFringeAmplByChanByBand[bandKey]->setElement(obsIdx,k,
555  residualFringePhseByChanByBand[bandKey]->setElement(obsIdx,k,
557 
558  bbcIdxs_1ByBand[bandKey][obsIdx][k] = o->bbcIdxByChan_1()->at(k);
559  bbcIdxs_2ByBand[bandKey][obsIdx][k] = o->bbcIdxByChan_2()->at(k);
560  corelIdxNumbersUsbByBand[bandKey][obsIdx][k] = o->corelIndexNumUSB()->at(k);
561  corelIdxNumbersLsbByBand[bandKey][obsIdx][k] = o->corelIndexNumLSB()->at(k);
562  loFreqs_1ByBand[bandKey]->setElement(obsIdx,k, o->loFreqByChan_1()->getElement(k));
563  loFreqs_2ByBand[bandKey]->setElement(obsIdx,k, o->loFreqByChan_2()->getElement(k));
564  channelIdsByBand [bandKey][obsIdx] += str.sprintf("%-2c", o->chanIdByChan()->at(k));
565  polarizationsByBand [bandKey][obsIdx] += str.sprintf("%-2c%-2c",
566  o->polarization_1ByChan()->at(k), o->polarization_2ByChan()->at(k));
567  };
568  //
569  fourfitErrorCodesByBand [bandKey][obsIdx].sprintf("%-2s", qPrintable(o->getErrorCode()));
570  frqGrpCodesByBand [bandKey][obsIdx].sprintf("%-2s", qPrintable(bandKey));
571  fourfitControlFileByBand [bandKey][obsIdx].sprintf("%s",
572  qPrintable(o->getFourfitControlFile()));
573  fourfitCommandByBand [bandKey][obsIdx].sprintf("%s",
574  qPrintable(o->getFourfitCommandOverride()));
575  baselineCodesByBand [bandKey][obsIdx].sprintf("%c%c",
576  obs->stn_1()->getCid(), obs->stn_2()->getCid());
577  tapeQualityCodesByBand [bandKey][obsIdx].sprintf("%-6s", qPrintable(o->getTapeQualityCode()));
578  corelVersionsByBand [bandKey][obsIdx] = -1; // mimic dbedit
579  startOffsetsByBand [bandKey][obsIdx] = o->getStartOffset();
580  bitsPerSamplesByBand [bandKey][obsIdx] = o->getBitsPerSample();
581  numLagsByBand [bandKey][obsIdx] = o->getNlags();
582  apLengthByBand [bandKey][obsIdx] = obs->getApLength();
583  stopOffsetsByBand [bandKey][obsIdx] = o->getStopOffset();
584  hopsRevisionNumbersByBand [bandKey][obsIdx] = o->getHopsRevisionNumber();
585  fourfitVersionsByBand [bandKey][obsIdx][0] = o->getFourfitVersion(0);
586  fourfitVersionsByBand [bandKey][obsIdx][1] = o->getFourfitVersion(1);
587  dbeditVersionByBand [bandKey][obsIdx][0] = 2007;
588  dbeditVersionByBand [bandKey][obsIdx][1] = 10;
589  dbeditVersionByBand [bandKey][obsIdx][2] = 27;
590 // refClkErrByBand [bandKey]->setElement(obsIdx, 0.0); // what is it?
591  deltaEpochsByBand [bandKey]->setElement(obsIdx, o->getCentrOffset());
592  //
593  urvrsByBand [bandKey]->setElement(obsIdx,0, o->getUrVr(0));
594  urvrsByBand [bandKey]->setElement(obsIdx,1, o->getUrVr(1));
595  instrDelaysByBand [bandKey]->setElement(obsIdx,0, o->getInstrDelay(0));
596  instrDelaysByBand [bandKey]->setElement(obsIdx,1, o->getInstrDelay(1));
597  starElevByBand [bandKey]->setElement(obsIdx,0, o->getCorrelStarElev_1()*RAD2DEG);
598  starElevByBand [bandKey]->setElement(obsIdx,1, o->getCorrelStarElev_2()*RAD2DEG);
599  zenithDelaysByBand [bandKey]->setElement(obsIdx,0, o->getCorrelZdelay_1());
600  zenithDelaysByBand [bandKey]->setElement(obsIdx,1, o->getCorrelZdelay_2());
601  //
602  for (int j=0; j<6; j++)
603  searchParamsByBand [bandKey]->setElement(obsIdx,j, o->getFourfitSearchParameters(j));
604 
605  sbdResidsByBand [bandKey]->setElement(obsIdx, o->sbDelay().getResidualFringeFitting());
606  rateResidsByBand [bandKey]->setElement(obsIdx, o->phDRate().getResidualFringeFitting());
607  effDurationsByBand [bandKey]->setElement(obsIdx, o->getEffIntegrationTime());
608 
609  o->getTstart().toYMDHMS_tr(nYear, nMonth, nDay, nHour, nMin, dSec);
610  startSecondsByBand [bandKey]->setElement(obsIdx, 60.0*nMin + dSec);
611  o->getTstop().toYMDHMS_tr(nYear, nMonth, nDay, nHour, nMin, dSec);
612  stopSecondsByBand [bandKey]->setElement(obsIdx, 60.0*nMin + dSec);
613  percentOfDiscardsByBand [bandKey]->setElement(obsIdx, o->getDiscardRatio());
614  uniformityFactorsByBand [bandKey]->setElement(obsIdx, o->getAcceptedRatio());
615  geocenterPhaseResidsByBand[bandKey]->setElement(obsIdx, o->getGeocenterResidPhase()*RAD2DEG);
616  geocenterPhaseTotalsByBand[bandKey]->setElement(obsIdx, o->getGeocenterTotalPhase()*RAD2DEG);
617  geocenterSbDelaysByBand [bandKey]->setElement(obsIdx, o->sbDelay().getGeocenterValue());
618  geocenterGrDelaysByBand [bandKey]->setElement(obsIdx, o->grDelay().getGeocenterValue());
619  geocenterDelayRatesByBand [bandKey]->setElement(obsIdx, o->phDRate().getGeocenterValue());
620  probOfFalsesByBand [bandKey]->setElement(obsIdx, o->getProbabOfFalseDetection());
621  corrAprioriDelaysByBand [bandKey]->setElement(obsIdx, o->getAprioriDra(0));
622  corrAprioriRatesByBand [bandKey]->setElement(obsIdx, o->getAprioriDra(1));
623  corrAprioriAccsByBand [bandKey]->setElement(obsIdx, o->getAprioriDra(2));
624  incohAmpsByBand [bandKey]->setElement(obsIdx, o->getIncohChanAddAmp());
625  incohAmps2ByBand [bandKey]->setElement(obsIdx, o->getIncohSegmAddAmp());
626  delayResidsByBand [bandKey]->setElement(obsIdx, o->grDelay().getResidualFringeFitting());
627  phaseCalRates_1ByBand [bandKey]->setElement(obsIdx, o->getPhaseCalRates(0));
628  phaseCalRates_2ByBand [bandKey]->setElement(obsIdx, o->getPhaseCalRates(1));
629  corrClocksByBand [bandKey]->setElement(obsIdx,0, o->getCorrClocks(0, 0));
630  corrClocksByBand [bandKey]->setElement(obsIdx,1, o->getCorrClocks(0, 1));
631  corrClocksByBand [bandKey]->setElement(obsIdx,2, o->getCorrClocks(1, 0));
632  corrClocksByBand [bandKey]->setElement(obsIdx,3, o->getCorrClocks(1, 1));
633 
634  mDlysByBand[bandKey]->setElement(obsIdx,0, o->vDlys()->getElement(0));
635  mDlysByBand[bandKey]->setElement(obsIdx,1, o->vDlys()->getElement(1));
636  mDlysByBand[bandKey]->setElement(obsIdx,2, o->vDlys()->getElement(2));
637  mAuxByBand[bandKey]->setElement(obsIdx,0, o->vAuxData()->getElement(0));
638  mAuxByBand[bandKey]->setElement(obsIdx,1, o->vAuxData()->getElement(1)*RAD2DEG);
639  mAuxByBand[bandKey]->setElement(obsIdx,2, o->vAuxData()->getElement(2));
640  mAuxByBand[bandKey]->setElement(obsIdx,3, o->vAuxData()->getElement(3));
641  };
642  };
643  dTec ->setElement(obsIdx, obs->getDTec());
644  dTecStdDev ->setElement(obsIdx, obs->getDTecStdDev());
645  };
646  //
647  //
648  //
649  if (originType_==OT_AGV && primaryBand_->history().size())
650  vgosDb->setCurrentVersion(primaryBand_->history().last()->getVersion());
651  //
652  //
653  if (stnsPresent.size())
654  for (StationsByName_it it=stationsByName_.begin(); it!=stationsByName_.end(); ++it)
655  {
656  if (stnsPresent.contains(it.key()))
657  scan2Station[it.key()] << ++stnsIdxs4scns[it.key()];
658  else
659  scan2Station[it.key()] << 0;
660  };
661  stnsPresent.clear();
662  stnsIdxs4scns.clear();
663  //
664  epochs4Scans = epochByScanId.values();
665  vgosDb->storeEpochs4Scans(epochs4Scans);
666  vgosDb->storeScanTimeMjd(epochs4Scans);
667  vgosDb->storeEpochs4Obs(epochs4Obs);
668  vgosDb->storeObsObjectNames(stations_1, stations_2, sources);
669 
670  // create head:
671  stations_1.clear();
672  sources.clear();
673  for (StationsByName_it it=stationsByName_.begin(); it!=stationsByName_.end(); ++it)
674  {
675  SgVlbiStationInfo *stn=it.value();
676  stations_1 << stn->getKey();
677  numScansPerStation << stn->auxObservationByScanId()->size();
678  for (QMap<QString, SgVlbiAuxObservation*>::iterator jt=stn->auxObservationByScanId()->begin();
679  jt!=stn->auxObservationByScanId()->end(); ++jt)
680  station2Scan[stn->getKey()] << idxByScan[jt.key()];
681  };
682  // fill zeros:
683  int maxSize=0;
684  for (QMap<QString, QList<int> >::iterator it=station2Scan.begin(); it!=station2Scan.end(); ++it)
685  if (maxSize<it.value().size())
686  maxSize=it.value().size();
687  for (QMap<QString, QList<int> >::iterator it=station2Scan.begin(); it!=station2Scan.end(); ++it)
688  if (it.value().size()<maxSize)
689  for (int i=it.value().size(); i<maxSize; i++)
690  it.value() << 0;
691  //
692  for (SourcesByName_it it=sourcesByName_.begin(); it!=sourcesByName_.end(); ++it)
693  sources << it.value()->getKey();
694 
697  stations_1, sources, tStart_, tFinis_, (int)cppsSoft_);
698 
699  //
700  // scan:
701  vgosDb->storeScanName(scanNames, scanFullNames);
703  vgosDb->storeScanCrootFname(crootFnames);
704  //
705  // crossRefs:
706  vgosDb->storeObsCrossRefs(obs2scan, obs2stn_1, obs2stn_2);
707  vgosDb->storeSourceCrossRefs(sources, scan2src);
708  vgosDb->storeStationCrossRefs(numScansPerStation, stations_1, station2Scan, scan2Station);
709  //
710  // output of band-dependent values:
711  for (int iB=0; iB<bands_.size(); iB++)
712  {
713  //
714  const QString& bandKey=bands_.at(iB)->getKey();
715  //
716  vgosDb->setNumOfChannels(maxNumOfChanByBand[bandKey]);
717  //
718  // obs:
719  vgosDb->storeObsSingleBandDelays(bandKey, sbDelaysByBand[bandKey]);
720  //
721  // GSI input: original and corrected gr.delays and rates:
723  {
724  vgosDb->storeObsGroupDelays(bandKey, grDelaysAltByBand[bandKey], "Original");
725  vgosDb->storeObsRates(bandKey, phRatesAltByBand[bandKey], "Original");
726  };
727  //
728  vgosDb->storeObsGroupDelays(bandKey, grDelaysByBand[bandKey], "");
729  vgosDb->storeObsRates(bandKey, phRatesByBand[bandKey], "");
730 
731  vgosDb->storeObsPhase(bandKey, phasesByBand[bandKey]);
732  vgosDb->storeObsRefFreqs(bandKey, refFreqsByBand[bandKey]);
733 // vgosDb->storeObsEffFreqs(bandKey, effFreqsByBand[bandKey]);
734 // vgosDb->storeObsEffFreqs(bandKey, effFreqsEqWgtByBand[bandKey], true);
735  vgosDb->storeObsCalUnphase(bandKey, phaseCal_1ByBand[bandKey], phaseCal_2ByBand[bandKey]);
736  vgosDb->storeObsAmbigSpacing(bandKey, ambigsByBand[bandKey]);
737  vgosDb->storeObsQualityCodes(bandKey, qualityCodesByBand[bandKey]);
738  vgosDb->storeObsDataFlag(bandKey, dataFlagsByBand[bandKey]);
739  vgosDb->storeObsCorrelation(bandKey, correlationByBand[bandKey]);
740  vgosDb->storeObsSNR(bandKey, snrByBand[bandKey]);
741  //
742  //
743  vgosDb->storeObsChannelInfo(bandKey, originType_,
744  channelIdsByBand[bandKey],
745  polarizationsByBand[bandKey],
746  numOfChannelsByBand[bandKey],
747  bitsPerSamplesByBand[bandKey],
748  errorRates_1ByBand[bandKey],
749  errorRates_2ByBand[bandKey],
750  bbcIdxs_1ByBand[bandKey],
751  bbcIdxs_2ByBand[bandKey],
752  corelIdxNumbersUsbByBand[bandKey],
753  corelIdxNumbersLsbByBand[bandKey],
754  sampleRateByBand[bandKey],
755  residualFringeAmplByChanByBand[bandKey],
756  residualFringePhseByChanByBand[bandKey],
757  refFreqByChanByBand[bandKey],
758  numOfSamplesByChan_USBByBand[bandKey],
759  numOfSamplesByChan_LSBByBand[bandKey],
760  numOfAccPeriodsByChan_USBByBand[bandKey],
761  numOfAccPeriodsByChan_LSBByBand[bandKey],
762  loFreqs_1ByBand[bandKey],
763  loFreqs_2ByBand[bandKey]);
764  //
765  vgosDb->storeObsPhaseCalInfo(bandKey, originType_,
766  phCalFrqs_1ByChanByBand[bandKey],
767  phCalAmps_1ByChanByBand[bandKey],
768  phCalPhss_1ByChanByBand[bandKey],
769  phCalOffs_1ByChanByBand[bandKey],
770  phaseCalRates_1ByBand[bandKey],
771  phCalFrqs_2ByChanByBand[bandKey],
772  phCalAmps_2ByChanByBand[bandKey],
773  phCalPhss_2ByChanByBand[bandKey],
774  phCalOffs_2ByChanByBand[bandKey],
775  phaseCalRates_2ByBand[bandKey]);
776  //
777  vgosDb->storeObsCorrelatorInfo(bandKey, originType_,
778  fourfitOutputFNameByBand[bandKey],
779  fourfitErrorCodesByBand[bandKey],
780  frqGrpCodesByBand[bandKey],
781  corelVersionsByBand[bandKey],
782  startOffsetsByBand[bandKey],
783  fourfitVersionsByBand[bandKey],
784  dbeditVersionByBand[bandKey],
785  deltaEpochsByBand[bandKey],
786  urvrsByBand[bandKey],
787  instrDelaysByBand[bandKey],
788  starElevByBand[bandKey],
789  zenithDelaysByBand[bandKey],
790  searchParamsByBand[bandKey],
791  baselineCodesByBand[bandKey],
792  tapeQualityCodesByBand[bandKey],
793  stopOffsetsByBand[bandKey],
794  hopsRevisionNumbersByBand[bandKey],
795  sampleRateByBand[bandKey],
796  sbdResidsByBand[bandKey],
797  rateResidsByBand[bandKey],
798  effDurationsByBand[bandKey],
799  startSecondsByBand[bandKey],
800  stopSecondsByBand[bandKey],
801  percentOfDiscardsByBand[bandKey],
802  uniformityFactorsByBand[bandKey],
803  geocenterPhaseResidsByBand[bandKey],
804  geocenterPhaseTotalsByBand[bandKey],
805  geocenterSbDelaysByBand[bandKey],
806  geocenterGrDelaysByBand[bandKey],
807  geocenterDelayRatesByBand[bandKey],
808  probOfFalsesByBand[bandKey],
809  corrAprioriDelaysByBand[bandKey],
810  corrAprioriRatesByBand[bandKey],
811  corrAprioriAccsByBand[bandKey],
812  incohAmpsByBand[bandKey],
813  incohAmps2ByBand[bandKey],
814  delayResidsByBand[bandKey],
815  corrRootFileNamesByBand[bandKey],
816  tapeIds_1ByBand[bandKey],
817  tapeIds_2ByBand[bandKey],
818  epochsOfCorrelationsByBand[bandKey],
819  epochsOfCentralsByBand[bandKey],
820  epochsOfFourfitingsByBand[bandKey],
821  epochsOfNominalScanTimeByBand[bandKey],
822  corrClocksByBand[bandKey],
823  mDlysByBand[bandKey],
824  mAuxByBand[bandKey]);
825  //
826 /*
827 // store data for each band:
828  if (originType_ == OT_MK4) // right now nothing to output for KOMB
829  vgosDb->storeMiscFourFit(bandKey, originType_,
830  fourfitControlFileByBand[bandKey], fourfitCommandByBand[bandKey],
831  numLagsByBand[bandKey], apLengthByBand[bandKey]);
832 */
833 // store data only from the primary:
834 /* */
835  if ((originType_==OT_MK4 || originType_==OT_AGV) && // right now nothing to output for KOMB
836  primaryBand_ &&
837  primaryBand_->getKey() == bandKey)
838  vgosDb->storeMiscFourFit("", originType_,
839  fourfitControlFileByBand[bandKey], fourfitCommandByBand[bandKey],
840  numLagsByBand[bandKey], apLengthByBand[bandKey]);
841 
842  }; // end of band iteration
843  //
844  // VGOS:
845  if (isAttr(Attr_HAS_DTEC))
846  vgosDb->storeObsDtec(dTec, dTecStdDev);
847  //
848  //
849  if (originType_==OT_MK4 ||
852  "Correlator", primaryBand_->history().size()?primaryBand_->history().last()->getEpoch():tZero,
853  "correlator operator", "History", name_, "1");
854  else if (originType_==OT_AGV)
857  primaryBand_->history().size()?primaryBand_->history().last()->getEpoch():tZero,
858  vgosDb->getCurrentIdentities()->getUserName() + ", " +
859  vgosDb->getCurrentIdentities()->getAcFullName(),
860  "History", name_,
862 
863  // contemporaryHistory_.addHistoryRecord("Data were extracted from the correlator output.");
864 
865  //
866  // clear resources:
867  qualityCodesByBand.clear();
868  dataFlagsByBand.clear();
869 
870  srcIdxByName.clear();
871  stnIdxByName.clear();
872  scan2src.clear();
873  obs2scan.clear();
874  obs2stn_1.clear();
875  obs2stn_2.clear();
876  //
877  // obs per band:
878  // clear temporary storages:
879  for (int i=0; i<vectors2del.size(); i++)
880  if (vectors2del.at(i))
881  {
882  delete vectors2del[i];
883  vectors2del[i] = NULL;
884  };
885  for (int i=0; i<matrices2del.size(); i++)
886  if (matrices2del.at(i))
887  {
888  delete matrices2del[i];
889  matrices2del[i] = NULL;
890  };
891  //
892  sbDelaysByBand.clear();
893  grDelaysByBand.clear();
894  phRatesByBand.clear();
895  phasesByBand.clear();
896  ambigsByBand.clear();
897  refFreqsByBand.clear();
898 // effFreqsByBand.clear();
899 // effFreqsEqWgtByBand.clear();
900  phaseCal_1ByBand.clear();
901  phaseCal_2ByBand.clear();
902  correlationByBand.clear();
903  snrByBand.clear();
904  //
905  //
906  bands.clear();
907  scanNames.clear();
908  scanFullNames.clear();
909  stations_1.clear();
910  stations_2.clear();
911  sources.clear();
912  epochs4Scans.clear();
913  epochs4Obs.clear();
914  epochByScanId.clear();
915  numScansPerStation.clear();
916  //
917  for (QMap<QString, QList<int> >::iterator it=station2Scan.begin(); it!=station2Scan.end(); ++it)
918  it.value().clear();
919  for (QMap<QString, QList<int> >::iterator it=scan2Station.begin(); it!=scan2Station.end(); ++it)
920  it.value().clear();
921  station2Scan.clear();
922  scan2Station.clear();
923 
924  //
925  //
926  for (StationsByName_it it=stationsByName_.begin(); it!=stationsByName_.end(); ++it)
927  {
928  SgVlbiStationInfo *stn=it.value();
929  const QString stnName(stn->getKey());
930  QList<SgMJD> stnEpochs;
931  SgVector *refClockOffset;
932  int idx;
933 
934  refClockOffset = new SgVector(stn->auxObservationByScanId()->size());
935  idx = 0;
936  for (QMap<QString, SgVlbiAuxObservation*>::iterator jt=stn->auxObservationByScanId()->begin();
937  jt!=stn->auxObservationByScanId()->end(); ++jt)
938  {
939  SgVlbiAuxObservation *auxObs=jt.value();
940  stnEpochs << *auxObs;
941  refClockOffset->setElement(idx, auxObs->getRefClockOffset());
942  idx++;
943  };
944  vgosDb->storeStationEpochs(stnName, stnEpochs);
945  // KOMB:
946  if (originType_ == OT_KOMB)
947  vgosDb->storeStationRefClockOffset(stnName, refClockOffset);
948  //
949  stnEpochs.clear();
950  delete refClockOffset;
951  };
952  };
953  //-- end of if (isAttr(Attr_FF_CREATED)) // it was a new session, no vgosDb tree existed yet
954  //
955 
956  //
957  if (config_)
958  {
959  if (originType_ == OT_AGV)
960  {
961  const SgIdentities *ids=vgosDb->getCurrentIdentities();
962  contemporaryHistory_.addHistoryRecord("Data were converted from ASCII vgosDa format to "
963  "vgosDb tree by " + ids->getUserName() + " at " + ids->getAcFullName() + ". Contact info: <" +
964  ids->getUserEmailAddress() + ">", SgMJD::currentMJD().toUtc());
965  }
966  else
968  };
969  //
970  if (vgosDb->getHave2redoLeapSecond())
971  vgosDb->storeLeapSecond(getLeapSeconds());
972 
973 
974  //
975  //
976  // theoreticals and partials:
978  {
979 // QString kind4Ephemeris("DE405JPL");
980  QString kind4Ephemeris("DE421JPL");
981  QString kind4Nutation ("IAU2006");
982  QString kind4HiFreqLibration("IERS2010");
983  QString kind4HiFreqErp ("IERS2003");
984  QString kind4EarthTide ("IERS2003");
985  QString kind4PoleTide ("IERS2003");
986 
987  QString kind4PoleTidePart("IERS2006");
988 
989  QMap<QString, SgMJD> epochByScanId;
990  int scanIdx, numOfScans;
991  //
992  // calculate number of scans:
993  for (int idx=0; idx<numOfObs; idx++)
994  {
995  SgVlbiObservation *obs=observations_.at(idx);
996  if (!epochByScanId.contains(obs->getScanId())) // new scan
997  epochByScanId.insert(obs->getScanId(), *obs);
998  };
999  numOfScans = epochByScanId.size();
1000  epochByScanId.clear();
1002  "::putDataIntoVgosDb(): counted " + QString("").setNum(numOfScans) +
1003  " scans for the session " + name_);
1004 
1005  //
1006  // obs (theoreticals and partials):
1007  //
1008  SgVector *vCalcDelay, *vCalcRate, *vFractC;
1009 
1010  SgMatrix *cEarthTide, *cOceanTide, *cOceanTideOld;
1011  SgMatrix *cOceanPoleTide, *cPoleTide, *cPoleTideOld, *cTiltRmvr;
1012  SgMatrix *mHiFyUt1, *mHiFyPxy, *mLibrUt1, *mLibrPxy, *mPx, *mPy;
1013  SgMatrix *cBend, *cBendSun, *cBendSunHigher;
1014  SgMatrix *mPlxRev;
1015  SgMatrix *t2c_val, *t2c_rat, *t2c_acc;
1016 
1017  SgMatrix *partBend;
1018  SgMatrix *dV_dPx, *dV_dPy, *dV_dUT1;
1019  SgMatrix *dV_dCipX, *dV_dCipY;
1020  SgMatrix *dV_dRA, *dV_dDN;
1021  SgMatrix *dDel_dR_1, *dRat_dR_1;
1022  SgMatrix *dV_dGamma, *dV_dParallax;
1023  SgMatrix *dV_dPtdX, *dV_dPtdY;
1024  //
1025  // for scan dependent stuff:
1026  SgMatrix *rSun, *rMoon, *rEarth, *vSun, *vMoon, *vEarth, *aEarth;
1027  SgMatrix *pPsiEpsWahr, *pPsiEpsWahr_rates, *pPsiEps, *pPsiEps_rates;
1028  SgMatrix *pXys, *pXys_rates, *pmXy;
1029  SgVector *ut1_tai;
1030 
1031 
1032  //
1033  vCalcDelay = new SgVector(numOfObs);
1034  vCalcRate = new SgVector(numOfObs);
1035  vFractC = new SgVector(numOfObs);
1036 
1037  cEarthTide = new SgMatrix(numOfObs, 2);
1038 // cFeedCorr = new SgMatrix(numOfObs, 2);
1039  cOceanTide = new SgMatrix(numOfObs, 2);
1040  cOceanTideOld = new SgMatrix(numOfObs, 2);
1041  cOceanPoleTide= new SgMatrix(numOfObs, 2);
1042  cPoleTide = new SgMatrix(numOfObs, 2);
1043  cPoleTideOld = new SgMatrix(numOfObs, 2);
1044  cTiltRmvr = new SgMatrix(numOfObs, 2);
1045  mHiFyUt1 = new SgMatrix(numOfObs, 2);
1046  mHiFyPxy = new SgMatrix(numOfObs, 2);
1047  mLibrUt1 = new SgMatrix(numOfObs, 2);
1048  mLibrPxy = new SgMatrix(numOfObs, 2);
1049  mPx = new SgMatrix(numOfObs, 2);
1050  mPy = new SgMatrix(numOfObs, 2);
1051  cBend = new SgMatrix(numOfObs, 2);
1052  cBendSun = new SgMatrix(numOfObs, 2);
1053  cBendSunHigher= new SgMatrix(numOfObs, 2);
1054 
1055  partBend = new SgMatrix(numOfObs, 2);
1056  dV_dPx = new SgMatrix(numOfObs, 2);
1057  dV_dPy = new SgMatrix(numOfObs, 2);
1058  dV_dUT1 = new SgMatrix(numOfObs, 4);
1059  dV_dCipX = new SgMatrix(numOfObs, 2);
1060  dV_dCipY = new SgMatrix(numOfObs, 2);
1061  dV_dRA = new SgMatrix(numOfObs, 2);
1062  dV_dDN = new SgMatrix(numOfObs, 2);
1063  dDel_dR_1 = new SgMatrix(numOfObs, 3);
1064  dRat_dR_1 = new SgMatrix(numOfObs, 3);
1065  dV_dGamma = new SgMatrix(numOfObs, 2);
1066  dV_dParallax = new SgMatrix(numOfObs, 2);
1067  dV_dPtdX = new SgMatrix(numOfObs, 2);
1068  dV_dPtdY = new SgMatrix(numOfObs, 2);
1069  mPlxRev = new SgMatrix(numOfObs, 2);
1070  rSun = new SgMatrix(numOfScans, 3);
1071  rMoon = new SgMatrix(numOfScans, 3);
1072  rEarth = new SgMatrix(numOfScans, 3);
1073  vSun = new SgMatrix(numOfScans, 3);
1074  vMoon = new SgMatrix(numOfScans, 3);
1075  vEarth = new SgMatrix(numOfScans, 3);
1076  aEarth = new SgMatrix(numOfScans, 3);
1077 
1078  pPsiEpsWahr = new SgMatrix(numOfScans, 2);
1079  pPsiEpsWahr_rates
1080  = new SgMatrix(numOfScans, 2);
1081  pPsiEps = new SgMatrix(numOfScans, 2);
1082  pPsiEps_rates = new SgMatrix(numOfScans, 2);
1083  pXys = new SgMatrix(numOfScans, 3);
1084  pXys_rates = new SgMatrix(numOfScans, 3);
1085 
1086  t2c_val = new SgMatrix(numOfScans, 9);
1087  t2c_rat = new SgMatrix(numOfScans, 9);
1088  t2c_acc = new SgMatrix(numOfScans, 9);
1089  pmXy = new SgMatrix(numOfScans, 2);
1090  ut1_tai = new SgVector(numOfScans);
1091 
1092  scanIdx = 0;
1093  for (int obsIdx=0; obsIdx<numOfObs; obsIdx++)
1094  {
1095  SgVlbiObservation *obs=observations_.at(obsIdx);
1096  int idx=obs->getMediaIdx();
1097 
1098  vCalcDelay ->setElement(idx, obs->getCalcConsensusDelay());
1099  vCalcRate ->setElement(idx, obs->getCalcConsensusRate());
1100  vFractC ->setElement(idx, obs->getFractC());
1101  // contributions:
1102  cEarthTide ->setElement(idx, 0, obs->getCalcEarthTideDelay());
1103  cEarthTide ->setElement(idx, 1, obs->getCalcEarthTideRate());
1104 // cFeedCorr ->setElement(idx, 0, obs->getCalcFeedCorrDelay());
1105 // cFeedCorr ->setElement(idx, 1, obs->getCalcFeedCorrRate());
1106  cOceanTide ->setElement(idx, 0, obs->getCalcOceanTideDelay());
1107  cOceanTide ->setElement(idx, 1, obs->getCalcOceanTideRate());
1108  cOceanTideOld ->setElement(idx, 0, obs->getCalcOceanTideOldDelay());
1109  cOceanTideOld ->setElement(idx, 1, obs->getCalcOceanTideOldRate());
1110  cOceanPoleTide->setElement(idx, 0, obs->getCalcOceanPoleTideLdDelay());
1111  cOceanPoleTide->setElement(idx, 1, obs->getCalcOceanPoleTideLdRate());
1112  cPoleTide ->setElement(idx, 0, obs->getCalcPoleTideDelay());
1113  cPoleTide ->setElement(idx, 1, obs->getCalcPoleTideRate());
1114  cPoleTideOld ->setElement(idx, 0, obs->getCalcPoleTideOldDelay());
1115  cPoleTideOld ->setElement(idx, 1, obs->getCalcPoleTideOldRate());
1116  cTiltRmvr ->setElement(idx, 0, obs->getCalcTiltRemvrDelay());
1117  cTiltRmvr ->setElement(idx, 1, obs->getCalcTiltRemvrRate());
1118  mHiFyUt1 ->setElement(idx, 0, obs->getCalcHiFyUt1Delay());
1119  mHiFyUt1 ->setElement(idx, 1, obs->getCalcHiFyUt1Rate());
1120  mHiFyPxy ->setElement(idx, 0, obs->getCalcHiFyPxyDelay());
1121  mHiFyPxy ->setElement(idx, 1, obs->getCalcHiFyPxyRate());
1122  mLibrUt1 ->setElement(idx, 0, obs->getCalcHiFyUt1LibrationDelay());
1123  mLibrUt1 ->setElement(idx, 1, obs->getCalcHiFyUt1LibrationRate());
1124  mLibrPxy ->setElement(idx, 0, obs->getCalcHiFyPxyLibrationDelay());
1125  mLibrPxy ->setElement(idx, 1, obs->getCalcHiFyPxyLibrationRate());
1126  mPx ->setElement(idx, 0, obs->getCalcPxDelay());
1127  mPx ->setElement(idx, 1, obs->getCalcPxRate());
1128  mPy ->setElement(idx, 0, obs->getCalcPyDelay());
1129  mPy ->setElement(idx, 1, obs->getCalcPyRate());
1130  cBend ->setElement(idx, 0, obs->getCalcConsBendingDelay());
1131  cBend ->setElement(idx, 1, obs->getCalcConsBendingRate());
1132  cBendSun ->setElement(idx, 0, obs->getCalcConsBendingSunDelay());
1133  cBendSun ->setElement(idx, 1, obs->getCalcConsBendingSunRate());
1134  cBendSunHigher->setElement(idx, 0, obs->getCalcConsBendingSunHigherDelay());
1135  cBendSunHigher->setElement(idx, 1, obs->getCalcConsBendingSunHigherRate());
1136  //
1137  mPlxRev ->setElement(idx, 0, obs->getDdel_dParallaxRev());
1138  mPlxRev ->setElement(idx, 1, obs->getDrat_dParallaxRev());
1139  //
1140  // partials:
1141  partBend ->setElement(idx, 0, obs->getDdel_dBend());
1142  partBend ->setElement(idx, 1, obs->getDrat_dBend());
1143  dV_dPx ->setElement(idx, 0, obs->getDdel_dPx());
1144  dV_dPx ->setElement(idx, 1, obs->getDrat_dPx());
1145  dV_dPy ->setElement(idx, 0, obs->getDdel_dPy());
1146  dV_dPy ->setElement(idx, 1, obs->getDrat_dPy());
1147 // dV_dUT1 ->setElement(idx, 0, obs->getDdel_dUT1());
1148 // dV_dUT1 ->setElement(idx, 1, obs->getDrat_dUT1());
1149  dV_dUT1 ->setElement(idx, 0, obs->getDdel_dUT1()/86400.0);
1150  dV_dUT1 ->setElement(idx, 1, obs->getDrat_dUT1()/86400.0);
1151 
1152  dV_dUT1 ->setElement(idx, 2, obs->getD2del_dUT12());
1153  dV_dUT1 ->setElement(idx, 3, obs->getD2rat_dUT12());
1154  dV_dCipX ->setElement(idx, 0, obs->getDdel_dCipX());
1155  dV_dCipX ->setElement(idx, 1, obs->getDrat_dCipX());
1156  dV_dCipY ->setElement(idx, 0, obs->getDdel_dCipY());
1157  dV_dCipY ->setElement(idx, 1, obs->getDrat_dCipY());
1158  dV_dRA ->setElement(idx, 0, obs->getDdel_dRA());
1159  dV_dRA ->setElement(idx, 1, obs->getDrat_dRA());
1160  dV_dDN ->setElement(idx, 0, obs->getDdel_dDN());
1161  dV_dDN ->setElement(idx, 1, obs->getDrat_dDN());
1162  dDel_dR_1 ->setElement(idx, 0, obs->getDdel_dR_1().at(X_AXIS));
1163  dDel_dR_1 ->setElement(idx, 1, obs->getDdel_dR_1().at(Y_AXIS));
1164  dDel_dR_1 ->setElement(idx, 2, obs->getDdel_dR_1().at(Z_AXIS));
1165  dRat_dR_1 ->setElement(idx, 0, obs->getDrat_dR_1().at(X_AXIS));
1166  dRat_dR_1 ->setElement(idx, 1, obs->getDrat_dR_1().at(Y_AXIS));
1167  dRat_dR_1 ->setElement(idx, 2, obs->getDrat_dR_1().at(Z_AXIS));
1168  dV_dGamma ->setElement(idx, 0, obs->getDdel_dGamma());
1169  dV_dGamma ->setElement(idx, 1, obs->getDrat_dGamma());
1170  dV_dParallax->setElement(idx, 0, obs->getDdel_dParallax());
1171  dV_dParallax->setElement(idx, 1, obs->getDrat_dParallax());
1172  dV_dPtdX ->setElement(idx, 0, obs->getDdel_dPolTideX());
1173  dV_dPtdX ->setElement(idx, 1, obs->getDrat_dPolTideX());
1174  dV_dPtdY ->setElement(idx, 0, obs->getDdel_dPolTideY());
1175  dV_dPtdY ->setElement(idx, 1, obs->getDrat_dPolTideY());
1176  //
1177  //
1178  // scan-based stuff:
1179  if (!epochByScanId.contains(obs->getScanId())) // new scan:
1180  {
1181  epochByScanId.insert(obs->getScanId(), *obs);
1182  const Sg3dVector *r=&obs->getRsun();
1183  rSun->setElement(scanIdx, 0, r->at(X_AXIS));
1184  rSun->setElement(scanIdx, 1, r->at(Y_AXIS));
1185  rSun->setElement(scanIdx, 2, r->at(Z_AXIS));
1186  r = &obs->getVsun();
1187  vSun->setElement(scanIdx, 0, r->at(X_AXIS));
1188  vSun->setElement(scanIdx, 1, r->at(Y_AXIS));
1189  vSun->setElement(scanIdx, 2, r->at(Z_AXIS));
1190  r = &obs->getRmoon();
1191  rMoon->setElement(scanIdx, 0, r->at(X_AXIS));
1192  rMoon->setElement(scanIdx, 1, r->at(Y_AXIS));
1193  rMoon->setElement(scanIdx, 2, r->at(Z_AXIS));
1194  r = &obs->getVmoon();
1195  vMoon->setElement(scanIdx, 0, r->at(X_AXIS));
1196  vMoon->setElement(scanIdx, 1, r->at(Y_AXIS));
1197  vMoon->setElement(scanIdx, 2, r->at(Z_AXIS));
1198  r = &obs->getRearth();
1199  rEarth->setElement(scanIdx, 0, r->at(X_AXIS));
1200  rEarth->setElement(scanIdx, 1, r->at(Y_AXIS));
1201  rEarth->setElement(scanIdx, 2, r->at(Z_AXIS));
1202  r = &obs->getVearth();
1203  vEarth->setElement(scanIdx, 0, r->at(X_AXIS));
1204  vEarth->setElement(scanIdx, 1, r->at(Y_AXIS));
1205  vEarth->setElement(scanIdx, 2, r->at(Z_AXIS));
1206  r = &obs->getAearth();
1207  aEarth->setElement(scanIdx, 0, r->at(X_AXIS));
1208  aEarth->setElement(scanIdx, 1, r->at(Y_AXIS));
1209  aEarth->setElement(scanIdx, 2, r->at(Z_AXIS));
1210 
1211  pPsiEpsWahr ->setElement(scanIdx, 0, obs->getCalcNutWahr_dPsiV());
1212  pPsiEpsWahr ->setElement(scanIdx, 1, obs->getCalcNutWahr_dEpsV());
1213  pPsiEpsWahr_rates ->setElement(scanIdx, 0, obs->getCalcNutWahr_dPsiR());
1214  pPsiEpsWahr_rates ->setElement(scanIdx, 1, obs->getCalcNutWahr_dEpsR());
1215  pPsiEps ->setElement(scanIdx, 0, obs->getCalcNut2006_dPsiV());
1216  pPsiEps ->setElement(scanIdx, 1, obs->getCalcNut2006_dEpsV());
1217  pPsiEps_rates ->setElement(scanIdx, 0, obs->getCalcNut2006_dPsiR());
1218  pPsiEps_rates ->setElement(scanIdx, 1, obs->getCalcNut2006_dEpsR());
1219  pXys ->setElement(scanIdx, 0, obs->getCalcCipXv());
1220  pXys ->setElement(scanIdx, 1, obs->getCalcCipYv());
1221  pXys ->setElement(scanIdx, 2, obs->getCalcCipSv());
1222  pXys_rates ->setElement(scanIdx, 0, obs->getCalcCipXr());
1223  pXys_rates ->setElement(scanIdx, 1, obs->getCalcCipYr());
1224  pXys_rates ->setElement(scanIdx, 2, obs->getCalcCipSr());
1225 
1226  const Sg3dMatrix &t2c_v=obs->getTrf2crfVal();
1227  const Sg3dMatrix &t2c_r=obs->getTrf2crfRat();
1228  const Sg3dMatrix &t2c_a=obs->getTrf2crfAcc();
1229  for (int k=0; k<3; k++)
1230  for (int l=0; l<3; l++)
1231  {
1232  t2c_val ->setElement(scanIdx, 3*k+l, t2c_v.at((DIRECTION)k, (DIRECTION)l));
1233  t2c_rat ->setElement(scanIdx, 3*k+l, t2c_r.at((DIRECTION)k, (DIRECTION)l));
1234  t2c_acc ->setElement(scanIdx, 3*k+l, t2c_a.at((DIRECTION)k, (DIRECTION)l));
1235  };
1236  ut1_tai ->setElement(scanIdx, obs->getCalcUt1_Tai());
1237  pmXy ->setElement(scanIdx, 0, obs->getCalcPmX());
1238  pmXy ->setElement(scanIdx, 1, obs->getCalcPmY());
1239  //
1240  scanIdx++;
1241  };
1242  };
1243  vgosDb->storeObsDelayTheoretical(vCalcDelay);
1244 
1245  vgosDb->storeObsRateTheoretical (vCalcRate);
1246  vgosDb->storeObsFractC(vFractC);
1247  //
1248 
1249  vgosDb->storeObsCalEarthTide(cEarthTide, kind4EarthTide);
1250  vgosDb->storeObsCalOcean(cOceanTide);
1251  vgosDb->storeObsCalOceanOld(cOceanTideOld);
1252  vgosDb->storeObsCalOceanPoleTideLoad(cOceanPoleTide);
1253  vgosDb->storeObsCalPoleTide(cPoleTide, kind4PoleTide);
1254  vgosDb->storeObsCalPoleTideOldRestore(cPoleTideOld);
1255  vgosDb->storeObsCalTiltRmvr(cTiltRmvr);
1256 
1257  vgosDb->storeObsCalHiFyErp(mHiFyUt1, mHiFyPxy, kind4HiFreqErp);
1258  vgosDb->storeObsCalHiFyLibration(mLibrUt1, mLibrPxy, kind4HiFreqLibration);
1259  vgosDb->storeObsCalWobble(mPx, mPy);
1260  vgosDb->storeObsCalParallax(mPlxRev);
1261  vgosDb->storeObsCalBend(cBend);
1262  vgosDb->storeObsCalBendSun(cBendSun);
1263  vgosDb->storeObsCalBendSunHigher(cBendSunHigher);
1264  //
1265  vgosDb->storeObsPartBend(partBend);
1266  vgosDb->storeObsPartEOP(dV_dPx, dV_dPy, dV_dUT1);
1267  vgosDb->storeObsPartNut2KXY(dV_dCipX, dV_dCipY, kind4Nutation);
1268  vgosDb->storeObsPartRaDec(dV_dRA, dV_dDN);
1269  vgosDb->storeObsPartXYZ(dDel_dR_1, dRat_dR_1);
1270  vgosDb->storeObsPartGamma(dV_dGamma);
1271  vgosDb->storeObsPartParallax(dV_dParallax);
1272  vgosDb->storeObsPartPoleTides(dV_dPtdX, dV_dPtdY, kind4PoleTidePart);
1273  //
1274  //
1275  // scan dependent data:
1276  vgosDb->storeScanEphemeris(rSun, rMoon, rEarth, vSun, vMoon, vEarth, aEarth, kind4Ephemeris);
1277  vgosDb->storeScanNutationEqxWahr(pPsiEpsWahr, pPsiEpsWahr_rates);
1278  vgosDb->storeScanNutationEqx(pPsiEps, pPsiEps_rates, kind4Nutation);
1279  vgosDb->storeScanNutationNro(pXys, pXys_rates, kind4Nutation);
1280  vgosDb->storeScanTrf2crf(t2c_val, t2c_rat, t2c_acc);
1281  vgosDb->storeErpApriori(ut1_tai, pmXy);
1282 
1283 
1284  delete pmXy;
1285  delete ut1_tai;
1286  delete t2c_val;
1287  delete t2c_rat;
1288  delete t2c_acc;
1289  delete pPsiEpsWahr;
1290  delete pPsiEpsWahr_rates;
1291  delete pPsiEps;
1292  delete pPsiEps_rates;
1293  delete pXys;
1294  delete pXys_rates;
1295 
1296  delete rSun;
1297  delete rMoon;
1298  delete rEarth;
1299  delete vSun;
1300  delete vMoon;
1301  delete vEarth;
1302  delete aEarth;
1303  delete mPlxRev;
1304  delete dV_dGamma;
1305  delete dV_dParallax;
1306  delete dV_dPtdX;
1307  delete dV_dPtdY;
1308  delete dDel_dR_1;
1309  delete dRat_dR_1;
1310  delete dV_dRA;
1311  delete dV_dDN;
1312  delete dV_dCipX;
1313  delete dV_dCipY;
1314  delete dV_dPx;
1315  delete dV_dPy;
1316  delete dV_dUT1;
1317  delete partBend;
1318  delete mHiFyUt1;
1319  delete mHiFyPxy;
1320  delete mLibrUt1;
1321  delete mLibrPxy;
1322  delete mPx;
1323  delete mPy;
1324  delete cBend;
1325  delete cBendSun;
1326  delete cBendSunHigher;
1327 
1328  delete cEarthTide;
1329  delete cOceanTide;
1330  delete cOceanTideOld;
1331  delete cOceanPoleTide;
1332  delete cPoleTide;
1333  delete cPoleTideOld;
1334  delete cTiltRmvr;
1335 
1336  delete vFractC;
1337  delete vCalcDelay;
1338  delete vCalcRate;
1339  //
1340  //
1341  // per station (theoreticals and partials):
1342  QString kind4TroposphereModel("NMF");
1343  for (StationsByName_it it=stationsByName_.begin(); it!=stationsByName_.end(); ++it)
1344  {
1345  SgVlbiStationInfo *stn=it.value();
1346  const QString stnName(stn->getKey());
1347  SgVector *parAngle;
1348  SgMatrix *azTheo, *elTheo;
1349  SgMatrix *calAxisOffset;
1350  SgMatrix *calNmfDry, *calNmfWet;
1351  SgMatrix *calHorzOLoad, *calVertOLoad;
1352  SgMatrix *ocnLdR, *ocnLdV;
1353  SgMatrix *partAxisOffset;
1354  SgMatrix *partTropZenithDry, *partTropZenithWet, *partTropGrad;
1355 
1356  int idx, num=stn->auxObservationByScanId()->size();
1357 
1358  parAngle = new SgVector(num);
1359  azTheo = new SgMatrix(num, 2);
1360  elTheo = new SgMatrix(num, 2);
1361  ocnLdR = new SgMatrix(num, 3);
1362  ocnLdV = new SgMatrix(num, 3);
1363  calAxisOffset = new SgMatrix(num, 2);
1364  calNmfDry = new SgMatrix(num, 2);
1365  calNmfWet = new SgMatrix(num, 2);
1366  calHorzOLoad = new SgMatrix(num, 2);
1367  calVertOLoad = new SgMatrix(num, 2);
1368  partAxisOffset = new SgMatrix(num, 2);
1369  partTropZenithDry = new SgMatrix(num, 2);
1370  partTropZenithWet = new SgMatrix(num, 2);
1371  partTropGrad = new SgMatrix(num, 4);
1372 
1373  idx = 0;
1374  for (QMap<QString, SgVlbiAuxObservation*>::iterator jt=stn->auxObservationByScanId()->begin();
1375  jt!=stn->auxObservationByScanId()->end(); ++jt, idx++)
1376  {
1377  SgVlbiAuxObservation *aux=jt.value();
1378  parAngle->setElement(idx, aux->getParallacticAngle());
1379  azTheo->setElement(idx, 0, aux->getAzimuthAngle());
1380  azTheo->setElement(idx, 1, aux->getAzimuthAngleRate());
1381  elTheo->setElement(idx, 0, aux->getElevationAngle());
1382  elTheo->setElement(idx, 1, aux->getElevationAngleRate());
1383  ocnLdR->setElement(idx, 0, aux->getOcnLdR().at(X_AXIS));
1384  ocnLdR->setElement(idx, 1, aux->getOcnLdR().at(Y_AXIS));
1385  ocnLdR->setElement(idx, 2, aux->getOcnLdR().at(Z_AXIS));
1386  ocnLdV->setElement(idx, 0, aux->getOcnLdV().at(X_AXIS));
1387  ocnLdV->setElement(idx, 1, aux->getOcnLdV().at(Y_AXIS));
1388  ocnLdV->setElement(idx, 2, aux->getOcnLdV().at(Z_AXIS));
1389  //
1390  calAxisOffset->setElement (idx, 0, aux->getCalcAxisOffset4Delay());
1391  calAxisOffset->setElement (idx, 1, aux->getCalcAxisOffset4Rate());
1392  calNmfDry->setElement (idx, 0, aux->getCalcNdryCont4Delay());
1393  calNmfDry->setElement (idx, 1, aux->getCalcNdryCont4Rate());
1394  calNmfWet->setElement (idx, 0, aux->getCalcNwetCont4Delay());
1395  calNmfWet->setElement (idx, 1, aux->getCalcNwetCont4Rate());
1396  calHorzOLoad->setElement (idx, 0, aux->getCalcOLoadHorz4Delay());
1397  calHorzOLoad->setElement (idx, 1, aux->getCalcOLoadHorz4Rate());
1398  calVertOLoad->setElement (idx, 0, aux->getCalcOLoadVert4Delay());
1399  calVertOLoad->setElement (idx, 1, aux->getCalcOLoadVert4Rate());
1400  //
1401  partAxisOffset->setElement(idx, 0, aux->getDdel_dAxsOfs());
1402  partAxisOffset->setElement(idx, 1, aux->getDrat_dAxsOfs());
1403 
1404  partTropZenithDry->setElement(idx, 0, aux->getDdel_dTzdDry());
1405  partTropZenithDry->setElement(idx, 1, aux->getDrat_dTzdDry());
1406  partTropZenithWet->setElement(idx, 0, aux->getDdel_dTzdWet());
1407  partTropZenithWet->setElement(idx, 1, aux->getDrat_dTzdWet());
1408  partTropGrad->setElement(idx, 0, aux->getDdel_dTzdGrdN());
1409  partTropGrad->setElement(idx, 1, aux->getDdel_dTzdGrdE());
1410  partTropGrad->setElement(idx, 2, aux->getDrat_dTzdGrdN());
1411  partTropGrad->setElement(idx, 3, aux->getDrat_dTzdGrdE());
1412  };
1413 
1414  vgosDb->storeStationParAngle(stnName, parAngle);
1415  vgosDb->storeStationAzEl(stnName, azTheo, elTheo);
1416  vgosDb->storeStationOceanLdDisp(stnName, ocnLdR, ocnLdV);
1417  // contributions:
1418  vgosDb->storeStationCalAxisOffset(stnName, calAxisOffset);
1419  vgosDb->storeStationCalSlantPathTropDry(stnName, calNmfDry, kind4TroposphereModel);
1420  vgosDb->storeStationCalSlantPathTropWet(stnName, calNmfWet, kind4TroposphereModel);
1421  vgosDb->storeStationCalOceanLoad(stnName, calHorzOLoad, calVertOLoad);
1422  // partials:
1423  vgosDb->storeStationPartAxisOffset(stnName, partAxisOffset);
1424  vgosDb->storeStationPartZenithDelayDry(stnName, partTropZenithDry, kind4TroposphereModel);
1425  vgosDb->storeStationPartZenithDelayWet(stnName, partTropZenithWet, kind4TroposphereModel);
1426  vgosDb->storeStationPartHorizonGrad(stnName, partTropGrad, kind4TroposphereModel);
1427 
1428 
1429  //
1430  delete partTropZenithDry;
1431  delete partTropZenithWet;
1432  delete partTropGrad;
1433  delete ocnLdR;
1434  delete ocnLdV;
1435  delete calHorzOLoad;
1436  delete calVertOLoad;
1437  delete calNmfDry;
1438  delete calNmfWet;
1439  delete parAngle;
1440  delete calAxisOffset;
1441  delete partAxisOffset;
1442  delete azTheo;
1443  delete elTheo;
1444  };
1445  //
1446  //
1447  // the session-wide data:
1448  // Calc Info:
1449  vgosDb->storeCalcInfo(calcInfo_);
1450  //
1451  // ERP (if exist):
1456  {
1457  SgVector *utArrayInfo, *pmArrayInfo, *utValues;
1458  SgMatrix *pmValues;
1459  double d;
1460  utArrayInfo = new SgVector(4);
1461  pmArrayInfo = new SgVector(3);
1462  utValues = new SgVector(tabs4Ut1Interpolation_->nRow());
1463  pmValues = new SgMatrix(tabs4PxyInterpolation_->nRow(), 2);
1464  // 0:
1466  utArrayInfo->setElement(0, d>2390000.0?d:d+2400000.5);
1468  pmArrayInfo->setElement(0, d>2390000.0?d:d+2400000.5);
1469  // 1:
1470  utArrayInfo->setElement(1, args4Ut1Interpolation_->n()>1?
1472  pmArrayInfo->setElement(1, args4PxyInterpolation_->n()>1?
1474  // 2:
1475  utArrayInfo->setElement(2, args4Ut1Interpolation_->n());
1476  pmArrayInfo->setElement(2, args4PxyInterpolation_->n());
1477  // 3:
1478  utArrayInfo->setElement(3, 1.0);
1479  //
1480  for (unsigned int i=0; i<tabs4Ut1Interpolation_->nRow(); i++)
1481  utValues->setElement(i, tabs4Ut1Interpolation_->getElement(i, 0));
1482  for (unsigned int i=0; i<tabs4PxyInterpolation_->nRow(); i++)
1483  {
1484  pmValues->setElement(i, 0, tabs4PxyInterpolation_->getElement(i, 0));
1485  pmValues->setElement(i, 1, tabs4PxyInterpolation_->getElement(i, 1));
1486  };
1487  //
1488  vgosDb->storeCalcEop(pmArrayInfo, utArrayInfo, pmValues, utValues, calcInfo_);
1489  //
1490  delete utArrayInfo;
1491  delete pmArrayInfo;
1492  delete utValues;
1493  delete pmValues;
1494  };
1495  }; // end of CALC's first part
1496  //
1497  //
1498  // the second part, a priori:
1499 
1501  {
1502  // a priori:
1503  QList<QString> sourcesNames, sourcesRefs, stationsNames, tectonicPlateNames;
1504  QList<int> axisTypes;
1505  SgVector *axisOffsets;
1506  SgMatrix *cooRaDe, *cooXYZ, *axisTilts;
1507 
1508  cooRaDe = new SgMatrix(sourcesByName_.size(), 2);
1509  cooXYZ = new SgMatrix(stationsByName_.size(), 3);
1510  axisTilts = new SgMatrix(stationsByName_.size(), 2);
1511  axisOffsets = new SgVector(stationsByName_.size());
1512  // collect info:
1513  int idx=0;
1514  for (SourcesByName_it it=sourcesByName_.begin(); it!=sourcesByName_.end(); ++it)
1515  {
1516  SgVlbiSourceInfo *src=it.value();
1517  sourcesNames.append(src->getKey());
1518  sourcesRefs .append(src->getAprioriReference());
1519  cooRaDe->setElement(idx, 0, src->getRA());
1520  cooRaDe->setElement(idx, 1, src->getDN());
1521  idx++;
1522  };
1523  idx = 0;
1524  for (StationsByName_it it=stationsByName_.begin(); it!=stationsByName_.end(); ++it)
1525  {
1526  SgVlbiStationInfo *stn=it.value();
1527  const Sg3dVector &r=stn->getR();
1528  stationsNames .append(stn->getKey());
1529  tectonicPlateNames.append(stn->getTectonicPlateName());
1530  //
1531  axisTypes.append(SgVlbiStationInfo::mntType2int(stn->getMntType()));
1532  axisOffsets->setElement(idx, stn->getAxisOffset());
1533  axisTilts->setElement(idx, 0, stn->getTilt(0));
1534  axisTilts->setElement(idx, 1, stn->getTilt(1));
1535  cooXYZ->setElement(idx, 0, r.at(X_AXIS));
1536  cooXYZ->setElement(idx, 1, r.at(Y_AXIS));
1537  cooXYZ->setElement(idx, 2, r.at(Z_AXIS));
1538  idx++;
1539  };
1540 
1541  // save the data:
1542  vgosDb->storeSourcesApriories(sourcesNames, sourcesRefs, cooRaDe);
1543  vgosDb->storeStationsApriories(stationsNames, cooXYZ, tectonicPlateNames);
1544 // // these data are not stored in agv files:
1545 // if (isAttr(Attr_FF_CALC_DATA_MODIFIED))
1546  vgosDb->storeAntennaApriories(stationsNames, axisTypes, axisOffsets, axisTilts);
1547 
1548  //
1549  if (getLeapSeconds() > 0)
1550  vgosDb->storeLeapSecond(getLeapSeconds());
1551 
1552  sourcesNames.clear();
1553  sourcesRefs.clear();
1554  stationsNames.clear();
1555  tectonicPlateNames.clear();
1556 
1557  delete axisOffsets;
1558  delete axisTilts;
1559  delete cooXYZ;
1560  delete cooRaDe;
1561  }; // end of the second part of CALC
1562  //
1563  //
1564  // the last part of CALC:
1566  {
1567  // band dependent data:
1568  // create carriers:
1569  QMap<QString, SgMatrix*> uvfPerAsecByBand, feedCorrByBand;
1570  for (int iBand=0; iBand<bands_.size(); iBand++)
1571  {
1572  const QString& bandKey=bands_.at(iBand)->getKey();
1573  uvfPerAsecByBand.insert(bandKey, new SgMatrix(numOfObs, 2));
1574  feedCorrByBand.insert (bandKey, new SgMatrix(numOfObs, 2));
1575  };
1576  // fill them:
1577  for (int iObs=0; iObs<numOfObs; iObs++)
1578  {
1579  SgVlbiObservation *obs=observations_.at(iObs);
1580  for (QMap<QString, SgVlbiObservable*>::iterator it=obs->observableByKey().begin();
1581  it!=obs->observableByKey().end(); ++it)
1582  {
1583  SgVlbiObservable *o=it.value();
1584  uvfPerAsecByBand[o->getBandKey()]->setElement(o->getMediaIdx(),0, o->getUvFrPerAsec(0));
1585  uvfPerAsecByBand[o->getBandKey()]->setElement(o->getMediaIdx(),1, o->getUvFrPerAsec(1));
1586  feedCorrByBand [o->getBandKey()]->setElement(o->getMediaIdx(),0, o->getCalcFeedCorrDelay());
1587  feedCorrByBand [o->getBandKey()]->setElement(o->getMediaIdx(),1, o->getCalcFeedCorrRate ());
1588  };
1589  };
1590  // write data into netCDF files:
1591  for (int iBand=0; iBand<bands_.size(); iBand++)
1592  {
1593  const QString& bandKey=bands_.at(iBand)->getKey();
1594  vgosDb->storeObsUVFperAsec (bandKey, uvfPerAsecByBand[bandKey]);
1595  vgosDb->storeObsCalFeedCorr(bandKey, feedCorrByBand [bandKey]);
1596  };
1597  // free memmory:
1598  for (QMap<QString, SgMatrix*>::iterator it=uvfPerAsecByBand.begin();
1599  it!=uvfPerAsecByBand.end(); ++it)
1600  delete it.value();
1601  for (QMap<QString, SgMatrix*>::iterator it=feedCorrByBand.begin();
1602  it!=feedCorrByBand.end(); ++it)
1603  delete it.value();
1604  //
1605  //
1606  };
1607  //
1608  //
1609  // end of CALC_MODIFIED
1610  //
1611  //
1612  //
1613  // stations (data from log files):
1615  {
1616  QString kind("");
1617  QMap<QString, QString> cableSignByKey;
1618  for (StationsByName_it it=stationsByName_.begin(); it!=stationsByName_.end(); ++it)
1619  {
1620  SgVlbiStationInfo *stn=it.value();
1621  const QString stnName(stn->getKey());
1622  SgVector *metAtmPres, *metAtmRh, *metAtmTemp;
1623  SgMatrix *cableCal;
1624  SgMatrix *tSyses;
1625  int idx, num=stn->auxObservationByScanId()->size();
1626  int numTsChans=stn->tsysIfFreqs().size();
1627  QVector<double> tsysFreqs(numTsChans);
1628  QVector<QString> tsysIds(numTsChans), tsysSbs(numTsChans), tsysPzs(numTsChans);
1629 
1630 
1631  metAtmPres= new SgVector(num);
1632  metAtmRh = new SgVector(num);
1633  metAtmTemp= new SgVector(num);
1634  cableCal = new SgMatrix(num, 1);
1635  tSyses = new SgMatrix(num, numTsChans);
1636  for (int j=0; j<numTsChans; j++)
1637  {
1638  tsysFreqs[j] = stn->tsysIfFreqs()[j];
1639  tsysIds[j] = stn->tsysIfIds()[j];
1640  tsysSbs[j] = stn->tsysIfSideBands()[j];
1641  tsysPzs[j] = stn->tsysIfPolarizations()[j];
1642  };
1643  idx = 0;
1644  for (QMap<QString, SgVlbiAuxObservation*>::iterator jt=stn->auxObservationByScanId()->begin();
1645  jt!=stn->auxObservationByScanId()->end(); ++jt, idx++)
1646  {
1647  SgVlbiAuxObservation *aux=jt.value();
1648 
1649  metAtmPres->setElement(idx, aux->meteoData().getPressure());
1650  metAtmRh ->setElement(idx, aux->meteoData().getRelativeHumidity());
1651  metAtmTemp->setElement(idx, aux->meteoData().getTemperature());
1652 
1653  cableCal->setElement(idx, 0, aux->getCableCalibration());
1654  for (int j=0; j<numTsChans; j++)
1655  tSyses->setElement(idx, j, aux->tSyses()->getElement(j));
1656  };
1657  //
1660  {
1662  kind = "";
1664  kind = "Cdms";
1666  kind = "Pcmt";
1668  kind = "CDMS";
1669  else
1671  "::putDataIntoVgosDb(): the station " + stnName +
1672  " has an unknown kind of cable calibration data");
1673  vgosDb->storeStationCalCable(stnName, cableCal, stn->getCableCalsOriginTxt(), kind);
1675  cableSignByKey[stnName] = stn->getCableCalMultiplierDBCal()==-1.0?"-":
1676  (stn->getCableCalMultiplierDBCal()==1.0?"+":"?");
1677  else
1678  cableSignByKey[stnName] = " ";
1679  };
1682  {
1683 
1685  kind = "";
1687  kind = "External";
1688  else
1690  "::putDataIntoVgosDb(): the station " + stnName +
1691  " has an unknown kind of meteo data");
1692  vgosDb->storeStationMet(stnName, metAtmPres, metAtmRh, metAtmTemp,
1693  stn->getMeteoDataOriginTxt(), kind);
1694  };
1697  {
1698  vgosDb->storeStationTsys(stnName, tSyses, tsysFreqs, tsysIds, tsysSbs, tsysPzs);
1699  };
1700 
1701  delete metAtmPres;
1702  delete metAtmRh;
1703  delete metAtmTemp;
1704  delete cableCal;
1705  };
1706  //
1707  // save cable cal signs that were applied to stations' data:
1708  if (cableSignByKey.size())
1709  vgosDb->storeMiscCable(cableSignByKey);
1710  cableSignByKey.clear();
1711  };
1712  //
1713 
1714 
1715 
1716  // ionospheric corrections:
1718  {
1719  // create carriers:
1720  QMap<QString, SgMatrix*> ionCalsByBand, ionSigsByBand;
1721  QMap<QString, SgMatrix*> effFreqsByBand, effFreqsEqWgtByBand;
1722  QMap<QString, QVector<int> >ionDataFlagByBand;
1723  QVector<int> ionBits;
1724  QString primeBandKey(primaryBand_?primaryBand_->getKey():"X");
1725 
1726  for (int iBand=0; iBand<bands_.size(); iBand++)
1727  {
1728  const QString& bandKey = bands_.at(iBand)->getKey();
1729  ionCalsByBand .insert(bandKey, new SgMatrix(numOfObs, 2));
1730  ionSigsByBand .insert(bandKey, new SgMatrix(numOfObs, 2));
1731  effFreqsByBand .insert(bandKey, new SgMatrix(numOfObs, 3));
1732  effFreqsEqWgtByBand .insert(bandKey, new SgMatrix(numOfObs, 3));
1733  ionDataFlagByBand .insert(bandKey, QVector<int>(numOfObs));
1734  for (int i=0; i<numOfObs; i++)
1735  ionDataFlagByBand[bandKey][i] = -1;
1736  };
1737  ionBits.resize(numOfObs);
1738  // fill them:
1739  for (int iObs=0; iObs<numOfObs; iObs++)
1740  {
1741  SgVlbiObservation *obs=observations_.at(iObs);
1742  //
1743  for (QMap<QString, SgVlbiObservable*>::iterator it=obs->observableByKey().begin();
1744  it!=obs->observableByKey().end(); ++it)
1745  {
1746  SgVlbiObservable *o=it.value();
1747  const QString& bandKey=o->getBandKey();
1748  int mediaIdx=o->getMediaIdx();
1749  ionCalsByBand [bandKey]->setElement(mediaIdx, 0, o->grDelay().getIonoValue());
1750  ionCalsByBand [bandKey]->setElement(mediaIdx, 1, o->phDRate().getIonoValue());
1751  ionSigsByBand [bandKey]->setElement(mediaIdx, 0, o->grDelay().getIonoSigma());
1752  ionSigsByBand [bandKey]->setElement(mediaIdx, 1, o->phDRate().getIonoSigma());
1753  //
1754  effFreqsByBand [bandKey]->setElement(mediaIdx, 0, o->grDelay().getEffFreq());
1755  effFreqsByBand [bandKey]->setElement(mediaIdx, 1, o->phDelay().getEffFreq());
1756  effFreqsByBand [bandKey]->setElement(mediaIdx, 2, o->phDRate().getEffFreq());
1757  effFreqsEqWgtByBand [bandKey]->setElement(mediaIdx, 0, o->grDelay().getEffFreqEqWgt());
1758  effFreqsEqWgtByBand [bandKey]->setElement(mediaIdx, 1, o->phDelay().getEffFreqEqWgt());
1759  effFreqsEqWgtByBand [bandKey]->setElement(mediaIdx, 2, o->phDRate().getEffFreqEqWgt());
1760  //
1761  if (obs->observableByKey().size() == 1)
1762  ionDataFlagByBand[o->getBandKey()][o->getMediaIdx()] = -1;
1763  else
1764  {
1765  ionDataFlagByBand[o->getBandKey()][o->getMediaIdx()] = 0;
1766  //The -3 flag is set if
1767  //ION_DELAY_SIGMA < 1.d-14 or ION_RATE_SIGMA < 1.d-17
1768  if (o->grDelay().getIonoSigma()<1.0e-14 || o->phDRate().getIonoSigma()<1.0e-17)
1769  ionDataFlagByBand[o->getBandKey()][o->getMediaIdx()] = -3;
1770  //The -4 flag is set if
1771  //ION_DELAY_SIGMA >1.d-8 or ION_RATE_SIGMA > 1.d-8
1772  if (o->grDelay().getIonoSigma()>1.0e-8 || o->phDRate().getIonoSigma()>1.0e-8)
1773  ionDataFlagByBand[o->getBandKey()][o->getMediaIdx()] = -4;
1774  };
1775  };
1776  ionBits[iObs] = obs->calculateIonoBits();
1777  };
1778  // write data into netCDF files:
1779  for (int iBand=0; iBand<bands_.size(); iBand++)
1780  {
1781  const QString& bandKey = bands_.at(iBand)->getKey();
1783  vgosDb->storeObsCalIonGroup(bandKey, ionCalsByBand[bandKey], ionSigsByBand[bandKey],
1784  ionDataFlagByBand[bandKey]);
1785  vgosDb->storeObsEffFreqs(bandKey, effFreqsByBand[bandKey]);
1786  vgosDb->storeObsEffFreqs(bandKey, effFreqsEqWgtByBand[bandKey], true);
1787  };
1789  vgosDb->storeIonoBits(ionBits);
1790  // free memmory:
1791  for (QMap<QString, SgMatrix*>::iterator it=ionCalsByBand.begin(); it!=ionCalsByBand.end(); ++it)
1792  delete it.value();
1793  for (QMap<QString, SgMatrix*>::iterator it=ionSigsByBand.begin(); it!=ionSigsByBand.end(); ++it)
1794  delete it.value();
1795  for (QMap<QString, SgMatrix*>::iterator it=effFreqsByBand.begin(); it!=effFreqsByBand.end(); ++it)
1796  delete it.value();
1797  for (QMap<QString, SgMatrix*>::iterator it=effFreqsEqWgtByBand.begin();
1798  it!=effFreqsEqWgtByBand.end(); ++it)
1799  delete it.value();
1800  effFreqsByBand.clear();
1801  effFreqsEqWgtByBand.clear();
1802  ionCalsByBand.clear();
1803  ionSigsByBand.clear();
1804  ionDataFlagByBand.clear();
1805  ionBits.clear();
1806  };
1807  // end of ionocorrections
1808  //
1809  //
1810  //
1812  {
1813  QVector<int> delUFlag, phsUFlag, ratUFlag, uAcSup;
1814  delUFlag.resize(numOfObs);
1815  phsUFlag.resize(numOfObs);
1816  ratUFlag.resize(numOfObs);
1817  uAcSup.resize(numOfObs);
1818  QString pbKey=primaryBand_->getKey();
1819  QString sbKey("");
1820  bool has2ndBand;
1821  has2ndBand = bands_.size() > 1;
1822  if (has2ndBand)
1823  {
1824  int bandIdx=0;
1825  sbKey = bands_.at(bandIdx++)->getKey();
1826  while (sbKey==pbKey && bandIdx<bands_.size()) // pick up a first non-prime band:
1827  sbKey = bands_.at(bandIdx++)->getKey();
1828  };
1829  for (int iObs=0; iObs<numOfObs; iObs++)
1830  {
1831  SgVlbiObservation *obs=observations_.at(iObs);
1832  SgVlbiObservable *pbObs=obs->observable(pbKey);
1833  SgVlbiObservable *sbObs=has2ndBand?obs->observable(sbKey):NULL;
1834  int mediaIdx=obs->getMediaIdx();
1835 
1836  if (!pbObs)
1837  std::cout << "Error: pbObs is NULL\n";
1838  //
1839  // store vgosDa flags as is:
1840  if (getOriginType() != OT_AGV)
1841  {
1842  if (pbObs->grDelay().getUnweightFlag()==0)
1843  {
1845  pbObs->grDelay().setUnweightFlag(1);
1846  else if (!obs->isAttr(SgObservation::Attr_PROCESSED))
1847  pbObs->grDelay().setUnweightFlag(2);
1848  //
1849  if (sbObs) // can be NULL
1850  {
1851  int qCodeSb=sbObs->getQualityFactor();
1852  if (qCodeSb==0 && !obs->isAttr(SgObservation::Attr_PROCESSED))
1853  pbObs->grDelay().setUnweightFlag(4);
1854  };
1855  //
1856  if (has2ndBand && !sbObs)
1857  pbObs->grDelay().setUnweightFlag(8);
1858  }
1859  else if (!obs->isAttr(SgObservation::Attr_NOT_VALID) &&
1861  pbObs->grDelay().setUnweightFlag(0);
1862  }; // end of vgosDa checking
1863  //
1864  //
1865  if (pbObs->grDelay().getUnweightFlag()==0 && (sbObs || !has2ndBand))
1866  uAcSup[mediaIdx] = -32768;
1867  else if (pbObs->grDelay().getUnweightFlag()==1)
1868  uAcSup[mediaIdx] = -32767;
1869  else
1870  uAcSup[mediaIdx] = -32763;
1871 
1872  delUFlag[mediaIdx] = pbObs->grDelay().getUnweightFlag();
1873  phsUFlag[mediaIdx] = pbObs->phDelay().getUnweightFlag();
1874  ratUFlag[mediaIdx] = pbObs->phDRate().getUnweightFlag();
1875  };
1876  vgosDb->storeObsEditData(delUFlag, phsUFlag, ratUFlag, uAcSup);
1877  delUFlag.clear();
1878  phsUFlag.clear();
1879  ratUFlag.clear();
1880  uAcSup.clear();
1881  };
1882 
1883  // numbers of ambiguities:
1887  {
1888  // create carriers:
1889  QMap<QString, QVector<int> >numOfAmbigsByBand, numOfSubAmbigsByBand, numOfPhsAmbigsByBand;
1890  QVector<int> stub;
1891  QMap<QString, SgVector*> grDelaysFullByBand, phDelaysFullByBand, phDelaysSigFullByBand;
1892 // bool hasPhaseAmbigs=false;
1894  stub.clear();
1895 
1896  for (int iBand=0; iBand<bands_.size(); iBand++)
1897  {
1898  const QString& bandKey=bands_.at(iBand)->getKey();
1899  numOfAmbigsByBand .insert(bandKey, QVector<int>(numOfObs));
1900  numOfSubAmbigsByBand.insert(bandKey, QVector<int>(numOfObs));
1901  numOfPhsAmbigsByBand.insert(bandKey, QVector<int>(numOfObs));
1902  grDelaysFullByBand[bandKey] = new SgVector(numOfObs);
1903  phDelaysFullByBand[bandKey] = new SgVector(numOfObs);
1904  phDelaysSigFullByBand[bandKey] = new SgVector(numOfObs);
1905  for (int i=0; i<numOfObs; i++)
1906  {
1907  numOfAmbigsByBand [bandKey][i] = 0;
1908  numOfSubAmbigsByBand[bandKey][i] = 0;
1909  numOfPhsAmbigsByBand[bandKey][i] = 0;
1910  };
1911  };
1912  // fill them:
1913  for (int iObs=0; iObs<numOfObs; iObs++)
1914  {
1915  SgVlbiObservation *obs=observations_.at(iObs);
1916  int mediaIdx=obs->getMediaIdx();
1917  for (QMap<QString, SgVlbiObservable*>::iterator it=obs->observableByKey().begin();
1918  it!=obs->observableByKey().end(); ++it)
1919  {
1920  SgVlbiObservable *o=it.value();
1921 // numOfAmbigsByBand[o->getBandKey()][o->getMediaIdx()] = o->getNumOfAmbiguities();
1922  numOfAmbigsByBand [o->getBandKey()][mediaIdx] = o->grDelay().getNumOfAmbiguities();
1923  numOfSubAmbigsByBand[o->getBandKey()][mediaIdx] = o->grDelay().getNumOfSubAmbigs();
1924  numOfPhsAmbigsByBand[o->getBandKey()][mediaIdx] = o->phDelay().getNumOfAmbiguities();
1925 // if (!hasPhaseAmbigs && o->phDelay().getNumOfAmbiguities()!=0)
1926 // hasPhaseAmbigs = true;
1927  grDelaysFullByBand[o->getBandKey()]->setElement(mediaIdx,
1928  o->grDelay().getValue() + o->grDelay().ambiguity());
1929  phDelaysFullByBand[o->getBandKey()]->setElement(mediaIdx,
1930  o->phDelay().getValue() + o->phDelay().ambiguity());
1931  phDelaysSigFullByBand[o->getBandKey()]->setElement(mediaIdx,
1932  o->phDelay().getSigma());
1933  };
1934  };
1935  // write data into netCDF files:
1936  for (int iBand=0; iBand<bands_.size(); iBand++)
1937  {
1938  const QString& bandKey = bands_.at(iBand)->getKey();
1939  if (!true)
1940  vgosDb->storeObsNumGroupAmbigs(bandKey, numOfAmbigsByBand[bandKey],
1941  numOfSubAmbigsByBand[bandKey]);
1942  else
1943  vgosDb->storeObsNumGroupAmbigs(bandKey, numOfAmbigsByBand[bandKey], stub);
1944  vgosDb->storeObsGroupDelaysFull(bandKey, grDelaysFullByBand[bandKey]);
1945  if (hasPhaseAmbigs)
1946  {
1947  vgosDb->storeObsNumPhaseAmbigs(bandKey, numOfPhsAmbigsByBand[bandKey]);
1948  vgosDb->storeObsPhaseDelaysFull(bandKey, phDelaysFullByBand[bandKey],
1949  phDelaysSigFullByBand[bandKey]);
1950  };
1951  };
1952  // free memmory:
1953  numOfAmbigsByBand .clear();
1954  numOfSubAmbigsByBand.clear();
1955  numOfPhsAmbigsByBand.clear();
1956  for (QMap<QString, SgVector*>::iterator it=grDelaysFullByBand.begin();
1957  it!=grDelaysFullByBand.end(); ++it)
1958  delete it.value();
1959  grDelaysFullByBand.clear();
1960  };
1961  // end of numbers of ambiguities:
1962 
1963  //
1964  //
1965  // save solve control parameters:
1966  //
1967  if (parametersDescriptor_ &&
1968  getOriginType()!=OT_MK4 &&
1969  getOriginType()!=OT_KOMB )
1970  {
1971  SgVector *vIntervals, *vConstraints;
1972  QList<QString> sites, refSites;
1973  QList<int> ionoFlags;
1974  int numOfSites=stationsByName_.size();
1975  // mimic current SOLVE behavior:
1976  vIntervals = new SgVector(1);
1977  vConstraints = new SgVector(numOfSites);
1978  //
1979  // save troposhere parameters setup:
1980  int idx=0;
1981  for (StationsByName_it it=stationsByName_.begin(); it!=stationsByName_.end(); ++it)
1982  {
1983  SgVlbiStationInfo *si=it.value();
1984  sites << si->getKey();
1985  ionoFlags << 9; // what else?
1986  vConstraints->setElement(idx,
1989  /(1.0e-12*24.0*vLight*100.0));
1990  idx++;
1991  };
1992  vIntervals->setElement(0, parametersDescriptor_->getZenith().getPwlStep()*24.0);
1993  vgosDb->storeAtmSetup(vIntervals, vConstraints, sites);
1994  //
1995  // save clock parameters setup:
1996  idx = 0;
1997  for (StationsByName_it it=stationsByName_.begin(); it!=stationsByName_.end(); ++it)
1998  {
1999  SgVlbiStationInfo *si=it.value();
2001  refSites << si->getKey();
2002  vConstraints->setElement(idx,
2005  idx++;
2006  };
2007  vIntervals->setElement(0, parametersDescriptor_->getClock0().getPwlStep()*24.0);
2008  vgosDb->storeClockSetup(vIntervals, vConstraints, sites, refSites);
2009 
2010  // just a placeholder for future:
2011  vgosDb->storeErpSetup(10.0, 0.67);
2012  //
2013  vgosDb->storeIonoSetup(ionoFlags, sites);
2014  //
2015  sites.clear();
2016  ionoFlags.clear();
2017  delete vConstraints;
2018  delete vIntervals;
2019  };
2020  //
2021  //
2022  // baseline weight corrections:
2024  {
2025  QVector<QString> baselineNames;
2026  SgMatrix *groupBlWeights;
2027  int numOfBaselines, idx;
2028  numOfBaselines = baselinesByName_.size();
2029  groupBlWeights = new SgMatrix(2, numOfBaselines);
2030  baselineNames.resize(numOfBaselines);
2031  idx = 0;
2032  for (BaselinesByName_it it=baselinesByName_.begin(); it!=baselinesByName_.end(); ++it)
2033  {
2034  SgVlbiBaselineInfo *bi=it.value();
2035  baselineNames[idx] = bi->getKey();
2036  groupBlWeights->setElement(0, idx, bi->getSigma2add(DT_DELAY));
2037  groupBlWeights->setElement(1, idx, bi->getSigma2add(DT_RATE ));
2038  idx++;
2039  };
2040  vgosDb->storeSolveWeights(baselineNames, groupBlWeights);
2041  baselineNames.clear();
2042  delete groupBlWeights;
2043  };
2044  //
2045  //
2046  // source and baseline selection statuses:
2047  if (parametersDescriptor_ &&
2048  getOriginType()!=OT_MK4 &&
2049  getOriginType()!=OT_KOMB )
2050  {
2051  int numOfStns, idx, jdx;
2052  QList<QString> sources, stations;
2053  QVector<int> sourcesSelection;
2054  QVector< QVector<int> > baselinesSelection;
2055  sourcesSelection.resize(sourcesByName_.size());
2056  idx = 0;
2057  for (SourcesByName_it it=sourcesByName_.begin(); it!=sourcesByName_.end(); ++it)
2058  {
2059  SgVlbiSourceInfo *si=it.value();
2060  sourcesSelection[idx] = si->calculateStatusBits();
2061  sources.append(si->getKey());
2062  idx++;
2063  };
2064  //
2065  numOfStns = stationsByName_.size();
2066  baselinesSelection.resize(stationsByName_.size());
2067  idx = 0;
2068  for (StationsByName_it it_i=stationsByName_.begin(); it_i!=stationsByName_.end(); ++it_i)
2069  {
2070  jdx = 0;
2071  baselinesSelection[idx].resize(numOfStns);
2072  for (StationsByName_it it_j=stationsByName_.begin(); it_j!=stationsByName_.end(); ++it_j)
2073  {
2074  QString st1Name(it_i.value()->getKey()), st2Name(it_j.value()->getKey());
2075  int bitArray;
2076  bitArray = 0;
2077  SgVlbiBaselineInfo *bi, *biR;
2078  if (baselinesByName_.contains(st1Name + ":" + st2Name))
2079  bi = baselinesByName_.value(st1Name + ":" + st2Name);
2080  else
2081  bi = NULL;
2082  if (baselinesByName_.contains (st2Name + ":" + st1Name))
2083  biR = baselinesByName_.value(st2Name + ":" + st1Name);
2084  else
2085  biR = NULL;
2086  //
2087  // ! * Format of BASLSTAT_I2 array: *
2088  // ! * Array BASLSTAT_I2 contains NUMSTA**2 elements, where *
2089  // ! * NUMSTA is the number of stations. *
2090  // ! * Baselines ISIT1, ISIT2 has index (ISITE1-1)*NUMSTA + ISITE2 *
2091  // ! * Where ISIT1, ISIT2 are indeces of the station *
2092  // ! * in interval [1, NUMSTA]. Stations index *
2093  // ! * correspond station name table kept in LCODE *
2094  // ! * SITNAMES. In general order of stations in this *
2095  // ! * station list MAY NOT coincide with order of *
2096  // ! * stations in the array ISITN_CHR kept in psfil.i !!*
2097  // ! * Each element of the array is 16-bits bit field. *
2098  // ! * Bits are counted from 1. *
2099  // ! * 1-st bit is set when at least one observation at the *
2100  // ! * baseline ISIT1, ISIT2 (but not ISIT2, ISIT1) took place*
2101  // ! * 2-nd bit is set when baseline ISIT1, ISIT2 (or ISIT2, ISIT1)*
2102  // ! * was selected in group delay solution. *
2103  // ! * 3-nd bit is set when baseline ISIT1, ISIT2 (or ISIT2, ISIT1)*
2104  // ! * was selected in phase delay solution. *
2105  // ! * 4-th bit is set when baseline-dependent clock for the *
2106  // ! * baseline ISIT1, ISIT2 (or ISIT2, ISIT1) was estimated *
2107  // ! * in group delay solution. *
2108  // ! * 5-th bit is set when baseline-dependent clock for the *
2109  // ! * baseline ISIT1, ISIT2 (or ISIT2, ISIT1) was estimated *
2110  // ! * in phase delay solution. *
2111  // ! * bits 6-16 are reserved for future used and always are zero. *
2112  // !
2113  // set the first bit:
2114  if (bi && bi->numTotal(DT_DELAY))
2115  bitArray |= (1<<0);
2116  //
2117  // bi and biR can be NULLs!
2118  //
2119  // set the second and third bits:
2120  SgVlbiStationInfo *s1i=NULL, *s2i=NULL;
2121  if (stationsByName_.contains(st1Name))
2122  s1i = stationsByName_.value(st1Name);
2123  if (stationsByName_.contains(st2Name))
2124  s2i = stationsByName_.value(st2Name);
2125  if ( ((bi && !bi ->isAttr(SgVlbiBaselineInfo::Attr_NOT_VALID)) ||
2126  (biR && !biR->isAttr(SgVlbiBaselineInfo::Attr_NOT_VALID))) &&
2127  (s1i && !s1i->isAttr(SgVlbiStationInfo::Attr_NOT_VALID)) &&
2128  (s2i && !s2i->isAttr(SgVlbiStationInfo::Attr_NOT_VALID)) )
2129  {
2130  bitArray |= (1<<1);
2131  bitArray |= (1<<2);
2132  };
2133  // set the fourth and fifth bits:
2134  if ((bi &&
2137  (biR &&
2140  {
2141  bitArray |= (1<<3);
2142  bitArray |= (1<<4);
2143  };
2144  baselinesSelection[idx][jdx] = bitArray;
2145  jdx++;
2146  };
2147  stations.append(it_i.value()->getKey());
2148  idx++;
2149  };
2150  vgosDb->storeSelectionStatus(sourcesSelection, baselinesSelection);
2151  sources.clear();
2152  stations.clear();
2153  sourcesSelection.clear();
2154  for (int i=0; i<baselinesSelection.size(); i++)
2155  baselinesSelection[i].clear();
2156  baselinesSelection.clear();
2157  //
2158  //
2159  QList<QString> baselines;
2160  for (BaselinesByName_it it_b=baselinesByName_.begin(); it_b!=baselinesByName_.end(); ++it_b)
2161  {
2162  SgVlbiBaselineInfo *bi=it_b.value();
2165  baselines << bi->getKey();
2166  };
2167  vgosDb->storeBaselineClockSetup(baselines);
2168  baselines.clear();
2169  };
2170  //
2171  //
2172  if (config_ &&
2173  config_->getEccentricitiesFileName().size() &&
2174  getOriginType()!=OT_MK4 &&
2175  getOriginType()!=OT_KOMB )
2176  {
2177  int numOfStns, idx;
2178  bool hasEccData;
2179  QVector<QString> stationsNames, eccTypes, eccNums;
2180  SgMatrix *eccVals;
2181 
2182  numOfStns = stationsByName_.size();
2183  stationsNames.resize(numOfStns);
2184  eccTypes.resize(numOfStns);
2185  eccNums.resize(numOfStns);
2186  eccVals = new SgMatrix(numOfStns, 3);
2187  idx = 0;
2188  hasEccData = false;
2189  for (StationsByName_it it=stationsByName_.begin(); it!=stationsByName_.end(); ++it)
2190  {
2191  SgVlbiStationInfo *si=it.value();
2192  if (si->eccRec())
2193  {
2194  if (!hasEccData && si->eccRec()->getEccType()!=SgEccRec::ET_N_A)
2195  hasEccData = true;
2196 
2197  stationsNames[idx] = si->getKey();
2198  eccTypes[idx] = si->eccRec()->getEccType()==SgEccRec::ET_XYZ ? "XY" : "NE";
2199  eccNums[idx] = si->eccRec()->getCdpNumber().leftJustified(10, ' ');
2200  eccVals->setElement(idx, 0, si->eccRec()->getDR().at(X_AXIS));
2201  eccVals->setElement(idx, 1, si->eccRec()->getDR().at(Y_AXIS));
2202  eccVals->setElement(idx, 2, si->eccRec()->getDR().at(Z_AXIS));
2203  }
2204  else
2206  "::putDataIntoVgosDb(): no ecc for station " + si->getKey());
2207  idx++;
2208  };
2209  if (hasEccData)
2210  vgosDb->storeEccentricities(stationsNames, eccTypes, eccNums, eccVals,
2212  else
2214  "::putDataIntoVgosDb(): no eccentricities found");
2215 
2216  stationsNames.clear();
2217  eccTypes.clear();
2218  eccNums.clear();
2219  delete eccVals;
2220  };
2221  //
2222  //
2223  if (config_ &&
2224  getOriginType()!=OT_MK4 &&
2225  getOriginType()!=OT_KOMB )
2226  {
2227  int obsCalFlags;
2228  QList<QString> calList;
2229  QVector<int> statCalFlags;
2230  QVector<QString> statCalNames, flybyNames, calSiteNames, obsCalNames;
2231  QVector< QVector<int> > flybyFlags;
2232 
2233  statCalNames.resize(6);
2234  for (int i=0; i<6; i++)
2235  statCalNames[i] = sCalList[i];
2236  //
2237  flybyNames.resize(8);
2238  for (int i=0; i<8; i++)
2239  flybyNames[i] = sFclList[i];
2240  //
2241  calSiteNames.resize(stationsByName_.size());
2242  statCalFlags.resize(stationsByName_.size());
2243  flybyFlags.resize(stationsByName_.size());
2244  int idx=0;
2245  for (StationsByName_it it=stationsByName_.begin(); it!=stationsByName_.end(); ++it)
2246  {
2247  SgVlbiStationInfo *si=it.value();
2248  calSiteNames[idx] = si->getKey();
2249  // currently, we use only cable cal from the list:
2250  statCalFlags[idx] = si->isAttr(SgVlbiStationInfo::Attr_IGNORE_CABLE_CAL)?0:1;
2251  flybyFlags[idx].resize(7);
2252  flybyFlags[idx][0] = 1<<(8-1);
2253  for (int j=1; j<7; j++)
2254  flybyFlags[idx][j] = 0;
2255  idx++;
2256  };
2257  //
2258  formObsCalibrationSetup(obsCalFlags, calList);
2259  obsCalNames.resize(calList.size());
2260  for (int i=0; i<calList.size(); i++)
2261  obsCalNames[i] = calList.at(i);
2262  //
2263  vgosDb->storeCalibrations(obsCalFlags, statCalFlags, flybyFlags, statCalNames, flybyNames,
2264  calSiteNames, obsCalNames);
2265  //
2266  calList.clear();
2267  statCalFlags.clear();
2268  statCalNames.clear();
2269  flybyNames.clear();
2270  calSiteNames.clear();
2271  obsCalNames.clear();
2272  for (int i=0; i<flybyFlags.size(); i++)
2273  flybyFlags[i].clear();
2274  flybyFlags.clear();
2275  };
2276  //
2277  //
2278  // clock breaks: (should add FF_CLOCK_BREAK_ADDED to check?)
2279  if ( getOriginType()!=OT_MK4 &&
2280  getOriginType()!=OT_KOMB &&
2282  {
2283  // another attempt:
2284  int numCbs;
2285  QVector<QString> cbNames;
2286  QVector<SgMJD> cbEpochs;
2287  QVector<int> cbFlags;
2288  //
2289  QMap<QString, SgParameterBreak*>
2290  breakParameterByBreak;
2291  QMap<QString, QString> breakNameByBreak;
2292  QList<SgParameterBreak*> cBreaks;
2293  QList<QString> cBreakNames, acmSites;
2294  QString sBreak("");
2295  QList<bool> acm_offsets, acm_rates;
2296  bool need2updateAprioriClocks=false;
2297  //
2298  // session-wide clock breaks:
2299  // collect the clock breaks:
2300  for (StationsByName_it it=stationsByName_.begin(); it!=stationsByName_.end(); ++it)
2301  {
2302  SgVlbiStationInfo *si=it.value();
2303  if (si->clockBreaks().size())
2304  {
2306  for (int j=0; j<si->clockBreaks().size(); j++)
2307  {
2308  SgParameterBreak *pb=si->clockBreaks().at(j);
2309  sBreak = pb->getEpoch4Export().toString(SgMJD::F_INTERNAL) + "@" + si->getKey();
2310  breakParameterByBreak.insert(sBreak, pb);
2311  breakNameByBreak.insert(sBreak, si->getKey());
2312  };
2313  };
2315  need2updateAprioriClocks = true;
2316  if (si->getNeed2useAPrioriClocks())
2317  {
2318  acmSites << si->getKey();
2319  acm_offsets << si->getAPrioriClockTerm_0();
2320  acm_rates << si->getAPrioriClockTerm_1();
2321  };
2322  };
2323  cBreaks = breakParameterByBreak.values();
2324  cBreakNames = breakNameByBreak.values();
2325  if ((numCbs=cBreaks.size()))
2326  {
2327  contemporaryHistory_.addHistoryRecord("Detected " + QString().setNum(numCbs) +
2328  " clock break" + (numCbs==1?"":"s"), SgMJD::currentMJD().toUtc());
2329  cbNames.resize(numCbs);
2330  cbEpochs.resize(numCbs);
2331  cbFlags.resize(numCbs);
2332  for (int i=0; i<numCbs; i++)
2333  {
2334  cbNames[i] = cBreakNames.at(i);
2335  cbEpochs[i] = cBreaks.at(i)->getEpoch4Export();
2336  cbFlags[i] = 7;
2337  contemporaryHistory_.addHistoryRecord("A clock break marker has been set for " +
2338  cBreakNames.at(i) + " at " +
2339  cBreaks.at(i)->getEpoch4Export().toString(), SgMJD::currentMJD().toUtc());
2340  };
2341  //
2342  // check already saved info:
2343  bool need2store;
2344  bool hasClockBreaks;
2345  QVector<QString> cbNames_old;
2346  QVector<SgMJD> cbEpochs_old;
2347  QVector<int> cbFlags_old;
2348  need2store = false;
2349  if ((hasClockBreaks=vgosDb->loadClockBreaks(cbNames_old, cbEpochs_old, cbFlags_old)))
2350  {
2351  if (cbNames_old != cbNames)
2352  {
2353  need2store = true;
2355  "::putDataIntoVgosDb(): the existed clock breaks names are different");
2356  };
2357  if (!need2store) // ok, the sizes and the station order too are the same
2358  {
2359  double d;
2360  for (int i=0; i<cbEpochs.size(); i++)
2361  if (!need2store && (d=fabs(cbEpochs.at(i) - cbEpochs_old.at(i)))>1.0e-2/DAY2SEC)
2362  {
2363  need2store = true;
2365  "::putDataIntoVgosDb(): the existed clock breaks epochs are different: " +
2366  cbEpochs.at(i).toString() + " vs " + cbEpochs_old.at(i).toString() +
2367  " (diff: " + interval2Str(d) + ") for the station " + cbNames.at(i));
2368  };
2369  };
2370  if (!need2store && cbFlags_old != cbFlags)
2371  {
2372  need2store = true;
2374  "::putDataIntoVgosDb(): the existed clock breaks flags are different");
2375  };
2376  cbNames_old.clear();
2377  cbEpochs_old.clear();
2378  cbFlags_old.clear();
2379  }
2380  else
2381  need2store = true;
2382  //
2383  if (need2store)
2384  {
2385  vgosDb->storeClockBreaks(cbNames, cbEpochs, cbFlags);
2387  "::putDataIntoVgosDb(): the existed clock breaks of the session were refereshed");
2388  }
2389  else
2391  "::putDataIntoVgosDb(): the session has clock breaks, the stored data were not modified");
2392  //
2393  cbNames.clear();
2394  cbEpochs.clear();
2395  cbFlags.clear();
2396  }
2397  else if (!vgosDb->vClockBreak().isEmpty()) // all previously defined clock breaks were removed:
2398  {
2399  vgosDb->vClockBreak().empty();
2401  "::putDataIntoVgosDb(): the vgosDb data tree was cleared from existed clock break(s)");
2402  }
2403  else
2405  "::putDataIntoVgosDb(): no clock break information were added to the vgosDb data tree");
2406  //
2407  cBreaks.clear();
2408  cBreakNames.clear();
2409  breakParameterByBreak.clear();
2410  breakNameByBreak.clear();
2411  //
2412  // check band's clock breaks, if they are exist, complain:
2413  for (QMap<QString, SgVlbiBand*>::iterator itb=bandByKey_.begin(); itb!=bandByKey_.end(); ++itb)
2414  {
2415  QString bandKey=itb.key();
2416  SgVlbiBand *band=itb.value();
2417  for (StationsByName_it it=band->stationsByName().begin(); it!=band->stationsByName().end(); ++it)
2418  {
2419  SgVlbiStationInfo *si=it.value();
2420  if (si->clockBreaks().size())
2422  "::putDataIntoVgosDb(): the station " + si->getKey() + " has " +
2423  QString("").setNum(si->clockBreaks().size()) + " clock break(s) at the " + bandKey +
2424  "-band. Saving the band dependent clock breaks is not implemented yet.");
2425  };
2426  };
2427  //
2428  // a priori clock model:
2429  if (need2updateAprioriClocks)
2430  {
2431  int numAcm=acmSites.size();
2432  if (numAcm)
2433  {
2434  SgMatrix *offsets_n_rates=new SgMatrix(numAcm, 2);
2435  for (int i=0; i<numAcm; i++)
2436  {
2437  offsets_n_rates->setElement(i, 0, acm_offsets.at(i));
2438  offsets_n_rates->setElement(i, 1, acm_rates.at(i));
2439  };
2440  vgosDb->storeClockApriories(acmSites, offsets_n_rates);
2441  delete offsets_n_rates;
2442  }
2443  else // special case: a user could remove/turn off a priori clocks:
2444  {
2445  vgosDb->vClockApriori().empty();
2447  "::putDataIntoVgosDb(): a set of a priori clocks has been removed from vgosDb tree");
2448  };
2449  };
2450 
2451 
2452 
2453 
2454 
2455 //----------------------------------
2456 
2457 
2458  /*
2459  QVector<QString> cbNames;
2460  QVector<SgMJD> cbEpochs;
2461  QVector<int> cbFlags;
2462  int numCbs;
2463  QMap<QString, SgParameterBreak*>
2464  breakParameterByBreak;
2465  QMap<QString, QString> breakNameByBreak;
2466  QList<SgParameterBreak*> cBreaks;
2467  QList<QString> cBreakNames;
2468  QString sBreak("");
2469  bool isClockBreaksModified;
2470 
2471  isClockBreaksModified = false;
2472  // session-wide clock breaks:
2473  for (StationsByName_it it=stationsByName_.begin(); it!=stationsByName_.end(); ++it)
2474  {
2475  SgVlbiStationInfo *si=it.value();
2476  if (si->clockBreaks().size())
2477  {
2478  if (si->clockBreaks().getIsModified())
2479  {
2480  isClockBreaksModified = true;
2481  logger->write(SgLogger::INF, SgLogger::IO_NCDF | SgLogger::DATA, className() +
2482  "::putDataIntoVgosDb(): the station " + si->getKey() + " has new clock break(s)");
2483  }
2484  else
2485  logger->write(SgLogger::INF, SgLogger::IO_NCDF | SgLogger::DATA, className() +
2486  "::putDataIntoVgosDb(): the station " + si->getKey() +
2487  " has clock break(s) but they are not new");
2488 
2489  si->calcCBEpochs4Export(*si->auxObservationByScanId());
2490  for (int j=0; j<si->clockBreaks().size(); j++)
2491  {
2492  SgParameterBreak *pb=si->clockBreaks().at(j);
2493  sBreak = pb->getEpoch4Export().toString(SgMJD::F_INTERNAL) + "@" + si->getKey();
2494  breakParameterByBreak.insert(sBreak, pb);
2495  breakNameByBreak.insert(sBreak, si->getKey());
2496  };
2497  };
2498  };
2499  cBreaks = breakParameterByBreak.values();
2500  cBreakNames = breakNameByBreak.values();
2501  if ((numCbs=cBreaks.size()) && isClockBreaksModified)
2502  {
2503  contemporaryHistory_.addHistoryRecord("Detected " + QString().setNum(numCbs) +
2504  " clock break" + (numCbs==1?"":"s"));
2505  cbNames.resize(numCbs);
2506  cbEpochs.resize(numCbs);
2507  cbFlags.resize(numCbs);
2508  for (int i=0; i<numCbs; i++)
2509  {
2510  cbNames[i] = cBreakNames.at(i);
2511  cbEpochs[i] = cBreaks.at(i)->getEpoch4Export();
2512  cbFlags[i] = 7;
2513  contemporaryHistory_.addHistoryRecord("A clock break marker has been set for " +
2514  cBreakNames.at(i) + " at " +
2515  cBreaks.at(i)->getEpoch4Export().toString());
2516  };
2517  vgosDb->storeClockBreaks(cbNames, cbEpochs, cbFlags);
2518  cbNames.clear();
2519  cbEpochs.clear();
2520  cbFlags.clear();
2521  }
2522  else
2523  logger->write(SgLogger::INF, SgLogger::IO_NCDF | SgLogger::DATA, className() +
2524  "::putDataIntoVgosDb(): no clock break information were added to the vgosDb data tree");
2525 
2526  cBreaks.clear();
2527  cBreakNames.clear();
2528  breakParameterByBreak.clear();
2529  breakNameByBreak.clear();
2530  //
2531  // band-specific clock breaks:
2532  for (QMap<QString, SgVlbiBand*>::iterator itb=bandByKey_.begin(); itb!=bandByKey_.end(); ++itb)
2533  {
2534  QString bandKey=itb.key();
2535  SgVlbiBand *band=itb.value();
2536  for (StationsByName_it it=band->stationsByName().begin(); it!=band->stationsByName().end(); ++it)
2537  {
2538  SgVlbiStationInfo *si=it.value();
2539  if (si->clockBreaks().size())
2540  {
2541  si->calcCBEpochs4Export(*stationsByName_.value(si->getKey())->auxObservationByScanId());
2542  for (int j=0; j<si->clockBreaks().size(); j++)
2543  {
2544  SgParameterBreak *pb=si->clockBreaks().at(j);
2545  sBreak = pb->getEpoch4Export().toString(SgMJD::F_INTERNAL) + "@" + si->getKey();
2546  breakParameterByBreak.insert(sBreak, pb);
2547  breakNameByBreak.insert(sBreak, si->getKey());
2548  };
2549  };
2550  };
2551  cBreaks = breakParameterByBreak.values();
2552  cBreakNames = breakNameByBreak.values();
2553  if ((numCbs=cBreaks.size()))
2554  {
2555  cbNames.resize(numCbs);
2556  cbEpochs.resize(numCbs);
2557  cbFlags.resize(numCbs);
2558  for (int i=0; i<numCbs; i++)
2559  {
2560  cbNames [i] = cBreakNames.at(i);
2561  cbEpochs[i] = cBreaks.at(i)->getEpoch4Export();
2562  cbFlags [i] = 7;
2563  };
2564  vgosDb->storeClockBreaks(cbNames, cbEpochs, cbFlags, bandKey);
2565  cbNames.clear();
2566  cbEpochs.clear();
2567  cbFlags.clear();
2568  };
2569  cBreaks.clear();
2570  cBreakNames.clear();
2571  breakParameterByBreak.clear();
2572  breakNameByBreak.clear();
2573  };
2574  */
2575 
2576 
2577  };
2578  //
2579  //
2580  //
2581  // at last, create new version of the wrapper file:
2582  vgosDb->composeWrapperFile();
2583  if (config_ && originType_ != OT_AGV)
2585  // collect everything interesting from the log:
2586  SgLogger *auxLogger=logger->lookupSupplementLog("History");
2587  if (auxLogger)
2588  {
2589  // vgosDbProcLogs-0.0.1 (Solstice): the sessio
2590  QRegExp reFltDriveName
2591  ("([\\w\\d]+)-([\\d\\.]+)\\s+\\(([\\w\\d\\s]+)\\):\\s+(.+)");
2592  QRegExp reFltNormMessg("([\\w\\d]+)::([\\w\\d]+)\\(\\):\\s+(.+)");
2593  QRegExp reFltWarnMessg("^Warning: ([\\w\\d]+)::([\\w\\d]+)\\(\\):\\s+(.+)");
2594  QRegExp reFltErrMessg("^ERROR: ([\\w\\d]+)::([\\w\\d]+)\\(\\):\\s+(.+)");
2595  QString sAttr(""), sSubj(""), sEvent("");
2596  const QList<QString*> &histSpool=auxLogger->getSpool();
2597  for (int i=0; i<histSpool.size(); i++)
2598  {
2599  const QString *pS=histSpool.at(i);
2600  if (reFltDriveName.indexIn(*pS) != -1)
2601  {
2602  sAttr = ".";
2603  sSubj = reFltDriveName.cap(1);
2604  sEvent= reFltDriveName.cap(4);
2605  };
2606  if (reFltNormMessg.indexIn(*pS) != -1)
2607  {
2608  sAttr = ".";
2609  sSubj = reFltNormMessg.cap(2);
2610  sEvent= reFltNormMessg.cap(3);
2611  };
2612  if (reFltWarnMessg.indexIn(*pS) != -1)
2613  {
2614  sAttr = "w";
2615  sSubj = reFltWarnMessg.cap(2);
2616  sEvent= reFltWarnMessg.cap(3);
2617  };
2618  if (reFltErrMessg.indexIn(*pS) != -1)
2619  {
2620  sAttr = "E";
2621  sSubj = reFltErrMessg.cap(2);
2622  sEvent= reFltErrMessg.cap(3);
2623  };
2624  if (sAttr.size() && sSubj.size() && sEvent.size())
2625  contemporaryHistory_.addHistoryRecord(sAttr + " " + sSubj + ": " + sEvent,
2626  SgMJD::currentMJD().toUtc());
2627 // contemporaryHistory_.addHistoryRecord(sSubj + ": " + sEvent);
2628  else
2630  sAttr = sSubj = sEvent = "";
2631  };
2632  };
2633  // save the history:
2635 
2636 
2637  if (vgosDb->getOperationMode() == SgNetCdf::OM_DRY_RUN)
2638  std::cout << "\nEnd of DRY RUN mode.\n";
2639  else
2640  {
2641  SgMJD finisEpoch(SgMJD::currentMJD());
2643  "::putDataIntoVgosDb(): the session " + name_ + " has been updated"
2644  ", elapsed time: " + QString("").sprintf("%.2f", (finisEpoch - startEpoch)*86400000.0) + " ms");
2645  };
2646  return isOk;
2647 };
2648 
2649 
2650 
2651 
2652 
2653 
2654 
2655 /*=====================================================================================================*/
2656 
2657 
2658 
2659 
2660 
2661 /*=====================================================================================================*/
2662 //
2663 // constants:
2664 //
2665 
2666 
2667 
2668 /*=====================================================================================================*/
2669 
2670 /*=====================================================================================================*/
const double vLight
Definition: SgConstants.cpp:33
SgLogger * logger
Definition: SgLogger.cpp:231
QString interval2Str(double days)
Definition: SgMJD.cpp:1370
const SgMJD tZero(1957, 10, 4)
#define DAY2SEC
radians to mas:
Definition: SgMathSupport.h:56
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
SgVersion libraryVersion("SgLib", 0, 7, 5, "Tuscarora (rc1)", SgMJD(2022, 2, 18, 17, 34))
QMap< QString, SgVlbiBaselineInfo * >::iterator BaselinesByName_it
const QString sFclList[]
const QString sCalList[]
QMap< QString, SgVlbiSourceInfo * >::iterator SourcesByName_it
QMap< QString, SgVlbiStationInfo * >::iterator StationsByName_it
@ DT_DELAY
Definition: SgWrmsable.h:44
@ DT_RATE
Definition: SgWrmsable.h:45
double at(DIRECTION i, DIRECTION j) const
Definition: Sg3dMatrix.h:93
double at(DIRECTION i) const
Definition: Sg3dVector.h:91
bool isAttr(uint a) const
Definition: SgAttribute.h:226
@ ET_N_A
Definition: SgEccRec.h:50
@ ET_XYZ
Definition: SgEccRec.h:52
const QString & getCdpNumber() const
Definition: SgEccRec.h:211
EccType getEccType() const
Definition: SgEccRec.h:251
const Sg3dVector & getDR() const
Definition: SgEccRec.h:243
const QString & getUserEmailAddress() const
Definition: SgIdentities.h:223
const QString & getAcFullName() const
Definition: SgIdentities.h:239
const QString & getUserName() const
Definition: SgIdentities.h:215
const SgIdentities * getCurrentIdentities() const
Definition: SgIoDriver.h:102
const SgVersion * getCurrentDriverVersion() const
Definition: SgIoDriver.h:104
virtual void write(LogLevel, quint32, const QString &, bool=false)
Definition: SgLogger.cpp:88
const QList< QString * > & getSpool() const
Definition: SgLogger.h:143
SgLogger * lookupSupplementLog(const QString &name)
Definition: SgLogger.cpp:199
@ IO_NCDF
Definition: SgLogger.h:66
@ DATA
Definition: SgLogger.h:78
Definition: SgMJD.h:59
@ 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
SgMJD toUtc() const
Definition: SgMJD.cpp:1229
QString toString(Format format=F_Verbose) const
Definition: SgMJD.cpp:1007
void toYMDHMS_tr(int &nYear, int &nMonth, int &nDay, int &nHour, int &nMin, double &dSec) const
Definition: SgMJD.cpp:1305
static SgMJD currentMJD()
Definition: SgMJD.cpp:118
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
double getPressure() const
Definition: SgMeteoData.h:242
double getTemperature() const
Definition: SgMeteoData.h:234
double getRelativeHumidity() const
Definition: SgMeteoData.h:250
@ OM_DRY_RUN
Definition: SgNetCdf.h:325
double getSigma2add(DataType) const
Definition: SgObjectInfo.h:367
const QString & getKey() const
Definition: SgObjectInfo.h:319
int numTotal(DataType dType) const
Definition: SgObjectInfo.h:343
virtual int getMediaIdx() const
@ Attr_NOT_VALID
omit the observation;
Definition: SgObservation.h:78
@ Attr_PROCESSED
the observation has been processed;
Definition: SgObservation.h:79
const SgMJD & getEpoch4Export() const
Definition: SgBreakModel.h:411
double getPwlStep() const
double getPwlAPriori() const
const SgParameterCfg & getZenith() const
const SgParameterCfg & getClock0() const
const QString & getEccentricitiesFileName() const
bool isEmpty() const
Definition: SgVgosDb.cpp:159
void empty()
Definition: SgVgosDb.h:130
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
const QString & getSoftwareName() const
Definition: SgVersion.h:254
QString toString() const
Definition: SgVersion.h:356
bool storeStationCalCable(const QString &stnName, const SgMatrix *cal, const QString &origin, const QString &kind)
bool storeObsCalOcean(const SgMatrix *)
SgVdbVariable & vClockBreak()
Definition: SgVgosDb.h:349
bool storeEpochs4Obs(const QList< SgMJD > &)
bool storeClockSetup(const SgVector *interval, const SgVector *rateConstraint, const QList< QString > &sites, const QList< QString > &refSites)
bool storeObsGroupDelaysFull(const QString &band, const SgVector *groupDelays)
bool storeObsObjectNames(const QList< QString > &stations_1, const QList< QString > &stations_2, const QList< QString > &sources)
bool storeScanName(const QList< QString > &scanNames, const QList< QString > &scanFullNames)
bool storeObsCalPoleTideOldRestore(const SgMatrix *cals)
bool storeObsCrossRefs(const QList< int > &obs2scan, const QList< int > &obs2stn_1, const QList< int > &obs2stn_2)
bool storeObsEffFreqs(const QString &band, const SgMatrix *freqs, bool areEqWgts=false)
bool storeSessionHead(const QString &corrType, const QString &corrName, const QString &piName, const QString &experimentName, int experimentSerialNumber, const QString &experimentDescription, const QString &recordingMode, const QList< QString > &stations, const QList< QString > &sources, const SgMJD &tStart, const SgMJD &tFinis, int cppsIdx)
bool storeObsQualityCodes(const QString &band, const QVector< char > &qualityCodes)
bool storeObsSingleBandDelays(const QString &band, const SgMatrix *singleBandDelays)
bool storeSourceCrossRefs(const QList< QString > &sources, const QList< int > &scan2src)
bool storeObsPartRaDec(const SgMatrix *dV_dRA, const SgMatrix *dV_dDN)
bool storeObsPartParallax(const SgMatrix *part)
bool storeObsGroupDelays(const QString &band, const SgMatrix *groupDelays, const QString &kind)
void setCorrelatorType(CorrelatorType ct)
Definition: SgVgosDb.h:340
void setCurrentVersion(int ver)
Definition: SgVgosDb.h:324
bool storeStationCalOceanLoad(const QString &stnName, const SgMatrix *calHorzOLoad, const SgMatrix *calVertOLoad)
bool storeObsRefFreqs(const QString &band, const SgVector *rf)
bool storeObsCalBendSun(const SgMatrix *cals)
bool storeScanTimeMjd(const QList< SgMJD > &epochs)
bool storeStationCalSlantPathTropWet(const QString &stnName, const SgMatrix *cal, const QString &kind)
@ CT_VLBA
Definition: SgVgosDb.h:190
@ CT_Difx
Definition: SgVgosDb.h:196
@ CT_GSI
Definition: SgVgosDb.h:192
@ CT_Mk3
Definition: SgVgosDb.h:189
@ CT_Mk4
Definition: SgVgosDb.h:194
@ CT_Unknown
Definition: SgVgosDb.h:188
@ CT_CRL
Definition: SgVgosDb.h:191
bool storeObsCalPoleTide(const SgMatrix *, const QString &kind)
bool storeStationRefClockOffset(const QString &stnName, const SgVector *v)
bool storeObsCalBendSunHigher(const SgMatrix *cals)
bool storeObsPhaseCalInfo(const QString &band, SgVlbiSessionInfo::OriginType originType, const SgMatrix *phCalFrqs_1ByChan, const SgMatrix *phCalAmps_1ByChan, const SgMatrix *phCalPhss_1ByChan, const SgMatrix *phCalOffs_1ByChan, const SgVector *phCalRates_1, const SgMatrix *phCalFrqs_2ByChan, const SgMatrix *phCalAmps_2ByChan, const SgMatrix *phCalPhss_2ByChan, const SgMatrix *phCalOffs_2ByChan, const SgVector *phCalRates_2)
bool storeStationTsys(const QString &stnName, const SgMatrix *tsyses, const QVector< double > &frqs, const QVector< QString > &ids, const QVector< QString > &sbs, const QVector< QString > &polzs)
bool storeStationPartAxisOffset(const QString &stnName, const SgMatrix *partAxisOffset)
bool storeObsCalUnphase(const QString &band, const SgMatrix *phaseCal_1, const SgMatrix *phaseCal_2)
bool storeScanEphemeris(const SgMatrix *rSun, const SgMatrix *rMoon, const SgMatrix *rEarth, const SgMatrix *vSun, const SgMatrix *vMoon, const SgMatrix *vEarth, const SgMatrix *aEarth, const QString &kind)
bool storeClockApriories(const QList< QString > &siteNames, const SgMatrix *offsets_n_rates)
bool saveForeignHistory(const SgVlbiHistory &history, const QString &softwareName, const SgMJD &epochOfCreation, const QString &creator, const QString &defaultDir, const QString &historyFileName, const QString &version, bool isMk3Compatible=true)
bool storeMiscFourFit(const QString &band, SgVlbiSessionInfo::OriginType originType, const QVector< QString > &fourfitControlFile, const QVector< QString > &fourfitCommand, const QVector< int > &numLags, const QVector< double > &apLength)
bool storeEpochs4Scans(const QList< SgMJD > &)
bool storeStationCalAxisOffset(const QString &stnName, const SgMatrix *cal)
bool storeErpApriori(const SgVector *ut1_tai, const SgMatrix *pm)
bool storeCalibrations(int obsCalFlags, const QVector< int > &statCalFlags, const QVector< QVector< int > > &flybyFlags, const QVector< QString > &statCalNames, const QVector< QString > &flybyNames, const QVector< QString > &calSiteNames, const QVector< QString > &obsCalNames)
bool storeStationEpochs(const QString &stnName, const QList< SgMJD > &epochs)
bool storeIonoSetup(const QList< int > &flags, const QList< QString > &sites)
bool storeObsCalEarthTide(const SgMatrix *, const QString &kind)
bool storeSourcesApriories(const QList< QString > &sourcesNames, const QList< QString > &sourcesRefs, const SgMatrix *cooRaDe)
SgNetCdf::OperationMode getOperationMode() const
Definition: SgVgosDb.h:300
bool storeSolveWeights(const QVector< QString > &baselineNames, SgMatrix *groupBlWeights)
bool loadClockBreaks(QVector< QString > &cbNames, QVector< SgMJD > &cbEpochs, QVector< int > &cbFlags)
bool storeAtmSetup(const SgVector *interval, const SgVector *rateConstraint, const QList< QString > &sites)
bool storeObsCorrelation(const QString &band, const SgVector *correlations)
bool storeObsCalIonGroup(const QString &band, const SgMatrix *ionCals, const SgMatrix *ionSigmas, const QVector< int > &ionDataFlag)
bool storeObsCalParallax(const SgMatrix *cals)
bool storeStationsApriories(const QList< QString > &stationsNames, const SgMatrix *cooXYZ, const QList< QString > &tectonicPlateNames)
void setNumOfChannels(int num)
Definition: SgVgosDb.h:328
bool getHave2redoLeapSecond() const
Definition: SgVgosDb.h:292
bool storeObsCalWobble(const SgMatrix *, const SgMatrix *)
bool storeStationPartZenithDelayDry(const QString &stnName, const SgMatrix *part, const QString &kind)
bool storeScanNutationEqxWahr(const SgMatrix *pPsiEps, const SgMatrix *pPsiEps_rates)
bool storeScanTrf2crf(const SgMatrix *val, const SgMatrix *rat, const SgMatrix *acc)
bool storeScanCrootFname(const QList< QString > &corrRootFnames)
bool storeScanNutationNro(const SgMatrix *pXys, const SgMatrix *pXys_rates, const QString &kind)
bool storeObsNumGroupAmbigs(const QString &band, const QVector< int > &numAmbigs, const QVector< int > &numSubAmbigs)
bool storeObsSNR(const QString &band, const SgVector *snrs)
bool storeObsUVFperAsec(const QString &band, const SgMatrix *uvfPerAsec)
bool storeScanNutationEqx(const SgMatrix *pPsiEps, const SgMatrix *pPsiEps_rates, const QString &kind)
bool storeObsCalBend(const SgMatrix *cals)
bool storeObsPartBend(const SgMatrix *partBend)
bool storeLeapSecond(int leapSeconds)
bool storeStationParAngle(const QString &stnName, const SgVector *parAngle)
bool storeErpSetup(double pmOffsetConstraint, double utOffsetConstraint)
bool storeStationOceanLdDisp(const QString &stnName, const SgMatrix *dis, const SgMatrix *vel)
bool storeCalcInfo(const SgModelsInfo &calcInfo)
bool storeStationPartHorizonGrad(const QString &stnName, const SgMatrix *part, const QString &kind)
bool storeObsAmbigSpacing(const QString &band, const SgVector *ambigs)
bool storeObsRates(const QString &band, const SgMatrix *rates, const QString &kind)
bool storeObsCalHiFyErp(const SgMatrix *, const SgMatrix *, const QString &kind)
bool storeBaselineClockSetup(const QList< QString > &baselines)
bool storeAntennaApriories(const QList< QString > &stationsNames, const QList< int > &axisTypes, const SgVector *axisOffsets, const SgMatrix *axisTilts)
bool storeStationAzEl(const QString &stnName, SgMatrix *const azTheo, SgMatrix *const elTheo)
bool storeClockBreaks(const QVector< QString > &cbNames, const QVector< SgMJD > &cbEpochs, const QVector< int > &cbFlags, const QString &band="")
bool storeObsPartXYZ(const SgMatrix *dDel_dR_1, const SgMatrix *dRat_dR_1)
bool storeIonoBits(const QVector< int > &ionoBits)
bool storeObsCalHiFyLibration(const SgMatrix *, const SgMatrix *, const QString &kind)
bool storeMiscCable(const QMap< QString, QString > &cableSignByKey)
bool storeObsDelayTheoretical(const SgVector *v)
bool storeObsDtec(const SgVector *dTec, const SgVector *dTecStdDev)
bool storeObsCalOceanOld(const SgMatrix *)
bool storeStationCalSlantPathTropDry(const QString &stnName, const SgMatrix *cal, const QString &kind)
bool storeObsEditData(const QVector< int > &delUFlag, const QVector< int > &phsUFlag, const QVector< int > &ratUFlag, const QVector< int > &uAcSup)
bool storeObsPhaseDelaysFull(const QString &band, const SgVector *groupDelays, const SgVector *phaseDelaySigs)
bool storeObsRateTheoretical(const SgVector *v)
bool storeStationPartZenithDelayWet(const QString &stnName, const SgMatrix *part, const QString &kind)
bool storeObsCalOceanPoleTideLoad(const SgMatrix *)
bool storeStationMet(const QString &stnName, SgVector *const metAtmPres, SgVector *const metAtmRH, SgVector *const metAtmTemp, const QString &origin, const QString &kind)
bool storeObsPartNut2KXY(const SgMatrix *dV_dCipX, const SgMatrix *dV_dCipY, const QString &kind)
bool storeObsCorrelatorInfo(const QString &band, SgVlbiSessionInfo::OriginType originType, const QVector< QString > &fourfitOutputFName, const QVector< QString > &fourfitErrorCodes, const QVector< QString > &frqGrpCodes, const QVector< int > &corelVersions, const QVector< int > &startOffsets, const QVector< QVector< int > > &fourfitVersions, const QVector< QVector< int > > &dbeditVersion, const SgVector *deltaEpochs, const SgMatrix *urvrs, const SgMatrix *instrDelays, const SgMatrix *starElev, const SgMatrix *zenithDelays, const SgMatrix *searchParams, const QVector< QString > &baselineCodes, const QVector< QString > &tapeQualityCodes, const QVector< int > &stopOffsets, const QVector< int > &hopsRevisionNumbers, const SgVector *sampleRate, const SgVector *sbdResids, const SgVector *rateResids, const SgVector *effDurations, const SgVector *startSeconds, const SgVector *stopSeconds, const SgVector *percentOfDiscards, const SgVector *uniformityFactors, const SgVector *geocenterPhaseResids, const SgVector *geocenterPhaseTotals, const SgVector *geocenterSbDelays, const SgVector *geocenterGrDelays, const SgVector *geocenterDelayRates, const SgVector *probOfFalses, const SgVector *corrAprioriDelays, const SgVector *corrAprioriRates, const SgVector *corrAprioriAccs, const SgVector *incohAmps, const SgVector *incohAmps2, const SgVector *delayResids, const QVector< QString > &vlb1FileNames, const QVector< QString > &tapeIds_1, const QVector< QString > &tapeIds_2, const QVector< QVector< int > > &epochsOfCorrelations, const QVector< QVector< int > > &epochsOfCentrals, const QVector< QVector< int > > &epochsOfFourfitings, const QVector< QVector< int > > &epochsOfNominalScanTime, const SgMatrix *corrClocks, const SgMatrix *mDlys, const SgMatrix *mAux)
bool storeCalcEop(const SgVector *pmArrayInfo, const SgVector *utArrayInfo, const SgMatrix *pmValues, const SgVector *utValues, const SgModelsInfo &calcInfo)
bool storeObsPartEOP(const SgMatrix *dV_dPx, const SgMatrix *dV_dPy, const SgMatrix *dV_dUT1)
bool storeObsFractC(const SgVector *v)
bool storeObsDataFlag(const QString &band, const QVector< int > &dataFlags)
bool storeObsPhase(const QString &band, const SgMatrix *phases)
bool storeObsNumPhaseAmbigs(const QString &band, const QVector< int > &numAmbigs)
bool storeEccentricities(const QVector< QString > &stationsNames, const QVector< QString > &eccTypes, const QVector< QString > &eccNums, SgMatrix *eccVals, const QString &eccFileName)
bool storeSelectionStatus(const QVector< int > &sourcesSelection, const QVector< QVector< int > > &stationsSelection)
bool storeObsPartPoleTides(const SgMatrix *dV_dPtdX, const SgMatrix *dV_dPtdY, const QString &kind)
bool saveLocalHistory(const SgVlbiHistory &history)
bool storeObsPartGamma(const SgMatrix *part)
bool storeObsCalFeedCorr(const SgMatrix *)
SgVdbVariable & vClockApriori()
Definition: SgVgosDb.h:350
bool storeStationCrossRefs(const QList< int > &numScansPerStation, const QList< QString > &stations, const QMap< QString, QList< int > > &station2scan, const QMap< QString, QList< int > > &scan2station)
bool storeObsCalTiltRmvr(const SgMatrix *cals)
bool storeObsChannelInfo(const QString &band, SgVlbiSessionInfo::OriginType originType, const QVector< QString > &channelIds, const QVector< QString > &polarizations, const QVector< int > &numOfChannels, const QVector< int > &bitsPerSamples, const QVector< QVector< int > > &errorRates_1, const QVector< QVector< int > > &errorRates_2, const QVector< QVector< int > > &bbcIdxs_1, const QVector< QVector< int > > &bbcIdxs_2, const QVector< QVector< int > > &corelIdxNumbersUsb, const QVector< QVector< int > > &corelIdxNumbersLsb, const SgVector *sampleRate, const SgMatrix *residFringeAmplByChan, const SgMatrix *residFringePhseByChan, const SgMatrix *refFreqByChan, const SgMatrix *numOfSamplesByChan_USB, const SgMatrix *numOfSamplesByChan_LSB, const SgMatrix *numOfAccPeriodsByChan_USB, const SgMatrix *numOfAccPeriodsByChan_LSB, const SgMatrix *loFreqs_1, const SgMatrix *loFreqs_2)
double getDrat_dAxsOfs() const
double getCalcAxisOffset4Rate() const
double getDdel_dTzdGrdN() const
double getCableCalibration() const
double getCalcOLoadHorz4Delay() const
double getCalcOLoadVert4Rate() const
const QString & getTapeId() const
double getCalcAxisOffset4Delay() const
double getCalcOLoadVert4Delay() const
double getElevationAngle() const
double getDrat_dTzdWet() const
double getCalcNwetCont4Delay() const
const Sg3dVector & getOcnLdR() const
double getElevationAngleRate() const
double getDrat_dTzdGrdN() const
double getRefClockOffset() const
double getCalcNdryCont4Rate() const
double getCalcNdryCont4Delay() const
double getParallacticAngle() const
double getDdel_dTzdWet() const
double getCalcNwetCont4Rate() const
double getAzimuthAngle() const
double getDrat_dTzdDry() const
double getDdel_dTzdDry() const
double getAzimuthAngleRate() const
double getDdel_dAxsOfs() const
double getDrat_dTzdGrdE() const
double getCalcOLoadHorz4Rate() const
double getDdel_dTzdGrdE() const
const Sg3dVector & getOcnLdV() const
QMap< QString, SgVlbiStationInfo * > & stationsByName()
Definition: SgVlbiBand.h:368
SgVlbiHistory & history()
Definition: SgVlbiBand.h:360
@ Attr_ESTIMATE_CLOCKS
estimate baseline clocks;
@ Attr_NOT_VALID
omit the baseline;
void addHistoryRecord(const QString &, const SgMJD &t)
double getEffFreq() const
double getGeocenterValue() const
short int getUnweightFlag() const
double getAmbiguitySpacing() const
double ambiguity() const
double getValue() const
int getNumOfAmbiguities() const
double getSigma() const
double getIonoValue() const
double getEffFreqEqWgt() const
double getResidualFringeFitting() const
int getNumOfSubAmbigs() const
double getAlternateValue() const
void setUnweightFlag(short int)
double getIonoSigma() const
QVector< int > * corelIndexNumLSB()
const QString & getFourfitOutputFName() const
double getUvFrPerAsec(int i) const
double getPhaseCalGrDelays(int i) const
int getQualityFactor() const
const SgMJD & getEpochOfCorrelation() const
double getSampleRate() const
QVector< char > * polarization_1ByChan()
double getInstrDelay(int i) const
SgVector * loFreqByChan_1()
QVector< char > * chanIdByChan()
QVector< int > * corelIndexNumUSB()
double getFourfitSearchParameters(int i) const
int getNumOfChannels() const
const QString & getTapeQualityCode() const
SgMatrix * phaseCalData_2ByChan()
const QString & getErrorCode() const
const SgMJD & getEpochOfScan() const
double getIncohChanAddAmp() const
SgVector * numOfAccPeriodsByChan_LSB()
double getAcceptedRatio() const
const SgMJD & getEpochOfFourfitting() const
double getCalcFeedCorrDelay() const
double getProbabOfFalseDetection() const
QVector< char > * polarization_2ByChan()
SgVector * numOfAccPeriodsByChan_USB()
QVector< int > * bbcIdxByChan_1()
SgVlbiMeasurement & phDRate()
double getCorrelZdelay_1() const
double getGeocenterTotalPhase() const
double getEffIntegrationTime() const
const SgMJD & getTstop() const
double getCorrClocks(int i, int j) const
SgVector * fringeAmplitudeByChan()
SgVector * vAuxData()
int getStartOffset() const
double getUrVr(int i) const
double getCentrOffset() const
SgVector * numOfSamplesByChan_LSB()
double getAprioriDra(int i) const
double getCorrelStarElev_2() const
double getDiscardRatio() const
int getNlags() const
double getTotalPhase() const
SgVector * vDlys()
int getHopsRevisionNumber() const
int getFourfitVersion(int idx) const
const QString & getFourfitControlFile() const
double getIncohSegmAddAmp() const
int getStopOffset() const
double getSnr() const
SgMatrix * phaseCalData_1ByChan()
const QString & getBandKey() const
SgVector * numOfSamplesByChan_USB()
const QString & getFourfitCommandOverride() const
double getPhaseCalRates(int i) const
double getCalcFeedCorrRate() const
double getReferenceFrequency() const
SgVlbiMeasurement & phDelay()
double getCorrelStarElev_1() const
int getBitsPerSample() const
const SgMJD & getEpochCentral() const
double getCorrCoeff() const
SgVector * loFreqByChan_2()
SgVlbiMeasurement & grDelay()
SgVlbiMeasurement & sbDelay()
SgVector * fringePhaseByChan()
double getGeocenterResidPhase() const
SgVector * refFreqByChan()
int getMediaIdx() const
QVector< int > * bbcIdxByChan_2()
const SgMJD & getTstart() const
double getCorrelZdelay_2() const
double getDrat_dCipY() const
double getCalcCipXv() const
double getCalcNutWahr_dEpsV() const
double getCalcTiltRemvrRate() const
double getCalcPoleTideOldDelay() const
const Sg3dVector & getVearth() const
double getCalcCipSr() const
double getCalcTiltRemvrDelay() const
SgVlbiStationInfo * stn_1()
const Sg3dMatrix & getTrf2crfAcc() const
double getCalcOceanPoleTideLdDelay() const
double getCalcConsBendingSunRate() const
SgVlbiAuxObservation * auxObs_2()
double getCalcNutWahr_dPsiV() const
double getCalcPmX() const
SgVlbiSourceInfo * src()
double getCalcPxDelay() const
double getCalcOceanTideDelay() const
double getDdel_dDN() const
double getDdel_dParallaxRev() const
double getCalcOceanPoleTideLdRate() const
double getDTecStdDev() const
double getCalcNut2006_dPsiV() const
const Sg3dVector & getRmoon() const
const Sg3dMatrix & getTrf2crfVal() const
double getCalcCipYv() const
double getDrat_dGamma() const
double getCalcPyDelay() const
double getDdel_dBend() const
const Sg3dVector & getVsun() const
double getDdel_dPy() const
double getCalcConsBendingSunHigherRate() const
double getApLength() const
double getDrat_dPx() const
double getCalcNutWahr_dPsiR() const
double getDdel_dPolTideX() const
double getCalcConsBendingSunDelay() const
double getCalcCipXr() const
double getCalcPoleTideOldRate() const
double getCalcConsBendingSunHigherDelay() const
double getCalcNut2006_dEpsV() const
double getCalcConsBendingDelay() const
double getCalcEarthTideDelay() const
const Sg3dVector & getDdel_dR_1() const
double getCalcConsensusRate() const
double getFractC() const
double getCalcHiFyPxyRate() const
double getD2rat_dUT12() const
double getDrat_dCipX() const
double getCalcCipYr() const
double getDrat_dPolTideY() const
double getCalcPxRate() const
double getCalcPyRate() const
const Sg3dVector & getRearth() const
double getCalcPoleTideRate() const
double getDrat_dBend() const
double getCalcCipSv() const
double getCalcHiFyUt1LibrationRate() const
SgVlbiStationInfo * stn_2()
const Sg3dVector & getVmoon() const
const QString & getCorrRootFileName() const
double getDdel_dCipY() const
double getCalcNut2006_dPsiR() const
double getCalcHiFyPxyLibrationRate() const
double getDTec() const
SgVlbiObservable * observable(const QString &)
double getD2del_dUT12() const
double getDrat_dUT1() const
double getCalcConsBendingRate() const
const Sg3dMatrix & getTrf2crfRat() const
double getCalcEarthTideRate() const
const QString & getScanName() const
double getDdel_dPx() const
double getDrat_dPy() const
const Sg3dVector & getDrat_dR_1() const
QMap< QString, SgVlbiObservable * > & observableByKey()
double getCalcHiFyPxyLibrationDelay() const
const QString & getScanId() const
double getDrat_dPolTideX() const
double getCalcPmY() const
double getDdel_dUT1() const
double getDrat_dRA() const
double getDrat_dParallax() const
SgVlbiAuxObservation * auxObs_1()
double getDdel_dParallax() const
double getDdel_dGamma() const
double getCalcNut2006_dEpsR() const
double getCalcOceanTideRate() const
double getCalcNutWahr_dEpsR() const
double getCalcPoleTideDelay() const
double getCalcHiFyUt1Delay() const
const Sg3dVector & getRsun() const
double getCalcOceanTideOldDelay() const
double getCalcConsensusDelay() const
double getDdel_dPolTideY() const
double getDrat_dDN() const
const Sg3dVector & getAearth() const
double getCalcHiFyPxyDelay() const
double getCalcHiFyUt1Rate() const
double getCalcHiFyUt1LibrationDelay() const
double getDrat_dParallaxRev() const
double getCalcUt1_Tai() const
double getDdel_dCipX() const
double getDdel_dRA() const
double getCalcOceanTideOldRate() const
const QString & getCorrelatorType() const
@ OT_MK4
observations are from Mk4-compatible correlator output;
@ OT_AGV
observations are in AGV format;
@ OT_KOMB
observations are from KOMB output (generated by NICT, Japan);
CorrelatorPostProcSoftware cppsSoft_
@ Attr_FF_AUX_OBS_MODIFIED
station log related data were modified; //vgosDbProcLogs
@ Attr_FF_EDIT_INFO_MODIFIED
edit info has been modified by user;
@ Attr_FF_WEIGHTS_CORRECTED
weights have been corrected;
@ Attr_FF_ION_C_CALCULATED
ionospheric corrections have been calculated;
@ Attr_FF_CALC_DATA_MODIFIED
the theoretical values were modified; //vgosDbCalc
@ Attr_FF_PHASE_DEL_USED
station clocks or zenith delays were set.
@ Attr_FF_OUTLIERS_PROCESSED
outliers have been processed;
@ Attr_HAS_DTEC
the session contains diffTec values;
@ Attr_FF_AMBIGS_RESOLVED
ambiguities have been resolved;
@ Attr_FF_CREATED
the session has been imported from correlator;//vgosDbMake
SgMJD tFinis_
last epoch of the observations;
OriginType getOriginType() const
QString correlatorType_
Type of the correlator;.
QString sessionCode_
official session code (from Masterfile);
QString piAgencyName_
Name of P.I. organization.
QString description_
Experiment description;.
QString correlatorName_
Correlator Name (from MasterFile)
OriginType originType_
type of origin of the imported file(s);
QString name_
name of the session (e.g., 10JUL22XE);
SgMJD tStart_
first epoch of the observations;
StationsByName stationsByName_
QList< SgVlbiBand * > & bands()
QList< SgVlbiBand * > bands_
void formObsCalibrationSetup(int &bitFlags, QList< QString > &calList)
SgVector * args4PxyInterpolation_
double getLeapSeconds()
void makeHistoryIntro(SgVlbiHistory &)
QMap< QString, SgVlbiBand * > bandByKey_
QList< SgVlbiObservation * > observations_
SgVlbiHistory contemporaryHistory_
SgModelsInfo calcInfo_
BaselinesByName baselinesByName_
void makeHistory(SgVlbiHistory &)
SgParametersDescriptor * parametersDescriptor_
SgVlbiBand * primaryBand_
bool putDataIntoVgosDb(SgVgosDb *vgosDb)
static QString className()
SgVector * args4Ut1Interpolation_
SgMatrix * tabs4Ut1Interpolation_
SourcesByName sourcesByName_
SgTaskConfig * config_
SgMatrix * tabs4PxyInterpolation_
double getRA() const
double getDN() const
const QString & getAprioriReference() const
QMap< QString, SgVlbiAuxObservation * > * auxObservationByScanId()
void calcCBEpochs4Export(const QMap< QString, SgVlbiAuxObservation * > &)
QVector< QString > & tsysIfSideBands()
CableCalsOrigin getCableCalsOrigin() const
QVector< double > & tsysIfFreqs()
double getAxisOffset() const
QVector< QString > & tsysIfIds()
const QString & getTectonicPlateName() const
@ Attr_NOT_VALID
omit the station;
@ 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;
MeteoDataOrigin getMeteoDataOrigin() const
static int mntType2int(MountingType)
const SgParameterCfg & getPcClocks() const
const Sg3dVector & getR()
double getCableCalMultiplierDBCal() const
const SgParameterCfg & getPcZenith() const
const QString & getCableCalsOriginTxt() const
double getTilt(int i) const
MountingType getMntType() const
SgBreakModel & clockBreaks()
double getAPrioriClockTerm_1() const
bool getNeed2useAPrioriClocks() const
double getAPrioriClockTerm_0() const
const QString & getMeteoDataOriginTxt() const
QVector< QString > & tsysIfPolarizations()