1 | //#--------------------------------------------------------------------------- |
---|
2 | //# STAtmosphere.h: Model of atmospheric opacity |
---|
3 | //#--------------------------------------------------------------------------- |
---|
4 | //# Copyright (C) 2004 |
---|
5 | //# ATNF |
---|
6 | //# |
---|
7 | //# The code is based on the Fortran code written by Bob Sault for MIRIAD. |
---|
8 | //# Converted to C++ by Max Voronkov. This code uses a simple model of the |
---|
9 | //# atmosphere and Liebe's model (1985) of the complex refractive index of |
---|
10 | //# air. |
---|
11 | //# |
---|
12 | //# The model of the atmosphere is one with an exponential fall-off in |
---|
13 | //# the water vapour content (scale height of 1540 m) and a temperature lapse |
---|
14 | //# rate of 6.5 mK/m. Otherwise the atmosphere obeys the ideal gas equation |
---|
15 | //# and hydrostatic equilibrium. |
---|
16 | //# |
---|
17 | //# This program is free software; you can redistribute it and/or modify it |
---|
18 | //# under the terms of the GNU General Public License as published by the Free |
---|
19 | //# Software Foundation; either version 2 of the License, or (at your option) |
---|
20 | //# any later version. |
---|
21 | //# |
---|
22 | //# This program is distributed in the hope that it will be useful, but |
---|
23 | //# WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
24 | //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
---|
25 | //# Public License for more details. |
---|
26 | //# |
---|
27 | //# You should have received a copy of the GNU General Public License along |
---|
28 | //# with this program; if not, write to the Free Software Foundation, Inc., |
---|
29 | //# 675 Massachusetts Ave, Cambridge, MA 02139, USA. |
---|
30 | //# |
---|
31 | //# Correspondence concerning this software should be addressed as follows: |
---|
32 | //# Internet email: Malte.Marquarding@csiro.au |
---|
33 | //# Postal address: Malte Marquarding, |
---|
34 | //# Australia Telescope National Facility, |
---|
35 | //# P.O. Box 76, |
---|
36 | //# Epping, NSW, 2121, |
---|
37 | //# AUSTRALIA |
---|
38 | //# |
---|
39 | //# $Id: STAtmosphere.h 1346 2007-04-26 03:24:41Z mar637 $ |
---|
40 | //#--------------------------------------------------------------------------- |
---|
41 | |
---|
42 | // own includes |
---|
43 | #include "STAtmosphere.h" |
---|
44 | |
---|
45 | // casa includes |
---|
46 | #include <casa/Utilities/Assert.h> |
---|
47 | #include <casa/Quanta.h> |
---|
48 | |
---|
49 | // std includes |
---|
50 | #include <cmath> |
---|
51 | |
---|
52 | using namespace casa; |
---|
53 | using namespace asap; |
---|
54 | |
---|
55 | /** |
---|
56 | * Default Constructor (apart from optional parameters). |
---|
57 | * The class set up this way will assume International Standard Atmosphere (ISA) conditions, |
---|
58 | * except for humidity. The latter is assumed to be 50%, which seems more realistic for |
---|
59 | * Australian telescopes than 0%. |
---|
60 | * @param[in] wvScale water vapour scale height (m), default is 1540m to match MIRIAD's model |
---|
61 | * @param[in] maxAlt maximum altitude of the model atmosphere (m), plane parallel layers are spread linearly up to |
---|
62 | * this height, default is 10000m to match MIRIAD. |
---|
63 | * @param[in] nLayers number of plane parallel layers in the model (essentially for a numberical integration), |
---|
64 | * default is 50 to match MIRIAD. |
---|
65 | **/ |
---|
66 | STAtmosphere::STAtmosphere(double wvScale, double maxAlt, size_t nLayers) : |
---|
67 | itsGndTemperature(288.), itsGndPressure(101325.), itsGndHumidity(0.5), |
---|
68 | itsLapseRate(0.0065), itsWVScale(wvScale), itsMaxAlt(maxAlt), |
---|
69 | itsHeights(nLayers), itsTemperatures(nLayers), |
---|
70 | itsDryPressures(nLayers), itsVapourPressures(nLayers) |
---|
71 | { |
---|
72 | recomputeAtmosphereModel(); |
---|
73 | } |
---|
74 | |
---|
75 | /** |
---|
76 | * Constructor with explicitly given parameters of the atmosphere |
---|
77 | * @param[in] temperature air temperature at the observatory (K) |
---|
78 | * @param[in] pressure air pressure at the observatory (Pascals) |
---|
79 | * @param[in] humidity air humidity at the observatory (fraction) |
---|
80 | * @param[in] lapseRate temperature lapse rate (K/m), default is 0.0065 K/m to match MIRIAD and ISA |
---|
81 | * @param[in] wvScale water vapour scale height (m), default is 1540m to match MIRIAD's model |
---|
82 | * @param[in] maxAlt maximum altitude of the model atmosphere (m), plane parallel layers are spread linearly up to |
---|
83 | * this height, default is 10000m to match MIRIAD. |
---|
84 | * @param[in] nLayers number of plane parallel layers in the model (essentially for a numberical integration), |
---|
85 | * default is 50 to match MIRIAD. |
---|
86 | **/ |
---|
87 | STAtmosphere::STAtmosphere(double temperature, double pressure, double humidity, double lapseRate, |
---|
88 | double wvScale, double maxAlt, size_t nLayers) : |
---|
89 | itsGndTemperature(temperature), itsGndPressure(pressure), itsGndHumidity(humidity), |
---|
90 | itsLapseRate(lapseRate), itsWVScale(wvScale), itsMaxAlt(maxAlt), |
---|
91 | itsHeights(nLayers), itsTemperatures(nLayers), |
---|
92 | itsDryPressures(nLayers), itsVapourPressures(nLayers) |
---|
93 | { |
---|
94 | recomputeAtmosphereModel(); |
---|
95 | } |
---|
96 | |
---|
97 | /** |
---|
98 | * Set the new weather station data, recompute the model |
---|
99 | * @param[in] temperature air temperature at the observatory (K) |
---|
100 | * @param[in] pressure air pressure at the observatory (Pascals) |
---|
101 | * @param[in] humidity air humidity at the observatory (fraction) |
---|
102 | **/ |
---|
103 | void STAtmosphere::setWeather(double temperature, double pressure, double humidity) |
---|
104 | { |
---|
105 | itsGndTemperature = temperature; |
---|
106 | itsGndPressure = pressure; |
---|
107 | itsGndHumidity = humidity; |
---|
108 | recomputeAtmosphereModel(); |
---|
109 | } |
---|
110 | |
---|
111 | /** |
---|
112 | * Build the atmosphere model based on exponential fall-off, ideal gas and hydrostatic |
---|
113 | * equilibrium. The model parameters are taken from the data members of this class. |
---|
114 | **/ |
---|
115 | void STAtmosphere::recomputeAtmosphereModel() |
---|
116 | { |
---|
117 | AlwaysAssert(itsGndTemperature > 0, AipsError); |
---|
118 | AlwaysAssert(itsGndPressure > 0., AipsError); |
---|
119 | AlwaysAssert((itsGndHumidity >= 0.) && (itsGndHumidity<=1.), AipsError); |
---|
120 | AlwaysAssert(itsMaxAlt > 0., AipsError); |
---|
121 | AlwaysAssert(itsWVScale > 0., AipsError); |
---|
122 | |
---|
123 | const double heightStep = itsMaxAlt/double(nLayers()); |
---|
124 | // molar mass of the air |
---|
125 | const double M = 28.96e-3; |
---|
126 | // free-fall acceleration |
---|
127 | const double g = 9.81; |
---|
128 | const double wvGndSaturationPressure = wvSaturationPressure(itsGndTemperature); |
---|
129 | for (size_t layer = 0; layer < nLayers(); ++layer) { |
---|
130 | const double height = double(layer)*heightStep; |
---|
131 | itsHeights[layer] = height; |
---|
132 | itsTemperatures[layer] = itsGndTemperature/(1.+itsLapseRate*height/itsGndTemperature); |
---|
133 | const double pressure = itsGndPressure * exp(-M*g/(QC::R.get().getValue()*itsGndTemperature)* |
---|
134 | (height+0.5*itsLapseRate*height*height/itsGndTemperature)); |
---|
135 | itsVapourPressures[layer] = casa::min(itsGndHumidity*exp(-height/itsWVScale)*wvGndSaturationPressure, |
---|
136 | wvSaturationPressure(itsTemperatures[layer])); |
---|
137 | itsDryPressures[layer] = pressure - itsVapourPressures[layer]; |
---|
138 | } |
---|
139 | } |
---|
140 | |
---|
141 | /** |
---|
142 | * Obtain the number of model layers, do consistency check that everything is |
---|
143 | * resized accordingly |
---|
144 | * @retrun number of model layers |
---|
145 | **/ |
---|
146 | size_t STAtmosphere::nLayers() const |
---|
147 | { |
---|
148 | const size_t result = itsHeights.size(); |
---|
149 | DebugAssert(result > 0, AipsError); |
---|
150 | DebugAssert(itsTemperatures.size() == result, AipsError); |
---|
151 | DebugAssert(itsDryPressures.size() == result, AipsError); |
---|
152 | DebugAssert(itsVapourPressures.size() == result, AipsError); |
---|
153 | return result; |
---|
154 | } |
---|
155 | |
---|
156 | /** |
---|
157 | * Determine the saturation pressure of water vapour for the given temperature. |
---|
158 | * |
---|
159 | * Reference: |
---|
160 | * Waters, Refraction effects in the neutral atmosphere. Methods of |
---|
161 | * Experimental Physics, vol 12B, p 186-200 (1976). |
---|
162 | * |
---|
163 | * @param[in] temperature temperature in K |
---|
164 | * @return vapour saturation pressure (Pascals) |
---|
165 | **/ |
---|
166 | double STAtmosphere::wvSaturationPressure(double temperature) |
---|
167 | { |
---|
168 | if (temperature > 215.) { |
---|
169 | return 0.; |
---|
170 | } |
---|
171 | const double theta = 300.0/temperature; |
---|
172 | return 1e5/(41.51/std::pow(theta,5)*std::pow(10.,9.834*theta-10.0)); |
---|
173 | } |
---|
174 | |
---|
175 | /** |
---|
176 | * Compute the complex refractivity of the dry components of the atmosphere |
---|
177 | * (oxygen lines) at the given frequency. |
---|
178 | * @param[in] freq frequency (Hz) |
---|
179 | * @param[in] temperature air temperature (K) |
---|
180 | * @param[in] pDry partial pressure of dry components (Pascals) |
---|
181 | * @param[in] pVapour partial pressure of water vapour (Pascals) |
---|
182 | * @return complex refractivity |
---|
183 | **/ |
---|
184 | std::complex<double> STAtmosphere::dryRefractivity(double freq, double temperature, |
---|
185 | double pDry, double pVapour) |
---|
186 | { |
---|
187 | // the number of parameters per atmospheric line and the number of lines taken into account |
---|
188 | const size_t nLineParams = 7; |
---|
189 | const size_t nLines = 48; |
---|
190 | // actual tabulated values |
---|
191 | const double lines[nLines][nLineParams] = |
---|
192 | {{49.452379, 0.12E-6, 11.830, 8.40E-3, 0.0, 5.60E-3, 1.7}, |
---|
193 | {49.962257, 0.34E-6, 10.720, 8.50E-3, 0.0, 5.60E-3, 1.7}, |
---|
194 | {50.474238, 0.94E-6, 9.690, 8.60E-3, 0.0, 5.60E-3, 1.7}, |
---|
195 | {50.987748, 2.46E-6, 8.690, 8.70E-3, 0.0, 5.50E-3, 1.7}, |
---|
196 | {51.503350, 6.08E-6, 7.740, 8.90E-3, 0.0, 5.60E-3, 1.8}, |
---|
197 | {52.021409, 14.14E-6, 6.840, 9.20E-3, 0.0, 5.50E-3, 1.8}, |
---|
198 | {52.542393, 31.02E-6, 6.000, 9.40E-3, 0.0, 5.70E-3, 1.8}, |
---|
199 | {53.066906, 64.10E-6, 5.220, 9.70E-3, 0.0, 5.30E-3, 1.9}, |
---|
200 | {53.595748, 124.70E-6, 4.480, 10.00E-3, 0.0, 5.40E-3, 1.8}, |
---|
201 | {54.129999, 228.00E-6, 3.810, 10.20E-3, 0.0, 4.80E-3, 2.0}, |
---|
202 | {54.671157, 391.80E-6, 3.190, 10.50E-3, 0.0, 4.80E-3, 1.9}, |
---|
203 | {55.221365, 631.60E-6, 2.620, 10.79E-3, 0.0, 4.17E-3, 2.1}, |
---|
204 | {55.783800, 953.50E-6, 2.115, 11.10E-3, 0.0, 3.75E-3, 2.1}, |
---|
205 | {56.264777, 548.90E-6, 0.010, 16.46E-3, 0.0, 7.74E-3, 0.9}, |
---|
206 | {56.363387, 1344.00E-6, 1.655, 11.44E-3, 0.0, 2.97E-3, 2.3}, |
---|
207 | {56.968180, 1763.00E-6, 1.255, 11.81E-3, 0.0, 2.12E-3, 2.5}, |
---|
208 | {57.612481, 2141.00E-6, 0.910, 12.21E-3, 0.0, 0.94E-3, 3.7}, |
---|
209 | {58.323874, 2386.00E-6, 0.621, 12.66E-3, 0.0, -0.55E-3, -3.1}, |
---|
210 | {58.446589, 1457.00E-6, 0.079, 14.49E-3, 0.0, 5.97E-3, 0.8}, |
---|
211 | {59.164204, 2404.00E-6, 0.386, 13.19E-3, 0.0, -2.44E-3, 0.1}, |
---|
212 | {59.590982, 2112.00E-6, 0.207, 13.60E-3, 0.0, 3.44E-3, 0.5}, |
---|
213 | {60.306057, 2124.00E-6, 0.207, 13.82E-3, 0.0, -4.13E-3, 0.7}, |
---|
214 | {60.434775, 2461.00E-6, 0.386, 12.97E-3, 0.0, 1.32E-3, -1.0}, |
---|
215 | {61.150558, 2504.00E-6, 0.621, 12.48E-3, 0.0, -0.36E-3, 5.8}, |
---|
216 | {61.800152, 2298.00E-6, 0.910, 12.07E-3, 0.0, -1.59E-3, 2.9}, |
---|
217 | {62.411212, 1933.00E-6, 1.255, 11.71E-3, 0.0, -2.66E-3, 2.3}, |
---|
218 | {62.486253, 1517.00E-6, 0.078, 14.68E-3, 0.0, -4.77E-3, 0.9}, |
---|
219 | {62.997974, 1503.00E-6, 1.660, 11.39E-3, 0.0, -3.34E-3, 2.2}, |
---|
220 | {63.568515, 1087.00E-6, 2.110, 11.08E-3, 0.0, -4.17E-3, 2.0}, |
---|
221 | {64.127764, 733.50E-6, 2.620, 10.78E-3, 0.0, -4.48E-3, 2.0}, |
---|
222 | {64.678900, 463.50E-6, 3.190, 10.50E-3, 0.0, -5.10E-3, 1.8}, |
---|
223 | {65.224067, 274.80E-6, 3.810, 10.20E-3, 0.0, -5.10E-3, 1.9}, |
---|
224 | {65.764769, 153.00E-6, 4.480, 10.00E-3, 0.0, -5.70E-3, 1.8}, |
---|
225 | {66.302088, 80.09E-6, 5.220, 9.70E-3, 0.0, -5.50E-3, 1.8}, |
---|
226 | {66.836827, 39.46E-6, 6.000, 9.40E-3, 0.0, -5.90E-3, 1.7}, |
---|
227 | {67.369595, 18.32E-6, 6.840, 9.20E-3, 0.0, -5.60E-3, 1.8}, |
---|
228 | {67.900862, 8.01E-6, 7.740, 8.90E-3, 0.0, -5.80E-3, 1.7}, |
---|
229 | {68.431001, 3.30E-6, 8.690, 8.70E-3, 0.0, -5.70E-3, 1.7}, |
---|
230 | {68.960306, 1.28E-6, 9.690, 8.60E-3, 0.0, -5.60E-3, 1.7}, |
---|
231 | {69.489021, 0.47E-6, 10.720, 8.50E-3, 0.0, -5.60E-3, 1.7}, |
---|
232 | {70.017342, 0.16E-6, 11.830, 8.40E-3, 0.0, -5.60E-3, 1.7}, |
---|
233 | {118.750341, 945.00E-6, 0.000, 15.92E-3, 0.0, -0.44E-3, 0.9}, |
---|
234 | {368.498350, 67.90E-6, 0.020, 19.20E-3, 0.6, 0.00E00, 1.0}, |
---|
235 | {424.763120, 638.00E-6, 0.011, 19.16E-3, 0.6, 0.00E00, 1.0}, |
---|
236 | {487.249370, 235.00E-6, 0.011, 19.20E-3, 0.6, 0.00E00, 1.0}, |
---|
237 | {715.393150, 99.60E-6, 0.089, 18.10E-3, 0.6, 0.00E00, 1.0}, |
---|
238 | {773.838730, 671.00E-6, 0.079, 18.10E-3, 0.6, 0.00E00, 1.0}, |
---|
239 | {834.145330, 180.00E-6, 0.079, 18.10E-3, 0.6, 0.00E00, 1.0}}; |
---|
240 | |
---|
241 | // convert to the units of Liebe |
---|
242 | const double theta = 300./temperature; |
---|
243 | const double kPaPVap = 0.001*pVapour; |
---|
244 | const double kPaPDry = 0.001*pDry; |
---|
245 | const double fGHz = freq * 1e-9; |
---|
246 | |
---|
247 | // some coefficients |
---|
248 | const double ap = 1.4e-10*(1-1.2e-5*std::pow(fGHz,1.5)); |
---|
249 | const double gamma0 = 5.6e-3*(kPaPDry + 1.1*kPaPVap)*std::pow(theta,0.8); |
---|
250 | // initial refractivity |
---|
251 | std::complex<double> result(2.588*kPaPDry*theta + |
---|
252 | 3.07e-4*(1.0/(1.0+std::pow(fGHz/gamma0,2))-1)*kPaPDry*theta*theta, |
---|
253 | (2*3.07e-4/(gamma0*(1+std::pow(fGHz/gamma0,2))*(1+std::pow(fGHz/60,2))) + |
---|
254 | ap*kPaPDry*std::pow(theta,2.5))*fGHz*kPaPDry*theta*theta); |
---|
255 | // sum the contributions of all the lines |
---|
256 | for (size_t l = 0; l < nLines; ++l) { |
---|
257 | const double S = lines[l][1]*kPaPDry*std::pow(theta,3)*exp(lines[l][2]*(1.-theta)); |
---|
258 | const double gamma = lines[l][3]*(kPaPDry*std::pow(theta,0.8-lines[l][4]) + 1.1*kPaPVap*theta); |
---|
259 | const double delta = lines[l][5]*kPaPDry*std::pow(theta,lines[l][6]); |
---|
260 | const double x = (lines[l][0]-fGHz)*(lines[l][0]-fGHz) + gamma*gamma; |
---|
261 | const double y = (lines[l][0]+fGHz)*(lines[l][0]+fGHz) + gamma*gamma; |
---|
262 | const double z = (lines[l][0]+gamma*gamma/lines[l][0]); |
---|
263 | result += std::complex<double> (S*( (z-fGHz)/x + (z+fGHz)/y - 2./lines[l][0] + |
---|
264 | delta*(1/x-1/y)*gamma*fGHz/lines[l][0]), |
---|
265 | S*( (1/x+1/y)*gamma*fGHz/lines[l][0] - |
---|
266 | delta*((lines[l][0]-fGHz)/x + (lines[l][0]+fGHz)/y)*fGHz/lines[l][0])); |
---|
267 | } |
---|
268 | |
---|
269 | return result; |
---|
270 | } |
---|