1 //==============================================================================
2 //
3 //  This file is part of GPSTk, the GPS Toolkit.
4 //
5 //  The GPSTk 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 GPSTk 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 GPSTk; 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-2020, 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 #ifndef NEILL_TROP_MODEL_HPP
41 #define NEILL_TROP_MODEL_HPP
42 
43 #include "TropModel.hpp"
44 
45 namespace gpstk
46 {
47       /** Tropospheric model based in the Neill mapping functions.
48        *
49        * This model uses the mapping functions developed by A.E. Niell and
50        * published in Neill, A.E., 1996, 'Global Mapping Functions for the
51        * Atmosphere Delay of Radio Wavelengths,' J. Geophys. Res., 101,
52        * pp. 3227-3246 (also see IERS TN 32).
53        *
54        * The coefficients of the hydrostatic mapping function depend on the
55        * latitude and height above sea level of the receiver station, and on
56        * the day of the year. On the other hand, the wet mapping function
57        * depends only on latitude.
58        *
59        * This mapping is independent from surface meteorology, while having
60        * comparable accuracy and precision to those that require such data.
61        * This characteristic makes this model very useful, and it is
62        * implemented in geodetic software such as JPL's Gipsy/OASIS.
63        *
64        * A typical way to use this model follows:
65        *
66        * @code
67        *   NeillTropModel neillTM;
68        *   neillTM.setReceiverLatitude(lat);
69        *   neillTM.setReceiverHeight(height);
70        *   neillTM.setDayOfYear(doy);
71        * @endcode
72        *
73        * Once all the basic model parameters are set (latitude, height and
74        * day of year), then we are able to compute the tropospheric correction
75        * as a function of elevation:
76        *
77        * @code
78        *   trop = neillTM.correction(elevation);
79        * @endcode
80        *
81        * @warning The Neill mapping functions are defined for elevation
82        * angles down to 3 degrees.
83        *
84        */
85    class NeillTropModel : public TropModel
86    {
87    public:
88 
89          /// Default constructor
NeillTropModel(void)90       NeillTropModel(void)
91       { validHeight=false; validLat=false; validDOY=false; valid=false; };
92 
93 
94          /// Constructor to create a Neill trop model providing just the
95          /// height of the receiver above mean sea level. The other
96          /// parameters must be set with the appropriate set methods before
97          /// calling correction methods.
98          ///
99          /// @param ht   Height of the receiver above mean sea level, in
100          ///             meters.
NeillTropModel(const double & ht)101       NeillTropModel(const double& ht)
102       { setReceiverHeight(ht); };
103 
104 
105          /// Constructor to create a Neill trop model providing the height of
106          /// the receiver above mean sea level (as defined by ellipsoid
107          /// model), its latitude and the day of year.
108          ///
109          /// @param ht   Height of the receiver above mean sea level,
110          ///             in meters.
111          /// @param lat  Latitude of receiver, in degrees.
112          /// @param doy  Day of year.
NeillTropModel(const double & ht,const double & lat,const int & doy)113       NeillTropModel( const double& ht,
114                       const double& lat,
115                       const int& doy )
116       { setReceiverHeight(ht); setReceiverLatitude(lat); setDayOfYear(doy); };
117 
118 
119          /// Constructor to create a Neill trop model providing the position
120          /// of the receiver and current time.
121          ///
122          /// @param RX   Receiver position.
123          /// @param time Time.
124       NeillTropModel( const Position& RX,
125                       const CommonTime& time );
126 
127 
128       /// Return the name of the model
name(void)129       virtual std::string name(void)
130          { return std::string("Neill"); }
131 
132          /** Compute and return the full tropospheric delay. The receiver
133           * height, latitude and Day oy Year must has been set before using
134           * the appropriate constructor or the provided methods.
135           *
136           * @param elevation Elevation of satellite as seen at receiver,
137           *                  in degrees.
138           * @throw InvalidTropModel
139           */
140       virtual double correction(double elevation) const;
141 
142 
143          /** Compute and return the full tropospheric delay, given the
144           *  positions of receiver and satellite.
145           *
146           * This version is more useful within positioning algorithms, where
147           * the receiver position may vary; it computes the elevation (and
148           * other receiver location information as height and latitude) and
149           * passes them to appropriate methods.
150           *
151           * You must set time using method setReceiverDOY() before calling
152           * this method.
153           *
154           * @param RX  Receiver position.
155           * @param SV  Satellite position.
156           * @throw InvalidTropModel
157           */
158       virtual double correction( const Position& RX,
159                                  const Position& SV );
160 
161 
162          /** Compute and return the full tropospheric delay, given the
163           *  positions of receiver and satellite and the time tag.
164           *
165           * This version is more useful within positioning algorithms, where
166           * the receiver position may vary; it computes the elevation (and
167           * other receiver location information as height and latitude), and
168           * passes them to appropriate methods.
169           *
170           * @param RX  Receiver position.
171           * @param SV  Satellite position.
172           * @param tt  Time (CommonTime object).
173           * @throw InvalidTropModel
174           */
175       virtual double correction( const Position& RX,
176                                  const Position& SV,
177                                  const CommonTime& tt );
178 
179 
180          /** Compute and return the full tropospheric delay, given the
181           *  positions of receiver and satellite and the day of the year.
182           *
183           * This version is more useful within positioning algorithms, where
184           * the receiver position may vary; it computes the elevation (and
185           * other receiver location information as height and latitude), and
186           * passes them to appropriate methods.
187           *
188           * @param RX  Receiver position.
189           * @param SV  Satellite position.
190           * @param doy Day of year.
191           * @throw InvalidTropModel
192           */
193       virtual double correction( const Position& RX,
194                                  const Position& SV,
195                                  const int& doy );
196 
197 
198          /** \deprecated
199           * Compute and return the full tropospheric delay, given the
200           * positions of receiver and satellite. . You must set time using
201           * method setReceiverDOY() before calling this method.
202           *
203           * @param RX  Receiver position in ECEF cartesian coordinates
204           *            (meters).
205           * @param SV  Satellite position in ECEF cartesian coordinates
206           *            (meters).
207           * @throw InvalidTropModel
208           */
209       virtual double correction( const Xvt& RX,
210                                  const Xvt& SV  );
211 
212 
213          /** \deprecated
214           * Compute and return the full tropospheric delay, given the
215           * positions of receiver and satellite and the time tag. This version
216           * is most useful within positioning algorithms, where the receiver
217           * position may vary; it computes the elevation (and other receiver
218           * location information as height and latitude) and passes them to
219           * appropriate methods.
220           *
221           * @param RX  Receiver position in ECEF cartesian coordinates
222           *            (meters)
223           * @param SV  Satellite position in ECEF cartesian coordinates
224           *            (meters)
225           * @param tt  Time (CommonTime object).
226           * @throw InvalidTropModel
227           */
228       virtual double correction( const Xvt& RX,
229                                  const Xvt& SV,
230                                  const CommonTime& tt );
231 
232 
233          /** \deprecated
234           * Compute and return the full tropospheric delay, given the
235           * positions of receiver and satellite and the day of the year. This
236           * version is most useful within positioning algorithms, where the
237           * receiver position may vary; it computes the elevation (and other
238           * receiver location information as height and latitude) and passes
239           * them to appropriate methods.
240           *
241           * @param RX  Receiver position in ECEF cartesian coordinates
242           *            (meters)
243           * @param SV  Satellite position in ECEF cartesian coordinates
244           *            (meters)
245           * @param doy Day of year.
246           * @throw InvalidTropModel
247           */
248       virtual double correction( const Xvt& RX,
249                                  const Xvt& SV,
250                                  const int& doy );
251 
252 
253          /** Compute and return the zenith delay for dry component of
254           * the troposphere.
255           * @throw InvalidTropModel
256           */
257       virtual double dry_zenith_delay(void) const;
258 
259 
260          /** Compute and return the zenith delay for wet component of
261           * the troposphere.
262           * @throw InvalidTropModel
263           */
wet_zenith_delay(void) const264       virtual double wet_zenith_delay(void) const
265       { return 0.1; };           // Returns a nominal value
266 
267 
268          /** Compute and return the mapping function for dry component of
269           * the troposphere.
270           *
271           * @param elevation Elevation of satellite as seen at receiver, in
272           *                  degrees
273           * @throw InvalidTropModel
274           */
275       virtual double dry_mapping_function(double elevation) const;
276 
277 
278          /** Compute and return the mapping function for wet component of
279           * the troposphere.
280           *
281           * @param elevation Elevation of satellite as seen at
282           *                  receiver, in degrees
283           * @throw InvalidTropModel
284           */
285       virtual double wet_mapping_function(double elevation) const;
286 
287 
288          /** This method configure the model to estimate the weather using
289           * height, latitude and day of year (DOY). It is called
290           * automatically when setting those parameters.
291           * @throw InvalidTropModel
292           */
293       void setWeather();
294 
295 
296          /** In Neill tropospheric model, this is a dummy method kept here
297           * just for consistency,
298           * @throw InvalidParameter
299           */
setWeather(const double & T,const double & P,const double & H)300       virtual void setWeather( const double& T,
301                                const double& P,
302                                const double& H )
303       {}
304 
305 
306          /** In Neill tropospheric model, this is a dummy method kept here
307           * just for consistency
308           * @throw InvalidParameter
309           */
setWeather(const WxObservation & wx)310       virtual void setWeather(const WxObservation& wx)
311       {}
312 
313 
314          /// Define the receiver height; this is required before calling
315          /// correction() or any of the zenith_delay routines.
316          ///
317          /// @param ht   Height of the receiver above mean sea level,
318          ///             in meters.
319       virtual void setReceiverHeight(const double& ht);
320 
321 
322          /// Define the receiver latitude; this is required before calling
323          /// correction() or any of the zenith_delay routines.
324          ///
325          /// @param lat  Latitude of receiver, in degrees.
326       virtual void setReceiverLatitude(const double& lat);
327 
328 
329          /// Set the time when tropospheric correction will be computed for,
330          /// in days of the year.
331          ///
332          /// @param doy  Day of the year.
333       virtual void setDayOfYear(const int& doy);
334 
335 
336          /// Set the time when tropospheric correction will be computed for,
337          /// in days of the year.
338          ///
339          /// @param time  Time object.
340       virtual void setDayOfYear(const CommonTime& time);
341 
342 
343          /** Convenient method to set all model parameters in one pass.
344           *
345           * @param time  Time object.
346           * @param rxPos Receiver position object.
347           */
348       virtual void setAllParameters( const CommonTime& time,
349                                      const Position& rxPos );
350 
351 
352    private:
353       double NeillHeight;
354       double NeillLat;
355       int NeillDOY;
356       bool validHeight;
357       bool validLat;
358       bool validDOY;
359    };
360 
361 }
362 #endif
363