General Purpose Geodetic Library
SgBreakModel.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) 2013-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_PARAMETER_BREAK
24 #define SG_PARAMETER_BREAK
25 
26 
27 #ifdef HAVE_CONFIG_H
28 # include <config.h>
29 #endif
30 
31 
32 
33 #include <math.h>
34 
35 #include <QtCore/QString>
36 #include <QtCore/QList>
37 #include <QtCore/QMap>
38 
39 
40 #include <SgAttribute.h>
41 #include <SgMJD.h>
42 
43 
44 
45 class QDataStream;
46 class SgParameter;
47 /***===================================================================================================*/
53 class SgParameterBreak : public SgMJD, public SgAttribute
54 {
55 public:
57  {
58  Attr_NOT_VALID = 1<<0,
59  Attr_MODIFIED = 1<<1,
60  Attr_DYNAMIC = 1<<2,
61  };
62 
63  // Statics:
66  static const QString className();
67 
68  //
69  // constructors/destructors:
70  //
74  inline SgParameterBreak();
75 
80 
84  SgParameterBreak(const SgMJD& t, double a0=0.0, double a1=0.0, double a2=0.0, bool isDynamic=false);
85 
90 
91 
92  //
93  // Interfaces:
94  //
98 
101  inline double getA0() const;
102 
105  inline double getA1() const;
106 
109  inline double getA2() const;
110 
113  inline double getS0() const;
114 
117  inline double getS1() const;
118 
121  inline double getS2() const;
122 
125  inline const SgMJD& getEpoch4Export() const;
126 
130  inline void setA0(double a);
131 
135  inline void setA1(double a);
136 
140  inline void setA2(double a);
141 
145  inline void setS0(double a);
146 
150  inline void setS1(double a);
151 
155  inline void setS2(double a);
156 
160  inline void setEpoch4Export(const SgMJD&);
161 
162  inline SgParameter* pA0() {return pA0_;};
163  inline SgParameter* pA1() {return pA1_;};
164  inline SgParameter* pA2() {return pA2_;};
165  inline const SgParameter* pA0() const {return pA0_;};
166  inline const SgParameter* pA1() const {return pA1_;};
167  inline const SgParameter* pA2() const {return pA2_;};
168 
169  //
170  // Functions:
171  //
176  inline double value(const SgMJD& t, double dT) const;
177  inline double rate (const SgMJD& t, double dT) const;
178 
181  void createParameters(const QString& prefix);
182 
185  void releaseParameters();
186 
189  void propagatePartials(QList<SgParameter*>& parameters, const SgMJD& t, double tau, double sign);
190  void propagatePartials4rates(QList<SgParameter*>& parameters, const SgMJD& t, double tau, double sign);
191 
192 
193  // I/O:
194  //
196 
198  //
199 
200 
201 private:
202  double a0_; // shift
203  double a1_; // changes in rate
204  double a2_; // and acceleration
205  double s0_; // sigma of shift
206  double s1_; // sigma of changes in rate
207  double s2_; // sigma of and acceleration
208  SgMJD epoch4Export_; // an export epoch, should be understandable by solve
212 };
213 /*=====================================================================================================*/
214 
215 
216 
217 
218 
219 
220 /***===================================================================================================*/
226 class SgBreakModel : public QList<SgParameterBreak*>
227 {
228 public:
229  // Statics:
232  static const QString className();
233 
234  //
235  // constructors/destructors:
236  //
240  inline SgBreakModel();
241 
245  inline ~SgBreakModel();
246 
247 
248  //
249  // Interfaces:
250  //
254 
257  inline const SgMJD& getT0() const;
258 
262  inline void setT0(const SgMJD& t);
263 
264  //
265  // Functions:
266  //
267  double value(const SgMJD& t) const;
268  double rate (const SgMJD& t) const;
269 
276  bool addBreak(const SgMJD& t, double a0=0.0, double a1=0.0, double a2=0.0, bool isDynamic=false);
277 
282  bool addBreak(SgParameterBreak* aBreak);
283 
287  bool delBreak(const SgMJD& t);
288 
292  bool delBreak(int n);
293 
294  inline void resetAllEditings();
295 
298  void createParameters(const QString& prefix);
299 
302  void releaseParameters();
303 
306  void propagatePartials(QList<SgParameter*>& parameters, const SgMJD& t, double tau, double sign);
307  void propagatePartials4rates(QList<SgParameter*>& parameters, const SgMJD& t, double tau, double sign);
308 
309  void sortEvents();
310 
311  // I/O:
312  //
314 
316  //
317 
318 
319 private:
321 };
322 /*=====================================================================================================*/
323 
324 
325 
326 
327 
328 
329 
330 
331 /*=====================================================================================================*/
332 /* */
333 /* SgParameterBreak inline members: */
334 /* */
335 /*=====================================================================================================*/
336 //
337 //
338 //
339 // CONSTRUCTORS:
340 //
341 // An empty constructor:
343 {
344  a0_ = 0.0;
345  a1_ = 0.0;
346  a2_ = 0.0;
347  s0_ = 0.0;
348  s1_ = 0.0;
349  s2_ = 0.0;
350  pA0_ = pA1_ = pA2_ = NULL;
351 };
352 
353 
354 
355 
356 
357 
358 //
359 // INTERFACES:
360 //
361 //
362 //
363 inline double SgParameterBreak::getA0() const
364 {
365  return a0_;
366 };
367 
368 
369 
370 //
371 inline double SgParameterBreak::getA1() const
372 {
373  return a1_;
374 };
375 
376 
377 
378 //
379 inline double SgParameterBreak::getA2() const
380 {
381  return a2_;
382 };
383 
384 
385 
386 //
387 inline double SgParameterBreak::getS0() const
388 {
389  return s0_;
390 };
391 
392 
393 
394 //
395 inline double SgParameterBreak::getS1() const
396 {
397  return s1_;
398 };
399 
400 
401 
402 //
403 inline double SgParameterBreak::getS2() const
404 {
405  return s2_;
406 };
407 
408 
409 
410 //
412 {
413  return epoch4Export_;
414 };
415 
416 
417 
418 //
419 inline void SgParameterBreak::setA0(double a)
420 {
421  a0_ = a;
422 };
423 
424 
425 
426 //
427 inline void SgParameterBreak::setA1(double a)
428 {
429  a1_ = a;
430 };
431 
432 
433 
434 //
435 inline void SgParameterBreak::setA2(double a)
436 {
437  a2_ = a;
438 };
439 
440 
441 
442 //
443 inline void SgParameterBreak::setS0(double s)
444 {
445  s0_ = s;
446 };
447 
448 
449 
450 //
451 inline void SgParameterBreak::setS1(double s)
452 {
453  s1_ = s;
454 };
455 
456 
457 
458 //
459 inline void SgParameterBreak::setS2(double s)
460 {
461  s2_ = s;
462 };
463 
464 
465 
466 //
468 {
469  epoch4Export_ = t;
470 };
471 
472 
473 
474 //
475 // FUNCTIONS:
476 //
477 //
478 //
479 inline double SgParameterBreak::value(const SgMJD& t, double dT) const
480 {
481  return isAttr(SgParameterBreak::Attr_DYNAMIC) || t<*this ? 0.0 : a0_ + a1_*dT + a2_*dT*dT;
482 };
483 
484 
485 
486 //
487 inline double SgParameterBreak::rate(const SgMJD& t, double dT) const
488 {
489  return isAttr(SgParameterBreak::Attr_DYNAMIC) || t<*this ? 0.0 : a1_ + 2.0*a2_*dT;
490 };
491 /*=====================================================================================================*/
492 
493 
494 
495 
496 
497 
498 /*=====================================================================================================*/
499 /* */
500 /* SgBreakModel inline members: */
501 /* */
502 /*=====================================================================================================*/
503 //
504 //
505 //
506 // CONSTRUCTORS:
507 //
508 // An empty constructor:
510  : QList<SgParameterBreak*>()
511 {
512  t0_ = tZero;
513 };
514 
515 
516 
517 // A destructor:
519 {
520  for (int i=0; i<size(); i++)
521  delete at(i);
522  clear();
523 };
524 
525 
526 
527 //
528 // INTERFACES:
529 //
530 //
531 //
532 inline const SgMJD& SgBreakModel::getT0() const
533 {
534  return t0_;
535 };
536 
537 
538 
539 //
540 inline void SgBreakModel::setT0(const SgMJD& t)
541 {
542  t0_ = t;
543 };
544 
545 
546 
547 //
549 {
550  for (int i=0; i<size(); i++)
551  delete at(i);
552  clear();
553 };
554 
555 
556 
557 //
558 // FUNCTIONS:
559 //
560 //
561 //
562 //
563 /*=====================================================================================================*/
564 
565 
566 
567 
568 
569 
570 
571 /*=====================================================================================================*/
572 //
573 // aux functions:
574 //
575 
576 
577 /*=====================================================================================================*/
578 #endif //SG_PARAMETER_BREAK
const SgMJD tZero(1957, 10, 4)
const SgMJD tInf(2100, 1, 1)
bool isAttr(uint a) const
Definition: SgAttribute.h:226
void setT0(const SgMJD &t)
Definition: SgBreakModel.h:540
SgBreakModel & operator=(const SgBreakModel &m)
double value(const SgMJD &t) const
bool delBreak(const SgMJD &t)
void createParameters(const QString &prefix)
double rate(const SgMJD &t) const
bool addBreak(const SgMJD &t, double a0=0.0, double a1=0.0, double a2=0.0, bool isDynamic=false)
bool loadIntermediateResults(QDataStream &)
const SgMJD & getT0() const
Definition: SgBreakModel.h:532
static const QString className()
void propagatePartials4rates(QList< SgParameter * > &parameters, const SgMJD &t, double tau, double sign)
void propagatePartials(QList< SgParameter * > &parameters, const SgMJD &t, double tau, double sign)
void releaseParameters()
void resetAllEditings()
Definition: SgBreakModel.h:548
bool saveIntermediateResults(QDataStream &) const
Definition: SgMJD.h:59
double getA2() const
Definition: SgBreakModel.h:379
void propagatePartials(QList< SgParameter * > &parameters, const SgMJD &t, double tau, double sign)
SgParameter * pA1_
Definition: SgBreakModel.h:210
void setA2(double a)
Definition: SgBreakModel.h:435
double value(const SgMJD &t, double dT) const
Definition: SgBreakModel.h:479
const SgParameter * pA1() const
Definition: SgBreakModel.h:166
SgParameter * pA2_
Definition: SgBreakModel.h:211
double getS1() const
Definition: SgBreakModel.h:395
double getA1() const
Definition: SgBreakModel.h:371
double rate(const SgMJD &t, double dT) const
Definition: SgBreakModel.h:487
SgParameter * pA2()
Definition: SgBreakModel.h:164
void setS0(double a)
Definition: SgBreakModel.h:443
double getS2() const
Definition: SgBreakModel.h:403
double getS0() const
Definition: SgBreakModel.h:387
void setS1(double a)
Definition: SgBreakModel.h:451
SgParameter * pA0()
Definition: SgBreakModel.h:162
bool loadIntermediateResults(QDataStream &)
SgParameter * pA0_
Definition: SgBreakModel.h:209
const SgMJD & getEpoch4Export() const
Definition: SgBreakModel.h:411
double getA0() const
Definition: SgBreakModel.h:363
void propagatePartials4rates(QList< SgParameter * > &parameters, const SgMJD &t, double tau, double sign)
void createParameters(const QString &prefix)
static const QString className()
void setA0(double a)
Definition: SgBreakModel.h:419
SgParameterBreak & operator=(const SgParameterBreak &b)
@ Attr_DYNAMIC
parameters supposed to be estimated during the common solution;
Definition: SgBreakModel.h:60
@ Attr_NOT_VALID
do not use this break;
Definition: SgBreakModel.h:58
@ Attr_MODIFIED
parameters were modified;
Definition: SgBreakModel.h:59
void setS2(double a)
Definition: SgBreakModel.h:459
bool saveIntermediateResults(QDataStream &) const
void setA1(double a)
Definition: SgBreakModel.h:427
SgParameter * pA1()
Definition: SgBreakModel.h:163
void setEpoch4Export(const SgMJD &)
Definition: SgBreakModel.h:467
const SgParameter * pA0() const
Definition: SgBreakModel.h:165
const SgParameter * pA2() const
Definition: SgBreakModel.h:167