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::storeStationMet(const QString& stnName,
182  SgVector*const metAtmPres, SgVector*const metAtmRH, SgVector*const metAtmTemp,
183  const QString& origin, const QString& kind)
184 {
185  if (!stnDescriptorByName_.contains(stnName))
186  {
188  "::storeStationMet(): unknown station " + stnName);
189  return false;
190  };
192  SgVdbVariable &var=dscr->vMet_;
193  //
194  var.setKind(kind); // empty is ok too
195  //
196  //
197  SgNetCdf ncdf(path2RootDir_ + "/" +
199  sessionCode_, stnName, "");
200  //
201  if (dscr->numOfPts_ != (int)metAtmPres->n())
202  {
204  "::storeStationMet(): atm.pressure size mismatch: " +
205  QString("").sprintf("%d vs %d", dscr->numOfPts_, metAtmPres->n()));
206  return false;
207  };
208  if (dscr->numOfPts_ != (int)metAtmRH->n())
209  {
211  "::storeStationMet(): atm.rel.humidity size mismatch: " +
212  QString("").sprintf("%d vs %d", dscr->numOfPts_, metAtmRH->n()));
213  return false;
214  };
215  if (dscr->numOfPts_ != (int)metAtmTemp->n())
216  {
218  "::storeStationMet(): atm.temperature size mismatch: " +
219  QString("").sprintf("%d vs %d", dscr->numOfPts_, metAtmTemp->n()));
220  return false;
221  };
222  //
223  if (!setupFormat(fcfMet, ncdf, stnName))
224  {
226  "::storeStationMet(): format description failed for " + stnName);
227  return false;
228  };
229  ncdf.setServiceVars(var.getStub(), origin, "StationScan", "TimeUTC.nc");
230  //
231  double *pT=ncdf.lookupVar(fcTempC .name())->data2double();
232  double *pP=ncdf.lookupVar(fcAtmPres.name())->data2double();
233  double *pH=ncdf.lookupVar(fcRelHum .name())->data2double();
234  for (int i=0; i<dscr->numOfPts_; i++)
235  {
236  pP[i] = metAtmPres->getElement(i);
237  pH[i] = metAtmRH ->getElement(i);
238  pT[i] = metAtmTemp->getElement(i);
239  };
240  // write data:
242  if (!ncdf.putData())
243  {
245  "::storeStationMet(): cannot put data into " + ncdf.getFileName());
246  return false;
247  };
250  "::storeStationMet(): the data were successfully stored in " + ncdf.getFileName());
251  return true;
252 };
253 
254 
255 
256 //
257 bool SgVgosDb::storeStationAzEl(const QString& stnName, SgMatrix*const azTheo, SgMatrix*const elTheo)
258 {
259  if (!stnDescriptorByName_.contains(stnName))
260  {
262  "::storeStationAzEl(): unknown station " + stnName);
263  return false;
264  };
266  SgVdbVariable &var=dscr->vAzEl_;
267  // !!!
268 // var.setSubDir(stnName.simplified());
269  //
270  SgNetCdf ncdf(path2RootDir_ + "/" +
272  sessionCode_, stnName, "");
273  //
274  if (dscr->numOfPts_ != (int)azTheo->nRow())
275  {
277  "::storeStationAzEl(): azimuth size mismatch: " +
278  QString("").sprintf("%d vs %d", dscr->numOfPts_, azTheo->nRow()));
279  return false;
280  };
281  if (dscr->numOfPts_ != (int)elTheo->nRow())
282  {
284  "::storeStationAzEl(): elevation size mismatch: " +
285  QString("").sprintf("%d vs %d", dscr->numOfPts_, elTheo->nRow()));
286  return false;
287  };
288  //
289  if (!setupFormat(fcfAzEl, ncdf, stnName))
290  {
292  "::storeStationAzEl(): format description failed");
293  return false;
294  };
295  ncdf.setServiceVars(var.getStub(), "Data are provided by CALC or similar software",
296  "StationScan", "TimeUTC.nc");
297  //
298  double *pAz=ncdf.lookupVar(fcAzTheo.name())->data2double();
299  double *pEl=ncdf.lookupVar(fcElTheo.name())->data2double();
300  for (int i=0; i<dscr->numOfPts_; i++)
301  {
302  pAz[2*i ] = azTheo->getElement(i, 0);
303  pAz[2*i + 1] = azTheo->getElement(i, 1);
304  pEl[2*i ] = elTheo->getElement(i, 0);
305  pEl[2*i + 1] = elTheo->getElement(i, 1);
306  };
307  // write data:
309  if (!ncdf.putData())
310  {
312  "::storeStationAzEl(): cannot put data into " + ncdf.getFileName());
313  return false;
314  };
317  "::storeStationAzEl(): the data were successfully stored in " + ncdf.getFileName());
318  return true;
319 };
320 
321 
322 
323 //
324 bool SgVgosDb::storeStationPartAxisOffset(const QString& stnName, const SgMatrix* partAxisOffset)
325 {
326  if (!stnDescriptorByName_.contains(stnName))
327  {
329  "::storeStationPartAxisOffset(): unknown station " + stnName);
330  return false;
331  };
333  SgVdbVariable &var=dscr->vPart_AxisOffset_;
334  // !!!
335 // var.setSubDir(stnName.simplified());
336  //
337  SgNetCdf ncdf(path2RootDir_ + "/" +
339  sessionCode_, stnName, "");
340  //
341  if (dscr->numOfPts_ != (int)partAxisOffset->nRow())
342  {
344  "::storeStationPartAxisOffset(): the size mismatch: " +
345  QString("").sprintf("%d vs %d", dscr->numOfPts_, partAxisOffset->nRow()));
346  return false;
347  };
348  //
349  if (!setupFormat(fcfPartAxisOffset, ncdf, stnName))
350  {
352  "::storeStationPartAxisOffset(): format description failed");
353  return false;
354  };
355  ncdf.setServiceVars(var.getStub(), "Data are provided by CALC or similar software",
356  "StationScan", "TimeUTC.nc");
357  //
358  double *p=ncdf.lookupVar(fcPartAxisOffset.name())->data2double();
359  for (int i=0; i<dscr->numOfPts_; i++)
360  {
361  p[2*i ] = partAxisOffset->getElement(i, 0);
362  p[2*i + 1] = partAxisOffset->getElement(i, 1);
363  };
364  // write data:
366  if (!ncdf.putData())
367  {
369  "::storeStationPartAxisOffset(): cannot put data into " + ncdf.getFileName());
370  return false;
371  };
374  "::storeStationPartAxisOffset(): the data were successfully stored in " + ncdf.getFileName());
375  return true;
376 };
377 
378 
379 
380 //
381 bool SgVgosDb::storeStationParAngle(const QString& stnName, const SgVector* parAngle)
382 {
383  if (!stnDescriptorByName_.contains(stnName))
384  {
386  "::storeStationParAngle(): unknown station [" + stnName + "]");
387  return false;
388  };
390  SgVdbVariable &var=dscr->vFeedRotation_;
391  // !!!
392 // var.setSubDir(stnName.simplified());
393  //
394  SgNetCdf ncdf(path2RootDir_ + "/" +
396  sessionCode_, stnName, "");
397  //
398  if (dscr->numOfPts_ != (int)parAngle->n())
399  {
401  "::storeStationParAngle(): the size mismatch: " +
402  QString("").sprintf("%d vs %d", dscr->numOfPts_, parAngle->n()));
403  return false;
404  };
405  //
406  if (!setupFormat(fcfFeedRotation, ncdf, stnName))
407  {
409  "::storeStationParAngle(): format description failed");
410  return false;
411  };
412  ncdf.setServiceVars(var.getStub(), "Data are provided by CALC or similar software",
413  "StationScan", "TimeUTC.nc");
414  //
415  double *p=ncdf.lookupVar(fcFeedRotation.name())->data2double();
416  for (int i=0; i<dscr->numOfPts_; i++)
417  p[i] = parAngle->getElement(i);
418  // write data:
420  if (!ncdf.putData())
421  {
423  "::storeStationParAngle(): cannot put data into " + ncdf.getFileName());
424  return false;
425  };
428  "::storeStationParAngle(): the data were successfully stored in " + ncdf.getFileName());
429  return true;
430 };
431 
432 
433 
434 //
435 bool SgVgosDb::storeStationCalAxisOffset(const QString& stnName, const SgMatrix* cal)
436 {
437  if (!stnDescriptorByName_.contains(stnName))
438  {
440  "::storeStationCalAxisOffset(): unknown station " + stnName);
441  return false;
442  };
444  SgVdbVariable &var=dscr->vCal_AxisOffset_;
445  // !!!
446 // var.setSubDir(stnName.simplified());
447  //
448  SgNetCdf ncdf(path2RootDir_ + "/" +
450  sessionCode_, stnName, "");
451  //
452  if (dscr->numOfPts_ != (int)cal->nRow())
453  {
455  "::storeStationCalAxisOffset(): the size mismatch: " +
456  QString("").sprintf("%d vs %d", dscr->numOfPts_, cal->nRow()));
457  return false;
458  };
459  //
460  if (!setupFormat(fcfCalAxisOffset, ncdf, stnName))
461  {
463  "::storeStationCalAxisOffset(): format description failed");
464  return false;
465  };
466  ncdf.setServiceVars(var.getStub(), "Data are provided by CALC or similar software",
467  "StationScan", "TimeUTC.nc");
468  //
469  double *p=ncdf.lookupVar(fcCalAxisOffset.name())->data2double();
470  for (int i=0; i<dscr->numOfPts_; i++)
471  {
472  p[2*i ] = cal->getElement(i, 0);
473  p[2*i + 1] = cal->getElement(i, 1);
474  };
475  // write data:
477  if (!ncdf.putData())
478  {
480  "::storeStationCalAxisOffset(): cannot put data into " + ncdf.getFileName());
481  return false;
482  };
485  "::storeStationCalAxisOffset(): the data were successfully stored in " + ncdf.getFileName());
486  return true;
487 };
488 
489 
490 
491 //
492 bool SgVgosDb::storeStationCalSlantPathTropDry(const QString& stnName, const SgMatrix* cal,
493  const QString& kind)
494 {
495  if (!stnDescriptorByName_.contains(stnName))
496  {
498  "::storeStationCalSlantPathTropDry(): unknown station " + stnName);
499  return false;
500  };
503  //
504  var.setKind(kind); // empty is ok too
505  //
506  //
507  SgNetCdf ncdf(path2RootDir_ + "/" +
509  sessionCode_, stnName, "");
510  //
511  if (dscr->numOfPts_ != (int)cal->nRow())
512  {
514  "::storeStationCalSlantPathTropDry(): the size mismatch: " +
515  QString("").sprintf("%d vs %d", dscr->numOfPts_, cal->nRow()));
516  return false;
517  };
518  //
519  if (!setupFormat(fcfCalSlantPathTropDry, ncdf, stnName))
520  {
522  "::storeStationCalSlantPathTropDry(): format description failed");
523  return false;
524  };
525  ncdf.setServiceVars(var.getStub(), "Data are provided by CALC or similar software",
526  "StationScan", "TimeUTC.nc");
527  //
528  double *p=ncdf.lookupVar(fcCalSlantPathTropDry.name())->data2double();
529  for (int i=0; i<dscr->numOfPts_; i++)
530  {
531  p[2*i ] = cal->getElement(i, 0);
532  p[2*i + 1] = cal->getElement(i, 1);
533  };
534  // write data:
536  if (!ncdf.putData())
537  {
539  "::storeStationCalSlantPathTropDry(): cannot put data into " + ncdf.getFileName());
540  return false;
541  };
544  "::storeStationCalSlantPathTropDry(): the data were successfully stored in " + ncdf.getFileName());
545  return true;
546 };
547 
548 
549 
550 //
551 bool SgVgosDb::storeStationCalSlantPathTropWet(const QString& stnName, const SgMatrix* cal,
552  const QString& kind)
553 {
554  if (!stnDescriptorByName_.contains(stnName))
555  {
557  "::storeStationCalSlantPathTropWet(): unknown station " + stnName);
558  return false;
559  };
562  //
563  var.setKind(kind); // empty is ok too
564  //
565  //
566  SgNetCdf ncdf(path2RootDir_ + "/" +
568  sessionCode_, stnName, "");
569  //
570  if (dscr->numOfPts_ != (int)cal->nRow())
571  {
573  "::storeStationCalSlantPathTropWet(): the size mismatch: " +
574  QString("").sprintf("%d vs %d", dscr->numOfPts_, cal->nRow()));
575  return false;
576  };
577  //
578  if (!setupFormat(fcfCalSlantPathTropWet, ncdf, stnName))
579  {
581  "::storeStationCalSlantPathTropWet(): format description failed");
582  return false;
583  };
584  ncdf.setServiceVars(var.getStub(), "Data are provided by CALC or similar software",
585  "StationScan", "TimeUTC.nc");
586  //
587  double *p=ncdf.lookupVar(fcCalSlantPathTropWet.name())->data2double();
588  for (int i=0; i<dscr->numOfPts_; i++)
589  {
590  p[2*i ] = cal->getElement(i, 0);
591  p[2*i + 1] = cal->getElement(i, 1);
592  };
593  // write data:
595  if (!ncdf.putData())
596  {
598  "::storeStationCalSlantPathTropWet(): cannot put data into " + ncdf.getFileName());
599  return false;
600  };
603  "::storeStationCalSlantPathTropWet(): the data were successfully stored in " + ncdf.getFileName());
604  return true;
605 };
606 
607 
608 
609 //
610 bool SgVgosDb::storeStationCalOceanLoad(const QString& stnName,
611  const SgMatrix* calHorzOLoad, const SgMatrix* calVertOLoad)
612 {
613  if (!stnDescriptorByName_.contains(stnName))
614  {
616  "::storeStationCalOceanLoad(): unknown station " + stnName);
617  return false;
618  };
620  SgVdbVariable &var=dscr->vCal_OceanLoad_;
621  // !!!
622 // var.setSubDir(stnName.simplified());
623  //
624  SgNetCdf ncdf(path2RootDir_ + "/" +
626  sessionCode_, stnName, "");
627  //
628  if (dscr->numOfPts_ != (int)calHorzOLoad->nRow())
629  {
631  "::storeStationCalOceanLoad(): the matrix HorzOLoad size mismatch: " +
632  QString("").sprintf("%d vs %d", dscr->numOfPts_, calHorzOLoad->nRow()));
633  return false;
634  };
635  //
636  if (dscr->numOfPts_ != (int)calVertOLoad->nRow())
637  {
639  "::storeStationCalOceanLoad(): the matrix VertOLoad size mismatch: " +
640  QString("").sprintf("%d vs %d", dscr->numOfPts_, calVertOLoad->nRow()));
641  return false;
642  };
643  //
644  if (!setupFormat(fcfCalStationOceanLoad, ncdf, stnName))
645  {
647  "::storeStationCalOceanLoad(): format description failed");
648  return false;
649  };
650  ncdf.setServiceVars(var.getStub(), "Data are provided by CALC or similar software",
651  "StationScan", "TimeUTC.nc");
652  //
654  double *pV=ncdf.lookupVar(fcCalStationOceanLoadVert .name())->data2double();
655  for (int i=0; i<dscr->numOfPts_; i++)
656  {
657  pH[2*i ] = calHorzOLoad->getElement(i, 0);
658  pH[2*i + 1] = calHorzOLoad->getElement(i, 1);
659  pV[2*i ] = calVertOLoad->getElement(i, 0);
660  pV[2*i + 1] = calVertOLoad->getElement(i, 1);
661  };
662  // write data:
664  if (!ncdf.putData())
665  {
667  "::storeStationCalOceanLoad(): cannot put data into " + ncdf.getFileName());
668  return false;
669  };
672  "::storeStationCalOceanLoad(): the data were successfully stored in " + ncdf.getFileName());
673  return true;
674 };
675 
676 
677 
678 //
679 bool SgVgosDb::storeStationOceanLdDisp(const QString& stnName, const SgMatrix* dis, const SgMatrix* vel)
680 {
681  if (!stnDescriptorByName_.contains(stnName))
682  {
684  "::storeStationOceanLdDisp(): unknown station " + stnName);
685  return false;
686  };
688  SgVdbVariable &var=dscr->vDis_OceanLoad_;
689  // !!!
690 // var.setSubDir(stnName.simplified());
691  //
692  SgNetCdf ncdf(path2RootDir_ + "/" +
694  sessionCode_, stnName, "");
695  //
696  if (dscr->numOfPts_ != (int)dis->nRow())
697  {
699  "::storeStationOceanLdDisp(): the matrix dis size mismatch: " +
700  QString("").sprintf("%d vs %d", dscr->numOfPts_, dis->nRow()));
701  return false;
702  };
703  //
704  if (dscr->numOfPts_ != (int)vel->nRow())
705  {
707  "::storeStationOceanLdDisp(): the matrix vel size mismatch: " +
708  QString("").sprintf("%d vs %d", dscr->numOfPts_, vel->nRow()));
709  return false;
710  };
711  //
712  if (!setupFormat(fcfDisOceanLoad, ncdf, stnName))
713  {
715  "::storeStationOceanLdDisp(): format description failed");
716  return false;
717  };
718  ncdf.setServiceVars(var.getStub(), "Data are provided by CALC or similar software",
719  "StationScan", "TimeUTC.nc");
720  //
721  double *p=ncdf.lookupVar(fcDisOceanLoad.name())->data2double();
722  for (int i=0; i<dscr->numOfPts_; i++)
723  {
724  p[6*i ] = dis->getElement(i, 0);
725  p[6*i + 1] = dis->getElement(i, 1);
726  p[6*i + 2] = dis->getElement(i, 2);
727  p[6*i + 3] = vel->getElement(i, 0);
728  p[6*i + 4] = vel->getElement(i, 1);
729  p[6*i + 5] = vel->getElement(i, 2);
730  };
731  // write data:
733  if (!ncdf.putData())
734  {
736  "::storeStationOceanLdDisp(): cannot put data into " + ncdf.getFileName());
737  return false;
738  };
741  "::storeStationOceanLdDisp(): the data were successfully stored in " + ncdf.getFileName());
742  return true;
743 };
744 
745 
746 
747 //
748 bool SgVgosDb::storeStationPartZenithDelayDry(const QString& stnName, const SgMatrix* part,
749  const QString& kind)
750 {
751  if (!stnDescriptorByName_.contains(stnName))
752  {
754  "::storeStationPartZenithDelayDry(): unknown station " + stnName);
755  return false;
756  };
759  //
760  var.setKind(kind); // empty is ok too
761  //
762  //
763  SgNetCdf ncdf(path2RootDir_ + "/" +
765  sessionCode_, stnName, "");
766  //
767  if (dscr->numOfPts_ != (int)part->nRow())
768  {
770  "::storeStationPartZenithDelayDry(): the size mismatch: " +
771  QString("").sprintf("%d vs %d", dscr->numOfPts_, part->nRow()));
772  return false;
773  };
774  //
775  if (!setupFormat(fcfPartZenithPathTropDry, ncdf, stnName))
776  {
778  "::storeStationPartZenithDelayDry(): format description failed");
779  return false;
780  };
781  ncdf.setServiceVars(var.getStub(), "Data are provided by CALC or similar software",
782  "StationScan", "TimeUTC.nc");
783  //
784  double *p=ncdf.lookupVar(fcPartZenithPathTropDry.name())->data2double();
785  for (int i=0; i<dscr->numOfPts_; i++)
786  {
787  p[2*i ] = part->getElement(i, 0);
788  p[2*i + 1] = part->getElement(i, 1);
789  };
790  // write data:
792  if (!ncdf.putData())
793  {
795  "::storeStationPartZenithDelayDry(): cannot put data into " + ncdf.getFileName());
796  return false;
797  };
800  "::storeStationPartZenithDelayDry(): the data successfully stored in " + ncdf.getFileName());
801  return true;
802 };
803 
804 
805 
806 //
807 bool SgVgosDb::storeStationPartZenithDelayWet(const QString& stnName, const SgMatrix* part,
808  const QString& kind)
809 {
810  if (!stnDescriptorByName_.contains(stnName))
811  {
813  "::storeStationPartZenithDelayWet(): unknown station " + stnName);
814  return false;
815  };
818  //
819  var.setKind(kind); // empty is ok too
820  //
821  //
822  SgNetCdf ncdf(path2RootDir_ + "/" +
824  sessionCode_, stnName, "");
825  //
826  if (dscr->numOfPts_ != (int)part->nRow())
827  {
829  "::storeStationPartZenithDelayWet(): the size mismatch: " +
830  QString("").sprintf("%d vs %d", dscr->numOfPts_, part->nRow()));
831  return false;
832  };
833  //
834  if (!setupFormat(fcfPartZenithPathTropWet, ncdf, stnName))
835  {
837  "::storeStationPartZenithDelayWet(): format description failed");
838  return false;
839  };
840  ncdf.setServiceVars(var.getStub(), "Data are provided by CALC or similar software",
841  "StationScan", "TimeUTC.nc");
842  //
843  double *p=ncdf.lookupVar(fcPartZenithPathTropWet.name())->data2double();
844  for (int i=0; i<dscr->numOfPts_; i++)
845  {
846  p[2*i ] = part->getElement(i, 0);
847  p[2*i + 1] = part->getElement(i, 1);
848  };
849  // write data:
851  if (!ncdf.putData())
852  {
854  "::storeStationPartZenithDelayWet(): cannot put data into " + ncdf.getFileName());
855  return false;
856  };
859  "::storeStationPartZenithDelayWet(): the data successfully stored in " + ncdf.getFileName());
860  return true;
861 };
862 
863 
864 
865 //
866 bool SgVgosDb::storeStationPartHorizonGrad(const QString& stnName, const SgMatrix* part,
867  const QString& kind)
868 {
869  if (!stnDescriptorByName_.contains(stnName))
870  {
872  "::storeStationPartHorizonGrad(): unknown station " + stnName);
873  return false;
874  };
877  //
878  var.setKind(kind); // empty is ok too
879  //
880  //
881  SgNetCdf ncdf(path2RootDir_ + "/" +
883  sessionCode_, stnName, "");
884  //
885  if (dscr->numOfPts_ != (int)part->nRow())
886  {
888  "::storeStationPartHorizonGrad(): the size mismatch: " +
889  QString("").sprintf("%d vs %d", dscr->numOfPts_, part->nRow()));
890  return false;
891  };
892  //
893  if (!setupFormat(fcfPartHorizonGrad, ncdf, stnName))
894  {
896  "::storeStationPartHorizonGrad(): format description failed");
897  return false;
898  };
899  ncdf.setServiceVars(var.getStub(), "Data are provided by CALC or similar software",
900  "StationScan", "TimeUTC.nc");
901  //
902  double *p=ncdf.lookupVar(fcPartHorizonGrad.name())->data2double();
903  for (int i=0; i<dscr->numOfPts_; i++)
904  {
905  p[4*i ] = part->getElement(i, 0);
906  p[4*i + 1] = part->getElement(i, 1);
907  p[4*i + 2] = part->getElement(i, 2);
908  p[4*i + 3] = part->getElement(i, 3);
909  };
910  // write data:
912  if (!ncdf.putData())
913  {
915  "::storeStationPartHorizonGrad(): cannot put data into " + ncdf.getFileName());
916  return false;
917  };
920  "::storeStationPartHorizonGrad(): the data successfully stored in " + ncdf.getFileName());
921  return true;
922 };
923 
924 
925 
926 //
927 bool SgVgosDb::storeStationRefClockOffset(const QString& stnName, const SgVector* v)
928 {
929  if (!stnDescriptorByName_.contains(stnName))
930  {
932  "::storeStationRefClockOffset(): unknown station " + stnName);
933  return false;
934  };
936  SgVdbVariable &var=dscr->vRefClockOffset_;
937  // !!!
938 // var.setSubDir(stnName.simplified());
939  //
940  SgNetCdf ncdf(path2RootDir_ + "/" +
942  sessionCode_, stnName, "");
943  //
944  if (dscr->numOfPts_ != (int)v->n())
945  {
947  "::storeStationRefClockOffset(): vector v size mismatch: " +
948  QString("").sprintf("%d vs %d", dscr->numOfPts_, v->n()));
949  return false;
950  };
951  //
952  if (!setupFormat(fcfRefClockOffset, ncdf, stnName))
953  {
955  "::storeStationRefClockOffset(): format description failed");
956  return false;
957  };
958  ncdf.setServiceVars(var.getStub(), "KOMB correlator files",
959  "StationScan", "TimeUTC.nc");
960  //
961  double *p=ncdf.lookupVar(fcRefClockOffset.name())->data2double();
962  for (int i=0; i<dscr->numOfPts_; i++)
963  p[i] = v->getElement(i);
964  // write data:
966  if (!ncdf.putData())
967  {
969  "::storeStationRefClockOffset(): cannot put data into " + ncdf.getFileName());
970  return false;
971  };
974  "::storeStationRefClockOffset(): the data were successfully stored in " + ncdf.getFileName());
975  return true;
976 };
977 
978 
979 
980 //
981 bool SgVgosDb::storeStationTsys(const QString& stnName, const SgMatrix* tsyses,
982  const QVector<double>& frqs, const QVector<QString>& ids, const QVector<QString>& sbs,
983  const QVector<QString>& polzs)
984 {
985  if (!stnDescriptorByName_.contains(stnName))
986  {
988  "::storeStationTsys(): unknown station " + stnName);
989  return false;
990  };
992  SgVdbVariable &var=dscr->vTsys_;
993  // !!!
994 // var.setSubDir(stnName.simplified());
995  //
996  SgNetCdf ncdf(path2RootDir_ + "/" +
998  sessionCode_, stnName, "");
999  //
1000  if (dscr->numOfPts_ != (int)tsyses->nRow())
1001  {
1003  "::storeStationTsys(): matrix tsyses size mismatch: " +
1004  QString("").sprintf("%d vs %d", dscr->numOfPts_, tsyses->nRow()));
1005  return false;
1006  };
1007  //
1008  //
1009  int numChans;
1010  numChans = tsyses->nCol();
1011  if (numChans != frqs.size())
1012  {
1014  "::storeStationTsys(): array of frqs size mismatch: " +
1015  QString("").sprintf("%d vs %d", numChans, frqs.size()));
1016  return false;
1017  };
1018  if (numChans != ids.size())
1019  {
1021  "::storeStationTsys(): array of ids size mismatch: " +
1022  QString("").sprintf("%d vs %d", numChans, ids.size()));
1023  return false;
1024  };
1025 
1026  int lIds, lSbs, lPzs;
1027  lIds = lSbs = lPzs = 0;
1028  for (int i=0; i<numChans; i++)
1029  {
1030  if (lIds < ids[i].size())
1031  lIds = ids[i].size();
1032  if (lSbs < sbs[i].size())
1033  lSbs = sbs[i].size();
1034  if (lPzs < polzs[i].size())
1035  lPzs = polzs[i].size();
1036  };
1037 
1038  fcTsysData.alternateDimension(1, numChans);
1039  fcTsysIfFreq.alternateDimension(0, numChans);
1040  fcTsysIfId.alternateDimension(0, numChans);
1041  fcTsysIfId.alternateDimension(1, lIds);
1042  fcTsysIfSideBand.alternateDimension(0, numChans);
1046 
1047  if (!setupFormat(fcfTsys, ncdf, stnName))
1048  {
1050  "::storeStationTsys(): format description failed");
1051  return false;
1052  };
1053  ncdf.setServiceVars(var.getStub(), "TSYS data",
1054  "StationScan", "TimeUTC.nc");
1055  //
1064 
1065  double *pTsys=ncdf.lookupVar(fcTsysData.name())->data2double();
1066  double *pFreqs=ncdf.lookupVar(fcTsysIfFreq.name())->data2double();
1067  char *pIds=ncdf.lookupVar(fcTsysIfId.name())->data2char();
1068  char *pSbs=ncdf.lookupVar(fcTsysIfSideBand.name())->data2char();
1069  char *pPzs=ncdf.lookupVar(fcTsysIfPolarization.name())->data2char();
1070 
1071  for (int i=0; i<dscr->numOfPts_; i++)
1072  for (int j=0; j<numChans; j++)
1073  pTsys[i*numChans + j] = tsyses->getElement(i, j);
1074  for (int j=0; j<numChans; j++)
1075  {
1076  pFreqs[j] = frqs[j];
1077  strncpy(pIds + lIds*j, qPrintable(ids[j]), lIds);
1078  strncpy(pSbs + lSbs*j, qPrintable(sbs[j]), lSbs);
1079  strncpy(pPzs + lPzs*j, qPrintable(polzs[j]), lPzs);
1080  };
1081 
1082  // write data:
1084  if (!ncdf.putData())
1085  {
1087  "::storeStationTsys(): cannot put data into " + ncdf.getFileName());
1088  return false;
1089  };
1092  "::storeStationTsys(): the data were successfully stored in " + ncdf.getFileName());
1093  return true;
1094 };
1095 
1096 
1097 
1098 
1099 
1100 
1101 
1102 /*=====================================================================================================*/
1103 
@ 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:2655
QList< SgVgosDb::FmtChkVar * > fcfCalSlantPathTropDry
Definition: SgVgosDb.h:2064
QList< SgVgosDb::FmtChkVar * > fcfCalAxisOffset
Definition: SgVgosDb.h:2063
SgVgosDb::FmtChkVar fcPartZenithPathTropDry
Definition: SgVgosDb.h:1986
SgVgosDb::FmtChkVar fcRefClockOffset
Definition: SgVgosDb.h:1986
SgVgosDb::FmtChkVar fcTsysIfSideBand
Definition: SgVgosDb.h:1987
QList< SgVgosDb::FmtChkVar * > fcfMet
Definition: SgVgosDb.h:2065
SgVgosDb::FmtChkVar fcCalStationOceanLoadHoriz
Definition: SgVgosDb.h:1984
SgVgosDb::FmtChkVar fcElTheo
Definition: SgVgosDb.h:1983
SgVgosDb::FmtChkVar fcTempC
Definition: SgVgosDb.h:1985
QList< SgVgosDb::FmtChkVar * > fcfPartZenithPathTropDry
Definition: SgVgosDb.h:2065
QList< SgVgosDb::FmtChkVar * > fcfPartZenithPathTropWet
Definition: SgVgosDb.h:2065
QList< SgVgosDb::FmtChkVar * > fcfRefClockOffset
Definition: SgVgosDb.h:2066
QList< SgVgosDb::FmtChkVar * > fcfTsys
Definition: SgVgosDb.h:2067
SgVgosDb::FmtChkVar fcTsysData
Definition: SgVgosDb.h:1987
SgVgosDb::FmtChkVar fcCalSlantPathTropWet
Definition: SgVgosDb.h:1984
QList< SgVgosDb::FmtChkVar * > fcfCalStationOceanLoad
Definition: SgVgosDb.h:2064
SgVgosDb::FmtChkVar fcCalStationOceanLoadVert
Definition: SgVgosDb.h:1984
QList< SgVgosDb::FmtChkVar * > fcfDisOceanLoad
Definition: SgVgosDb.h:2065
SgVgosDb::FmtChkVar fcTsysIfPolarization
Definition: SgVgosDb.h:1989
SgVgosDb::FmtChkVar fcPartZenithPathTropWet
Definition: SgVgosDb.h:1986
QList< SgVgosDb::FmtChkVar * > fcfPartHorizonGrad
Definition: SgVgosDb.h:2066
SgVgosDb::FmtChkVar fcCalCable
Definition: SgVgosDb.h:1983
QList< SgVgosDb::FmtChkVar * > fcfCalCable
Definition: SgVgosDb.h:2063
QList< SgVgosDb::FmtChkVar * > fcfCalSlantPathTropWet
Definition: SgVgosDb.h:2064
SgVgosDb::FmtChkVar fcFeedRotation
Definition: SgVgosDb.h:1983
SgVgosDb::FmtChkVar fcPartHorizonGrad
Definition: SgVgosDb.h:1986
SgVgosDb::FmtChkVar fcCalSlantPathTropDry
Definition: SgVgosDb.h:1984
SgVgosDb::FmtChkVar fcAzTheo
SgVgosDb::FmtChkVar fcRelHum
Definition: SgVgosDb.h:1985
SgVgosDb::FmtChkVar fcDisOceanLoad
Definition: SgVgosDb.h:1985
SgVgosDb::FmtChkVar fcTsysIfId
Definition: SgVgosDb.h:1987
QList< SgVgosDb::FmtChkVar * > fcfPartAxisOffset
Definition: SgVgosDb.h:2065
SgVgosDb::FmtChkVar fcTsysIfFreq
Definition: SgVgosDb.h:1987
SgVgosDb::FmtChkVar fcAtmPres
Definition: SgVgosDb.h:1985
QList< SgVgosDb::FmtChkVar * > fcfFeedRotation
Definition: SgVgosDb.h:2063
SgVgosDb::FmtChkVar fcPartAxisOffset
Definition: SgVgosDb.h:1985
SgVgosDb::FmtChkVar fcCalAxisOffset
Definition: SgVgosDb.h:1983
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:2336
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:1530
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 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:1446
QString sessionCode_
Definition: SgVgosDb.h:1416
bool storeStationAzEl(const QString &stnName, SgMatrix *const azTheo, SgMatrix *const elTheo)
QString outputFormatId_
Definition: SgVgosDb.h:1402
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:1394
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:1290
SgVdbVariable vCal_SlantPathTropWet_
Definition: SgVgosDb.h:1281
SgVdbVariable vCal_SlantPathTropDry_
Definition: SgVgosDb.h:1280
SgVdbVariable vPart_HorizonGrad_
Definition: SgVgosDb.h:1287
SgVdbVariable vPart_ZenithPathTropDry_
Definition: SgVgosDb.h:1285
SgVdbVariable vCal_Cable_
Definition: SgVgosDb.h:1279
SgVdbVariable vFeedRotation_
Definition: SgVgosDb.h:1277
SgVdbVariable vCal_AxisOffset_
Definition: SgVgosDb.h:1278
SgVdbVariable vPart_AxisOffset_
Definition: SgVgosDb.h:1284
SgVdbVariable vDis_OceanLoad_
Definition: SgVgosDb.h:1288
SgVdbVariable vCal_OceanLoad_
Definition: SgVgosDb.h:1282
SgVdbVariable vPart_ZenithPathTropWet_
Definition: SgVgosDb.h:1286