KalmanFilter.hpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4 //
5 // The GNSSTk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation; either version 3.0 of the License, or
8 // any later version.
9 //
10 // The GNSSTk is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with GNSSTk; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 // This software was developed by Applied Research Laboratories at the
20 // University of Texas at Austin.
21 // Copyright 2004-2022, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 //==============================================================================
26 //
27 // This software was developed by Applied Research Laboratories at the
28 // University of Texas at Austin, under contract to an agency or agencies
29 // within the U.S. Department of Defense. The U.S. Government retains all
30 // rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 // Pursuant to DoD Directive 523024
33 //
34 // DISTRIBUTION STATEMENT A: This software has been approved for public
35 // release, distribution is unlimited.
36 //
37 //==============================================================================
38 
40 
41 #ifndef KALMAN_FILTER_INCLUDE
42 #define KALMAN_FILTER_INCLUDE
43 
44 #include "Exception.hpp"
45 #include "Matrix.hpp"
46 #include "Namelist.hpp"
47 #include "SRIFilter.hpp"
48 #include "Vector.hpp"
49 #include "logstream.hpp"
50 #include <map>
51 #include <sstream>
52 #include <string>
53 
54 namespace gnsstk
55 {
137  {
138  public:
139  // enum to define the current filter operation, mostly for output()
140  typedef enum FilterStageEnum
141  {
142  Unknown = 0,
146  IB3, // for "in between" meaning Interim
147  TU,
148  MU,
149  SU,
151  } FilterStage;
152 
153  // enum to define the return values for defineMeasurements()
155  {
156  Process = 0,
162  } KalmanReturn;
163 
164  // ----------------------------------------------------------------------------
165  // data
166  protected:
168  bool doOutput;
182  bool singular;
187  bool doSRISU;
192  bool extended;
197  bool smoother;
199  bool inverted;
206  bool dryRun;
207 
208  int NTU;
209  int NMU;
210  int NSU;
211  int Nstate;
212  int Nnoise;
213 
215  double time;
216  double nominalDT;
217  double big, small;
218  std::string KFtag;
219 
223  // MU
230  // TU
237  // SU
240 
242  typedef struct Smoother_storage_record
243  {
250  double Time;
252  std::map<int, SmootherStoreRec> SmootherStore;
253 
254  public:
255  // functions
256  // -----------------------------------------------------------------------------
257  /* 1. Define all the 'define' functions; this constitutes the filter
258  design; these get information from the user and MUST be implemented in
259  the derived class. */
260 
276  virtual int defineInitial(double& T0, gnsstk::Vector<double>& X,
278 
300  virtual KalmanReturn defineMeasurements(double& T,
301  const gnsstk::Vector<double>& X,
302  const gnsstk::Matrix<double>& C,
303  bool useFlag) = 0;
304 
315  virtual void defineTimestep(double T, double DT,
318  bool useFlag) = 0;
319 
328  virtual int defineInterim(int which, double Time) { return -1; }
329 
330  // -----------------------------------------------------------------------------
337  : NTU(0), NMU(0), NSU(0), Nstate(0), stage(Unknown), Nnoise(0),
338  extended(false), smoother(false), doSRISU(true), doOutput(true),
339  doInversions(true), singular(true), timeReversed(false),
340  dryRun(false)
341  {
342  }
343 
348  KalmanFilter(const gnsstk::Namelist& NL) { Reset(NL); }
349 
354  void Reset(const gnsstk::Namelist& NL) { initialize(NL); }
355 
357  virtual ~KalmanFilter(){};
358 
359  // -----------------------------------------------------------------------------
363  virtual void initializeFilter()
364  {
365  try
366  {
367  double T;
368 
369  int isInfo;
371  gnsstk::Matrix<double> initCov; // may be info or cov
372 
373  // call derived class to get initial time, apriori state
374  // and covariance
375  isInfo = defineInitial(T, initX, initCov);
376  time = T;
377  stage = Init;
378 
379  try
380  {
381  if (isInfo == -1)
382  {
383  srif.addAPrioriInformation(initCov, initX);
384  Invert(std::string("Invert after adding a priori info"));
385  }
386  else if (isInfo == 1)
387  {
388  srif.addAPriori(initCov, initX);
389  Invert(std::string("Invert after adding a priori info"));
391  // Cov = initCov;
392  // State = initX;
393  // inverted = true;
394  }
395  else
396  { // returned zero
397  State = initX;
398  Cov = initCov;
399  inverted = false;
400  }
401  }
402  catch (gnsstk::Exception& e)
403  {
404  e.addText("Failed to add apriori");
405  GNSSTK_RETHROW(e);
406  }
407 
408  if (inverted)
409  {
410  output(NTU);
411  }
412  }
413  catch (gnsstk::Exception& e)
414  {
415  e.addText("initializeFilter");
416  GNSSTK_RETHROW(e);
417  }
418  }
419 
420  // -------------------------------------------------------------
433  virtual void ForwardFilter(double finalT, double DT)
434  {
435  int iret;
436  try
437  {
438  // don't allow a non-positive timestep
439  if ((!timeReversed && DT <= 0.0) || (timeReversed && DT >= 0.0))
440  {
442  std::string("Filter time step must be ") +
443  (timeReversed ? std::string("< 0") : std::string("> 0")));
444  GNSSTK_THROW(e);
445  }
446 
447  // save filter timestep, which is the timestep of one TU,
448  // and ~timestep between consecutive defineMeasurements()
449  nominalDT = DT;
450 
451  // to avoid round-off problems, make time comparisons only to within
452  // tol
453  const double tol(nominalDT / 10.0);
454 
455  // forward filter: loop over time
456  double tmax(finalT + nominalDT);
457  while (
458  (timeReversed ? (time - tmax >= tol) : (time - tmax <= -tol)))
459  {
460 
461  // ------------------------------------------------------------
462  // interim #1
463  iret = KalmanInterim(1, time);
464 
465  if (iret)
466  {
467  stage = IB1;
468  Invert(std::string("Invert after interim 1"));
469  output(NTU);
470  }
471 
472  // ------------------------------------------------------------
473  /* MU: returns 0: Process : ok, process normally
474  * 1: ProcessThenQuit : quit after this data,
475  * 2: SkipThisEpoch : don't process this data, but
476  * proceed 3: SkipThenQuit : skip this data, and
477  * then quit 4: QuitImmediately : stop now
478  * This defines nexttime as the next available data epoch. */
479  double nexttime = time;
480  KalmanReturn kfret = KalmanMeasurementUpdate(nexttime);
481  if (kfret == QuitImmediately || kfret == SkipThenQuit)
482  {
483  break;
484  }
485  // else SkipThisEpoch
486  else if (kfret == Process || kfret == ProcessThenQuit)
487  {
488  stage = MU;
489 
490  if (doInversions)
491  {
492  Invert(std::string("Invert after MU"));
493  output(NMU);
494  }
495  }
496  // TD would you ever want several TUs before the first good MU?
497  else if (kfret == SkipThisEpoch && NTU == 0)
498  {
499  time = nexttime;
500  continue;
501  }
502 
503  // ------------------------------------------------------------
504  // interim #2
505  iret = KalmanInterim(2, time);
506 
507  if (iret)
508  {
509  stage = IB2;
510  Invert(std::string("Invert after interim 2"));
511  output(NTU);
512  }
513 
514  // ------------------------------------------------------------
515  // compute next timestep
516  double deltaT = nexttime - time;
517  // why the 1.5? why not? it must be >1 and <=2
518  if (::fabs(deltaT) > 1.5 * ::fabs(nominalDT))
519  {
520  deltaT = nominalDT;
521  }
522 
523  // TU. this will update time by deltaT
524  KalmanTimeUpdate(time, deltaT);
525  stage = TU;
526 
527  if (doInversions)
528  {
529  Invert(std::string("Invert after TU"));
530  output(NTU);
531  }
532 
533  // ------------------------------------------------------------
534  // interim #3
535  iret = KalmanInterim(3, time);
536 
537  if (iret)
538  {
539  stage = IB3;
540  Invert(std::string("Invert after interim 3"));
541  output(NTU);
542  }
543 
544  if (kfret == ProcessThenQuit || kfret == SkipThenQuit)
545  {
546  break;
547  }
548 
549  } // end loop over forward filter
550  }
551  catch (gnsstk::Exception& e)
552  {
553  e.addText("ForwardFilter");
554  GNSSTK_RETHROW(e);
555  }
556  }
557 
558  // -------------------------------------------------------------
563  void BackwardFilter(double M)
564  {
565  GNSSTK_THROW(
566  gnsstk::Exception("BackwardFilter must be called with integer NTU"));
567  }
568 
569  // -------------------------------------------------------------
575  virtual void BackwardFilter(int M)
576  {
577  try
578  {
579  if (!isSmoother())
580  {
581  gnsstk::Exception e("Use setSmoother(true) to turn on smoothing");
582  GNSSTK_THROW(e);
583  }
584  if (singular)
585  {
586  gnsstk::Exception e("Cannot smooth singular filter");
587  GNSSTK_THROW(e);
588  }
589 
590  stage = SU;
591  if (M < 0)
592  {
593  M = 0;
594  }
595 
596  while (NTU > M)
597  {
598 
599  // Do the SU. Decrements time by timestep, and decrements NTU
600  // (first)
602 
603  // get state after SU -- only if using SRISU, not SRIS_DM
604  if (doSRISU)
605  {
606  Invert(std::string("Invert after SRISU"));
607  }
608 
609  // ------------------------------------------------------------
610  // interim #4
611  // Calls defineInterim(4,time); NB ignore return value
612  KalmanInterim(4, time);
613 
614  // output - do it here so names agree forward/backward
615  output(NTU);
616 
617  } // end loop
618  }
619  catch (gnsstk::Exception& e)
620  {
621  e.addText("BackwardFilter");
622  GNSSTK_RETHROW(e);
623  }
624  }
625 
626  // -------------------------------------------------------------
632  virtual void output(int N)
633  {
634  if (!doOutput)
635  {
636  return;
637  }
638 
639  unsigned int i;
640  std::ostringstream oss;
641 
642  if (stage == Unknown)
643  {
644  LOG(ERROR) << "Kalman stage not defined in output().";
645  return;
646  }
647  LOG(DEBUG) << "Enter KalmanFilter::output(" << N << ")";
648 
649  // if MU or SU, output the namelist first
650  // TD make verbose
651  if (stage == Init || stage == MU || stage == SU)
652  {
653  oss << ((stage == MU || stage == Init) ? "KNL" : "KSL") << KFtag
654  << " " << std::fixed << N << " " << std::setprecision(3)
655  << time;
657  for (i = 0; i < NL.size(); i++)
658  oss << std::setw(10) << NL.getName(i);
659 
660  LOG(INFO) << oss.str();
661  oss.str("");
662  }
663 
664  // output a label
665  switch (stage)
666  {
667  case Init:
668  oss << "KIN";
669  break;
670  case IB1:
671  case IB2:
672  case IB3:
673  oss << "KIB";
674  break;
675  case TU:
676  oss << "KTU";
677  break;
678  case MU:
679  oss << "KMU";
680  break;
681  case SU:
682  oss << "KSU";
683  break;
684  default:
685  case Unknown:
686  LOG(INFO) << "Kalman stage not defined." << std::endl;
687  return;
688  }
689  oss << KFtag << " ";
690 
691  // output the time
692  oss << std::fixed << N << " " << std::setprecision(3) << time;
693 
694  // output the state
695  for (i = 0; i < State.size(); i++)
696  oss << " " << std::setw(9) << State(i);
697 
698  // output sqrt of diagonal covariance elements
699  oss << std::scientific << std::setprecision(2);
700  for (i = 0; i < State.size(); i++)
701  oss << " " << std::setw(10) << (singular ? 0.0 : ::sqrt(Cov(i, i)));
702 
703  LOG(INFO) << oss.str();
704  }
705 
706  // ---------------------------------------------------------------------
707  // The support routines
708  // -------------------------------------------------------------------------
712  virtual int KalmanInterim(int which, double Time)
713  {
714  try
715  {
716  int iret = defineInterim(which, Time);
717  if (iret < 0)
718  {
719  return Process;
720  }
721  return iret;
722  }
723  catch (gnsstk::Exception& e)
724  {
725  e.addText("KINT");
726  GNSSTK_RETHROW(e);
727  }
728  }
729 
730  // -------------------------------------------------------------
740  {
741  try
742  {
743  // Pass in T=current, return T=next data epoch;
744  // if next > curr+nominalDT, should return SkipThisEpoch so TU will
745  // catch up
746  KalmanReturn ret =
749  if (ret == Process || ret == ProcessThenQuit)
750  {
751  if (extended)
752  {
753  srif.zeroState();
754  }
755  // NB. derived class must update reference trajectory
756 
757  if (!dryRun)
758  {
759  // this func whitens before update, then unwhitens resid
760  // (PFResid)
761  PFResid = Data; // MU will replace with post-fit residuals
763  }
764 
765  inverted = false;
766  NMU++;
767  }
768 
769  return ret;
770  }
771  catch (gnsstk::Exception& e)
772  {
773  e.addText("KMU");
774  GNSSTK_RETHROW(e);
775  }
776  }
777 
778  // -------------------------------------------------------------
783  virtual void KalmanTimeUpdate(double T, double DT)
784  {
785  try
786  {
787  // LOG(INFO) << "KTU with NTU NMU " << NTU << " " << NMU;
788 
789  double timesave(time);
790 
791  time += DT;
793 
794  Nnoise = Rw.rows(); // Nnoise is member, but temporary
796 
797  // control
798  if (Control.size() > 0)
799  {
800  srif.shift(-PhiInv * Control); // not tested
801  }
802 
803  // create a new smoother storage record
804  if (isSmoother())
805  { // save for smoother
808  // timeUpdate will trash these
809  rec.PhiInv = PhiInv;
810  rec.G = G;
811  if (Control.size() > 0)
812  {
813  rec.Control = Control;
814  }
815  }
816 
817  Zw = 0.0; // yes this is necessary
819  if (!dryRun)
820  {
821  srif.timeUpdate(PhiInv, Rw, G, Zw, Rwx);
822  }
823  inverted = false;
824 
825  if (isSmoother())
826  { // save for smoother
828  // indexing is 0...NTU-1
829  rec.Rw = Rw;
830  rec.Rwx = Rwx;
831  rec.Zw = Zw;
832  rec.Time = timesave;
833  }
834 
835  NTU++;
836  }
837  catch (gnsstk::Exception& e)
838  {
839  e.addText("KTU");
840  GNSSTK_RETHROW(e);
841  }
842  }
843 
844  // -------------------------------------------------------------
846  virtual void KalmanSmootherUpdate()
847  {
848  try
849  {
850  NTU--;
851  NSU++;
852 
853  // LOG(DEBUG) << " SU at " << NTU << " with state " <<
854  // srif.getNames();
857  gnsstk::Matrix<double> Rwx = rec.Rwx;
859  gnsstk::Matrix<double> G = rec.G;
861  // SU knows nothing about time; this is just for output purposes
862  time = rec.Time;
863 
864  // TD should Control vector correction be here???
865 
866  if (!dryRun)
867  {
868  if (doSRISU)
869  {
871  Phi = inverse(PhiInv);
872  srif.smootherUpdate(Phi, Rw, G, Zw, Rwx);
873  inverted = false;
874  }
875  else
876  {
877  srif.DMsmootherUpdate(Cov, State, PhiInv, Rw, G, Zw, Rwx);
878  }
879  }
880 
881  // correct for Control vector
882  if (rec.Control.size() > 0)
883  {
885  if (doSRISU)
886  {
888  }
889  else
890  {
891  State -= PhiInv * Control;
892  }
893  }
894  }
895  catch (gnsstk::Exception& e)
896  {
897  e.addText("KSU");
898  GNSSTK_RETHROW(e);
899  }
900  }
901 
902  // ----------------------------------------------------------------------------
903  // Utilities
904 
906  bool getDoInvert() { return doInversions; }
907  void setDoInvert(bool on) { doInversions = on; }
908 
910  bool getDoOutput() { return doOutput; }
911  void setDoOutput(bool on) { doOutput = on; }
912 
914  bool isExtended() { return extended; }
915  void setExtended(bool ext) { extended = ext; }
916 
918  void setSmoother(bool ext) { smoother = ext; }
919  bool isSmoother() { return smoother; }
920 
922  void setSRISU(bool ext) { doSRISU = ext; }
923  bool isSRISU() { return doSRISU; }
924 
926  bool isSingular() { return singular; }
927 
929  void setTimeReverse(bool tr = true) { timeReversed = tr; }
930  bool isTimeReversed() { return timeReversed; }
931 
933  void setDryRun(bool t = true) { dryRun = t; }
934  bool isDryRun() { return dryRun; }
935 
937  std::string getTag() { return KFtag; }
938  void setTag(std::string tag) { KFtag = tag; }
939 
941  void setSRI(gnsstk::SRI& sri)
942  {
943  srif = static_cast<gnsstk::SRIFilter&>(sri);
944  }
945  gnsstk::SRI getSRI() { return static_cast<gnsstk::SRI>(srif); }
946 
953 
955  int getNMU() { return NMU; }
956 
957  private:
958  // --------------------------------------------------------------------------
963  void initialize(const gnsstk::Namelist& NL)
964  {
965  Nstate = NL.size();
966  // Nnoise = Ns; // Nnoise is for the user only
967  NTU = NMU = NSU = 0;
968 
969  stage = Unknown;
970 
971  // initialize the SRIF
972  srif = gnsstk::SRIFilter(NL);
973  inverted = false;
974 
977 
978  // clear smoother store
979  SmootherStore.clear();
980  }
981 
983  void Invert(const std::string& msg = std::string())
984  {
985  if (dryRun)
986  {
987  LOG(INFO) << "Dry invert" << (msg.empty() ? "" : " " + msg);
988  return;
989  }
990  if (!doInversions)
991  {
992  LOG(DEBUG) << msg << " (doInversions false)";
993  return;
994  }
995 
996  // get state and covariance
997  try
998  {
1000  singular = false;
1001  inverted = true;
1002  Nstate = srif.size();
1003  LOG(DEBUG) << msg << " (non-singular)";
1004  }
1005  catch (gnsstk::Exception& e)
1006  {
1007  singular = true;
1008  inverted = false;
1009  LOG(DEBUG) << msg << " (singular)";
1010  e.addText(msg);
1011  GNSSTK_RETHROW(e);
1012  }
1013  catch (std::exception& e)
1014  {
1015  gnsstk::Exception E(std::string("std exception: ") + e.what());
1016  GNSSTK_THROW(E);
1017  }
1018  }
1019 
1020  }; // end class KalmanFilter
1021 
1022 } // namespace gnsstk
1023 #endif
gnsstk::KalmanFilter::singular
bool singular
Definition: KalmanFilter.hpp:182
gnsstk::KalmanFilter::getTag
std::string getTag()
KF tag is a user-defined string output on each line.
Definition: KalmanFilter.hpp:937
gnsstk::KalmanFilter::NTU
int NTU
count of time updates: ++ in TU, – in SU
Definition: KalmanFilter.hpp:208
gnsstk::KalmanFilter::setDryRun
void setDryRun(bool t=true)
if dryRun, do not operate the filter, just print
Definition: KalmanFilter.hpp:933
gnsstk::KalmanFilter::Rw
gnsstk::Matrix< double > Rw
SRIF matrix used internally.
Definition: KalmanFilter.hpp:236
gnsstk::KalmanFilter::defineInitial
virtual int defineInitial(double &T0, gnsstk::Vector< double > &X, gnsstk::Matrix< double > &Cov)=0
gnsstk::KalmanFilter::NMU
int NMU
count of measurement updates
Definition: KalmanFilter.hpp:209
gnsstk::KalmanFilter::SMResid
gnsstk::Vector< double > SMResid
post-smoother residuals - value after SU
Definition: KalmanFilter.hpp:239
gnsstk::KalmanFilter::KalmanFilter
KalmanFilter()
Definition: KalmanFilter.hpp:336
gnsstk::KalmanFilter::Smoother_storage_record::G
gnsstk::Matrix< double > G
Definition: KalmanFilter.hpp:247
gnsstk::KalmanFilter::doSRISU
bool doSRISU
Definition: KalmanFilter.hpp:187
gnsstk::KalmanFilter::setTag
void setTag(std::string tag)
Definition: KalmanFilter.hpp:938
gnsstk::KalmanFilter::StageCount
@ StageCount
Definition: KalmanFilter.hpp:150
gnsstk::SRI::zeroState
void zeroState()
Zero out (set all elements to zero) the state (Vector Z) only.
Definition: SRI.hpp:328
gnsstk::KalmanFilter::PFResid
gnsstk::Vector< double > PFResid
post-fit residuals - valid after MU
Definition: KalmanFilter.hpp:224
gnsstk::SRI::size
unsigned int size() const
Definition: SRI.hpp:554
gnsstk::SRI::addAPriori
void addAPriori(const Matrix< double > &Cov, const Vector< double > &X)
Definition: SRI.cpp:1017
gnsstk::KalmanFilter::ReturnCount
@ ReturnCount
Definition: KalmanFilter.hpp:161
gnsstk::KalmanFilter::doInversions
bool doInversions
Definition: KalmanFilter.hpp:177
gnsstk::KalmanFilter::Process
@ Process
Definition: KalmanFilter.hpp:156
gnsstk::KalmanFilter::State
gnsstk::Vector< double > State
filter state
Definition: KalmanFilter.hpp:220
gnsstk::KalmanFilter::inverted
bool inverted
if true then the SRI has been inverted and State and Cov are valid
Definition: KalmanFilter.hpp:199
gnsstk::KalmanFilter::setDoInvert
void setDoInvert(bool on)
Definition: KalmanFilter.hpp:907
gnsstk::KalmanFilter::KalmanTimeUpdate
virtual void KalmanTimeUpdate(double T, double DT)
Definition: KalmanFilter.hpp:783
gnsstk::KalmanFilter::Smoother_storage_record::Rw
gnsstk::Matrix< double > Rw
Definition: KalmanFilter.hpp:244
gnsstk::KalmanFilter::Smoother_storage_record::Control
gnsstk::Vector< double > Control
Definition: KalmanFilter.hpp:249
gnsstk::KalmanFilter::ForwardFilter
virtual void ForwardFilter(double finalT, double DT)
Definition: KalmanFilter.hpp:433
gnsstk::KalmanFilter::dryRun
bool dryRun
Definition: KalmanFilter.hpp:206
gnsstk::KalmanFilter::big
double big
Definition: KalmanFilter.hpp:217
gnsstk::KalmanFilter::initialize
void initialize(const gnsstk::Namelist &NL)
Definition: KalmanFilter.hpp:963
gnsstk::KalmanFilter::TU
@ TU
Definition: KalmanFilter.hpp:147
gnsstk::KalmanFilter::setSmoother
void setSmoother(bool ext)
if smoother, save info during forward filter for use by backward filter
Definition: KalmanFilter.hpp:918
gnsstk::KalmanFilter::getState
gnsstk::Vector< double > getState()
get the state (must be non-singular)
Definition: KalmanFilter.hpp:950
gnsstk::KalmanFilter::setDoOutput
void setDoOutput(bool on)
Definition: KalmanFilter.hpp:911
gnsstk::KalmanFilter::KalmanInterim
virtual int KalmanInterim(int which, double Time)
Definition: KalmanFilter.hpp:712
gnsstk::KalmanFilter::NSU
int NSU
count of smoother updates
Definition: KalmanFilter.hpp:210
gnsstk::KalmanFilter::Init
@ Init
Definition: KalmanFilter.hpp:143
gnsstk::KalmanFilter::SU
@ SU
Definition: KalmanFilter.hpp:149
gnsstk::SRI
Definition: SRI.hpp:175
logstream.hpp
gnsstk::KalmanFilter::getNMU
int getNMU()
get number of measurements processed
Definition: KalmanFilter.hpp:955
gnsstk::SRIFilter::measurementUpdate
void measurementUpdate(const Matrix< double > &H, Vector< double > &D, const Matrix< double > &CM=SRINullMatrix)
Definition: SRIFilter.cpp:123
gnsstk::KalmanFilter::initializeFilter
virtual void initializeFilter()
Definition: KalmanFilter.hpp:363
gnsstk::Matrix::rows
size_t rows() const
The number of rows in the matrix.
Definition: Matrix.hpp:165
gnsstk::KalmanFilter::getDoOutput
bool getDoOutput()
if doOutput, output() is called at each step
Definition: KalmanFilter.hpp:910
gnsstk::KalmanFilter::Partials
gnsstk::Matrix< double > Partials
matrix defined by defineM() and used in MU
Definition: KalmanFilter.hpp:226
gnsstk::KalmanFilter::Invert
void Invert(const std::string &msg=std::string())
Definition: KalmanFilter.hpp:983
gnsstk::KalmanFilter::isTimeReversed
bool isTimeReversed()
Definition: KalmanFilter.hpp:930
gnsstk::SRIFilter
Definition: SRIFilter.hpp:93
gnsstk::KalmanFilter::SmootherStore
std::map< int, SmootherStoreRec > SmootherStore
Definition: KalmanFilter.hpp:252
gnsstk::KalmanFilter::IB1
@ IB1
Definition: KalmanFilter.hpp:144
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::SRIFilter::timeUpdate
void timeUpdate(Matrix< double > &PhiInv, Matrix< double > &Rw, Matrix< double > &G, Vector< double > &Zw, Matrix< double > &Rwx)
Definition: SRIFilter.cpp:235
gnsstk::KalmanFilter::getDoInvert
bool getDoInvert()
if doInversions, SRIF is inverted at each step, defining State and Cov
Definition: KalmanFilter.hpp:906
gnsstk::KalmanFilter::KalmanMeasurementUpdate
virtual KalmanReturn KalmanMeasurementUpdate(double &T)
Definition: KalmanFilter.hpp:739
gnsstk::KalmanFilter::doOutput
bool doOutput
if true, output at each stage using output() routine. NB used inside output()
Definition: KalmanFilter.hpp:168
gnsstk::KalmanFilter::G
gnsstk::Matrix< double > G
SRIF matrix used internally - noise.
Definition: KalmanFilter.hpp:235
gnsstk::KalmanFilter::isExtended
bool isExtended()
if extended, use an extended Kalman (not implemented)
Definition: KalmanFilter.hpp:914
gnsstk::KalmanFilter::time
double time
seconds since start
Definition: KalmanFilter.hpp:215
gnsstk::Exception
Definition: Exception.hpp:151
gnsstk::KalmanFilter::nominalDT
double nominalDT
change in time for one TU seconds
Definition: KalmanFilter.hpp:216
gnsstk::KalmanFilter::KalmanMUReturnValuesEnum
KalmanMUReturnValuesEnum
Definition: KalmanFilter.hpp:154
gnsstk::KalmanFilter::setSRI
void setSRI(gnsstk::SRI &sri)
get the filter SRI
Definition: KalmanFilter.hpp:941
gnsstk::KalmanFilter::getNames
gnsstk::Namelist getNames()
get the state namelist
Definition: KalmanFilter.hpp:948
gnsstk::KalmanFilter::FilterStage
enum gnsstk::KalmanFilter::FilterStageEnum FilterStage
gnsstk::KalmanFilter::timeReversed
bool timeReversed
if true then independent variable "time" decreases
Definition: KalmanFilter.hpp:201
gnsstk::KalmanFilter::output
virtual void output(int N)
Definition: KalmanFilter.hpp:632
gnsstk::KalmanFilter::stage
FilterStage stage
current stage of the filter - see enum
Definition: KalmanFilter.hpp:214
gnsstk::KalmanFilter::Smoother_storage_record::Time
double Time
Definition: KalmanFilter.hpp:250
gnsstk::Matrix< double >
gnsstk::KalmanFilter::Unknown
@ Unknown
Definition: KalmanFilter.hpp:142
gnsstk::KalmanFilter::KalmanSmootherUpdate
virtual void KalmanSmootherUpdate()
Definition: KalmanFilter.hpp:846
gnsstk::KalmanFilter::Data
gnsstk::Vector< double > Data
vector defined by defineM() and used in MU
Definition: KalmanFilter.hpp:228
gnsstk::SRIFilter::smootherUpdate
void smootherUpdate(Matrix< double > &Phi, Matrix< double > &Rw, Matrix< double > &G, Vector< double > &Zw, Matrix< double > &Rwx)
Definition: SRIFilter.cpp:251
gnsstk::KalmanFilter::isDryRun
bool isDryRun()
Definition: KalmanFilter.hpp:934
gnsstk::ERROR
@ ERROR
Definition: logstream.hpp:57
gnsstk::KalmanFilter::KalmanReturn
enum gnsstk::KalmanFilter::KalmanMUReturnValuesEnum KalmanReturn
gnsstk::KalmanFilter::srif
gnsstk::SRIFilter srif
SRIF.
Definition: KalmanFilter.hpp:222
gnsstk::KalmanFilter::MCov
gnsstk::Matrix< double > MCov
measurement covariance (defineM() for MU)
Definition: KalmanFilter.hpp:229
gnsstk::Namelist::size
unsigned int size() const
return the size of the list.
Definition: Namelist.hpp:408
gnsstk::KalmanFilter::SkipThenQuit
@ SkipThenQuit
Definition: KalmanFilter.hpp:159
gnsstk::KalmanFilter
Definition: KalmanFilter.hpp:136
gnsstk::KalmanFilter::IB3
@ IB3
Definition: KalmanFilter.hpp:146
gnsstk::Namelist::getName
std::string getName(const unsigned int in) const
Definition: Namelist.cpp:485
gnsstk::KalmanFilter::smoother
bool smoother
Definition: KalmanFilter.hpp:197
gnsstk::KalmanFilter::Smoother_storage_record::Rwx
gnsstk::Matrix< double > Rwx
Definition: KalmanFilter.hpp:245
gnsstk::KalmanFilter::isSingular
bool isSingular()
true when filter is singular
Definition: KalmanFilter.hpp:926
gnsstk::SRIFilter::DMsmootherUpdate
static void DMsmootherUpdate(Matrix< double > &P, Vector< double > &X, Matrix< double > &Phinv, Matrix< double > &Rw, Matrix< double > &G, Vector< double > &Zw, Matrix< double > &Rwx)
Definition: SRIFilter.cpp:266
GNSSTK_RETHROW
#define GNSSTK_RETHROW(exc)
Definition: Exception.hpp:369
gnsstk::Vector< double >
gnsstk::KalmanFilter::defineInterim
virtual int defineInterim(int which, double Time)
Definition: KalmanFilter.hpp:328
gnsstk::KalmanFilter::Cov
gnsstk::Matrix< double > Cov
filter covariance
Definition: KalmanFilter.hpp:221
gnsstk::KalmanFilter::defineMeasurements
virtual KalmanReturn defineMeasurements(double &T, const gnsstk::Vector< double > &X, const gnsstk::Matrix< double > &C, bool useFlag)=0
gnsstk::KalmanFilter::PhiInv
gnsstk::Matrix< double > PhiInv
SRIF matrix used internally - inv state trans.
Definition: KalmanFilter.hpp:234
gnsstk::KalmanFilter::KalmanFilter
KalmanFilter(const gnsstk::Namelist &NL)
Definition: KalmanFilter.hpp:348
gnsstk::KalmanFilter::isSRISU
bool isSRISU()
Definition: KalmanFilter.hpp:923
LOG
#define LOG(level)
define the macro that is used to write to the log stream
Definition: logstream.hpp:315
gnsstk::KalmanFilter::isSmoother
bool isSmoother()
Definition: KalmanFilter.hpp:919
gnsstk::KalmanFilter::defineTimestep
virtual void defineTimestep(double T, double DT, const gnsstk::Vector< double > &State, const gnsstk::Matrix< double > &Cov, bool useFlag)=0
gnsstk::KalmanFilter::KFtag
std::string KFtag
optional tag to put in output (2nd field)
Definition: KalmanFilter.hpp:218
gnsstk::Vector::size
size_t size() const
STL size.
Definition: Vector.hpp:207
Exception.hpp
gnsstk::INFO
@ INFO
Definition: logstream.hpp:57
gnsstk::SRI::addAPrioriInformation
void addAPrioriInformation(const Matrix< double > &ICov, const Vector< double > &X)
Definition: SRI.cpp:1042
gnsstk::SRI::getNames
Namelist getNames() const
Definition: SRI.hpp:557
Namelist.hpp
gnsstk::KalmanFilter::setSRISU
void setSRISU(bool ext)
if doSRISU use SRIF form of smoother, else DM smoother
Definition: KalmanFilter.hpp:922
gnsstk::KalmanFilter::extended
bool extended
Definition: KalmanFilter.hpp:192
SRIFilter.hpp
gnsstk::KalmanFilter::Reset
void Reset(const gnsstk::Namelist &NL)
Definition: KalmanFilter.hpp:354
gnsstk::KalmanFilter::Zw
gnsstk::Vector< double > Zw
SRIF vector used internally.
Definition: KalmanFilter.hpp:231
gnsstk::KalmanFilter::BackwardFilter
virtual void BackwardFilter(int M)
Definition: KalmanFilter.hpp:575
gnsstk::SRI::shift
void shift(const Vector< double > &X0)
Definition: SRI.cpp:584
gnsstk::KalmanFilter::Smoother_storage_record::Zw
gnsstk::Vector< double > Zw
Definition: KalmanFilter.hpp:248
gnsstk::Exception::addText
Exception & addText(const std::string &errorText)
Definition: Exception.cpp:133
GNSSTK_THROW
#define GNSSTK_THROW(exc)
Definition: Exception.hpp:366
gnsstk::Namelist
Definition: Namelist.hpp:287
gnsstk::DEBUG
@ DEBUG
Definition: logstream.hpp:57
gnsstk::KalmanFilter::getCovariance
gnsstk::Matrix< double > getCovariance()
get the covariance (must be non-singular)
Definition: KalmanFilter.hpp:952
gnsstk::KalmanFilter::small
double small
condition number at last inversion = b/s
Definition: KalmanFilter.hpp:217
Matrix.hpp
gnsstk::KalmanFilter::Smoother_storage_record
Storage for smoothing algorithm; stored by forward filter, used by SU.
Definition: KalmanFilter.hpp:242
gnsstk::KalmanFilter::SkipThisEpoch
@ SkipThisEpoch
Definition: KalmanFilter.hpp:158
gnsstk::KalmanFilter::FilterStageEnum
FilterStageEnum
Definition: KalmanFilter.hpp:140
gnsstk::KalmanFilter::ProcessThenQuit
@ ProcessThenQuit
Definition: KalmanFilter.hpp:157
gnsstk::KalmanFilter::IB2
@ IB2
Definition: KalmanFilter.hpp:145
gnsstk::inverse
SparseMatrix< T > inverse(const SparseMatrix< T > &A)
Definition: SparseMatrix.hpp:1890
gnsstk::KalmanFilter::setExtended
void setExtended(bool ext)
Definition: KalmanFilter.hpp:915
gnsstk::KalmanFilter::~KalmanFilter
virtual ~KalmanFilter()
destructor
Definition: KalmanFilter.hpp:357
gnsstk::KalmanFilter::Nstate
int Nstate
number of state elements
Definition: KalmanFilter.hpp:211
gnsstk::KalmanFilter::Smoother_storage_record::PhiInv
gnsstk::Matrix< double > PhiInv
Definition: KalmanFilter.hpp:246
gnsstk::KalmanFilter::getSRI
gnsstk::SRI getSRI()
Definition: KalmanFilter.hpp:945
gnsstk::KalmanFilter::setTimeReverse
void setTimeReverse(bool tr=true)
if timeReversed, time T decreases during the forward filter
Definition: KalmanFilter.hpp:929
gnsstk::SRI::getStateAndCovariance
void getStateAndCovariance(Vector< double > &X, Matrix< double > &C, double *ptrSmall=NULL, double *ptrBig=NULL) const
Definition: SRI.cpp:1136
gnsstk::KalmanFilter::QuitImmediately
@ QuitImmediately
Definition: KalmanFilter.hpp:160
gnsstk::KalmanFilter::BackwardFilter
void BackwardFilter(double M)
Definition: KalmanFilter.hpp:563
Vector.hpp
gnsstk::KalmanFilter::Nnoise
int Nnoise
Nnoise is there only for the user.
Definition: KalmanFilter.hpp:212
gnsstk::KalmanFilter::Control
gnsstk::Vector< double > Control
SRIF vector used internally.
Definition: KalmanFilter.hpp:232
gnsstk::KalmanFilter::SmootherStoreRec
struct gnsstk::KalmanFilter::Smoother_storage_record SmootherStoreRec
Storage for smoothing algorithm; stored by forward filter, used by SU.
gnsstk::KalmanFilter::MU
@ MU
Definition: KalmanFilter.hpp:148


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:39