TropModel.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 
39 #include "TropModel.hpp"
40 #include "EphemerisRange.hpp" // for Elevation()
41 #include "MathBase.hpp" // SQRT
42 #include "GNSSconstants.hpp" // DEG_TO_RAD
43 #include "GPSEllipsoid.hpp" // ell.a() = R earth
44 #include "GNSSconstants.hpp" // TWO_PI
45 #include "YDSTime.hpp"
46 
47 
48 namespace gnsstk
49 {
50  // for temperature conversion from Celcius to Kelvin
51  const double TropModel::CELSIUS_TO_KELVIN = 273.15;
52 
53  double TropModel::correction(double elevation) const
54  {
56 
57  if(elevation < 0.0)
58  return 0.0;
59 
60  return (dry_zenith_delay() * dry_mapping_function(elevation)
61  + wet_zenith_delay() * wet_mapping_function(elevation));
62 
63  } // end TropModel::correction(elevation)
64 
65 
66  double TropModel::correction(const Position& RX,
67  const Position& SV,
68  const CommonTime& tt)
69  {
71 
72  double c;
73  try
74  {
75  c = correction(RX.elevation(SV));
76  }
77  catch(InvalidTropModel& e)
78  {
79  GNSSTK_RETHROW(e);
80  }
81  return c;
82  } // end TropModel::correction(RX,SV,TT)
83 
84 
85  void TropModel::setWeather(const double& T,
86  const double& P,
87  const double& H)
88  {
89  temp = T + CELSIUS_TO_KELVIN;
90  press = P;
91  humid = H;
92  if (temp < 0.0)
93  {
94  valid = false;
95  InvalidParameter e("Invalid temperature.");
96  GNSSTK_THROW(e);
97  }
98  if (press < 0.0)
99  {
100  valid = false;
101  InvalidParameter e("Invalid pressure.");
102  GNSSTK_THROW(e);
103  }
104  if (humid < 0.0 || humid > 105.0)
105  {
106  valid = false;
107  InvalidParameter e("Invalid humidity.");
108  GNSSTK_THROW(e);
109  }
110  /* truncates humidity to 100 if between 105 and 100.
111  * models cannot handle supersaturation.
112  */
113  if (humid > 100)
114  {
115  humid = 100.0;
116  }
117  } // end TropModel::setWeather(T,P,H)
118 
119 
121  {
122  if (wx.isAllValid())
123  {
124  try
125  {
127  valid = true;
128  }
129  catch(InvalidParameter& e)
130  {
131  valid = false;
132  GNSSTK_RETHROW(e);
133  }
134  }
135  else
136  {
137  valid = false;
138  InvalidParameter e("Invalid weather data.");
139  GNSSTK_THROW(e);
140  }
141  }
142 
143 
144  void TropModel::weatherByStandardAtmosphereModel(const double& ht, double& T, double& P, double& H)
145  {
146  // reference height and it's relate weather(T P H)
147  const double h0 = 0.0; // meter
148  const double Tr = +18.0; // Celsius
149  const double pr = 1013.25; // millibarc
150  const double Hr = 50; // humidity
151 
152  T = Tr-0.0065*(ht-h0);
153  P = pr * std::pow((1 - 0.0000226 * (ht - h0)), 5.225);
154  H = Hr * std::exp(-0.0006396 * (ht - h0));
155 
156  }
157 }
gnsstk::TropModel::correction
virtual double correction(double elevation) const
Definition: TropModel.cpp:53
YDSTime.hpp
gnsstk::TropModel::dry_zenith_delay
virtual double dry_zenith_delay() const =0
gnsstk::TropModel::weatherByStandardAtmosphereModel
static void weatherByStandardAtmosphereModel(const double &ht, double &T, double &P, double &H)
Definition: TropModel.cpp:144
gnsstk::WxObservation::temperature
float temperature
degrees Centigrade
Definition: WxObsMap.hpp:82
gnsstk::WxObservation
A Single Weather Observation.
Definition: WxObsMap.hpp:55
THROW_IF_INVALID
#define THROW_IF_INVALID()
Definition: TropModel.hpp:57
TropModel.hpp
GNSSconstants.hpp
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::WxObservation::pressure
float pressure
millibars
Definition: WxObsMap.hpp:83
gnsstk::TropModel::CELSIUS_TO_KELVIN
static const GNSSTK_EXPORT double CELSIUS_TO_KELVIN
Definition: TropModel.hpp:108
gnsstk::TropModel::humid
double humid
latest value of relative humidity (percent)
Definition: TropModel.hpp:282
EphemerisRange.hpp
gnsstk::WxObservation::isAllValid
bool isAllValid() const noexcept
Definition: WxObsMap.cpp:75
gnsstk::CommonTime
Definition: CommonTime.hpp:84
gnsstk::TropModel::wet_zenith_delay
virtual double wet_zenith_delay() const =0
gnsstk::TropModel::valid
bool valid
true only if current model parameters are valid
Definition: TropModel.hpp:279
gnsstk::TropModel::press
double press
latest value of pressure (millibars)
Definition: TropModel.hpp:281
GNSSTK_RETHROW
#define GNSSTK_RETHROW(exc)
Definition: Exception.hpp:369
gnsstk::TrackingCode::P
@ P
Legacy GPS precise code.
GPSEllipsoid.hpp
gnsstk::TropModel::dry_mapping_function
virtual double dry_mapping_function(double elevation) const =0
gnsstk::TropModel::setWeather
virtual void setWeather(const double &T, const double &P, const double &H)
Definition: TropModel.cpp:85
gnsstk::TropModel::wet_mapping_function
virtual double wet_mapping_function(double elevation) const =0
gnsstk::Position
Definition: Position.hpp:136
GNSSTK_THROW
#define GNSSTK_THROW(exc)
Definition: Exception.hpp:366
gnsstk::WxObservation::humidity
float humidity
percent
Definition: WxObsMap.hpp:84
gnsstk::TropModel::temp
double temp
latest value of temperature (kelvin or celsius)
Definition: TropModel.hpp:280
MathBase.hpp
gnsstk::Position::elevation
double elevation(const Position &Target) const
Definition: Position.cpp:1308


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