//#--------------------------------------------------------------------------- //# STAtmosphere.h: Model of atmospheric opacity //#--------------------------------------------------------------------------- //# Copyright (C) 2004 //# ATNF //# //# The code is based on the Fortran code written by Bob Sault for MIRIAD. //# Converted to C++ by Max Voronkov. This code uses a simple model of the //# atmosphere and Liebe's model (1985) of the complex refractive index of //# air. //# //# The model of the atmosphere is one with an exponential fall-off in //# the water vapour content (scale height of 1540 m) and a temperature lapse //# rate of 6.5 mK/m. Otherwise the atmosphere obeys the ideal gas equation //# and hydrostatic equilibrium. //# //# This program is free software; you can redistribute it and/or modify it //# under the terms of the GNU General Public License as published by the Free //# Software Foundation; either version 2 of the License, or (at your option) //# any later version. //# //# This program is distributed in the hope that it will be useful, but //# WITHOUT ANY WARRANTY; without even the implied warranty of //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General //# Public License for more details. //# //# You should have received a copy of the GNU General Public License along //# with this program; if not, write to the Free Software Foundation, Inc., //# 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning this software should be addressed as follows: //# Internet email: Malte.Marquarding@csiro.au //# Postal address: Malte Marquarding, //# Australia Telescope National Facility, //# P.O. Box 76, //# Epping, NSW, 2121, //# AUSTRALIA //# //# $Id: STAtmosphere.h 1346 2007-04-26 03:24:41Z mar637 $ //#--------------------------------------------------------------------------- // own includes #include "STAtmosphere.h" // casa includes #include #include // std includes #include using namespace casacore; using namespace asap; /** * Default Constructor (apart from optional parameters). * The class set up this way will assume International Standard Atmosphere (ISA) conditions, * except for humidity. The latter is assumed to be 50%, which seems more realistic for * Australian telescopes than 0%. * @param[in] wvScale water vapour scale height (m), default is 1540m to match MIRIAD's model * @param[in] maxAlt maximum altitude of the model atmosphere (m), plane parallel layers are spread linearly up to * this height, default is 10000m to match MIRIAD. * @param[in] nLayers number of plane parallel layers in the model (essentially for a numberical integration), * default is 50 to match MIRIAD. **/ STAtmosphere::STAtmosphere(double wvScale, double maxAlt, size_t nLayers) : itsHeights(nLayers), itsTemperatures(nLayers), itsDryPressures(nLayers), itsVapourPressures(nLayers), itsGndTemperature(288.), itsPressure(101325.), itsGndHumidity(0.5), itsLapseRate(0.0065), itsWVScale(wvScale), itsMaxAlt(maxAlt), itsObsHeight(200.) { recomputeAtmosphereModel(); } /** * Constructor with explicitly given parameters of the atmosphere * @param[in] temperature air temperature at the observatory (K) * @param[in] pressure air pressure at the sea level if the observatory elevation is set * (default is set to 200m) or at the observatory ground level if the elevation * is set to 0 (Pascals) * @param[in] humidity air humidity at the observatory (fraction) * @param[in] lapseRate temperature lapse rate (K/m), default is 0.0065 K/m to match MIRIAD and ISA * @param[in] wvScale water vapour scale height (m), default is 1540m to match MIRIAD's model * @param[in] maxAlt maximum altitude of the model atmosphere (m), plane parallel layers are spread linearly up to * this height, default is 10000m to match MIRIAD. * @param[in] nLayers number of plane parallel layers in the model (essentially for a numberical integration), * default is 50 to match MIRIAD. **/ STAtmosphere::STAtmosphere(double temperature, double pressure, double humidity, double lapseRate, double wvScale, double maxAlt, size_t nLayers) : itsHeights(nLayers), itsTemperatures(nLayers), itsDryPressures(nLayers), itsVapourPressures(nLayers), itsGndTemperature(temperature), itsPressure(pressure), itsGndHumidity(humidity), itsLapseRate(lapseRate), itsWVScale(wvScale), itsMaxAlt(maxAlt), itsObsHeight(200.) { recomputeAtmosphereModel(); } /** * Set the new weather station data, recompute the model * @param[in] temperature air temperature at the observatory (K) * @param[in] pressure air pressure at the sea level if the observatory elevation is set to non-zero value * (default is set to 200m) or at the observatory ground level if the elevation * is set to 0 (Pascals) * @param[in] humidity air humidity at the observatory (fraction) **/ void STAtmosphere::setWeather(double temperature, double pressure, double humidity) { itsGndTemperature = temperature; itsPressure = pressure; itsGndHumidity = humidity; recomputeAtmosphereModel(); } /** * Set the elevation of the observatory (height above mean sea level) * It affects only interpretation of the pressure supplied as part of the weather data, if this value * is non-zero, the pressure (e.g. in setWeather or constructor) is that at mean sea level. If the * observatory elevation is set to zero, regardless on real elevation, the pressure is that at the * observatory ground level. * * By default, 200m is assumed and the pressure should be a mean sea level pressure.. * @param[in] elev elevation in metres **/ void STAtmosphere::setObservatoryElevation(double elev) { itsObsHeight = elev; recomputeAtmosphereModel(); } /** * Build the atmosphere model based on exponential fall-off, ideal gas and hydrostatic * equilibrium. The model parameters are taken from the data members of this class. **/ void STAtmosphere::recomputeAtmosphereModel() { AlwaysAssert(itsGndTemperature > 0, AipsError); AlwaysAssert(itsPressure > 0., AipsError); AlwaysAssert((itsGndHumidity >= 0.) && (itsGndHumidity<=1.), AipsError); AlwaysAssert(itsMaxAlt > 0., AipsError); AlwaysAssert(itsWVScale > 0., AipsError); const double heightStep = itsMaxAlt/double(nLayers()); // molar mass of the air const double M = 28.96e-3; // free-fall acceleration const double g = 9.81; const double wvGndSaturationPressure = wvSaturationPressure(itsGndTemperature); const double gndPressure = itsPressure*exp(-M*g/(QC::R.get().getValue()*itsGndTemperature)* (itsObsHeight+0.5*itsLapseRate*itsObsHeight*itsObsHeight/itsGndTemperature)); for (size_t layer = 0; layer < nLayers(); ++layer) { const double height = double(layer)*heightStep; itsHeights[layer] = height; itsTemperatures[layer] = itsGndTemperature/(1.+itsLapseRate*height/itsGndTemperature); const double pressure = gndPressure * exp(-M*g/(QC::R.get().getValue()*itsGndTemperature)* (height+0.5*itsLapseRate*height*height/itsGndTemperature)); itsVapourPressures[layer] = casacore::min(itsGndHumidity*exp(-height/itsWVScale)*wvGndSaturationPressure, wvSaturationPressure(itsTemperatures[layer])); itsDryPressures[layer] = pressure - itsVapourPressures[layer]; //std::cout<<"layer="<