LCOV - code coverage report
Current view: top level - atmosphere/ATM - ATMProfile.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 7 14 50.0 %
Date: 2024-10-10 15:00:01 Functions: 7 15 46.7 %

          Line data    Source code
       1             : #ifndef _ATM_PROFILE_H
       2             : #define _ATM_PROFILE_H
       3             : /*******************************************************************************
       4             :  * ALMA - Atacama Large Millimiter Array
       5             :  * (c) Instituto de Estructura de la Materia, 2009
       6             :  *
       7             :  * This library is free software; you can redistribute it and/or
       8             :  * modify it under the terms of the GNU Lesser General Public
       9             :  * License as published by the Free Software Foundation; either
      10             :  * version 2.1 of the License, or (at your option) any later version.
      11             :  *
      12             :  * This library is distributed in the hope that it will be useful,
      13             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15             :  * Lesser General Public License for more details.
      16             :  *
      17             :  * You should have received a copy of the GNU Lesser General Public
      18             :  * License along with this library; if not, write to the Free Software
      19             :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
      20             :  *
      21             :  * "@(#) $Id: ATMProfile.h Exp $"
      22             :  *
      23             :  * who       when      what
      24             :  * --------  --------  ----------------------------------------------
      25             :  * pardo     24/03/09  created
      26             :  */
      27             : 
      28             : #ifndef __cplusplus
      29             : #error This is a C++ include file and cannot be used from plain C
      30             : #endif
      31             : 
      32             : #include "ATMCommon.h"
      33             : #include "ATMHumidity.h"
      34             : #include "ATMLength.h"
      35             : #include "ATMMassDensity.h"
      36             : #include "ATMNumberDensity.h"
      37             : #include "ATMPressure.h"
      38             : #include "ATMTemperature.h"
      39             : #include "ATMEnumerations.h"
      40             : 
      41             : #include <string>
      42             : #include <vector>
      43             : 
      44             : using std::string;
      45             : using std::vector;
      46             : 
      47             : 
      48             : ATM_NAMESPACE_BEGIN
      49             : 
      50             : /** \brief Class for an atmospheric profile object.
      51             :  *
      52             :  *         An  atmospheric profile is composed of 4 quantities as a function of altitude z:
      53             :  *         - the layer thickness
      54             :  *         - the pressure P
      55             :  *         - the temperature T and
      56             :  *         - the gas densities for H2O, O3, CO, N2O, NO2, SO2.<br>
      57             :  *
      58             :  *   This object is needed  for computing the absorption and
      59             :  *   phase coefficients, as well as for performing radiative transfer
      60             :  *   calculations (only layer thickness/T are needed).
      61             :  *
      62             :  *   This class builds an atmospheric profile that can be used to
      63             :  *   calculate absorption and phase coefficients, as well as to
      64             :  *   perform forward and/or retrieval radiative transfer calculations.
      65             :  *   It is composed of a set of parameters needed to build a layer thickness/P/T/gas densities
      66             :  *   densities profile from simple parameters currently available at observatories
      67             :  *   (from weather stations for example) using functions from
      68             :  *   the ATM library. The set of input parameters consists of the
      69             :  *   pressure P, the temperature T and the relative humidity at the ground, the altitude of
      70             :  *   the site, the tropospheric temperature lapse rate,... The profile is built as:
      71             :  *   thickness of the considered atmospheric layers above the site, and mean
      72             :  *   P,T,H2O,O3,CO,N2O, NO2, SO2 in
      73             :  *   them. The total number of atmospheric layers in the particular profile
      74             :  *   is also available (a negative value indicates an error).<br>
      75             :  *   The zenith column  of water vapor can be calculated
      76             :  *   by simply integrating the H2O profile. \f[ column\;\;H_{2}O\;\; (mm) =\sum_{layers} \Delta z \cdot [ H_{2}O ] \f]
      77             :  */
      78             : class AtmProfile
      79             : {
      80             : public:
      81             :   /** A constructor of an empty profile with n layers, that can be filled up later. */
      82             :   AtmProfile(unsigned int n);
      83             : 
      84             :   /** A long constructor of the atmospheric profile from the basic set of parameters described above.
      85             :       Please note that this constructor assumes that the &altitude of the antenna is the SAME of the
      86             :       weather station that provides: &groundPressure, &groundTemperature, and &relativeHumidity */
      87             :   AtmProfile(const Length &altitude,
      88             :              const Pressure &groundPressure,
      89             :              const Temperature &groundTemperature,
      90             :              double tropoLapseRate,
      91             :              const Humidity &relativeHumidity,
      92             :              const Length &wvScaleHeight,
      93             :              const Pressure &pressureStep,
      94             :              double pressureStepFactor,
      95             :              const Length &topAtmProfile,
      96             :              unsigned int atmType); //Atmospheretype atmType);
      97             : 
      98             : 
      99             :   /** A long constructor of the atmospheric profile from the basic set of parameters described above which,
     100             :       in addition, includes user-defined temperature profile  */
     101             :   AtmProfile(const Length &altitude,
     102             :              const Pressure &groundPressure,
     103             :              const Temperature &groundTemperature,
     104             :              double tropoLapseRate,
     105             :              const Humidity &relativeHumidity,
     106             :              const Length &wvScaleHeight,
     107             :              const Pressure &pressureStep,
     108             :              double pressureStepFactor,
     109             :              const Length &topAtmProfile,
     110             :              unsigned int atmType,
     111             :              const vector<Length> &v_layerBoundaries,
     112             :              const vector<Temperature> &v_layerTemperature);
     113             : 
     114             : 
     115             : 
     116             :   /** A long constructor of the atmospheric profile from the basic set of parameters described above. */
     117             :   /*
     118             :    AtmProfile(Length altitude, Pressure    groundPressure,
     119             :    Temperature groundTemperature, double  tropoLapseRate,
     120             :    Humidity relativeHumidity, Length wvScaleHeight,
     121             :    Pressure pressureStep, double pressureStepFactor,
     122             :    Length topAtmProfile, int typeAtm);
     123             : 
     124             :    */
     125             : 
     126             :   /** A short constructor of the atmospheric profile. With respect to the long constructor, this one considers
     127             :    the following (recomended) default values: pressureStep = 10 mb,
     128             :    pressureStepFactor = 1.2, topAtmProfile = 48.0 km */
     129             :   AtmProfile(const Length &altitude,
     130             :              const Pressure &groundPressure,
     131             :              const Temperature &groundTemperature,
     132             :              double tropoLapseRate,
     133             :              const Humidity &relativeHumidity,
     134             :              const Length &wvScaleHeight,
     135             :              unsigned int atmType); //Atmospheretype atmType);
     136             : 
     137             :   /*AtmProfile(const Length &altitude,
     138             :              const Pressure &groundPressure,
     139             :              const Temperature &groundTemperature,
     140             :              const Humidity &relativeHumidity,
     141             :              const vector<Length> &v_layerTop,
     142             :              const vector<Pressure> &v_layerTopPressure,
     143             :              const vector<Temperature> &v_layerTopTemperature,
     144             :              const vector<Humidity> &v_layerTopHumidity); */
     145             : 
     146             :   /** The user provides his own atmospheric profile (basic one: four vectors for layer thickness in m,
     147             :    average pressure in each layer in mb, average temperature in each layer in K, and average water
     148             :    vapor density in each layer in kg/m**3). QUESTION: SHOULD O3, CO, N2O, NO2, SO2 PROFILES BE FILLED UP
     149             :    INTERNALLY FROM A STANDARD ATMOSPHERE OR LEFT ITS ABUNDANCES EQUAL TO ZERO ? */
     150             :   AtmProfile(const Length &altitude,
     151             :              const vector<Length> &v_layerThickness,
     152             :              const vector<Pressure> &v_layerPressure,
     153             :              const vector<Temperature> &v_layerTemperature,
     154             :              const vector<MassDensity> &v_layerWaterVapor);
     155             :   AtmProfile(const vector<Length> &v_layerBoundaries,
     156             :              const vector<Pressure> &v_layerPressure,
     157             :              const vector<Temperature> &v_layerTemperature,
     158             :              const vector<MassDensity> &v_layerWaterVapor);
     159             : 
     160             :   AtmProfile(const Length &altitude,
     161             :              const vector<Length> &v_layerThickness,
     162             :              const vector<Pressure> &v_layerPressure,
     163             :              const vector<Temperature> &v_layerTemperature,
     164             :              const vector<NumberDensity> &v_layerWaterVapor);
     165             :   AtmProfile(const vector<Length> &v_layerBoundaries,
     166             :              const vector<Pressure> &v_layerPressure,
     167             :              const vector<Temperature> &v_layerTemperature,
     168             :              const vector<NumberDensity> &v_layerWaterVapor);
     169             : 
     170             :   /** The user provides his own atmospheric profile (in this case five vectors for layer thickness in m,
     171             :    average pressure in each layer in mb, average temperature in each layer in K, average water vapor
     172             :    density in each layer in kg/m**3, and average ozone number density in each layer in molecules/m**3)
     173             :    QUESTION: SHOULD CO and N2O, NO2, SO2 PROFILES BE FILLED UP
     174             :    INTERNALLY FROM A STANDARD ATMOSPHERE OR LEFT ITS ABUNDANCES EQUAL TO ZERO ? */
     175             : 
     176             :   AtmProfile(const Length &altitude,
     177             :              const vector<Length> &v_layerThickness,
     178             :              const vector<Pressure> &v_layerPressure,
     179             :              const vector<Temperature> &v_layerTemperature,
     180             :              const vector<MassDensity> &v_layerWaterVapor,
     181             :              const vector<NumberDensity> &v_layerO3);
     182             :   AtmProfile(const Length &altitude,
     183             :              const vector<Length> &v_layerThickness,
     184             :              const vector<Pressure> &v_layerPressure,
     185             :              const vector<Temperature> &v_layerTemperature,
     186             :              const vector<NumberDensity> &v_layerWaterVapor,
     187             :              const vector<NumberDensity> &v_layerO3);
     188             : 
     189             :   /** The user provides his own atmospheric profile (in this case seven vectors for layer thickness in m,
     190             :    average pressure in each layer in mb, average temperature in each layer in K, average water vapor
     191             :    density in each layer in kg/m**3, average ozone number density in each layer in molecules/m**3,
     192             :    average CO number density in each layer in molecules/m**3, average N2O, NO2, SO2 number density in each
     193             :    layer in molecules/m**3) */
     194             :   AtmProfile(const Length &altitude,
     195             :              const vector<Length> &v_layerThickness,
     196             :              const vector<Pressure> &v_layerPressure,
     197             :              const vector<Temperature> &v_layerTemperature,
     198             :              const vector<MassDensity> &v_layerWaterVapor,
     199             :              const vector<NumberDensity> &v_layerO3,
     200             :              const vector<NumberDensity> &v_layerCO,
     201             :              const vector<NumberDensity> &v_layerN2O,
     202             :              const vector<NumberDensity> &v_layerNO2,
     203             :              const vector<NumberDensity> &v_layerSO2);
     204             : 
     205             :   AtmProfile(const Length &altitude,
     206             :              const vector<Length> &v_layerThickness,
     207             :              const vector<Pressure> &v_layerPressure,
     208             :              const vector<Temperature> &v_layerTemperature,
     209             :              const vector<NumberDensity> &v_layerWaterVapor,
     210             :              const vector<NumberDensity> &v_layerO3,
     211             :              const vector<NumberDensity> &v_layerCO,
     212             :              const vector<NumberDensity> &v_layerN2O,
     213             :              const vector<NumberDensity> &v_layerNO2,
     214             :              const vector<NumberDensity> &v_layerSO2);
     215             : 
     216             :   AtmProfile(const AtmProfile &a); // copy constructor
     217             : 
     218          13 :   virtual ~AtmProfile() {}
     219             : 
     220             :   /** Setter to update the AtmProfile if some basic atmospheric parameter has changed.
     221             :    * @pre   an atmospheric profile already exists
     222             :    * @param altitude          the new altitude, a Length
     223             :    * @param groundPressure    the Pressure at the ground level
     224             :    * @param groundTemperature the Temperature at the ground level
     225             :    * @param tropoLapseRate    the tropospheric lapse rate
     226             :    * @param relativeHumidity  the relative Humidity
     227             :    * @param wvScaleHeight     the scale height of the water vapor, a Length
     228             :    * @return true if the atmospheric profile has been update, else false because the basic parameters have not changed
     229             :    * @post   the atmospheric profile has been updated, only if at least one of the basic parameters has changed
     230             :    *
     231             :    * \note  there is an overriding on this method in the sub-class AbsorptionPhaseProfile which in turn
     232             :    *        has an  overriding in its WaterVaporRetrieval sub-class. Hence this method must not be overloaded
     233             :    *        in this AtmProfile class.
     234             :    */
     235             :   bool setBasicAtmosphericParameters(const Length &altitude,
     236             :                                      const Pressure &groundPressure,
     237             :                                      const Temperature &groundTemperature,
     238             :                                      double tropoLapseRate,
     239             :                                      const Humidity &relativeHumidity,
     240             :                                      const Length &wvScaleHeight);
     241             : 
     242             :   /** Accessor to the type of current atmosphere **/
     243             :   string getAtmosphereType() const;
     244             : 
     245             :   /** Accessor to the type of atmosphere specified by the number**/
     246             :   static string getAtmosphereType(unsigned int typeAtm);
     247             : 
     248             :   /** Accessor to the current Ground Temperature used in the object */
     249         124 :   Temperature getGroundTemperature() const { return groundTemperature_; }
     250             : 
     251             :   /** Accessor to the current Tropospheric Lapse Rate used in the object (temperature/length units) */
     252           0 :   double getTropoLapseRate() const { return tropoLapseRate_; }
     253             : 
     254             :   /** Accessor to the current Ground Pressure used in the object (pressure units) */
     255         120 :   Pressure getGroundPressure() const { return groundPressure_; }
     256             : 
     257             :   /** Accessor to the current Tropopause Temperature used in the object */
     258           0 :   Temperature getTropopauseTemperature() const { return tropoTemperature_; }
     259             : 
     260             :   /** Accessor to the current Ground Relative Humidity in the object (humidity units) */
     261           0 :   Humidity getRelativeHumidity() const { return relativeHumidity_; }
     262             : 
     263             :   /** Accessor to the current Water Vapor Scale Height in the object (length units) */
     264           0 :   Length getWvScaleHeight() const { return wvScaleHeight_; }
     265             : 
     266             :   /** Accessor to the current Primary Pressure Step in the object. The Primary Pressure Step
     267             :    (pressure units) is used to define the thickness of the first layer in the profile.
     268             :    Pressure difference between the boundaries of first layer will be equal to the
     269             :    Primary Pressure Step. */
     270             :   Pressure getPressureStep() const { return pressureStep_; }
     271             : 
     272             :   /** Accessor to the current Pressure_Step_Factor in the object. The Pressure_Step_Factor
     273             :    (no units) is the Pressure step change between consecutive layers when moving upwards.
     274             :    Pressure difference between the boundaries of the (n+1)-th layer (DP_n+1) will
     275             :    be DP_n**DP1. */
     276             :   Pressure getPressureStepFactor() const { return pressureStepFactor_; }
     277             : 
     278             :   /** Accessor to the ground altitude of site (length units) */
     279           0 :   Length getAltitude() const { return altitude_; }
     280             : 
     281             :   /** Alternative accessor to the ground altitude of site (length units) */
     282             :   Length getGroundAltitude() const { return altitude_; }
     283             : 
     284             :    /** setter for the ground altitude of site (length units). Careful! It will remove or add layers if necessary.
     285             :        Ground values of T/P/h would change as well */
     286             :   void setAltitude(const Length &groundaltitude);
     287             : 
     288             :   /** Alternative setter for the ground altitude of site (length units). Careful! It will remove or add layers if necessary.
     289             :        Ground values of T/P/h would change as well */
     290             :   // void setGroundAltitude(const Length &groundaltitude);
     291             : 
     292             :   /** Accessor to the altitude of the tropopause (length units) */
     293           0 :   Length getTropopauseAltitude() const { return tropoAltitude_; }
     294             : 
     295             :   /** Accessor to the Maximum allowed altitude for the Atmospheric Profile above the site (length units) */
     296             :   Length getTopAtmProfile() const { return topAtmProfile_; }
     297             : 
     298             :   /** Accessor to the number of layers of the atmospheric profile */
     299        3281 :   unsigned int getNumLayer() const { return numLayer_; }
     300             : 
     301             :   /** Method to access the Temperature Profile  */
     302             :   vector<Temperature> getTemperatureProfile() const;
     303             : 
     304             :   /**
     305             :    * Method to access the average Temperature in layer i (thickness of layers in ThicknessProfile)
     306             :    * @exception AtmException if the layer is not valid.
     307             :    **/
     308             :   Temperature getLayerTemperature(unsigned int i) const;
     309             : 
     310             :   /**
     311             :    * Method to access the Temperature at bottom of layer i (thickness of layers in ThicknessProfile)
     312             :    * @exception AtmException if the layer is not valid.
     313             :    **/
     314             :   Temperature getLayerBottomTemperature(unsigned int i) const;
     315             : 
     316             :   /**
     317             :    * Method to access the Temperature at top of layer i (thickness of layers in ThicknessProfile)
     318             :    * @exception AtmException if the layer is not valid.
     319             :    **/
     320             :   Temperature getLayerTopTemperature(unsigned int i) const;
     321             : 
     322             :   /** Setter for the average Temperature in layer i (allows to touch one layer each time once a profile has been defined) */
     323             :   void setLayerTemperature(unsigned int i, const Temperature &layerTemperature);
     324             : 
     325             :   /** Method to retrieve the layer thickness from site altitude upwards.
     326             :    *  Use Altitude to + ThicknessProfile to know the vertical grid. */
     327             :   vector<Length> getThicknessProfile() const;
     328             : 
     329             :   /**
     330             :    * Method to access the layer thickness of layer i
     331             :    * @exception AtmException if the layer is not valid.
     332             :    */
     333             :   Length getLayerThickness(unsigned int i) const;
     334             : 
     335             :   /** Setter for the thickness of layer i (allows to touch one layer each time once a profile has been defined). We do
     336             :    *  not advise to use this one unless you change P and T accordingly */
     337             :   void setLayerThickness(unsigned int i, const Length &layerThickness);
     338             :   //void setLayerThickness(const Length &layerThickness, unsigned int i) { setLayerThickness(i, layerThickness); }
     339             : 
     340             :   /**
     341             :    * Method to access the Bottom Height of layer i above the Ground
     342             :    * @exception AtmException if the layer is not valid.
     343             :    */
     344             :   Length getLayerBottomHeightAboveGround(unsigned int i) const;
     345             : 
     346             :   /**
     347             :    * Method to access the Bottom Height of layer i above the Sea Level
     348             :    * @exception AtmException if the layer is not valid.
     349             :    */
     350             :   Length getLayerBottomHeightAboveSeaLevel(unsigned int i) const;
     351             : 
     352             : 
     353             :   /**
     354             :    * Method to access the Top Height of layer i above the Ground
     355             :    * @exception AtmException if the layer is not valid.
     356             :    */
     357             :   Length getLayerTopHeightAboveGround(unsigned int i) const;
     358             : 
     359             :   /**
     360             :    * Method to access the Top Height of layer i above the Sea Level
     361             :    * @exception AtmException if the layer is not valid.
     362             :    */
     363             :   Length getLayerTopHeightAboveSeaLevel(unsigned int i) const;
     364             : 
     365             : 
     366             :   /** Function to retrieve Average Water vapor density in a given layer in kg/m**3
     367             :    *  (thickness of layers in ThicknessProfile)
     368             :    * @exception AtmException if the layer is not valid.
     369             :    */
     370             :   MassDensity getLayerWaterVaporMassDensity(unsigned int i) const;
     371             :   MassDensity getLayerBottomWaterVaporMassDensity(unsigned int i) const;
     372             :   MassDensity getLayerTopWaterVaporMassDensity(unsigned int i) const;
     373             :   NumberDensity getLayerWaterVaporNumberDensity(unsigned int i) const;
     374             :   NumberDensity getLayerBottomWaterVaporNumberDensity(unsigned int i) const;
     375             :   NumberDensity getLayerTopWaterVaporNumberDensity(unsigned int i) const;
     376             : 
     377             :   /** Setter for the average Water vapor density in layer i in kg/m**3 (allows to touch one layer each
     378             :    *  time once a profile has been defined) */
     379             :   void setLayerWaterVaporMassDensity(unsigned int i, const MassDensity &layerWaterVapor);
     380             :   //void setLayerWaterVaporMassDensity(const MassDensity &layerWaterVapor, unsigned int i) { setLayerWaterVaporMassDensity(i, layerWaterVapor); }
     381             :   void setLayerWaterVaporNumberDensity(unsigned int i, const NumberDensity &layerWaterVapor);
     382             :   //void setLayerWaterVapor(const NumberDensity &layerWaterVapor, unsigned int i) { setLayerWaterVapor(i, layerWaterVapor); }
     383             : 
     384             :   /** Method to get the Pressure Profile */
     385             :   vector<Pressure> getPressureProfile() const;
     386             : 
     387             :   /** Method to access the average Pressure in layer i
     388             :    * @exception AtmException if the layer is not valid.
     389             :    */
     390             :   Pressure getLayerPressure(unsigned int i) const;
     391             : 
     392             :   /** Method to access the Pressure at bottom of layer i
     393             :    * @exception AtmException if the layer is not valid.
     394             :    */
     395             :   Pressure getLayerBottomPressure(unsigned int i) const;
     396             : 
     397             :   /** Method to access the Pressure at top of layer i
     398             :    * @exception AtmException if the layer is not valid.
     399             :    */
     400             :   Pressure getLayerTopPressure(unsigned int i) const;
     401             : 
     402             :   /** Setter for the average Pressure in layer i (allows to touch one layer each
     403             :    *  time once a profile has been defined) */
     404             :   void setLayerPressure(unsigned int i, const Pressure &layerPressure) { v_layerPressure_[i] = layerPressure.get(Pressure::UnitMilliBar); }
     405             :   //void setLayerPressure(const Pressure &layerPressure, unsigned int i) { setLayerPressure(i, layerPressure); }
     406             : 
     407             :   /** Function to retrieve CO density in a given layer (thickness of layers
     408             :    *  in ThicknessProfile)  */
     409          90 :   NumberDensity getLayerCO(unsigned int i) const { return NumberDensity(v_layerCO_[i], NumberDensity::UnitInverseCubicMeter); }
     410             :   /** Setter for the average number density of CO in layer i in molecules/m**3 (allows to touch one layer each
     411             :    *  time once a profile has been defined) */
     412             :   void setLayerCO(unsigned int i, const NumberDensity &layerCO) { v_layerCO_[i] = layerCO.get(NumberDensity::UnitInverseCubicMeter); }
     413             :   //void setLayerCO(const NumberDensity &layerCO, unsigned int i) { setLayerCO(i, layerCO); }
     414             : 
     415             :   /** Function to retrieve O3 density in a given layer (thickness of layers
     416             :    *  in ThicknessProfile) */
     417          90 :   NumberDensity getLayerO3(unsigned int i) const { return NumberDensity(v_layerO3_[i], NumberDensity::UnitInverseCubicMeter); }
     418             :   /** Setter for the average number density of O3 in layer i in molecules/m**3 (allows to touch one layer each
     419             :    *  time once a profile has been defined) */
     420             :   void setLayerO3(unsigned int i, const NumberDensity &layerO3) { v_layerO3_[i] = layerO3.get(NumberDensity::UnitInverseCubicMeter); }
     421             :   //void setLayerO3(const NumberDensity &layerO3, unsigned int i) { setLayerO3(i, layerO3); }
     422             : 
     423             :   /** Function to retrieve N2O density in a given layer (thickness of layers
     424             :    *  in ThicknessProfile)   */
     425          90 :   NumberDensity getLayerN2O(unsigned int i) const { return NumberDensity(v_layerN2O_[i], NumberDensity::UnitInverseCubicMeter); }
     426             :   /** Setter for the average number density of N2O in layer i in molecules/m**3 (allows to touch one layer each
     427             :    *  time once a profile has been defined) */
     428             :   void setLayerN2O(unsigned int i, const NumberDensity &layerN2O) { v_layerN2O_[i] = layerN2O.get(NumberDensity::UnitInverseCubicMeter); }
     429             :   //void setLayerN2O(const NumberDensity &layerN2O, unsigned int i) { setLayerN2O(i, layerN2O); }
     430             : 
     431             :   /** Function to retrieve NO2 density in a given layer (thickness of layers
     432             :    *  in ThicknessProfile)   */
     433             :   NumberDensity getLayerNO2(unsigned int i) const { return NumberDensity(v_layerNO2_[i], NumberDensity::UnitInverseCubicMeter); }
     434             :   /** Setter for the average number density of NO2 in layer i in molecules/m**3 (allows to touch one layer each
     435             :    *  time once a profile has been defined) */
     436             :   void setLayerNO2(unsigned int i, const NumberDensity &layerNO2) { v_layerNO2_[i] = layerNO2.get(NumberDensity::UnitInverseCubicMeter); }
     437             :   //void setLayerNO2(const NumberDensity &layerNO2, unsigned int i) { setLayerNO2(i, layerNO2); }
     438             : 
     439             :   /** Function to retrieve SO2 density in a given layer (thickness of layers
     440             :    *  in ThicknessProfile)   */
     441             :   NumberDensity getLayerSO2(unsigned int i) const { return NumberDensity(v_layerSO2_[i], NumberDensity::UnitInverseCubicMeter); }
     442             :   /** Setter for the average number density of SO2 in layer i in molecules/m**3 (allows to touch one layer each
     443             :    *  time once a profile has been defined) */
     444             :   void setLayerSO2(unsigned int i, const NumberDensity &layerSO2) { v_layerSO2_[i] = layerSO2.get(NumberDensity::UnitInverseCubicMeter); }
     445             :   //void setLayerSO2(const NumberDensity &layerSO2, unsigned int i) { setLayerSO2(i, layerSO2); }
     446             : 
     447             :   void setBasicAtmosphericParameterThresholds(const Length &altitudeThreshold,
     448             :                                              const Pressure &groundPressureThreshold,
     449             :                                              const Temperature &groundTemperatureThreshold,
     450             :                                              double tropoLapseRateThreshold,
     451             :                                              const Humidity &relativeHumidityThreshold,
     452             :                                              const Length &wvScaleHeightThreshold);
     453             : 
     454             : 
     455             :   /** Method to get the zenith column  of water vapor. It is computed by
     456             :    *  simply integrating the H2O profile:
     457             :    *  \f$ column\;\;H_{2}O\;\; (mm) =\sum_{layers} \Delta z \cdot [ H_{2}O ] \f$
     458             :    */
     459             :   Length getGroundWH2O() const;
     460             : 
     461             :   // Thresholds
     462             :   Length      getAltitudeThreshold()   const {return altitudeThreshold_;};
     463             :   Pressure    getGroundPressureThreshold() const {return groundPressureThreshold_;};
     464             :   Temperature getGroundTemperatureThreshold() const {return groundTemperatureThreshold_;};
     465             :   double      getTropoLapseRateThreshold() const {return tropoLapseRateThreshold_;};
     466             :   Humidity    getRelativeHumidityThreshold() const {return relativeHumidityThreshold_;};
     467             :   Length      getWvScaleHeightThreshold() const {return wvScaleHeightThreshold_;};
     468             : 
     469             :   void        setAltitudeThreshold(const Length &altitudeThreshold) {altitudeThreshold_=altitudeThreshold;};
     470             :   void        setGroundPressureThreshold(const Pressure &groundPressureThreshold) {groundPressureThreshold_=groundPressureThreshold;};
     471             :   void        setGroundTemperatureThreshold(const Temperature &groundTemperatureThreshold) {groundTemperatureThreshold_=groundTemperatureThreshold;};
     472             : 
     473             : 
     474             :   //@}
     475             : 
     476             : protected:
     477             :   unsigned int typeAtm_; //!< 1: tropical, 2: midlatSummer, 3: midlatWinter, 4: subarcticSummer, 5: subarcticWinter
     478             :   Temperature groundTemperature_; //!< Ambient temperature at the site (K)
     479             :   double tropoLapseRate_; //!< tropospheric lapse rate in K/km
     480             :   Temperature tropoTemperature_; //!< Temperature at the tropopause
     481             :   unsigned int tropoLayer_; //!< Layer where tropopause starts
     482             :   Length tropoAltitude_; //!< Altitude where tropopause starts
     483             :   Pressure groundPressure_; //!< Ground pressure at the site
     484             :   Humidity relativeHumidity_; /** Relative humidity at the site (%)
     485             :    used only to make an estimate
     486             :    of the water vapor column, first guess) */
     487             :   Length wvScaleHeight_; //!< scale height of water vapor distribution (km)
     488             :   Pressure pressureStep_; //!< Pressure basic step (mb)
     489             :   double pressureStepFactor_; /** Multiplicative factor for presure steps.
     490             :    Example of pressure parameters:
     491             :    P_ground=550; DP: 10; DP1:
     492             :    1.2 ==> The pressure levels will
     493             :    then be 550, 560, 572, 586.4, .... */
     494             : 
     495             :   Length altitude_; //!< Altitude of the site (km)
     496             :   Length topAtmProfile_; //!< Top of atmospheric profile (km)
     497             :   unsigned int numLayer_; //!< Total number of layers in the output  atmospheric profiles
     498             :   double fractionLast_;  //!< Fraction of last layer needed for some calculations
     499             :   bool newBasicParam_;
     500             :   vector<double> v_layerThickness_; //!< Thickness of layer (m)
     501             :   vector<double> v_layerTemperature_; //!< Temp. of layers (K)
     502             :   vector<double> v_layerTemperature0_; //!< Temp. at bottom of layers (K)
     503             :   vector<double> v_layerTemperature1_; //!< Temp. at top of layer (K)
     504             :   vector<double> v_layerWaterVapor_; //!< Average water vapor kg/m**3 in the layer
     505             :   vector<double> v_layerWaterVapor0_; //!< Water vapor kg/m**3 at bottom of layer
     506             :   vector<double> v_layerWaterVapor1_; //!< Water vapor kg/m**3 at top of layer
     507             :   vector<double> v_layerPressure_; //!< Pressure of layers (mb)
     508             :   vector<double> v_layerPressure0_; //!< Pressure at bottom of layers (mb)
     509             :   vector<double> v_layerPressure1_; //!< Pressure at top of layers (mb)
     510             :   vector<double> v_layerCO_; //!< CO in molecules per m**3
     511             :   vector<double> v_layerO3_; //!< O3 in molecules per m**3
     512             :   vector<double> v_layerN2O_; //!< N2O in molecules per m**3
     513             :   vector<double> v_layerNO2_; //!< NO2 in molecules per m**3
     514             :   vector<double> v_layerSO2_; //!< SO2 in molecules per m**3
     515             :   Length altitudeThreshold_;
     516             :   Pressure groundPressureThreshold_;
     517             :   Temperature groundTemperatureThreshold_;
     518             :   double tropoLapseRateThreshold_;
     519             :   Humidity relativeHumidityThreshold_;
     520             :   Length wvScaleHeightThreshold_;
     521             : 
     522             :   unsigned int ier_;
     523             : 
     524             :   /** Default constructor (required if copy constructor in derived classes) */
     525           0 :   AtmProfile() {}
     526             : 
     527             :   /*
     528             :    * \fn Method to build the profile,
     529             :    */
     530             :   unsigned int mkAtmProfile(); /** returns error code: <0 unsuccessful           */
     531             : 
     532             :   /** Method to update an atmospheric profile based on one or more new basic parameter(s)
     533             :    * @param altitude          the new altitude, a Length
     534             :    * @param groundPressure    the Pressure at the ground level
     535             :    * @param groundTemperature the Temperature at the ground level
     536             :    * @param tropoLapseRate    the tropospheric lapse rate
     537             :    * @param relativeHumidity  the relative Humidity
     538             :    * @param wvScaleHeight     the scale height of the water vapor, a Length
     539             :    * @return true if the atmospheric profile has been update, else false because the basic parameters have not changed
     540             :    * @post   the atmospheric profile has been updated only if at least one of the basic parameters has changed
     541             :    */
     542             :   bool updateAtmProfile(const Length &altitude,
     543             :                         const Pressure &groundPressure,
     544             :                         const Temperature &groundTemperature,
     545             :                         double tropoLapseRate,
     546             :                         const Humidity &relativeHumidity,
     547             :                         const Length &wvScaleHeight);
     548             :   void initBasicAtmosphericParameterThresholds();
     549             : 
     550             : private:
     551             :   MassDensity rwat(const Temperature &t, const Humidity &rh, const Pressure &p) const;
     552             :   Humidity rwat_inv(const Temperature &tt, const MassDensity &dd, const Pressure &pp) const;
     553             :   vector<NumberDensity> st76(const Length &ha, unsigned int tip) const;
     554             :   double poli2(double ha,
     555             :                double x1,
     556             :                double x2,
     557             :                double x3,
     558             :                double y1,
     559             :                double y2,
     560             :                double y3) const;
     561             :   /*
     562             :    // static Pressure pressureStep_default(  10.0,Pressure::UnitMilliBar);
     563             :    //  static double pSd; // = 10.0;  // pressureStep_default in mb
     564             :    static Pressure pressureStep_default_;
     565             : 
     566             : 
     567             :    static double pressureStepFactor_default_; // =    1.2;
     568             :    //static double pSFd; // = 1.2;
     569             : 
     570             : 
     571             : 
     572             :    static Length  topAtmProfile_default_; //(  48.0,Length::UnitKiloMeter);
     573             :    //static tAPd; // = 48.0;
     574             :    */
     575             : 
     576             :   /** Default value of Atmospheric type (to reproduce behavior above the tropopause) */
     577             :   //static Atmospheretype atmType_default =  tropical;
     578             : 
     579             : }; // class AtmProfile
     580             : 
     581             : ATM_NAMESPACE_END
     582             : /*
     583             :   Pressure AtmProfile::pressureStep_default_(Pressure(1.2,Pressure::UnitMilliBar));
     584             :   double AtmProfile::pressureStepFactor_default_(1.2);
     585             :   Length AtmProfile::topAtmProfile_default_(Length(48,Length::UnitKiloMeter));
     586             : */
     587             : 
     588             : /** \page AtmProfile_example Example with the AtmProfile class.
     589             :  *  Our main function always starts like this:
     590             :  *  \skip #include "AtmTypeName.h"
     591             :  *  \until {
     592             :  *
     593             :  *  First we set a constant that will be used in the calculations:
     594             :  *  \skip double
     595             :  *  \until 0.04799274551
     596             :  *  Then we set the parameters necessary to create an atmospheric profile (if you do not want to enter the whole profile yourself):
     597             :  *  \skip  Atmospheretype
     598             :  *  \until 1.2
     599             :  *  The above input information is printed on the screen
     600             :  *  \skip cout
     601             :  *  \until K/km
     602             :  *  With all this information an AtmProfile object can now be created:
     603             :  *  \skipline AtmProfile
     604             :  *  The AtmProfile object "myProflie" is accessed and partially shown on the screen
     605             :  *  \skip cout
     606             :  *  \until scale height */
     607             : 
     608             : 
     609             : #endif /*!_ATM_PROFILE_H*/

Generated by: LCOV version 1.16