LinearClockModel.cpp
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 
45 #include <math.h>
46 #include "Stats.hpp"
47 
48 #include "LinearClockModel.hpp"
49 
50 namespace gnsstk
51 {
52  using namespace std;
53 
54  void LinearClockModel::reset() noexcept
55  {
58  clockObs.clear();
59  prnStatus.clear();
60  clockModel.Reset();
61  tossCount=0;
62  }
63 
68  {
69  ORDEpoch::ORDMap::const_iterator itr;
70  const gnsstk::CommonTime t=oe.time;
71 
72  // Start off by getting an estimate of this epoch's clock
73  // note that this also sets the prn status map
74  gnsstk::Stats<double> stat = simpleOrdClock(oe);
75  SvStatusMap& statusMap = prnStatus[t];
76  statusMap = status;
77 
78  double mean;
79  if (clockModel.N()==0)
80  {
81  startTime = endTime = baseTime = t;
82  tossCount = 0;
83  }
84 
85  const double deltaT = t-baseTime;
86 
87  if (t<startTime)
88  startTime=t;
89  if (t>endTime)
90  endTime=t;
91 
92  if (clockModel.N()>24)
93  mean = clockModel.Slope()*deltaT + clockModel.Intercept();
94  else
95  mean = stat.Average();
96 
97  if (std::abs(stat.Average() - mean) > 20)
98  {
99  cout << t
100  << " slope=" << setw(12) << clockModel.Slope()
101  << ", intercept=" << setw(8) << clockModel.Intercept()
102  << ", est=" << setw(8) << clockModel.Slope()*deltaT + clockModel.Intercept()
103  << ", N=" << setw(6) << clockModel.N()
104  << ", stdev=" << setw(6) << clockModel.StdDevY()
105  << endl;
106  tossCount++;
107  if (tossCount>5)
108  {
109  reset();
110  cout << "Reseting model" << endl;
111  }
112  }
113  else
114  {
115  tossCount=0;
116  for (itr = oe.ords.begin(); itr != oe.ords.end(); itr++)
117  if (statusMap[itr->second.getSvID()] == USED)
118  {
119  const double ord = itr->second.getORD();
120  clockModel.Add(deltaT, ord);
121  std::pair<const double,double> o(deltaT, ord);
122  clockObs.insert(o);
123  }
124  }
125 
126  std::multimap<double,double>::iterator i1,i2;
127  i1 = clockObs.begin();
128  while (i1!=clockObs.end())
129  {
130  i2=i1;
131  i1++;
132  double dt = i2->first;
133  double ord = i2->second;
134  if ((deltaT - dt)>1800)
135  {
136  clockObs.erase(i2);
137  clockModel.Subtract(dt, ord);
138  }
139  else
140  break;
141  }
142  }
143 
144  void LinearClockModel::dump(std::ostream& s, short detail) const noexcept
145  {
146  s << "base: " << baseTime
147  << ", start: " << startTime
148  << ", end: " << endTime
149  << endl
150  << "Clock: est(end)=" << getOffset(endTime)
151  << ", n=" << clockModel.N()
152  << ", b=" << clockModel.Intercept()
153  << ", m=" << clockModel.Slope()
154  << ", sigma=" << clockModel.StdDevY()
155  << ", r=" << clockModel.Correlation()
156  << endl;
157 
158  if (detail>0)
159  {
160  s << "min elev: " << elvmask
161  << ", max sigma: " << sigmam
162  << endl;
163 
164  map<CommonTime,SvStatusMap>::const_iterator e = prnStatus.find(endTime);
165  const SvStatusMap& statusMap = e->second;
166  SvStatusMap::const_iterator i;
167  for ( i=statusMap.begin(); i!= statusMap.end(); i++)
168  s << i->first << "/" << i->second << " ";
169  s << endl;
170  }
171  }
172 }
LinearClockModel.hpp
gnsstk::CommonTime::BEGINNING_OF_TIME
static const GNSSTK_EXPORT CommonTime BEGINNING_OF_TIME
earliest representable CommonTime
Definition: CommonTime.hpp:102
gnsstk::LinearClockModel::reset
void reset() noexcept
Reset the accumulated statistics on the clock.
Definition: LinearClockModel.cpp:54
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::Stats< double >
Stats.hpp
gnsstk::CommonTime::END_OF_TIME
static const GNSSTK_EXPORT CommonTime END_OF_TIME
latest representable CommonTime
Definition: CommonTime.hpp:104
gnsstk::CommonTime
Definition: CommonTime.hpp:84
example5.oe
oe
Definition: example5.py:19
gnsstk::ORDEpoch
Definition: ORDEpoch.hpp:59
std
Definition: Angle.hpp:142
gnsstk::Stats::Average
T Average(void) const
return the average
Definition: Stats.hpp:329
gnsstk::LinearClockModel::addEpoch
virtual void addEpoch(const ORDEpoch &oe)
Definition: LinearClockModel.cpp:67
gnsstk::LinearClockModel::dump
void dump(std::ostream &s, short detail=1) const noexcept
Definition: LinearClockModel.cpp:144
gnsstk::ObsClockModel::SvStatusMap
std::map< SatID, SvStatus > SvStatusMap
defines a store for each SV's SvStatus
Definition: ObsClockModel.hpp:90


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