General Purpose Geodetic Library
SgParameter.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 <SgParameter.h>
25 #include <SgLogger.h>
26 
27 
28 
29 
30 /*=======================================================================================================
31 *
32 * METHODS:
33 *
34 *======================================================================================================*/
35 //
36 // static first:
37 const QString SgParameter::className()
38 {
39  return "SgParameter";
40 };
41 
42 
43 
44 //
46 {
48  value_ = p.getValue();
49  solution_ = p.getSolution();
50  sigma_ = p.getSigma();
51  scale_ = p.getScale();
52  pMode_ = p.getPMode();
53  sType_ = p.getSType();
56  tau_ = p.getTau();
57  psd_RWN_ = p.getPsd_RWN();
58  psd_BN_ = p.getPsd_BN();
59  prefix_ = p.getPrefix();
60  step_ = p.getStep();
61  ttl_ = p.getTTL();
63  tLeft_ = p.getTLeft();
64  tRight_ = p.getTRight();
65  idx_ = p.getIdx();
66  return *this;
67 };
68 
69 
70 
71 //
73 {
74  scale_ = cfg.getScale();
75  switch (cfg.getPMode())
76  {
80  break;
82  step_ = cfg.getPwlStep();
83 // sigmaAPriori_ = cfg.getPwlAPriori()*step_/scale_;
87  break;
89  step_ = cfg.getArcStep();
90  ttl_ = step_;
93  break;
94  default:
95  step_ = cfg.getArcStep();
98  break;
99  };
100  //
101  tau_ = cfg.getTau();
102  psd_RWN_ = cfg.getWhiteNoise()/scale_;
103  psd_BN_ = cfg.getBreakNoise()/scale_;
104  pMode_ = cfg.getPMode();
105  sType_ = cfg.getSType();
106  //
109  else
111 };
112 
113 
114 
115 //
117 {
118  scale_ = cfg.getScale();
119  switch ((pMode_=pMode))
120  {
124  break;
126  step_ = cfg.getPwlStep();
127 // sigmaAPriori_ = cfg.getPwlAPriori()*step_/scale_;
131  break;
133  step_ = cfg.getArcStep();
134  ttl_ = step_;
137  break;
138  default:
139  step_ = cfg.getArcStep();
142  break;
143  };
144 
145  tau_ = cfg.getTau();
146  psd_RWN_ = cfg.getWhiteNoise()/scale_;
147  psd_BN_ = cfg.getBreakNoise()/scale_;
148  sType_ = cfg.getSType();
149  //
152  else
154 };
155 
156 
157 
158 //
160 {
161  scale_ = p.getScale();
164  tau_ = p.getTau();
165  psd_RWN_ = p.getPsd_RWN();
166  psd_BN_ = p.getPsd_BN();
167  pMode_ = p.getPMode();
168  sType_ = p.getSType();
169  step_ = p.getStep();
170  prefix_ = p.getPrefix();
171  ttl_ = p.getTTL();
173 };
174 
175 
176 
177 //
179 {
180  if (p)
181  {
182  value_ += p->getSolution();
183  solution_ = p->getSolution();
184  sigma_ = p->getSigma();
185  }
186  else
188  ": update(): cannot update from NULL");
189 };
190 
191 
192 
193 //
194 double SgParameter::calcM(double dT)
195 {
196  double d=0.0;
197  switch (sType_)
198  {
200  d = 0.0;
201  break;
203  d = exp( -24.0*dT/tau_ ); // Tau in hours
204  break;
205  default:
207  //d = isAttr(Attr_IS_BREAK) ? 0.0 : 1.0;
208  d = 1.0;
209  break;
210  };
211  return d;
212 };
213 
214 
215 
216 //
217 double SgParameter::calcRW(double dT)
218 {
219  double psd = isAttr(Attr_IS_BREAK) ? psd_BN_ : psd_RWN_;
220  double e=0.0, m=0.0;
221  switch (sType_)
222  {
224  e = -1.0;
225  break;
227  m = calcM(dT);
228  e = tau_/2.0*(1.0 - m*m)*psd*psd; // Tau in hours
229  break;
230  default:
232  e = 24.0*dT*psd*psd;
233  // e = 24.0*dT*24.0*dT*psd*psd/2.0; ???IRW???
234  break;
235  };
236 
237  if (isAttr(Attr_IS_BREAK))
238  {
240  ": a Break Flag detected for the parameter [" + getName() + "]; processed");
242  };
243  return e>0.0 ? 1.0/sqrt(e) : sigmaAPriori_;
244 };
245 /*=======================================================================================================
246 *
247 * FRIENDS:
248 *
249 *======================================================================================================*/
250 //
251 
252 
253 
254 /*=====================================================================================================*/
255 //
256 // aux functions:
257 //
259 {
260  return p1->getName() < p2->getName();
261 };
262 
263 
264 
265 //
267 {
268  return p1->getTTL()==p2->getTTL() ? p1->getName()<p2->getName() : p1->getTTL()<p2->getTTL();
269 };
270 
271 
272 
273 //
275 {
276  return p1->getTLeft()==p2->getTLeft() ?
277  (p1->getTRight()==p2->getTRight() ? p1->getName()<p2->getName() : p1->getTRight()<p2->getTRight()) :
278  p1->getTLeft()<p2->getTLeft();
279 };
280 
281 
282 
283 //
285 {
286  return p1->getTRight()==p2->getTRight() ?
287  (p1->getTLeft()==p2->getTLeft() ? p1->getName()<p2->getName() : p1->getTLeft()>p2->getTLeft()) :
288  p1->getTRight()<p2->getTRight();
289 };
290 
291 
292 
293 //
295 {
296  if (!x)
297  {
299  "updateSolutionAtParameterList(): the vector x is NULL");
300  return;
301  };
302  if (!x->n())
303  {
305  "updateSolutionAtParameterList(): the dimension of vector x is zero");
306  return;
307  };
308  if (!P)
309  {
311  "updateSolutionAtParameterList(): the matrix P is NULL");
312  return;
313  };
314  if (!P->n())
315  {
317  "updateSolutionAtParameterList(): the dimension of matrix P is zero");
318  return;
319  };
320  if ((int)x->n() != list.size())
321  {
322  logger->write(SgLogger::ERR, SgLogger::ESTIMATOR, "updateSolutionAtParameterList(): "
323  "the number of parameters and the dimension of vector x are different; solution is ignored");
324  return;
325  };
326  if ((int)P->n() != list.size())
327  {
328  logger->write(SgLogger::ERR, SgLogger::ESTIMATOR, "updateSolutionAtParameterList(): "
329  "the number of parameters and the dimension of matrix P are different; solution is ignored");
330  return;
331  };
332 
333  for (int i=0; i<list.count(); i++)
334  {
335  SgParameter* p = list.at(i);
336  p->setSolution(x->getElement(i));
337  p->setSigma(sqrt(P->getElement(i, i)));
338  };
339 };
340 
341 
342 
343 //
344 void reportParameterList(const QList<SgParameter*>& list, bool isShowTLeftRight)
345 {
347  return;
348 
349  QString str;
350  for (int i=0; i<list.count(); i++)
351  {
352  SgParameter* p = list.at(i);
353  /*
354  str.sprintf(": %20.8f/%20.8f (%.8f) @ %8d pnt ",
355  p->getValue()*p->getScale(), p->getSolution()*p->getScale(),
356  p->getSigma()*p->getScale(), p->getNumObs());
357  */
358  str.sprintf(": %14.3f (%.3f) @ %6d pnt ",
359  p->getSolution()*p->getScale(), p->getSigma()*p->getScale(), p->getNumObs());
360  if (isShowTLeftRight)
364  else
369  };
370  if (list.count())
371  logger->write(SgLogger::DBG, SgLogger::ESTIMATOR, "+++ end of report +++");
372 };
373 
374 
375 
376 //
377 /*
378 void clearStatisticsForParameters(QList<SgParameter*>& list)
379 {
380  for (int i=0; i<list.count(); i++)
381  list.at(i)->clearStatistics();
382 };
383 */
384 
385 
386 // i/o:
387 
388 
389 /*=====================================================================================================*/
390 //
391 // constants:
392 //
393 
394 
395 /*=====================================================================================================*/
SgLogger * logger
Definition: SgLogger.cpp:231
bool lessThan4_ParameterByTTLSortingOrder(SgParameter *p1, SgParameter *p2)
void reportParameterList(const QList< SgParameter * > &list, bool isShowTLeftRight)
bool lessThan4_ParameterByTRightSortingOrder(SgParameter *p1, SgParameter *p2)
void updateSolutionAtParameterList(QList< SgParameter * > &list, SgVector *x, SgSymMatrix *P)
bool lessThan4_ParameterByTLeftSortingOrder(SgParameter *p1, SgParameter *p2)
bool lessThan4_ParameterByNameSortingOrder(SgParameter *p1, SgParameter *p2)
bool isAttr(uint a) const
Definition: SgAttribute.h:226
void delAttr(uint a)
Definition: SgAttribute.h:210
void addAttr(uint a)
Definition: SgAttribute.h:202
virtual void write(LogLevel, quint32, const QString &, bool=false)
Definition: SgLogger.cpp:88
@ ESTIMATOR
Definition: SgLogger.h:90
bool isEligible(LogLevel lvl, quint32 f) const
Definition: SgLogger.h:151
@ F_YYYYMMDDHHMMSSSS
Long verbose: Fri, the 2nd of Apr, 2010; 17hr 02min 43.6400sec.
Definition: SgMJD.h:67
QString toString(Format format=F_Verbose) const
Definition: SgMJD.cpp:1007
double getTau() const
double getStocAPriori() const
int getPwlNumOfPolynomials() const
double getConvAPriori() const
SType getSType() const
double getPwlStep() const
double getPwlAPriori() const
double getWhiteNoise() const
double getBreakNoise() const
@ Attr_IS_PROPAGATED
propagate the parameter in time;
PMode getPMode() const
double getScale() const
double getArcStep() const
double getPsd_BN() const
Definition: SgParameter.h:507
double sigma_
a sigma of the latest estimation;
Definition: SgParameter.h:299
double calcRW(double)
double getStep() const
Definition: SgParameter.h:523
double getScale() const
Definition: SgParameter.h:451
const QString & getPrefix() const
Definition: SgParameter.h:515
int idx_
an index in common list of parameters
Definition: SgParameter.h:316
double solution_
a solution from latest estimation;
Definition: SgParameter.h:298
double value_
the value of adjustment process (cumulative);
Definition: SgParameter.h:297
double getSolution() const
Definition: SgParameter.h:435
SgMJD getTRight() const
Definition: SgParameter.h:555
SgParameterCfg::PMode pMode_
Definition: SgParameter.h:302
double getPsd_RWN() const
Definition: SgParameter.h:499
QString prefix_
Definition: SgParameter.h:309
double ttl_
Definition: SgParameter.h:311
SgMJD getTLeft() const
Definition: SgParameter.h:547
SgMJD tLeft_
Definition: SgParameter.h:314
SgMJD tRight_
Definition: SgParameter.h:315
static const QString className()
Definition: SgParameter.cpp:37
int getNumOfPolynomials() const
Definition: SgParameter.h:539
void tune(const SgParameterCfg &)
Definition: SgParameter.cpp:72
SgParameterCfg::PMode getPMode() const
Definition: SgParameter.h:459
double psd_RWN_
PSD of Ruled White Noise.
Definition: SgParameter.h:307
void setSigma(double v)
Definition: SgParameter.h:587
double psd_BN_
PSD of White Noise used in break.
Definition: SgParameter.h:308
double getValue() const
Definition: SgParameter.h:427
SgParameterCfg::SType sType_
Definition: SgParameter.h:303
double getSigma() const
Definition: SgParameter.h:443
int getIdx() const
Definition: SgParameter.h:563
void update(SgParameter *p)
double getSigmaAPriori() const
Definition: SgParameter.h:475
SgParameter & operator=(const SgParameter &a)
Definition: SgParameter.cpp:45
double step_
Definition: SgParameter.h:310
double sigmaAPrioriAux_
a priori std. deviation (to init the Inform. matrix)
Definition: SgParameter.h:305
double scale_
a scale factor;
Definition: SgParameter.h:300
void setSolution(double v)
Definition: SgParameter.h:579
SgParameterCfg::SType getSType() const
Definition: SgParameter.h:467
double calcM(double)
int numOfPolynomials_
number of polinomials for a model
Definition: SgParameter.h:312
double getTTL() const
Definition: SgParameter.h:531
double getTau() const
Definition: SgParameter.h:491
double sigmaAPriori_
a priori std. deviation (to init the Inform. matrix)
Definition: SgParameter.h:304
double getSigmaAPrioriAux() const
Definition: SgParameter.h:483
double tau_
time of relaxation (for stochastic parameters)
Definition: SgParameter.h:306
int getNumObs() const
Definition: SgPartial.h:299
const SgMJD & getTStart() const
Definition: SgPartial.h:315
SgMJD getTMean(const SgMJD &=tZero) const
Definition: SgPartial.h:416
SgPartial & operator=(const SgPartial &a)
Definition: SgPartial.cpp:44
const QString & getName() const
Definition: SgPartial.h:283
@ Attr_IS_PROPAGATED
the parameter's info have to be propagated in future
Definition: SgPartial.h:51
@ Attr_IS_BREAK
there is a break in the parameter's behavior
Definition: SgPartial.h:50
const SgMJD & getTFinis() const
Definition: SgPartial.h:323
double getElement(unsigned int i, unsigned int j) const
Definition: SgSymMatrix.h:274
unsigned int n() const
Definition: SgUtMatrix.h:290
unsigned int n() const
Definition: SgVector.h:327
double getElement(unsigned int i) const
Definition: SgVector.h:362