IonoModelStore.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 
44 #include "IonoModelStore.hpp"
45 #include "TimeString.hpp"
46 
47 using namespace std;
48 
49 namespace gnsstk
50 {
51 
52  /* Get the ionospheric correction value.
53  *
54  * \param time the time of the observation
55  * \param rxgeo the WGS84 geodetic position of the receiver
56  * \param svel the elevation angle between the rx and SV (degrees)
57  * \param svaz the azimuth angle between the rx and SV (degrees)
58  * \param band the GPS band the observation was made from
59  * \return the ionospheric correction (meters)
60  */
61  double IonoModelStore::getCorrection(const CommonTime& time,
62  const Position& rxgeo,
63  double svel,
64  double svaz,
65  CarrierBand band) const
66  {
67  IonoModelMap::const_iterator i = ims.upper_bound(time);
68  if (!ims.empty() && i != ims.begin())
69  {
70  i--;
71  return i->second.getCorrection(time, rxgeo, svel, svaz, band);
72  }
73  else
74  {
75  NoIonoModelFound e;
76  GNSSTK_THROW(e);
77  }
78 
79  } // End of method 'IonoModelStore::getCorrection()'
80 
81 
82  /* Add an IonoModel to this collection
83  *
84  * \param mt the time the model is valid from
85  * \param im the IonoModel to add
86  * \return true if the model was added, false otherwise
87  */
88  bool IonoModelStore::addIonoModel(const CommonTime& mt, const IonoModel& im)
89  noexcept
90  {
91  if (!im.isValid())
92  return false;
93 
94  IonoModelMap::const_iterator i = ims.upper_bound(mt);
95  if (!ims.empty() && i != ims.begin())
96  {
97  // Compare to previous stored model and, if they have the
98  // the same alpha and beta parameters, don't store it.
99  i--;
100  if (im == i->second)
101  {
102  return false;
103  }
104  }
105  ims[mt] = im;
106 
107  return true;
108 
109  } // End of method 'IonoModelStore::addIonoModel()'
110 
111 
117  void IonoModelStore::edit(const CommonTime& tmin,
118  const CommonTime& tmax)
119  {
120  // Get the first element >= tmin
121  IonoModelMap::iterator lower = ims.lower_bound(tmin);
122  if (lower != ims.begin())
123  {
124  if (lower->first != tmin)
125  {
126  // An earlier element has not yet been superceeded at tmin, so
127  // retain the earlier element and delete all previous elements.
128  // This should prevent the removeal of models that are still
129  // in use at tmin.
130  lower--;
131  }
132  // Erase all old elements
133  ims.erase(ims.begin(), lower);
134  }
135  // Get the first element > tmax
136  IonoModelMap::iterator upper = ims.upper_bound(tmax);
137  if (upper != ims.end())
138  {
139  // Erase all future elements
140  ims.erase(upper, ims.end());
141  }
142  }
143 
144 
145  gnsstk::CommonTime IonoModelStore::getInitialTime() const
146  {
147  return (ims.empty() ? CommonTime::END_OF_TIME : ims.begin()->first);
148  }
149 
150 
151  gnsstk::CommonTime IonoModelStore::getFinalTime() const
152  {
153  return (ims.empty() ? CommonTime::BEGINNING_OF_TIME : ims.rbegin()->first);
154  }
155 
156 
157  void IonoModelStore::dump(std::ostream& s) const
158  {
159  unsigned n = 1;
160  IonoModelMap::const_iterator i = ims.begin();
161  for ( ; i != ims.end(); ++i, ++n)
162  {
163  s << std::setw(3) << n << gnsstk::printTime(i->first, " : %04Y %03j %08.2s ");
164  i->second.dump(s);
165  }
166  }
167 
168 } // End of namespace gnsstk
gnsstk::dump
void dump(vector< SatPass > &SatPassList, ostream &os, bool rev, bool dbug)
Definition: SatPassUtilities.cpp:59
gnsstk::BEGINNING_OF_TIME
const Epoch BEGINNING_OF_TIME(CommonTime::BEGINNING_OF_TIME)
Earliest representable Epoch.
gnsstk::CarrierBand
CarrierBand
Definition: CarrierBand.hpp:54
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
IonoModelStore.hpp
example4.time
time
Definition: example4.py:103
gnsstk::CommonTime
Definition: CommonTime.hpp:84
gnsstk::END_OF_TIME
const Epoch END_OF_TIME(CommonTime::END_OF_TIME)
Latest Representable Epoch.
gnsstk::printTime
std::string printTime(const CommonTime &t, const std::string &fmt)
Definition: TimeString.cpp:64
gnsstk::IonoModel
Definition: IonoModel.hpp:70
std
Definition: Angle.hpp:142
gnsstk::Position
Definition: Position.hpp:136
GNSSTK_THROW
#define GNSSTK_THROW(exc)
Definition: Exception.hpp:366
TimeString.hpp


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