LCOV - code coverage report
Current view: top level - atmosphere/ATM - ATMPressure.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 34 62 54.8 %
Date: 2024-10-29 13:38:20 Functions: 6 8 75.0 %

          Line data    Source code
       1             : /*******************************************************************************
       2             :  * ALMA - Atacama Large Millimiter Array
       3             :  * (c) Instituto de Estructura de la Materia, 2009
       4             :  *
       5             :  * This library is free software; you can redistribute it and/or
       6             :  * modify it under the terms of the GNU Lesser General Public
       7             :  * License as published by the Free Software Foundation; either
       8             :  * version 2.1 of the License, or (at your option) any later version.
       9             :  *
      10             :  * This library is distributed in the hope that it will be useful,
      11             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13             :  * Lesser General Public License for more details.
      14             :  *
      15             :  * You should have received a copy of the GNU Lesser General Public
      16             :  * License along with this library; if not, write to the Free Software
      17             :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
      18             :  *
      19             :  * "@(#) $Id: ATMPressure.cpp Exp $"
      20             :  *
      21             :  * who       when      what
      22             :  * --------  --------  ----------------------------------------------
      23             :  * pardo     24/03/09  created
      24             :  */
      25             : #include "ATMPressure.h"
      26             : 
      27             : 
      28             : 
      29             : ATM_NAMESPACE_BEGIN
      30             : 
      31          29 : Pressure::Pressure() :
      32          29 :   valueIS_(0.0)
      33             : {
      34          29 : }
      35           0 : Pressure::Pressure(double pressure) :
      36           0 :   valueIS_(pressure)
      37             : {
      38           0 : }
      39             : 
      40         130 : Pressure::Pressure(double pressure, const std::string &units)
      41             : {
      42         130 :   if(units == "Pa" || units == "PA") {
      43         121 :     valueIS_ = pressure;
      44           9 :   } else if(units == "hPa" || units == "HPA") {
      45           0 :     valueIS_ = pressure * 100.0;
      46           9 :   } else if(units == "bar" || units == "BAR") {
      47           0 :     valueIS_ = 1.0E+5 * pressure;
      48           9 :   } else if(units == "mb" || units == "MB") {
      49           9 :     valueIS_ = 1.0E+2 * pressure;
      50           0 :   } else if(units == "mbar" || units == "MBAR") {
      51           0 :     valueIS_ = 1.0E+2 * pressure;
      52           0 :   } else if(units == "atm" || units == "ATM") {
      53           0 :     valueIS_ = pressure * 101325.;
      54             :   } else {
      55           0 :     valueIS_ = pressure;
      56             :   }
      57             : 
      58         130 : }
      59             : 
      60        2610 : Pressure::Pressure(double pressure, Pressure::Units units)
      61             : {
      62        2610 :   if(units == Pressure::UnitPascal) {
      63           5 :     valueIS_ = pressure;
      64        2605 :   } else if(units == Pressure::UnitHectoPascal) {
      65           0 :     valueIS_ = pressure * 100.0;
      66        2605 :   } else if(units == Pressure::UnitBar) {
      67           0 :     valueIS_ = 1.0E+5 * pressure;
      68        2605 :   } else if(units == Pressure::UnitMilliBar) {
      69        2605 :     valueIS_ = 1.0E+2 * pressure;
      70           0 :   } else if(units == Pressure::UnitAtmosphere) {
      71           0 :     valueIS_ = pressure * 101325.;
      72             :   } else {
      73           0 :     valueIS_ = pressure;
      74             :   }
      75             : 
      76        2610 : }
      77             : 
      78        2899 : Pressure::~Pressure()
      79             : {
      80        2899 : }
      81             : 
      82        2608 : double Pressure::get(std::string const &units) const
      83             : {
      84        2608 :   if(units == "Pa" || units == "PA") {
      85        2512 :     return valueIS_;
      86          96 :   } else if(units == "hPa" || units == "HPA" || units == "hpa") {
      87           0 :     return 1.0E-2 * valueIS_;
      88          96 :   } else if(units == "bar" || units == "BAR") {
      89           0 :     return 1.0E-5 * valueIS_;
      90          96 :   } else if(units == "mb" || units == "MB") {
      91          96 :     return 1.0E-2 * valueIS_;
      92           0 :   } else if(units == "mbar" || units == "MBAR") {
      93           0 :     return 1.0E-2 * valueIS_;
      94           0 :   } else if(units == "atm" || units == "ATM") {
      95           0 :     return valueIS_ / 101325.;
      96             :   } else {
      97           0 :     return valueIS_;
      98             :   }
      99             : 
     100             : }
     101             : 
     102         375 : double Pressure::get(Pressure::Units units) const
     103             : {
     104         375 :   if(units == Pressure::UnitPascal) {
     105           0 :     return valueIS_;
     106         375 :   } else if(units == Pressure::UnitHectoPascal) {
     107           0 :     return 1.0E-2 * valueIS_;
     108         375 :   } else if(units == Pressure::UnitBar) {
     109           0 :     return 1.0E-5 * valueIS_;
     110         375 :   } else if(units == Pressure::UnitMilliBar) {
     111         375 :     return 1.0E-2 * valueIS_;
     112           0 :   } else if(units == Pressure::UnitAtmosphere) {
     113           0 :     return valueIS_ / 101325.;
     114             :   } else {
     115           0 :     return valueIS_;
     116             :   }
     117             : 
     118             : }
     119             : 
     120             : ATM_NAMESPACE_END

Generated by: LCOV version 1.16