CARMA C++
Atmosphere.h
1 #ifndef SZA_UTIL_ATMOSPHERE_H
2 #define SZA_UTIL_ATMOSPHERE_H
3 
11 /*
12  * Set the temperature lapse rate, termination precision, and optical
13  * and radio wavelengths required by the slalib refraction function
14  * (slaRefco()). Note that for wavelengths longward of 100 microns
15  * slaRefco() uses a model that is currently independent of wavelength,
16  * so the accuracy of the chosen radio wavelength is not pertinent.
17  */
18 
19 #include "carma/szautil/Angle.h"
20 #include "carma/szautil/Length.h"
21 #include "carma/szautil/Pressure.h"
22 #include "carma/szautil/Temperature.h"
23 #include "carma/szautil/Rx.h"
25 
26 namespace sza {
27  namespace util {
28 
29  class Atmosphere {
30  public:
31 
32  // Set parameters we need for the refraction calc
33 
34  enum {
35  NONE = 0x0,
36  TEMP = 0x1,
37  PRESSURE = 0x2,
38  HUMIDITY = 0x4,
39  ALTITUDE = 0x8,
40  LATITUDE = 0x10,
41  WAVE = 0x20,
42  ALLREFRAC = TEMP|PRESSURE|HUMIDITY|ALTITUDE|LATITUDE|WAVE,
43  ALLOPTICAL = TEMP|PRESSURE|HUMIDITY|ALTITUDE|LATITUDE,
44  ALLPATH = TEMP|PRESSURE|HUMIDITY|ALTITUDE
45  };
46 
47  struct RefractionCoefficients {
48  double a;
49  double b;
50  };
51 
52  // As suggested by slalib documentation (deg K/meter)
53 
54  static const double tropoLapseRate_;
55 
56  // By default, refraction calculation will be done to 10
57  // milli-arcseconds accuracy
58 
59  static Angle refracAccuracy_;
60 
61  // Default for optical refraction will be wavelengths near the
62  // center of the visible spectrum
63 
64  static Wavelength opticalWavelength_;
65 
66  // Constructor.
67 
68  Atmosphere();
69 
70  // Destructor.
71 
72  virtual ~Atmosphere();
73 
74  // Fully-specified method for computing refraction coefficients
75 
76  static RefractionCoefficients
77  refractionCoefficients(Length altitude, Temperature airTemp,
78  double pressure, double humidity,
79  Wavelength wavelength,
80  Angle latitude,
81  double tropoLapseRate=tropoLapseRate_,
82  Angle accuracy=refracAccuracy_);
83 
84  // Set the internal refraction coefficients for the passed
85  // values
86 
87  void
88  setRefractionCoefficients(Length altitude, Temperature airTemp,
89  double pressure, double humidity,
90  Wavelength wavelength,
91  Angle latitude,
92  double tropoLapseRate=tropoLapseRate_,
93  Angle accuracy=refracAccuracy_);
94 
95  // Set from internal values
96 
97  void setRefractionCoefficients();
98 
99  // Calculate the refraction offset for a given elevation, using
100  // internal refraction coefficients
101 
102  static Angle offset(Angle& elevation,
103  Atmosphere::RefractionCoefficients& coeff);
104  Angle offset(Angle& elevation);
105 
106  // Default methods using internal members
107 
108  RefractionCoefficients
109  refractionCoefficients();
110 
111  RefractionCoefficients
112  opticalRefractionCoefficients();
113 
114  void setAirTemperature(Temperature airTemp);
115 
116  void setPressure(double pressure);
117 
118  void setHumidity(double humidity);
119 
120  void setFrequency(sza::util::Frequency frequency);
121 
122  void setRx(sza::util::Rx::Id rxId);
123 
124  void setAltitude(Length altitude);
125 
126  void setLatitude(Angle latitude);
127 
128  void setWavelength(Wavelength wavelength);
129 
130  // Methods for computing refraction coefficients
131 
132  bool canComputeRefraction();
133 
134  bool canComputeOpticalRefraction();
135 
136  // If all parameters are set, calculate the refraction
137 
138  void computeRefraction();
139 
140  // Methods for computing pathlength
141 
142  bool canComputePathlength();
143 
144  Pressure saturatedVaporPressure(Temperature airTemp);
145  double refractivityTotal(Temperature airTemp, Pressure pressure, double relHumid);
146  double refractivityDry(Temperature airTemp, Pressure pressure, double relHumid);
147  double refractivityWet(Temperature airTemp, Pressure pressure, double relHumid);
148 
149  Length excessPathlength(double refractivity, Length scaleHeight, Length altitude, Angle elevation);
150  Length excessPathlengthTotal(Temperature airTemp, Pressure pressure, double relHumid, Length altitude, Angle elevation);
151  Length excessPathlengthTotal(Angle elevation);
152 
153  static const Length dryScaleHeight_;
154  static const Length wetScaleHeight_;
155  static const Angle pathlengthElevationLimit_;
156  private:
157 
158  RefractionCoefficients coeff_;
159  bool coefficientsAreSet_;
160 
161  Temperature airTemperature_;
162  Length altitude_;
163  Angle latitude_;
164  Wavelength wavelength_;
165  double humidity_;
166  double pressure_;
167 
168  unsigned lacking_;
169 
170  void initialize();
171 
172  }; // End class Atmosphere
173 
174  } // End namespace util
175 } // End namespace sza
176 
177 
178 
179 #endif // End #ifndef SZA_UTIL_ATMOSPHERE_H
Tagged: Wed Dec 1 11:58:54 PST 2004.