GGTropModel.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 "GPSEllipsoid.hpp"
40 #include "GGTropModel.hpp"
41 
42 #define THROW_IF_INVALID_DETAILED() {if (!valid) { \
43  InvalidTropModel e; \
44  if(!validWeather) e.addText("Invalid trop model: weather"); \
45  if(!validHeights) e.addText("Invalid trop model: validHeights"); \
46  if(!validRxHeight) e.addText("Invalid trop model: validRxHeight"); \
47  GNSSTK_THROW(e);}}
48 
49 namespace gnsstk
50 {
51  static const double GGdryscale = 8594.777388436570600;
52  static const double GGwetscale = 2540.042008403690900;
53 
55  {
56  TropModel::setWeather(20.0, 980.0, 50.0);
57  Cdrydelay = 2.59629761092150147e-4; // zenith delay, dry
58  Cwetdelay = 4.9982784999977412e-5; // zenith delay, wet
59  Cdrymap = 42973.886942182834900; // height for mapping, dry
60  Cwetmap = 12700.210042018454260; // height for mapping, wet
61  valid = true;
62  } // end GGTropModel::GGTropModel()
63 
64 
66  {
67  setWeather(wx);
68  valid = true;
69  }
70 
71 
72  GGTropModel::GGTropModel(const double& T,
73  const double& P,
74  const double& H)
75  {
76  setWeather(T,P,H);
77  valid = true;
78  }
79 
81  {
83  return (Cdrydelay * GGdryscale);
84  }
85 
87  {
89  return (Cwetdelay * GGwetscale);
90  }
91 
92  double GGTropModel::dry_mapping_function(double elevation) const
93  {
95 
96  if(elevation < 0.0) return 0.0;
97 
98  GPSEllipsoid ell;
99  double ce=std::cos(elevation*DEG_TO_RAD), se=std::sin(elevation*DEG_TO_RAD);
100  double ad = -se/Cdrymap;
101  double bd = -ce*ce/(2.0*ell.a()*Cdrymap);
102  double Rd = SQRT((ell.a()+Cdrymap)*(ell.a()+Cdrymap)
103  - ell.a()*ell.a()*ce*ce) - ell.a()*se;
104 
105  double Ad[9], ad2=ad*ad, bd2=bd*bd;
106  Ad[0] = 1.0;
107  Ad[1] = 4.0*ad;
108  Ad[2] = 6.0*ad2 + 4.0*bd;
109  Ad[3] = 4.0*ad*(ad2+3.0*bd);
110  Ad[4] = ad2*ad2 + 12.0*ad2*bd + 6.0*bd2;
111  Ad[5] = 4.0*ad*bd*(ad2+3.0*bd);
112  Ad[6] = bd2*(6.0*ad2+4.0*bd);
113  Ad[7] = 4.0*ad*bd*bd2;
114  Ad[8] = bd2*bd2;
115 
116  // compute dry component of the mapping function
117  double sumd=0.0;
118  for(int j=9; j>=1; j--) {
119  sumd += Ad[j-1]/double(j);
120  sumd *= Rd;
121  }
122  return sumd/GGdryscale;
123 
124  }
125 
126 
127  double GGTropModel::wet_mapping_function(double elevation) const
128  {
130 
131  if(elevation < 0.0) return 0.0;
132 
133  GPSEllipsoid ell;
134  double ce = std::cos(elevation*DEG_TO_RAD), se = std::sin(elevation*DEG_TO_RAD);
135  double aw = -se/Cwetmap;
136  double bw = -ce*ce/(2.0*ell.a()*Cwetmap);
137  double Rw = SQRT((ell.a()+Cwetmap)*(ell.a()+Cwetmap)
138  - ell.a()*ell.a()*ce*ce) - ell.a()*se;
139 
140  double Aw[9], aw2=aw*aw, bw2=bw*bw;
141  Aw[0] = 1.0;
142  Aw[1] = 4.0*aw;
143  Aw[2] = 6.0*aw2 + 4.0*bw;
144  Aw[3] = 4.0*aw*(aw2+3.0*bw);
145  Aw[4] = aw2*aw2 + 12.0*aw2*bw + 6.0*bw2;
146  Aw[5] = 4.0*aw*bw*(aw2+3.0*bw);
147  Aw[6] = bw2*(6.0*aw2+4.0*bw);
148  Aw[7] = 4.0*aw*bw*bw2;
149  Aw[8] = bw2*bw2;
150 
151  double sumw=0.0;
152  for(int j=9; j>=1; j--) {
153  sumw += Aw[j-1]/double(j);
154  sumw *= Rw;
155  }
156  return sumw/GGwetscale;
157 
158  }
159 
160  void GGTropModel::setWeather(const double& T,
161  const double& P,
162  const double& H)
163  {
165  double th=300./temp;
166  /* water vapor partial pressure (mb)
167  * this comes from Leick and is not good.
168  * double wvpp=6.108*(RHum*0.01)*exp((17.15*Tk-4684.0)/(Tk-38.45));
169  */
170  double wvpp=2.409e9*humid*th*th*th*th*std::exp(-22.64*th);
171  Cdrydelay = 7.7624e-5*press/temp;
172  Cwetdelay = 1.0e-6*(-12.92+3.719e+05/temp)*(wvpp/temp);
173  Cdrymap = (5.0*0.002277*press)/Cdrydelay;
174  Cwetmap = (5.0*0.002277/Cwetdelay)*(1255.0/temp+0.5)*wvpp;
175  valid = true;
176  } // end GGTropModel::setWeather(T,P,H)
177 
178 
180  {
182  }
183 }
se
double se
obliquity cos, T*cos, sin coefficients
Definition: IERS2003NutationData.hpp:48
gnsstk::GGTropModel::wet_mapping_function
virtual double wet_mapping_function(double elevation) const
Definition: GGTropModel.cpp:127
gnsstk::GGdryscale
static const double GGdryscale
Definition: GGTropModel.cpp:51
gnsstk::GGTropModel::dry_mapping_function
virtual double dry_mapping_function(double elevation) const
Definition: GGTropModel.cpp:92
SQRT
#define SQRT(x)
Definition: MathBase.hpp:74
GGTropModel.hpp
gnsstk::GGwetscale
static const double GGwetscale
Definition: GGTropModel.cpp:52
gnsstk::GGTropModel::Cdrymap
double Cdrymap
Definition: GGTropModel.hpp:102
gnsstk::WxObservation
A Single Weather Observation.
Definition: WxObsMap.hpp:55
gnsstk::GPSEllipsoid
Definition: GPSEllipsoid.hpp:67
THROW_IF_INVALID
#define THROW_IF_INVALID()
Definition: TropModel.hpp:57
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
std::sin
double sin(gnsstk::Angle x)
Definition: Angle.hpp:144
gnsstk::GGTropModel::wet_zenith_delay
virtual double wet_zenith_delay() const
Definition: GGTropModel.cpp:86
gnsstk::TropModel::humid
double humid
latest value of relative humidity (percent)
Definition: TropModel.hpp:282
ce
double ce
Definition: IERS1996NutationData.hpp:47
gnsstk::GGTropModel::setWeather
virtual void setWeather(const double &T, const double &P, const double &H)
Definition: GGTropModel.cpp:160
gnsstk::GGTropModel::GGTropModel
GGTropModel()
Empty constructor.
Definition: GGTropModel.cpp:54
gnsstk::TropModel::valid
bool valid
true only if current model parameters are valid
Definition: TropModel.hpp:279
std::cos
double cos(gnsstk::Angle x)
Definition: Angle.hpp:146
gnsstk::TropModel::press
double press
latest value of pressure (millibars)
Definition: TropModel.hpp:281
gnsstk::TrackingCode::P
@ P
Legacy GPS precise code.
gnsstk::GGTropModel::dry_zenith_delay
virtual double dry_zenith_delay() const
Definition: GGTropModel.cpp:80
GPSEllipsoid.hpp
gnsstk::GGTropModel::Cwetdelay
double Cwetdelay
Definition: GGTropModel.hpp:101
gnsstk::TropModel::setWeather
virtual void setWeather(const double &T, const double &P, const double &H)
Definition: TropModel.cpp:85
gnsstk::GGTropModel::Cwetmap
double Cwetmap
Definition: GGTropModel.hpp:103
gnsstk::TropModel::temp
double temp
latest value of temperature (kelvin or celsius)
Definition: TropModel.hpp:280
gnsstk::GGTropModel::Cdrydelay
double Cdrydelay
Definition: GGTropModel.hpp:100
gnsstk::WGS84Ellipsoid::a
virtual double a() const noexcept
Definition: WGS84Ellipsoid.hpp:62
gnsstk::DEG_TO_RAD
static const double DEG_TO_RAD
Conversion Factor from degrees to radians (units: degrees^-1)
Definition: GNSSconstants.hpp:76


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