General Purpose Geodetic Library
SgParameterCfg.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 #include <QtCore/QDataStream>
25 
26 #include <SgLogger.h>
27 #include <SgParameterCfg.h>
28 
29 const QString typeNames[] = {"WhiteNoise", "MarkovProcess", "RandomWalk"};
30 
31 const QString modeNames[] = {"None", "Global", "Arc", "Local", "PWL", "Stochastic"};
32 
33 /*=======================================================================================================
34 *
35 * METHODS:
36 *
37 *======================================================================================================*/
38 //
39 // static first:
41 {
42  return "SgParameterCfg";
43 };
44 
45 
46 
47 // a constuctor:
48 SgParameterCfg::SgParameterCfg(const QString& name, PMode pMode, SType sType, double convAPriori,
49  double arcStep, double stocAPriori, double breakNoise, double tau,
50  double whiteNoise, double pwlStep, double pwlAPriori, int pwlNumOfPolynomials,
51  double scale, const QString& scaleName)
52 : SgAttribute()
53 {
54  name_ = name;
55  pMode_= pMode;
56  sType_= sType;
57  scale_ = scale;
58  scaleName_ = scaleName;
59  //
60  convAPriori_ = convAPriori;
61  arcStep_ = arcStep;
62  //
63  pwlAPriori_ = pwlAPriori;
64  pwlStep_ = pwlStep;
65  pwlNumOfPolynomials_ = pwlNumOfPolynomials;
66  //
67  stocAPriori_ = stocAPriori;
68  breakNoise_ = breakNoise;
69  tau_ = tau;
70  whiteNoise_ = whiteNoise;
71 };
72 
73 
74 
75 //
76 const QString& SgParameterCfg::type2String(SType type)
77 {
78  return typeNames[type];
79 };
80 
81 
82 
83 //
84 const QString& SgParameterCfg::mode2String(PMode mode)
85 {
86  return modeNames[mode];
87 };
88 
89 
90 
91 //
93 {
94  s << name_ << getAttributes() << (unsigned int)pMode_ << (unsigned int)sType_ << scale_ << scaleName_
96  << breakNoise_ << tau_ << whiteNoise_;
97  if (s.status() != QDataStream::Ok)
98  {
100  ": saveIntermediateResults(): error writting data");
101  return false;
102  };
103  return s.status() == QDataStream::Ok;
104 };
105 
106 
107 
108 //
110 {
111  QString name, scaleName;
112  unsigned int attributes, pMode, sType;
113  double scale, convAPriori, arcStep, pwlAPriori, pwlStep, stocAPriori;
114  double breakNoise, tau, whiteNoise;
115  int pwlNumOfPolynomials;
116  //
117  s >> name >> attributes >> pMode >> sType >> scale >> scaleName
118  >> convAPriori >> arcStep >> pwlAPriori >> pwlStep >> pwlNumOfPolynomials >> stocAPriori
119  >> breakNoise >> tau >> whiteNoise;
120  //
121  if (s.status() != QDataStream::Ok)
122  {
124  ": loadIntermediateResults(): error reading data: " +
125  (s.status()==QDataStream::ReadPastEnd?"read past end of the file":"read corrupt data"));
126  return false;
127  };
128  if (name_ != name)
129  {
131  ": loadIntermediateResults(): error reading data: wrong order, names mismatch: got [" + name +
132  "], expected [" + name_ + "]");
133  return false;
134  };
135  setAttributes(attributes);
136  pMode_ = (PMode) pMode;
137  sType_ = (SType) sType;
138  scale_ = scale;
139  scaleName_ = scaleName;
140  convAPriori_ = convAPriori;
141  arcStep_ = arcStep;
142  pwlAPriori_ = pwlAPriori;
143  pwlStep_ = pwlStep;
144  pwlNumOfPolynomials_ = pwlNumOfPolynomials;
145  stocAPriori_ = stocAPriori;
146  breakNoise_ = breakNoise;
147  tau_ = tau;
148  whiteNoise_ = whiteNoise;
149  //
150  return s.status()==QDataStream::Ok;
151 };
152 /*=====================================================================================================*/
153 
154 
155 
156 /*=======================================================================================================
157 *
158 * FRIENDS:
159 *
160 *======================================================================================================*/
161 //
162 
163 
164 
165 /*=====================================================================================================*/
166 //
167 // aux functions:
168 //
169 
170 
171 // i/o:
172 
173 
174 /*=====================================================================================================*/
175 //
176 // constants:
177 //
178 
179 /*=====================================================================================================*/
SgLogger * logger
Definition: SgLogger.cpp:231
const QString modeNames[]
const QString typeNames[]
void setAttributes(unsigned int a)
Definition: SgAttribute.h:191
unsigned int getAttributes() const
Definition: SgAttribute.h:183
virtual void write(LogLevel, quint32, const QString &, bool=false)
Definition: SgLogger.cpp:88
@ IO_BIN
Definition: SgLogger.h:64
bool saveIntermediateResults(QDataStream &) const
double scale_
Value of the scale factor.
static const QString & type2String(SType)
bool loadIntermediateResults(QDataStream &)
int pwlNumOfPolynomials_
number of polynomials in the PWL model
double arcStep_
a step for arc parameter
double whiteNoise_
psd of ruled white noise
static const QString className()
QString scaleName_
Name of the scale factor.
double breakNoise_
psd of noise process used for "breaks"
static const QString & mode2String(PMode)
double stocAPriori_
a priori std. deviation (stochastic pars)
double pwlStep_
a step for modelling by picewise linear function
double tau_
time of relaxation
double pwlAPriori_
a priori std. deviation (for pisewice linear B-coeffs)
double convAPriori_
a priori std. deviation (conventional pars)