GGHeightTropModel.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 
40 #include "GPSEllipsoid.hpp"
41 #include "GGHeightTropModel.hpp"
42 
43 #define THROW_IF_INVALID_DETAILED() {if (!valid) { \
44  InvalidTropModel e; \
45  if(!validWeather) e.addText("Invalid trop model: weather"); \
46  if(!validHeights) e.addText("Invalid trop model: validHeights"); \
47  if(!validRxHeight) e.addText("Invalid trop model: validRxHeight"); \
48  GNSSTK_THROW(e);}}
49 
50 namespace gnsstk
51 {
53  {
54  validWeather = false; //setWeather(20.0,980.0,50.0);
55  validHeights = false; //setHeights(0.0,0.0,0.0);
56  validRxHeight = false;
57  }
58 
59 
61  {
62  valid = validRxHeight = validHeights = false;
63  setWeather(wx);
64  }
65 
66 
68  const double& P,
69  const double& H)
70  {
71  validRxHeight = validHeights = false;
72  setWeather(T,P,H);
73  }
74 
75 
77  const double& P,
78  const double& H,
79  const double hT,
80  const double hP,
81  const double hH)
82  {
83  validRxHeight = false;
84  setWeather(T,P,H);
85  setHeights(hT,hP,hH);
86  }
87 
88  // re-define this to get the throws
89  double GGHeightTropModel::correction(double elevation) const
90  {
92 
93  if(elevation < 0.0) return 0.0;
94 
95  return (dry_zenith_delay() * dry_mapping_function(elevation)
96  + wet_zenith_delay() * wet_mapping_function(elevation));
97 
98  }
99 
100 
102  const Position& SV,
103  const CommonTime& tt)
104  {
106 
107  // compute height from RX
109 
110  return TropModel::correction(RX.elevation(SV));
111 
112  } // end GGHeightTropModel::correction(RX,SV,TT)
113 
115  const Xvt& SV,
116  const CommonTime& tt)
117  {
118  Position R(RX),S(SV);
119  return GGHeightTropModel::correction(R,S,tt);
120  }
121 
122 
124  {
126  double hrate=6.5e-3;
127  double Ts=temp+hrate*height;
128  double em=978.77/(2.8704e4*hrate);
129  double Tp=Ts-hrate*hpress;
130  double ps=press*std::pow(Ts/Tp,em)/1000.0;
131  double rs=77.624e-3/Ts;
132  double ho=11.385/rs;
133  rs *= ps;
134  double zen=(ho-height)/ho;
135  zen = rs*zen*zen*zen*zen;
136  // normalize
137  zen *= (ho-height)/5;
138  return zen;
139 
140  }
141 
142 
144  {
146 
147  double hrate=6.5e-3; // deg K / m
148  double Th=temp-273.15-hrate*(hhumid-htemp);
149  double Ta=7.5*Th/(237.3+Th);
150  // water vapor partial pressure
151  double e0=6.11e-5*humid*std::pow(10.0,Ta);
152  double Ts=temp+hrate*htemp;
153  double em=978.77/(2.8704e4*hrate);
154  double Tk=Ts-hrate*hhumid;
155  double es=e0*std::pow(Ts/Tk,4.0*em);
156  double rs=(371900.0e-3/Ts-12.92e-3)/Ts;
157  double ho=11.385*(1255/Ts+0.05)/rs;
158  double zen=(ho-height)/ho;
159  zen = rs*es*zen*zen*zen*zen;
160  //normalize
161  zen *= (ho-height)/5;
162  return zen;
163 
164  }
165 
166 
167  double GGHeightTropModel::dry_mapping_function(double elevation) const
168  {
170 
171  if(elevation < 0.0) return 0.0;
172 
173  double hrate=6.5e-3;
174  double Ts=temp+hrate*htemp;
175  double ho=(11.385/77.624e-3)*Ts;
176  double se=std::sin(elevation*DEG_TO_RAD);
177  if(se < 0.0) se=0.0;
178 
179  GPSEllipsoid ell;
180  double rt,a,b,rn[8],al[8],er=ell.a();
181  rt = (er+ho)/(er+height);
182  rt = rt*rt - (1.0-se*se);
183  if(rt < 0) rt=0.0;
184  rt = (er+height)*(SQRT(rt)-se);
185  a = -se/(ho-height);
186  b = -(1.0-se*se)/(2.0*er*(ho-height));
187  rn[0] = rt*rt;
188  for(int j=1; j<8; j++) rn[j]=rn[j-1]*rt;
189  al[0] = 2*a;
190  al[1] = 2*a*a+4*b/3;
191  al[2] = a*(a*a+3*b);
192  al[3] = a*a*a*a/5+2.4*a*a*b+1.2*b*b;
193  al[4] = 2*a*b*(a*a+3*b)/3;
194  al[5] = b*b*(6*a*a+4*b)*0.1428571;
195  if(b*b > 1.0e-35) {
196  al[6] = a*b*b*b/2;
197  al[7] = b*b*b*b/9;
198  } else {
199  al[6] = 0.0;
200  al[7] = 0.0;
201  }
202  double map=rt;
203  for(int k=0; k<8; k++) map += al[k]*rn[k];
204  // normalize
205  double norm=(ho-height)/5;
206  return map/norm;
207  }
208 
209 
210  double GGHeightTropModel::wet_mapping_function(double elevation) const
211  {
213  if(elevation < 0.0) return 0.0;
214 
215  double hrate=6.5e-3;
216  double Ts=temp+hrate*htemp;
217  double rs=(371900.0e-3/Ts-12.92e-3)/Ts;
218  double ho=11.385*(1255/Ts+0.05)/rs;
219  double se=std::sin(elevation*DEG_TO_RAD);
220  if(se < 0.0) se=0.0;
221 
222  GPSEllipsoid ell;
223  double rt,a,b,rn[8],al[8],er=ell.a();
224  rt = (er+ho)/(er+height);
225  rt = rt*rt - (1.0-se*se);
226  if(rt < 0) rt=0.0;
227  rt = (er+height)*(SQRT(rt)-se);
228  a = -se/(ho-height);
229  b = -(1.0-se*se)/(2.0*er*(ho-height));
230  rn[0] = rt*rt;
231  for(int i=1; i<8; i++) rn[i]=rn[i-1]*rt;
232  al[0] = 2*a;
233  al[1] = 2*a*a+4*b/3;
234  al[2] = a*(a*a+3*b);
235  al[3] = a*a*a*a/5+2.4*a*a*b+1.2*b*b;
236  al[4] = 2*a*b*(a*a+3*b)/3;
237  al[5] = b*b*(6*a*a+4*b)*0.1428571;
238  if(b*b > 1.0e-35) {
239  al[6] = a*b*b*b/2;
240  al[7] = b*b*b*b/9;
241  } else {
242  al[6] = 0.0;
243  al[7] = 0.0;
244  }
245  double map=rt;
246  for(int j=0; j<8; j++) map += al[j]*rn[j];
247  // normalize map function
248  double norm=(ho-height)/5;
249  return map/norm;
250 
251  }
252 
253 
254  void GGHeightTropModel::setWeather(const double& T,
255  const double& P,
256  const double& H)
257  {
258  try
259  {
261  validWeather = true;
263  }
264  catch(InvalidParameter& e)
265  {
266  valid = validWeather = false;
267  GNSSTK_RETHROW(e);
268  }
269  }
270 
271 
273  {
274  try
275  {
277  validWeather = true;
279  }
280  catch(InvalidParameter& e)
281  {
282  valid = validWeather = false;
283  GNSSTK_RETHROW(e);
284  }
285  }
286 
287 
288  void GGHeightTropModel::setHeights(const double& hT,
289  const double& hP,
290  const double& hH)
291  {
292  htemp = hT; // height (m) at which temp applies
293  hpress = hP; // height (m) at which press applies
294  hhumid = hH; // height (m) at which humid applies
295  validHeights = true;
297  }
298 
299 
301  {
302  height = ht;
303  validRxHeight = true;
304  if(!validHeights) {
305  htemp = hpress = hhumid = ht;
306  validHeights = true;
307  }
309  }
310 
311 }
gnsstk::TropModel::correction
virtual double correction(double elevation) const
Definition: TropModel.cpp:53
se
double se
obliquity cos, T*cos, sin coefficients
Definition: IERS2003NutationData.hpp:48
gnsstk::GGHeightTropModel::dry_zenith_delay
virtual double dry_zenith_delay() const
Definition: GGHeightTropModel.cpp:123
gnsstk::GGHeightTropModel::GGHeightTropModel
GGHeightTropModel()
Empty constructor.
Definition: GGHeightTropModel.cpp:52
SQRT
#define SQRT(x)
Definition: MathBase.hpp:74
THROW_IF_INVALID_DETAILED
#define THROW_IF_INVALID_DETAILED()
Definition: GGHeightTropModel.cpp:43
gnsstk::GGHeightTropModel::wet_zenith_delay
virtual double wet_zenith_delay() const
Definition: GGHeightTropModel.cpp:143
gnsstk::GGHeightTropModel::correction
virtual double correction(double elevation) const
Definition: GGHeightTropModel.cpp:89
gnsstk::GGHeightTropModel::setHeights
void setHeights(const double &hT, const double &hP, const double &hH)
Definition: GGHeightTropModel.cpp:288
gnsstk::GGHeightTropModel::hhumid
double hhumid
height (m) at which humid applies
Definition: GGHeightTropModel.hpp:169
gnsstk::WxObservation
A Single Weather Observation.
Definition: WxObsMap.hpp:55
gnsstk::GPSEllipsoid
Definition: GPSEllipsoid.hpp:67
gnsstk::GGHeightTropModel::hpress
double hpress
height (m) at which press applies
Definition: GGHeightTropModel.hpp:168
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::GGHeightTropModel::validRxHeight
bool validRxHeight
flag for valid receiver height
Definition: GGHeightTropModel.hpp:172
std::sin
double sin(gnsstk::Angle x)
Definition: Angle.hpp:144
gnsstk::GGHeightTropModel::setReceiverHeight
void setReceiverHeight(const double &ht)
Definition: GGHeightTropModel.cpp:300
GGHeightTropModel.hpp
gnsstk::TropModel::humid
double humid
latest value of relative humidity (percent)
Definition: TropModel.hpp:282
gnsstk::Position::getHeight
double getHeight() const noexcept
return height above ellipsoid (meters)
Definition: Position.hpp:474
gnsstk::CommonTime
Definition: CommonTime.hpp:84
gnsstk::Xvt
Definition: Xvt.hpp:60
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::setWeather
virtual void setWeather(const double &T, const double &P, const double &H)
Definition: TropModel.cpp:85
gnsstk::GGHeightTropModel::height
double height
height (m) of the receiver
Definition: GGHeightTropModel.hpp:166
gnsstk::Position
Definition: Position.hpp:136
gnsstk::norm
T norm(const SparseVector< T > &SV)
Definition: SparseVector.hpp:705
gnsstk::GGHeightTropModel::dry_mapping_function
virtual double dry_mapping_function(double elevation) const
Definition: GGHeightTropModel.cpp:167
gnsstk::GGHeightTropModel::htemp
double htemp
height (m) at which temp applies
Definition: GGHeightTropModel.hpp:167
gnsstk::GGHeightTropModel::validHeights
bool validHeights
flag for valid height
Definition: GGHeightTropModel.hpp:171
gnsstk::GGHeightTropModel::setWeather
virtual void setWeather(const double &T, const double &P, const double &H)
Definition: GGHeightTropModel.cpp:254
gnsstk::TropModel::temp
double temp
latest value of temperature (kelvin or celsius)
Definition: TropModel.hpp:280
gnsstk::GGHeightTropModel::validWeather
bool validWeather
flag for valid weather
Definition: GGHeightTropModel.hpp:170
gnsstk::GGHeightTropModel::wet_mapping_function
virtual double wet_mapping_function(double elevation) const
Definition: GGHeightTropModel.cpp:210
gnsstk::Position::elevation
double elevation(const Position &Target) const
Definition: Position.cpp:1308
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