| 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 |
|
|---|