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 GG_HEIGHT_TROP_MODEL_HPP
41 #define GG_HEIGHT_TROP_MODEL_HPP
42 
43 #include "TropModel.hpp"
44 
45 namespace gpstk
46 {
47    //---------------------------------------------------------------------------------
48    /** Tropospheric model with heights based on Goad and Goodman(1974),
49     *  "A Modified Hopfield Tropospheric Refraction Correction Model," Paper
50     *  presented at the Fall Annual Meeting of the American Geophysical Union,
51     *  San Francisco, December 1974.
52     *
53     *  (Not the same as GGTropModel because this has height dependence, and the
54     *  computation of this model does not break cleanly into wet and dry components.)
55     *
56     *  NB this model requires heights, both of the weather parameters,
57     *    and of the receiver.
58     *  Thus, usually, caller will set heights at the same time the weather is set:
59     *
60     * @code
61     *    GGHeightTropModel ggh;
62     *    ggh.setWeather(T,P,H);
63     *    ggh.setHeights(hT,hP,hH);
64     * @endcode
65     *
66     *  and when the correction (and/or delay and map) is computed,
67     *  receiver height is set before the call to correction(elevation):
68     *
69     * @code
70     *    ggh.setReceiverHeight(height);
71     *    trop = ggh.correction(elevation);
72     * @endcode
73     *
74     *  NB setReceiverHeight(ht) sets the 'weather heights' as well, if they are not
75     *    already defined.
76     */
77    class GGHeightTropModel : public TropModel
78    {
79    public:
80          /// Empty constructor
81       GGHeightTropModel(void);
82 
83          /** Creates a trop model, with weather observation input
84           * @param wx the weather to use for this correction.
85           * @throw InvalidParameter
86           */
87       GGHeightTropModel(const WxObservation& wx);
88 
89          /** Create a tropospheric model from explicit weather data
90           * @param T temperature in degrees Celsius
91           * @param P atmospheric pressure in millibars
92           * @param H relative humidity in percent
93           * @throw InvalidParameter
94           */
95       GGHeightTropModel(const double& T,
96                         const double& P,
97                         const double& H);
98 
99          /** Create a valid model from explicit input.
100           * @param T temperature in degrees Celsius
101           * @param P atmospheric pressure in millibars
102           * @param H relative humidity in percent
103           * @param hT height at which temperature applies in meters.
104           * @param hP height at which atmospheric pressure applies in meters.
105           * @param hH height at which relative humidity applies in meters.
106           * @throw InvalidParameter
107           */
108       GGHeightTropModel(const double& T,
109                         const double& P,
110                         const double& H,
111                         const double hT,
112                         const double hP,
113                         const double hH);
114 
115          /// Return the name of the model
name(void)116       virtual std::string name(void)
117       { return std::string("GGHeight"); }
118 
119          /** Compute and return the full tropospheric delay
120           * @param elevation Elevation of satellite as seen at
121           *   receiver, in degrees
122           * @throw InvalidTropModel
123           */
124       virtual double correction(double elevation) const;
125 
126          /**
127           * Compute and return the full tropospheric delay, given the positions of
128           * receiver and satellite and the time tag. This version is most useful
129           * within positioning algorithms, where the receiver position and timetag
130           * may vary; it computes the elevation (and other receiver location
131           * information) and passes them to appropriate set...() routines and the
132           * correction(elevation) routine.
133           * @param RX  Receiver position
134           * @param SV  Satellite position
135           * @param tt  Time tag of the signal
136           * @throw InvalidTropModel
137           */
138       virtual double correction(const Position& RX,
139                                 const Position& SV,
140                                 const CommonTime& tt);
141 
142          /** \deprecated
143           * Compute and return the full tropospheric delay, given the positions of
144           * receiver and satellite and the time tag. This version is most useful
145           * within positioning algorithms, where the receiver position and timetag
146           * may vary; it computes the elevation (and other receiver location
147           * information) and passes them to appropriate set...() routines and the
148           * correction(elevation) routine.
149           * @param RX  Receiver position in ECEF cartesian coordinates (meters)
150           * @param SV  Satellite position in ECEF cartesian coordinates (meters)
151           * @param tt  Time tag of the signal
152           * @throw InvalidTropModel
153           */
154       virtual double correction(const Xvt& RX,
155                                 const Xvt& SV,
156                                 const CommonTime& tt);
157 
158          /** Compute and return the zenith delay for dry component
159           * of the troposphere
160           * @throw InvalidTropModel
161           */
162       virtual double dry_zenith_delay(void) const;
163 
164          /** Compute and return the zenith delay for wet component of
165           * the troposphere
166           * @throw InvalidTropModel */
167       virtual double wet_zenith_delay(void) const;
168 
169          /** Compute and return the mapping function for dry component of
170           * the troposphere.
171           * @param elevation Elevation of satellite as seen at
172           *   receiver, in degrees
173           * @throw InvalidTropModel
174           */
175       virtual double dry_mapping_function(double elevation) const;
176 
177          /** Compute and return the mapping function for wet component of
178           * the troposphere.
179           * @param elevation Elevation of satellite as seen at
180           *   receiver, in degrees
181           * @throw InvalidTropModel
182           */
183       virtual double wet_mapping_function(double elevation) const;
184 
185          /** Re-define the weather data.
186           * Typically called initially, and whenever the weather changes.
187           * @param T temperature in degrees Celsius
188           * @param P atmospheric pressure in millibars
189           * @param H relative humidity in percent
190           * @throw InvalidParameter
191           */
192       virtual void setWeather(const double& T,
193                               const double& P,
194                               const double& H);
195 
196          /** Re-define the tropospheric model with explicit weather data.
197           * Typically called just before correction().
198           * @param wx the weather to use for this correction
199           * @throw InvalidParameter
200           */
201       virtual void setWeather(const WxObservation& wx);
202 
203          /// Re-define the heights at which the weather parameters apply.
204          /// Typically called whenever setWeather is called.
205          /// @param hT height at which temperature applies in meters.
206          /// @param hP height at which atmospheric pressure applies in meters.
207          /// @param hH height at which relative humidity applies in meters.
208       void setHeights(const double& hT,
209                       const double& hP,
210                       const double& hH);
211 
212          /// Define the receiver height; this required before calling
213          /// correction() or any of the zenith_delay or mapping_function routines.
214       void setReceiverHeight(const double& ht);
215 
216    private:
217       double height;                // height (m) of the receiver
218       double htemp;                 // height (m) at which temp applies
219       double hpress;                // height (m) at which press applies
220       double hhumid;                // height (m) at which humid applies
221       bool validWeather;
222       bool validHeights;
223       bool validRxHeight;
224    };
225 }
226 
227 #endif
228