General Purpose Geodetic Library
SgVgosDbStoreStation.cpp
Go to the documentation of this file.
1 /*
2  *
3  * This file is a part of Space Geodetic Library. The library is used by
4  * nuSolve, a part of CALC/SOLVE system, and designed to make analysis of
5  * geodetic VLBI observations.
6  * Copyright (C) 2010-2020 Sergei Bolotin.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 
24 
25 #include <math.h>
26 
27 #include <SgLogger.h>
28 #include <SgNetCdf.h>
29 #include <SgVgosDb.h>
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 /*=====================================================================================================*/
43 /* */
44 /* SgVgosDb implementation (continue -- loadStation part of vgosDb data tree) */
45 /* */
46 /*=====================================================================================================*/
47 //
48 //
49 bool SgVgosDb::storeStationEpochs(const QString& stnName, const QList<SgMJD>& epochs)
50 {
51  if (!stnDescriptorByName_.contains(stnName))
52  {
54  "::storeStationEpochs(): unknown station " + stnName);
55  return false;
56  };
58  SgVdbVariable &var=dscr->vTimeUTC_;
59  SgNetCdf ncdf(path2RootDir_ + "/" +
61  sessionCode_, stnName, "");
62  //
63  if (dscr->numOfPts_ != epochs.size())
64  {
66  "::storeStationEpochs(): size mismatch: " +
67  QString("").sprintf("%d vs %d", dscr->numOfPts_, epochs.size()));
68  return false;
69  };
70  //
75  if (!setupFormat(fcfTimeUTC, ncdf, stnName))
76  {
78  "::storeStationEpochs(): format description failed");
79  return false;
80  };
81  ncdf.setServiceVars(var.getStub(), "Data are extracted from correlator files", "", "");
83  fcYmdhm .setHave2hideLCode(false);
84  //
85  //
86  double dSec;
87  int nYear, nMonth, nDay, nHour, nMin;
88  double *pS=ncdf.lookupVar(fcSecond.name())->data2double();
89  short *pD=ncdf.lookupVar(fcYmdhm .name())->data2short();
90 // short *pU=ncdf.lookupVar(fcUtc4 .name())->data2short();
91  for (int i=0; i<dscr->numOfPts_; i++)
92  {
93  epochs.at(i).toYMDHMS_tr(nYear, nMonth, nDay, nHour, nMin, dSec);
94  pD[5*i + 0] = nYear;
95  pD[5*i + 1] = nMonth;
96  pD[5*i + 2] = nDay;
97  pD[5*i + 3] = nHour;
98  pD[5*i + 4] = nMin;
99  pS[i] = dSec;
100 /*
101  pU[6*i + 0] = nYear;
102  pU[6*i + 1] = nMonth;
103  pU[6*i + 2] = nDay;
104  pU[6*i + 3] = nHour;
105  pU[6*i + 4] = nMin;
106  pU[6*i + 5] = round(dSec);
107 */
108  };
109  // write data:
111  if (!ncdf.putData())
112  {
114  "::storeStationEpochs(): cannot put data into " + ncdf.getFileName());
115  return false;
116  };
119  "::storeStationEpochs(): the data were successfully stored in " + ncdf.getFileName());
120  return true;
121 };
122 
123 
124 
125 //
126 bool SgVgosDb::storeStationCalCable(const QString& stnName, const SgMatrix* cal,
127  const QString& origin, const QString& kind)
128 {
129  if (!stnDescriptorByName_.contains(stnName))
130  {
132  "::storeStationCalCable(): unknown station " + stnName);
133  return false;
134  };
136  SgVdbVariable &var=dscr->vCal_Cable_;
137  //
138  var.setKind(kind); // empty is ok too
139  //
140  //
141  SgNetCdf ncdf(path2RootDir_ + "/" +
143  sessionCode_, stnName, "");
144  //
145  if (dscr->numOfPts_ != (int)cal->nRow())
146  {
148  "::storeStationCalCable(): cable cal size mismatch: " +
149  QString("").sprintf("%d vs %d", dscr->numOfPts_, cal->nRow()));
150  return false;
151  };
152  //
153  if (!setupFormat(fcfCalCable, ncdf, stnName))
154  {
156  "::storeStationCalCable(): format description failed for " + stnName);
157  return false;
158  };
159  ncdf.setServiceVars(var.getStub(), origin, "StationScan", "TimeUTC.nc");
160  //
161  double *pC=ncdf.lookupVar(fcCalCable.name())->data2double();
162  for (int i=0; i<dscr->numOfPts_; i++)
163  pC[i] = cal->getElement(i, 0);
164  // write data:
166  if (!ncdf.putData())
167  {
169  "::storeStationCalCable(): cannot put data into " + ncdf.getFileName());
170  return false;
171  };
174  "::storeStationCalCable(): the data were successfully stored in " + ncdf.getFileName());
175  return true;
176 };
177 
178 
179 
180 //
181 bool SgVgosDb::storeStationCalCblCorrections(const QString& stnName, const SgMatrix* cal,
182  const QString& origin /*, const QString& kind*/)
183 {
184  if (!stnDescriptorByName_.contains(stnName))
185  {
187  "::storeStationCalCblCorrections(): unknown station " + stnName);
188  return false;
189  };
192  //
193  // var.setKind(kind); // empty is ok too
194  //
195  //
196  SgNetCdf ncdf(path2RootDir_ + "/" +
198  sessionCode_, stnName, "");
199  //
200  if (dscr->numOfPts_ != (int)cal->nRow())
201  {
203  "::storeStationCalCblCorrections(): cable cal size mismatch: " +
204  QString("").sprintf("%d vs %d", dscr->numOfPts_, cal->nRow()));
205  return false;
206  };
207  //
208  if (!setupFormat(fcfCalCblCorrections, ncdf, stnName))
209  {
211  "::storeStationCalCblCorrections(): format description failed for " + stnName);
212  return false;
213  };
214  ncdf.setServiceVars(var.getStub(), origin, "StationScan", "TimeUTC.nc");
215  //
216  double *pC=ncdf.lookupVar(fcCalCblCorrections.name())->data2double();
217  for (int i=0; i<dscr->numOfPts_; i++)
218  {
219  pC[3*i ] = cal->getElement(i, 0);
220  pC[3*i + 1] = cal->getElement(i, 1);
221  pC[3*i + 2] = cal->getElement(i, 2);
222 
223  };
224  //
225  // write data:
227  if (!ncdf.putData())
228  {
230  "::storeStationCalCblCorrections(): cannot put data into " + ncdf.getFileName());
231  return false;
232  };
235  "::storeStationCalCblCorrections(): the data were successfully stored in " + ncdf.getFileName());
236  return true;
237 };
238 
239 
240 
241 //
242 bool SgVgosDb::storeStationMet(const QString& stnName,
243  SgVector*const metAtmPres, SgVector*const metAtmRH, SgVector*const metAtmTemp,
244  const QString& origin, const QString& kind)
245 {
246  if (!stnDescriptorByName_.contains(stnName))
247  {
249  "::storeStationMet(): unknown station " + stnName);
250  return false;
251  };
253  SgVdbVariable &var=dscr->vMet_;
254  //
255  var.setKind(kind); // empty is ok too
256  //
257  //
258  SgNetCdf ncdf(path2RootDir_ + "/" +
260  sessionCode_, stnName, "");
261  //
262  if (dscr->numOfPts_ != (int)metAtmPres->n())
263  {
265  "::storeStationMet(): atm.pressure size mismatch: " +
266  QString("").sprintf("%d vs %d", dscr->numOfPts_, metAtmPres->n()));
267  return false;
268  };
269  if (dscr->numOfPts_ != (int)metAtmRH->n())
270  {
272  "::storeStationMet(): atm.rel.humidity size mismatch: " +
273  QString("").sprintf("%d vs %d", dscr->numOfPts_, metAtmRH->n()));
274  return false;
275  };
276  if (dscr->numOfPts_ != (int)metAtmTemp->n())
277  {
279  "::storeStationMet(): atm.temperature size mismatch: " +
280  QString("").sprintf("%d vs %d", dscr->numOfPts_, metAtmTemp->n()));
281  return false;
282  };
283  //
284  if (!setupFormat(fcfMet, ncdf, stnName))
285  {
287  "::storeStationMet(): format description failed for " + stnName);
288  return false;
289  };
290  ncdf.setServiceVars(var.getStub(), origin, "StationScan", "TimeUTC.nc");
291  //
292  double *pT=ncdf.lookupVar(fcTempC .name())->data2double();
293  double *pP=ncdf.lookupVar(fcAtmPres.name())->data2double();
294  double *pH=ncdf.lookupVar(fcRelHum .name())->data2double();
295  for (int i=0; i<dscr->numOfPts_; i++)
296  {
297  pP[i] = metAtmPres->getElement(i);
298  pH[i] = metAtmRH ->getElement(i);
299  pT[i] = metAtmTemp->getElement(i);
300  };
301  // write data:
303  if (!ncdf.putData())
304  {
306  "::storeStationMet(): cannot put data into " + ncdf.getFileName());
307  return false;
308  };
311  "::storeStationMet(): the data were successfully stored in " + ncdf.getFileName());
312  return true;
313 };
314 
315 
316 
317 //
318 bool SgVgosDb::storeStationAzEl(const QString& stnName, SgMatrix*const azTheo, SgMatrix*const elTheo)
319 {
320  if (!stnDescriptorByName_.contains(stnName))
321  {
323  "::storeStationAzEl(): unknown station " + stnName);
324  return false;
325  };
327  SgVdbVariable &var=dscr->vAzEl_;
328  // !!!
329 // var.setSubDir(stnName.simplified());
330  //
331  SgNetCdf ncdf(path2RootDir_ + "/" +
333  sessionCode_, stnName, "");
334  //
335  if (dscr->numOfPts_ != (int)azTheo->nRow())
336  {
338  "::storeStationAzEl(): azimuth size mismatch: " +
339  QString("").sprintf("%d vs %d", dscr->numOfPts_, azTheo->nRow()));
340  return false;
341  };
342  if (dscr->numOfPts_ != (int)elTheo->nRow())
343  {
345  "::storeStationAzEl(): elevation size mismatch: " +
346  QString("").sprintf("%d vs %d", dscr->numOfPts_, elTheo->nRow()));
347  return false;
348  };
349  //
350  if (!setupFormat(fcfAzEl, ncdf, stnName))
351  {
353  "::storeStationAzEl(): format description failed");
354  return false;
355  };
356  ncdf.setServiceVars(var.getStub(), "Data are provided by CALC or similar software",
357  "StationScan", "TimeUTC.nc");
358  //
359  double *pAz=ncdf.lookupVar(fcAzTheo.name())->data2double();
360  double *pEl=ncdf.lookupVar(fcElTheo.name())->data2double();
361  for (int i=0; i<dscr->numOfPts_; i++)
362  {
363  pAz[2*i ] = azTheo->getElement(i, 0);
364  pAz[2*i + 1] = azTheo->getElement(i, 1);
365  pEl[2*i ] = elTheo->getElement(i, 0);
366  pEl[2*i + 1] = elTheo->getElement(i, 1);
367  };
368  // write data:
370  if (!ncdf.putData())
371  {
373  "::storeStationAzEl(): cannot put data into " + ncdf.getFileName());
374  return false;
375  };
378  "::storeStationAzEl(): the data were successfully stored in " + ncdf.getFileName());
379  return true;
380 };
381 
382 
383 
384 //
385 bool SgVgosDb::storeStationPartAxisOffset(const QString& stnName, const SgMatrix* partAxisOffset)
386 {
387  if (!stnDescriptorByName_.contains(stnName))
388  {
390  "::storeStationPartAxisOffset(): unknown station " + stnName);
391  return false;
392  };
394  SgVdbVariable &var=dscr->vPart_AxisOffset_;
395  // !!!
396 // var.setSubDir(stnName.simplified());
397  //
398  SgNetCdf ncdf(path2RootDir_ + "/" +
400  sessionCode_, stnName, "");
401  //
402  if (dscr->numOfPts_ != (int)partAxisOffset->nRow())
403  {
405  "::storeStationPartAxisOffset(): the size mismatch: " +
406  QString("").sprintf("%d vs %d", dscr->numOfPts_, partAxisOffset->nRow()));
407  return false;
408  };
409  //
410  if (!setupFormat(fcfPartAxisOffset, ncdf, stnName))
411  {
413  "::storeStationPartAxisOffset(): format description failed");
414  return false;
415  };
416  ncdf.setServiceVars(var.getStub(), "Data are provided by CALC or similar software",
417  "StationScan", "TimeUTC.nc");
418  //
419  double *p=ncdf.lookupVar(fcPartAxisOffset.name())->data2double();
420  for (int i=0; i<dscr->numOfPts_; i++)
421  {
422  p[2*i ] = partAxisOffset->getElement(i, 0);
423  p[2*i + 1] = partAxisOffset->getElement(i, 1);
424  };
425  // write data:
427  if (!ncdf.putData())
428  {
430  "::storeStationPartAxisOffset(): cannot put data into " + ncdf.getFileName());
431  return false;
432  };
435  "::storeStationPartAxisOffset(): the data were successfully stored in " + ncdf.getFileName());
436  return true;
437 };
438 
439 
440 
441 //
442 bool SgVgosDb::storeStationParAngle(const QString& stnName, const SgVector* parAngle)
443 {
444  if (!stnDescriptorByName_.contains(stnName))
445  {
447  "::storeStationParAngle(): unknown station [" + stnName + "]");
448  return false;
449  };
451  SgVdbVariable &var=dscr->vFeedRotation_;
452  // !!!
453 // var.setSubDir(stnName.simplified());
454  //
455  SgNetCdf ncdf(path2RootDir_ + "/" +
457  sessionCode_, stnName, "");
458  //
459  if (dscr->numOfPts_ != (int)parAngle->n())
460  {
462  "::storeStationParAngle(): the size mismatch: " +
463  QString("").sprintf("%d vs %d", dscr->numOfPts_, parAngle->n()));
464  return false;
465  };
466  //
467  if (!setupFormat(fcfFeedRotation, ncdf, stnName))
468  {
470  "::storeStationParAngle(): format description failed");
471  return false;
472  };
473  ncdf.setServiceVars(var.getStub(), "Data are provided by CALC or similar software",
474  "StationScan", "TimeUTC.nc");
475  //
476  double *p=ncdf.lookupVar(fcFeedRotation.name())->data2double();
477  for (int i=0; i<dscr->numOfPts_; i++)
478  p[i] = parAngle->getElement(i);
479  // write data:
481  if (!ncdf.putData())
482  {
484  "::storeStationParAngle(): cannot put data into " + ncdf.getFileName());
485  return false;
486  };
489  "::storeStationParAngle(): the data were successfully stored in " + ncdf.getFileName());
490  return true;
491 };
492 
493 
494 
495 //
496 bool SgVgosDb::storeStationCalAxisOffset(const QString& stnName, const SgMatrix* cal)
497 {
498  if (!stnDescriptorByName_.contains(stnName))
499  {
501  "::storeStationCalAxisOffset(): unknown station " + stnName);
502  return false;
503  };
505  SgVdbVariable &var=dscr->vCal_AxisOffset_;
506  // !!!
507 // var.setSubDir(stnName.simplified());
508  //
509  SgNetCdf ncdf(path2RootDir_ + "/" +
511  sessionCode_, stnName, "");
512  //
513  if (dscr->numOfPts_ != (int)cal->nRow())
514  {
516  "::storeStationCalAxisOffset(): the size mismatch: " +
517  QString("").sprintf("%d vs %d", dscr->numOfPts_, cal->nRow()));
518  return false;
519  };
520  //
521  if (!setupFormat(fcfCalAxisOffset, ncdf, stnName))
522  {
524  "::storeStationCalAxisOffset(): format description failed");
525  return false;
526  };
527  ncdf.setServiceVars(var.getStub(), "Data are provided by CALC or similar software",
528  "StationScan", "TimeUTC.nc");
529  //
530  double *p=ncdf.lookupVar(fcCalAxisOffset.name())->data2double();
531  for (int i=0; i<dscr->numOfPts_; i++)
532  {
533  p[2*i ] = cal->getElement(i, 0);
534  p[2*i + 1] = cal->getElement(i, 1);
535  };
536  // write data:
538  if (!ncdf.putData())
539  {
541  "::storeStationCalAxisOffset(): cannot put data into " + ncdf.getFileName());
542  return false;
543  };
546  "::storeStationCalAxisOffset(): the data were successfully stored in " + ncdf.getFileName());
547  return true;
548 };
549 
550 
551 
552 //
553 bool SgVgosDb::storeStationCalSlantPathTropDry(const QString& stnName, const SgMatrix* cal,
554  const QString& kind)
555 {
556  if (!stnDescriptorByName_.contains(stnName))
557  {
559  "::storeStationCalSlantPathTropDry(): unknown station " + stnName);
560  return false;
561  };
564  //
565  var.setKind(kind); // empty is ok too
566  //
567  //
568  SgNetCdf ncdf(path2RootDir_ + "/" +
570  sessionCode_, stnName, "");
571  //
572  if (dscr->numOfPts_ != (int)cal->nRow())
573  {
575  "::storeStationCalSlantPathTropDry(): the size mismatch: " +
576  QString("").sprintf("%d vs %d", dscr->numOfPts_, cal->nRow()));
577  return false;
578  };
579  //
580  if (!setupFormat(fcfCalSlantPathTropDry, ncdf, stnName))
581  {
583  "::storeStationCalSlantPathTropDry(): format description failed");
584  return false;
585  };
586  ncdf.setServiceVars(var.getStub(), "Data are provided by CALC or similar software",
587  "StationScan", "TimeUTC.nc");
588  //
589  double *p=ncdf.lookupVar(fcCalSlantPathTropDry.name())->data2double();
590  for (int i=0; i<dscr->numOfPts_; i++)
591  {
592  p[2*i ] = cal->getElement(i, 0);
593  p[2*i + 1] = cal->getElement(i, 1);
594  };
595  // write data:
597  if (!ncdf.putData())
598  {
600  "::storeStationCalSlantPathTropDry(): cannot put data into " + ncdf.getFileName());
601  return false;
602  };
605  "::storeStationCalSlantPathTropDry(): the data were successfully stored in " + ncdf.getFileName());
606  return true;
607 };
608 
609 
610 
611 //
612 bool SgVgosDb::storeStationCalSlantPathTropWet(const QString& stnName, const SgMatrix* cal,
613  const QString& kind)
614 {
615  if (!stnDescriptorByName_.contains(stnName))
616  {
618  "::storeStationCalSlantPathTropWet(): unknown station " + stnName);
619  return false;
620  };
623  //
624  var.setKind(kind); // empty is ok too
625  //
626  //
627  SgNetCdf ncdf(path2RootDir_ + "/" +
629  sessionCode_, stnName, "");
630  //
631  if (dscr->numOfPts_ != (int)cal->nRow())
632  {
634  "::storeStationCalSlantPathTropWet(): the size mismatch: " +
635  QString("").sprintf("%d vs %d", dscr->numOfPts_, cal->nRow()));
636  return false;
637  };
638  //
639  if (!setupFormat(fcfCalSlantPathTropWet, ncdf, stnName))
640  {
642  "::storeStationCalSlantPathTropWet(): format description failed");
643  return false;
644  };
645  ncdf.setServiceVars(var.getStub(), "Data are provided by CALC or similar software",
646  "StationScan", "TimeUTC.nc");
647  //
648  double *p=ncdf.lookupVar(fcCalSlantPathTropWet.name())->data2double();
649  for (int i=0; i<dscr->numOfPts_; i++)
650  {
651  p[2*i ] = cal->getElement(i, 0);
652  p[2*i + 1] = cal->getElement(i, 1);
653  };
654  // write data:
656  if (!ncdf.putData())
657  {
659  "::storeStationCalSlantPathTropWet(): cannot put data into " + ncdf.getFileName());
660  return false;
661  };
664  "::storeStationCalSlantPathTropWet(): the data were successfully stored in " + ncdf.getFileName());
665  return true;
666 };
667 
668 
669 
670 //
671 bool SgVgosDb::storeStationCalOceanLoad(const QString& stnName,
672  const SgMatrix* calHorzOLoad, const SgMatrix* calVertOLoad)
673 {
674  if (!stnDescriptorByName_.contains(stnName))
675  {
677  "::storeStationCalOceanLoad(): unknown station " + stnName);
678  return false;
679  };
681  SgVdbVariable &var=dscr->vCal_OceanLoad_;
682  // !!!
683 // var.setSubDir(stnName.simplified());
684  //
685  SgNetCdf ncdf(path2RootDir_ + "/" +
687  sessionCode_, stnName, "");
688  //
689  if (dscr->numOfPts_ != (int)calHorzOLoad->nRow())
690  {
692  "::storeStationCalOceanLoad(): the matrix HorzOLoad size mismatch: " +
693  QString("").sprintf("%d vs %d", dscr->numOfPts_, calHorzOLoad->nRow()));
694  return false;
695  };
696  //
697  if (dscr->numOfPts_ != (int)calVertOLoad->nRow())
698  {
700  "::storeStationCalOceanLoad(): the matrix VertOLoad size mismatch: " +
701  QString("").sprintf("%d vs %d", dscr->numOfPts_, calVertOLoad->nRow()));
702  return false;
703  };
704  //
705  if (!setupFormat(fcfCalStationOceanLoad, ncdf, stnName))
706  {
708  "::storeStationCalOceanLoad(): format description failed");
709  return false;
710  };
711  ncdf.setServiceVars(var.getStub(), "Data are provided by CALC or similar software",
712  "StationScan", "TimeUTC.nc");
713  //
715  double *pV=ncdf.lookupVar(fcCalStationOceanLoadVert .name())->data2double();
716  for (int i=0; i<dscr->numOfPts_; i++)
717  {
718  pH[2*i ] = calHorzOLoad->getElement(i, 0);
719  pH[2*i + 1] = calHorzOLoad->getElement(i, 1);
720  pV[2*i ] = calVertOLoad->getElement(i, 0);
721  pV[2*i + 1] = calVertOLoad->getElement(i, 1);
722  };
723  // write data:
725  if (!ncdf.putData())
726  {
728  "::storeStationCalOceanLoad(): cannot put data into " + ncdf.getFileName());
729  return false;
730  };
733  "::storeStationCalOceanLoad(): the data were successfully stored in " + ncdf.getFileName());
734  return true;
735 };
736 
737 
738 
739 //
740 bool SgVgosDb::storeStationOceanLdDisp(const QString& stnName, const SgMatrix* dis, const SgMatrix* vel)
741 {
742  if (!stnDescriptorByName_.contains(stnName))
743  {
745  "::storeStationOceanLdDisp(): unknown station " + stnName);
746  return false;
747  };
749  SgVdbVariable &var=dscr->vDis_OceanLoad_;
750  // !!!
751 // var.setSubDir(stnName.simplified());
752  //
753  SgNetCdf ncdf(path2RootDir_ + "/" +
755  sessionCode_, stnName, "");
756  //
757  if (dscr->numOfPts_ != (int)dis->nRow())
758  {
760  "::storeStationOceanLdDisp(): the matrix dis size mismatch: " +
761  QString("").sprintf("%d vs %d", dscr->numOfPts_, dis->nRow()));
762  return false;
763  };
764  //
765  if (dscr->numOfPts_ != (int)vel->nRow())
766  {
768  "::storeStationOceanLdDisp(): the matrix vel size mismatch: " +
769  QString("").sprintf("%d vs %d", dscr->numOfPts_, vel->nRow()));
770  return false;
771  };
772  //
773  if (!setupFormat(fcfDisOceanLoad, ncdf, stnName))
774  {
776  "::storeStationOceanLdDisp(): format description failed");
777  return false;
778  };
779  ncdf.setServiceVars(var.getStub(), "Data are provided by CALC or similar software",
780  "StationScan", "TimeUTC.nc");
781  //
782  double *p=ncdf.lookupVar(fcDisOceanLoad.name())->data2double();
783  for (int i=0; i<dscr->numOfPts_; i++)
784  {
785  p[6*i ] = dis->getElement(i, 0);
786  p[6*i + 1] = dis->getElement(i, 1);
787  p[6*i + 2] = dis->getElement(i, 2);
788  p[6*i + 3] = vel->getElement(i, 0);
789  p[6*i + 4] = vel->getElement(i, 1);
790  p[6*i + 5] = vel->getElement(i, 2);
791  };
792  // write data:
794  if (!ncdf.putData())
795  {
797  "::storeStationOceanLdDisp(): cannot put data into " + ncdf.getFileName());
798  return false;
799  };
802  "::storeStationOceanLdDisp(): the data were successfully stored in " + ncdf.getFileName());
803  return true;
804 };
805 
806 
807 
808 //
809 bool SgVgosDb::storeStationPartZenithDelayDry(const QString& stnName, const SgMatrix* part,
810  const QString& kind)
811 {
812  if (!stnDescriptorByName_.contains(stnName))
813  {
815  "::storeStationPartZenithDelayDry(): unknown station " + stnName);
816  return false;
817  };
820  //
821  var.setKind(kind); // empty is ok too
822  //
823  //
824  SgNetCdf ncdf(path2RootDir_ + "/" +
826  sessionCode_, stnName, "");
827  //
828  if (dscr->numOfPts_ != (int)part->nRow())
829  {
831  "::storeStationPartZenithDelayDry(): the size mismatch: " +
832  QString("").sprintf("%d vs %d", dscr->numOfPts_, part->nRow()));
833  return false;
834  };
835  //
836  if (!setupFormat(fcfPartZenithPathTropDry, ncdf, stnName))
837  {
839  "::storeStationPartZenithDelayDry(): format description failed");
840  return false;
841  };
842  ncdf.setServiceVars(var.getStub(), "Data are provided by CALC or similar software",
843  "StationScan", "TimeUTC.nc");
844  //
845  double *p=ncdf.lookupVar(fcPartZenithPathTropDry.name())->data2double();
846  for (int i=0; i<dscr->numOfPts_; i++)
847  {
848  p[2*i ] = part->getElement(i, 0);
849  p[2*i + 1] = part->getElement(i, 1);
850  };
851  // write data:
853  if (!ncdf.putData())
854  {
856  "::storeStationPartZenithDelayDry(): cannot put data into " + ncdf.getFileName());
857  return false;
858  };
861  "::storeStationPartZenithDelayDry(): the data successfully stored in " + ncdf.getFileName());
862  return true;
863 };
864 
865 
866 
867 //
868 bool SgVgosDb::storeStationPartZenithDelayWet(const QString& stnName, const SgMatrix* part,
869  const QString& kind)
870 {
871  if (!stnDescriptorByName_.contains(stnName))
872  {
874  "::storeStationPartZenithDelayWet(): unknown station " + stnName);
875  return false;
876  };
879  //
880  var.setKind(kind); // empty is ok too
881  //
882  //
883  SgNetCdf ncdf(path2RootDir_ + "/" +
885  sessionCode_, stnName, "");
886  //
887  if (dscr->numOfPts_ != (int)part->nRow())
888  {
890  "::storeStationPartZenithDelayWet(): the size mismatch: " +
891  QString("").sprintf("%d vs %d", dscr->numOfPts_, part->nRow()));
892  return false;
893  };
894  //
895  if (!setupFormat(fcfPartZenithPathTropWet, ncdf, stnName))
896  {
898  "::storeStationPartZenithDelayWet(): format description failed");
899  return false;
900  };
901  ncdf.setServiceVars(var.getStub(), "Data are provided by CALC or similar software",
902  "StationScan", "TimeUTC.nc");
903  //
904  double *p=ncdf.lookupVar(fcPartZenithPathTropWet.name())->data2double();
905  for (int i=0; i<dscr->numOfPts_; i++)
906  {
907  p[2*i ] = part->getElement(i, 0);
908  p[2*i + 1] = part->getElement(i, 1);
909  };
910  // write data:
912  if (!ncdf.putData())
913  {
915  "::storeStationPartZenithDelayWet(): cannot put data into " + ncdf.getFileName());
916  return false;
917  };
920  "::storeStationPartZenithDelayWet(): the data successfully stored in " + ncdf.getFileName());
921  return true;
922 };
923 
924 
925 
926 //
927 bool SgVgosDb::storeStationPartHorizonGrad(const QString& stnName, const SgMatrix* part,
928  const QString& kind)
929 {
930  if (!stnDescriptorByName_.contains(stnName))
931  {
933  "::storeStationPartHorizonGrad(): unknown station " + stnName);
934  return false;
935  };
938  //
939  var.setKind(kind); // empty is ok too
940  //
941  //
942  SgNetCdf ncdf(path2RootDir_ + "/" +
944  sessionCode_, stnName, "");
945  //
946  if (dscr->numOfPts_ != (int)part->nRow())
947  {
949  "::storeStationPartHorizonGrad(): the size mismatch: " +
950  QString("").sprintf("%d vs %d", dscr->numOfPts_, part->nRow()));
951  return false;
952  };
953  //
954  if (!setupFormat(fcfPartHorizonGrad, ncdf, stnName))
955  {
957  "::storeStationPartHorizonGrad(): format description failed");
958  return false;
959  };
960  ncdf.setServiceVars(var.getStub(), "Data are provided by CALC or similar software",
961  "StationScan", "TimeUTC.nc");
962  //
963  double *p=ncdf.lookupVar(fcPartHorizonGrad.name())->data2double();
964  for (int i=0; i<dscr->numOfPts_; i++)
965  {
966  p[4*i ] = part->getElement(i, 0);
967  p[4*i + 1] = part->getElement(i, 1);
968  p[4*i + 2] = part->getElement(i, 2);
969  p[4*i + 3] = part->getElement(i, 3);
970  };
971  // write data:
973  if (!ncdf.putData())
974  {
976  "::storeStationPartHorizonGrad(): cannot put data into " + ncdf.getFileName());
977  return false;
978  };
981  "::storeStationPartHorizonGrad(): the data successfully stored in " + ncdf.getFileName());
982  return true;
983 };
984 
985 
986 
987 //
988 bool SgVgosDb::storeStationRefClockOffset(const QString& stnName, const SgVector* v)
989 {
990  if (!stnDescriptorByName_.contains(stnName))
991  {
993  "::storeStationRefClockOffset(): unknown station " + stnName);
994  return false;
995  };
997  SgVdbVariable &var=dscr->vRefClockOffset_;
998  // !!!
999 // var.setSubDir(stnName.simplified());
1000  //
1001  SgNetCdf ncdf(path2RootDir_ + "/" +
1003  sessionCode_, stnName, "");
1004  //
1005  if (dscr->numOfPts_ != (int)v->n())
1006  {
1008  "::storeStationRefClockOffset(): vector v size mismatch: " +
1009  QString("").sprintf("%d vs %d", dscr->numOfPts_, v->n()));
1010  return false;
1011  };
1012  //
1013  if (!setupFormat(fcfRefClockOffset, ncdf, stnName))
1014  {
1016  "::storeStationRefClockOffset(): format description failed");
1017  return false;
1018  };
1019  ncdf.setServiceVars(var.getStub(), "KOMB correlator files",
1020  "StationScan", "TimeUTC.nc");
1021  //
1022  double *p=ncdf.lookupVar(fcRefClockOffset.name())->data2double();
1023  for (int i=0; i<dscr->numOfPts_; i++)
1024  p[i] = v->getElement(i);
1025  // write data:
1027  if (!ncdf.putData())
1028  {
1030  "::storeStationRefClockOffset(): cannot put data into " + ncdf.getFileName());
1031  return false;
1032  };
1035  "::storeStationRefClockOffset(): the data were successfully stored in " + ncdf.getFileName());
1036  return true;
1037 };
1038 
1039 
1040 
1041 //
1042 bool SgVgosDb::storeStationTsys(const QString& stnName, const SgMatrix* tsyses,
1043  const QVector<double>& frqs, const QVector<QString>& ids, const QVector<QString>& sbs,
1044  const QVector<QString>& polzs)
1045 {
1046  if (!stnDescriptorByName_.contains(stnName))
1047  {
1049  "::storeStationTsys(): unknown station " + stnName);
1050  return false;
1051  };
1052  StationDescriptor *dscr=stnDescriptorByName_[stnName];
1053  SgVdbVariable &var=dscr->vTsys_;
1054  // !!!
1055 // var.setSubDir(stnName.simplified());
1056  //
1057  SgNetCdf ncdf(path2RootDir_ + "/" +
1059  sessionCode_, stnName, "");
1060  //
1061  if (dscr->numOfPts_ != (int)tsyses->nRow())
1062  {
1064  "::storeStationTsys(): matrix tsyses size mismatch: " +
1065  QString("").sprintf("%d vs %d", dscr->numOfPts_, tsyses->nRow()));
1066  return false;
1067  };
1068  //
1069  //
1070  int numChans;
1071  numChans = tsyses->nCol();
1072  if (numChans != frqs.size())
1073  {
1075  "::storeStationTsys(): array of frqs size mismatch: " +
1076  QString("").sprintf("%d vs %d", numChans, frqs.size()));
1077  return false;
1078  };
1079  if (numChans != ids.size())
1080  {
1082  "::storeStationTsys(): array of ids size mismatch: " +
1083  QString("").sprintf("%d vs %d", numChans, ids.size()));
1084  return false;
1085  };
1086 
1087  int lIds, lSbs, lPzs;
1088  lIds = lSbs = lPzs = 0;
1089  for (int i=0; i<numChans; i++)
1090  {
1091  if (lIds < ids[i].size())
1092  lIds = ids[i].size();
1093  if (lSbs < sbs[i].size())
1094  lSbs = sbs[i].size();
1095  if (lPzs < polzs[i].size())
1096  lPzs = polzs[i].size();
1097  };
1098 
1099  fcTsysData.alternateDimension(1, numChans);
1100  fcTsysIfFreq.alternateDimension(0, numChans);
1101  fcTsysIfId.alternateDimension(0, numChans);
1102  fcTsysIfId.alternateDimension(1, lIds);
1103  fcTsysIfSideBand.alternateDimension(0, numChans);
1107 
1108  if (!setupFormat(fcfTsys, ncdf, stnName))
1109  {
1111  "::storeStationTsys(): format description failed");
1112  return false;
1113  };
1114  ncdf.setServiceVars(var.getStub(), "TSYS data",
1115  "StationScan", "TimeUTC.nc");
1116  //
1125 
1126  double *pTsys=ncdf.lookupVar(fcTsysData.name())->data2double();
1127  double *pFreqs=ncdf.lookupVar(fcTsysIfFreq.name())->data2double();
1128  char *pIds=ncdf.lookupVar(fcTsysIfId.name())->data2char();
1129  char *pSbs=ncdf.lookupVar(fcTsysIfSideBand.name())->data2char();
1130  char *pPzs=ncdf.lookupVar(fcTsysIfPolarization.name())->data2char();
1131 
1132  for (int i=0; i<dscr->numOfPts_; i++)
1133  for (int j=0; j<numChans; j++)
1134  pTsys[i*numChans + j] = tsyses->getElement(i, j);
1135  for (int j=0; j<numChans; j++)
1136  {
1137  pFreqs[j] = frqs[j];
1138  strncpy(pIds + lIds*j, qPrintable(ids[j]), lIds);
1139  strncpy(pSbs + lSbs*j, qPrintable(sbs[j]), lSbs);
1140  strncpy(pPzs + lPzs*j, qPrintable(polzs[j]), lPzs);
1141  };
1142 
1143  // write data:
1145  if (!ncdf.putData())
1146  {
1148  "::storeStationTsys(): cannot put data into " + ncdf.getFileName());
1149  return false;
1150  };
1153  "::storeStationTsys(): the data were successfully stored in " + ncdf.getFileName());
1154  return true;
1155 };
1156 
1157 
1158 
1159 
1160 
1161 
1162 
1163 /*=====================================================================================================*/
1164 
@ SD_NumStnPts
Definition: SgIoDriver.h:56
@ SD_Any
Definition: SgIoDriver.h:62
SgLogger * logger
Definition: SgLogger.cpp:231
SgVgosDb::FmtChkVar fcSecond("Second", NC_DOUBLE, true, QList< int >()<< SD_Any, "SEC TAG ", "Seconds part of UTC TAG.........", "second")
SgVgosDb::FmtChkVar fcYmdhm("YMDHM", NC_SHORT, true, QList< int >()<< SD_Any<< 5, "UTC TAG ", "Epoch UTC YMDHM.................")
QList< SgVgosDb::FmtChkVar * > fcfTimeUTC
Definition: SgVgosDb.cpp:2669
QList< SgVgosDb::FmtChkVar * > fcfCalSlantPathTropDry
Definition: SgVgosDb.h:2078
SgVgosDb::FmtChkVar fcCalCblCorrections
Definition: SgVgosDb.h:1997
QList< SgVgosDb::FmtChkVar * > fcfCalAxisOffset
Definition: SgVgosDb.h:2077
SgVgosDb::FmtChkVar fcPartZenithPathTropDry
Definition: SgVgosDb.h:2000
SgVgosDb::FmtChkVar fcRefClockOffset
Definition: SgVgosDb.h:2000
SgVgosDb::FmtChkVar fcTsysIfSideBand
Definition: SgVgosDb.h:2001
QList< SgVgosDb::FmtChkVar * > fcfMet
Definition: SgVgosDb.h:2079
SgVgosDb::FmtChkVar fcCalStationOceanLoadHoriz
Definition: SgVgosDb.h:1998
SgVgosDb::FmtChkVar fcElTheo
Definition: SgVgosDb.h:1996
SgVgosDb::FmtChkVar fcTempC
Definition: SgVgosDb.h:1999
QList< SgVgosDb::FmtChkVar * > fcfPartZenithPathTropDry
Definition: SgVgosDb.h:2079
QList< SgVgosDb::FmtChkVar * > fcfPartZenithPathTropWet
Definition: SgVgosDb.h:2079
QList< SgVgosDb::FmtChkVar * > fcfRefClockOffset
Definition: SgVgosDb.h:2080
QList< SgVgosDb::FmtChkVar * > fcfTsys
Definition: SgVgosDb.h:2081
SgVgosDb::FmtChkVar fcTsysData
Definition: SgVgosDb.h:2001
SgVgosDb::FmtChkVar fcCalSlantPathTropWet
Definition: SgVgosDb.h:1998
QList< SgVgosDb::FmtChkVar * > fcfCalStationOceanLoad
Definition: SgVgosDb.h:2078
SgVgosDb::FmtChkVar fcCalStationOceanLoadVert
Definition: SgVgosDb.h:1998
QList< SgVgosDb::FmtChkVar * > fcfDisOceanLoad
Definition: SgVgosDb.h:2079
SgVgosDb::FmtChkVar fcTsysIfPolarization
Definition: SgVgosDb.h:2003
SgVgosDb::FmtChkVar fcPartZenithPathTropWet
Definition: SgVgosDb.h:2000
QList< SgVgosDb::FmtChkVar * > fcfPartHorizonGrad
Definition: SgVgosDb.h:2080
SgVgosDb::FmtChkVar fcCalCable
Definition: SgVgosDb.h:1996
QList< SgVgosDb::FmtChkVar * > fcfCalCable
Definition: SgVgosDb.h:2077
QList< SgVgosDb::FmtChkVar * > fcfCalSlantPathTropWet
Definition: SgVgosDb.h:2078
SgVgosDb::FmtChkVar fcFeedRotation
Definition: SgVgosDb.h:1996
SgVgosDb::FmtChkVar fcPartHorizonGrad
Definition: SgVgosDb.h:2000
SgVgosDb::FmtChkVar fcCalSlantPathTropDry
Definition: SgVgosDb.h:1998
SgVgosDb::FmtChkVar fcAzTheo
SgVgosDb::FmtChkVar fcRelHum
Definition: SgVgosDb.h:1999
QList< SgVgosDb::FmtChkVar * > fcfCalCblCorrections
Definition: SgVgosDb.h:2077
SgVgosDb::FmtChkVar fcDisOceanLoad
Definition: SgVgosDb.h:1999
SgVgosDb::FmtChkVar fcTsysIfId
Definition: SgVgosDb.h:2001
QList< SgVgosDb::FmtChkVar * > fcfPartAxisOffset
Definition: SgVgosDb.h:2079
SgVgosDb::FmtChkVar fcTsysIfFreq
Definition: SgVgosDb.h:2001
SgVgosDb::FmtChkVar fcAtmPres
Definition: SgVgosDb.h:1999
QList< SgVgosDb::FmtChkVar * > fcfFeedRotation
Definition: SgVgosDb.h:2077
SgVgosDb::FmtChkVar fcPartAxisOffset
Definition: SgVgosDb.h:1999
SgVgosDb::FmtChkVar fcCalAxisOffset
Definition: SgVgosDb.h:1996
QList< SgVgosDb::FmtChkVar * > fcfAzEl
const SgIdentities * currentIdentities_
Definition: SgIoDriver.h:133
virtual void write(LogLevel, quint32, const QString &, bool=false)
Definition: SgLogger.cpp:88
@ IO_NCDF
Definition: SgLogger.h:66
unsigned int nRow() const
Definition: SgMatrix.h:352
double getElement(unsigned int i, unsigned int j) const
Definition: SgMatrix.h:385
unsigned int nCol() const
Definition: SgMatrix.h:360
const char * data2char() const
Definition: SgNetCdf.cpp:459
const short * data2short() const
Definition: SgNetCdf.cpp:481
const double * data2double() const
Definition: SgNetCdf.cpp:525
SgNcdfVariable * lookupVar(const QString &name) const
Definition: SgNetCdf.h:395
void setServiceVars(const QString &stub, const QString &dataOrigin, const QString &timeTag, const QString &timeTagFile)
Definition: SgNetCdf.cpp:1263
bool putData()
Definition: SgNetCdf.cpp:1357
const QString & getFileName() const
Definition: SgNetCdf.h:497
@ OM_REGULAR
Definition: SgNetCdf.h:324
void setOperationMode(OperationMode om)
Definition: SgNetCdf.h:381
QString name4export(const QString &rootDir, SgNetCdf::OperationMode om, const QString &aBand="")
Definition: SgVgosDb.cpp:167
void setKind(const QString &str)
Definition: SgVgosDb.h:104
const QString & getStub() const
Definition: SgVgosDb.h:93
unsigned int n() const
Definition: SgVector.h:327
double getElement(unsigned int i) const
Definition: SgVector.h:362
void setHave2hideLCode(bool have2)
Definition: SgVgosDb.h:225
const QString & name() const
Definition: SgVgosDb.h:213
void alternateDimension(int i, int num)
Definition: SgVgosDb.h:222
bool storeStationCalCable(const QString &stnName, const SgMatrix *cal, const QString &origin, const QString &kind)
static const QString className()
Definition: SgVgosDb.cpp:251
bool setupFormat(const QList< FmtChkVar * > &, SgNetCdf &, const QString &stationKey=QString(""), const QString &bandKey=QString(""))
Definition: SgVgosDb.cpp:2350
bool storeStationCalOceanLoad(const QString &stnName, const SgMatrix *calHorzOLoad, const SgMatrix *calVertOLoad)
bool storeStationCalSlantPathTropWet(const QString &stnName, const SgMatrix *cal, const QString &kind)
SgNetCdf::OperationMode operationMode_
Definition: SgVgosDb.h:1543
bool storeStationRefClockOffset(const QString &stnName, const SgVector *v)
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 storeStationCalCblCorrections(const QString &stnName, const SgMatrix *cal, const QString &origin)
bool storeStationCalAxisOffset(const QString &stnName, const SgMatrix *cal)
bool storeStationEpochs(const QString &stnName, const QList< SgMJD > &epochs)
bool storeStationPartZenithDelayDry(const QString &stnName, const SgMatrix *part, const QString &kind)
bool storeStationParAngle(const QString &stnName, const SgVector *parAngle)
bool storeStationOceanLdDisp(const QString &stnName, const SgMatrix *dis, const SgMatrix *vel)
bool storeStationPartHorizonGrad(const QString &stnName, const SgMatrix *part, const QString &kind)
QMap< QString, StationDescriptor * > stnDescriptorByName_
Definition: SgVgosDb.h:1459
QString sessionCode_
Definition: SgVgosDb.h:1429
bool storeStationAzEl(const QString &stnName, SgMatrix *const azTheo, SgMatrix *const elTheo)
QString outputFormatId_
Definition: SgVgosDb.h:1414
bool storeStationCalSlantPathTropDry(const QString &stnName, const SgMatrix *cal, const QString &kind)
bool storeStationPartZenithDelayWet(const QString &stnName, const SgMatrix *part, const QString &kind)
QString path2RootDir_
Definition: SgVgosDb.h:1406
bool storeStationMet(const QString &stnName, SgVector *const metAtmPres, SgVector *const metAtmRH, SgVector *const metAtmTemp, const QString &origin, const QString &kind)
SgVdbVariable vRefClockOffset_
Definition: SgVgosDb.h:1302
SgVdbVariable vCal_SlantPathTropWet_
Definition: SgVgosDb.h:1293
SgVdbVariable vCal_SlantPathTropDry_
Definition: SgVgosDb.h:1292
SgVdbVariable vPart_HorizonGrad_
Definition: SgVgosDb.h:1299
SgVdbVariable vPart_ZenithPathTropDry_
Definition: SgVgosDb.h:1297
SgVdbVariable vCal_Cable_
Definition: SgVgosDb.h:1289
SgVdbVariable vCal_CblCorrections_
Definition: SgVgosDb.h:1291
SgVdbVariable vFeedRotation_
Definition: SgVgosDb.h:1287
SgVdbVariable vCal_AxisOffset_
Definition: SgVgosDb.h:1288
SgVdbVariable vPart_AxisOffset_
Definition: SgVgosDb.h:1296
SgVdbVariable vDis_OceanLoad_
Definition: SgVgosDb.h:1300
SgVdbVariable vCal_OceanLoad_
Definition: SgVgosDb.h:1294
SgVdbVariable vPart_ZenithPathTropWet_
Definition: SgVgosDb.h:1298