General Purpose Geodetic Library
SgWrmsable.h
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 #ifndef SG_WRMSABLE_H
24 #define SG_WRMSABLE_H
25 
26 
27 #ifdef HAVE_CONFIG_H
28 # include <config.h>
29 #endif
30 
31 
32 #include <math.h>
33 
34 #include <iostream>
35 
36 #include <QtCore/QString>
37 
38 #include <SgMJD.h>
39 
40 
41 
43 {
44  DT_DELAY = 0,
45  DT_RATE = 1,
46 };
47 
48 
49 class QDataStream;
50 
51 
52 class SgTaskConfig;
53 class SgVlbiObservable;
54 
55 
56 
57 /***===================================================================================================*/
64 {
65 public:
66  // Statics:
69  static const QString className();
70 
71  //
72  // constructors/destructors:
73  //
77  inline SgWrmsable(DataType);
78 
79  inline SgWrmsable(const SgWrmsable&);
80 
84  inline ~SgWrmsable();
85 
86 
87 
88  //
89  // Interfaces:
90  //
93  inline DataType getDataType() const {return dataType_;};
94 
97  inline int getNumTotal() const {return numTotal_;};
98 
101  inline int getNumUsable() const {return numUsable_;};
102 
105  inline int getNumProcessed() const {return numProcessed_;};
106 
109  inline double getSigma2add() const {return sigma2add_;};
110 
113  inline const SgMJD& tFirst() const {return tFirst_;};
114 
117  inline const SgMJD& tLast() const {return tLast_;};
118 
121  inline double getNormedResid() const {return normedResid_;};
122 
125  inline double getSFF_NrmRes() const {return sff_NrmRes_;};
126 
129  inline double getSFF_NrmRes_plus_15() const {return sff_NrmRes_plus_15_;};
130 
131  //
132  // sets:
133  inline void setDataType(DataType dType) {dataType_ = dType;};
134 
138  inline void setNumTotal(int n) {numTotal_ = n;};
139 
140  inline void setNumUsable(int n) {numUsable_ = n;};
141 
145  inline void setNumProcessed(int n) {numProcessed_ = n;};
146 
147 // /**Sets an epoch of the first observations.
148 // * \param t -- epoch;
149 // */
150 // inline void setTFirst(const SgMJD& t) {tFirst_ = t;};
151 
152 // /**Sets an epoch of the last observations.
153 // * \param t -- epoch;
154 // */
155 // inline void setTLast(const SgMJD& t) {tLast_ = t;};
156 
157  inline void setSigma2add(double s) {sigma2add_ = s;};
158 
162  inline void setNormedResid(double d) {normedResid_ = d;};
163 
167  inline void setSFF_NrmRes(double d) {sff_NrmRes_ = d;};
168 
172  inline void setSFF_NrmRes_plus_15(double d) {sff_NrmRes_plus_15_ = d;};
173 
174 
175  //
176  // Functions:
177  //
180  inline double chi2() const {return sumWrms2_;};
181 
184  inline double reducedChi2() const {return chi2()/dof();};
185 
188  inline double weightScaleCoefficient() const {return sumW_;};
189 
192  inline void incNumTotal(int inc=1) {numTotal_ += inc;};
193 
196  inline void decNumTotal(int inc=1) {numTotal_ -= inc;};
197 
198  inline void incNumUsable(int inc=1) {numUsable_ += inc;};
199  inline void decNumUsable(int inc=1) {numUsable_ -= inc;};
200 
203  inline void clearWrms();
204 
209  void addWrms(const SgMJD& t, double o_c, double w, double auxSum);
210 
213  inline double dispersion(bool isSolveCompatible) const;
214 
217  inline double wrms() const;
218 
219  inline double dof() const;
220 
221  void recalcSigma2add(double minSigma);
222 
224 
225  inline void resetAllEditings();
226 
227  void calcNormalizedResiduals(const QList<SgVlbiObservable*> &observables, const SgTaskConfig* cfg);
228  //
229  // Friends:
230  //
231 
232  //
233  // I/O:
234  //
236 
238 
239 
240 
241 private:
246  double sumW_; // sum of weights
247  double sumWrms1_; // sum of weighted residuals
248  double sumWrmsWrms_; // sum of (weighted residuals)^2
249  double sumWrms2_; // sum of weighted residuals*residuals
250  double sumAuxOne_;
251  double sumAuxTwo_;
252  double sigma2add_;
255  //
256  // auxiliaries (mostly, for emulating CALC/SOLVE report outputs):
257  double normedResid_;
258  double sff_NrmRes_;
260 };
261 /*=====================================================================================================*/
262 
263 
264 
265 
266 
267 /*=====================================================================================================*/
268 /* */
269 /* SgObjectInfo inline members: */
270 /* */
271 /*=====================================================================================================*/
272 //
273 //
274 // CONSTRUCTORS:
275 //
276 // An empty constructor:
278  tFirst_(tInf),
279  tLast_(tZero)
280 {
281  dataType_ = dType;
282  numTotal_ = 0;
283  numUsable_ = 0;
284  numProcessed_ = 0;
285  sumW_ = 0.0;
286  sumWrms1_ = 0.0;
287  sumWrmsWrms_ = 0.0;
288  sumWrms2_ = 0.0;
289  sumAuxOne_ = 0.0;
290  sumAuxTwo_ = 0.0;
291  sigma2add_ = 0.0;
292  normedResid_ = 0.0;
293  sff_NrmRes_ = 0.0;
294  sff_NrmRes_plus_15_ = 0.0;
295 };
296 
297 
298 
299 //
301  tFirst_(w.tFirst()),
302  tLast_(w.tLast())
303 {
304  dataType_ = w.getDataType();
305  numTotal_ = w.getNumTotal();
306  numUsable_ = w.getNumUsable();
308  sumW_ = w.sumW_;
309  sumWrms1_ = w.sumWrms1_;
311  sumWrms2_ = w.sumWrms2_;
318 };
319 
320 
321 
322 // A destructor:
324 {
325  // nothing to do
326 };
327 
328 
329 
330 //
331 // INTERFACES:
332 //
333 //
334 
335 
336 //
337 // FUNCTIONS:
338 //
339 //
340 inline double SgWrmsable::dispersion(bool isSolveCompatible) const
341 {
342  if (numProcessed_ <= 1 || sumW_ == 0.0)
343  return 0.0;
344  return isSolveCompatible?
345 // old (pre 0.5.1):
346 //->sqrt(sumWrmsWrms_/(numProcessed_ - 1))/sumW_ :
347  sqrt(sumWrms2_/(numProcessed_ - 1)) :
348 // dispersion as it should be:
350 };
351 
352 
353 
354 //
356 {
360  tFirst_ = tInf;
361  tLast_ = tZero;
362 };
363 
364 
365 
366 //
367 inline double SgWrmsable::wrms() const
368 {
369  return (sumW_>0.0 && numProcessed_>0) ? sqrt(sumWrms2_/sumW_) : 0.0;
370 };
371 
372 
373 
374 //
375 inline double SgWrmsable::dof() const
376 {
377  return numProcessed_>1 ? numProcessed_-sumAuxOne_ : 1.0;
378 };
379 
380 
381 
382 //
384 {
385  clearWrms();
386  sigma2add_ = 0.0;
387 };
388 
389 
390 
391 //
392 // FRIENDS:
393 //
394 //
395 //
396 
397 
398 /*=====================================================================================================*/
399 
400 
401 
402 
403 
404 /*=====================================================================================================*/
405 //
406 // aux functions:
407 //
408 
409 
410 /*=====================================================================================================*/
411 #endif //SG_WRMSABLE_H
const SgMJD tZero(1957, 10, 4)
const SgMJD tInf(2100, 1, 1)
DataType
Definition: SgWrmsable.h:43
@ DT_DELAY
Definition: SgWrmsable.h:44
@ DT_RATE
Definition: SgWrmsable.h:45
Definition: SgMJD.h:59
void setNormedResid(double d)
Definition: SgWrmsable.h:162
void setSigma2add(double s)
Definition: SgWrmsable.h:157
SgMJD tLast_
Definition: SgWrmsable.h:254
double weightScaleCoefficient() const
Definition: SgWrmsable.h:188
double sumWrms2_
Definition: SgWrmsable.h:249
const SgMJD & tFirst() const
Definition: SgWrmsable.h:113
void addWrms(const SgMJD &t, double o_c, double w, double auxSum)
Definition: SgWrmsable.cpp:53
void setDataType(DataType dType)
Definition: SgWrmsable.h:133
void calcNormalizedResiduals(const QList< SgVlbiObservable * > &observables, const SgTaskConfig *cfg)
Definition: SgWrmsable.cpp:141
double dispersion(bool isSolveCompatible) const
Definition: SgWrmsable.h:340
const SgMJD & tLast() const
Definition: SgWrmsable.h:117
double reducedChi2() const
Definition: SgWrmsable.h:184
DataType dataType_
Definition: SgWrmsable.h:242
double getNormedResid() const
Definition: SgWrmsable.h:121
double normedResid_
Definition: SgWrmsable.h:257
double wrms() const
Definition: SgWrmsable.h:367
void setNumProcessed(int n)
Definition: SgWrmsable.h:145
double sff_NrmRes_
Definition: SgWrmsable.h:258
void clearWrms()
Definition: SgWrmsable.h:355
double sff_NrmRes_plus_15_
Definition: SgWrmsable.h:259
int getNumUsable() const
Definition: SgWrmsable.h:101
double sumAuxOne_
Definition: SgWrmsable.h:250
void setNumTotal(int n)
Definition: SgWrmsable.h:138
double sumWrmsWrms_
Definition: SgWrmsable.h:248
double sumWrms1_
Definition: SgWrmsable.h:247
void copyStatistics(SgWrmsable *wrms)
Definition: SgWrmsable.cpp:71
void recalcSigma2add(double minSigma)
Definition: SgWrmsable.cpp:95
double sumAuxTwo_
Definition: SgWrmsable.h:251
bool loadIntermediateResults(QDataStream &)
Definition: SgWrmsable.cpp:195
int numTotal_
Definition: SgWrmsable.h:243
double getSFF_NrmRes_plus_15() const
Definition: SgWrmsable.h:129
int getNumTotal() const
Definition: SgWrmsable.h:97
void setSFF_NrmRes(double d)
Definition: SgWrmsable.h:167
void incNumTotal(int inc=1)
Definition: SgWrmsable.h:192
double getSigma2add() const
Definition: SgWrmsable.h:109
DataType getDataType() const
Definition: SgWrmsable.h:93
int getNumProcessed() const
Definition: SgWrmsable.h:105
double getSFF_NrmRes() const
Definition: SgWrmsable.h:125
int numUsable_
Definition: SgWrmsable.h:244
void decNumUsable(int inc=1)
Definition: SgWrmsable.h:199
static const QString className()
Definition: SgWrmsable.cpp:44
void resetAllEditings()
Definition: SgWrmsable.h:383
void incNumUsable(int inc=1)
Definition: SgWrmsable.h:198
void setSFF_NrmRes_plus_15(double d)
Definition: SgWrmsable.h:172
double dof() const
Definition: SgWrmsable.h:375
SgWrmsable(DataType)
Definition: SgWrmsable.h:277
bool saveIntermediateResults(QDataStream &) const
Definition: SgWrmsable.cpp:176
SgMJD tFirst_
Definition: SgWrmsable.h:253
int numProcessed_
Definition: SgWrmsable.h:245
double chi2() const
Definition: SgWrmsable.h:180
double sumW_
Definition: SgWrmsable.h:246
void decNumTotal(int inc=1)
Definition: SgWrmsable.h:196
void setNumUsable(int n)
Definition: SgWrmsable.h:140
double sigma2add_
Definition: SgWrmsable.h:252