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 8652 : Pressure::Pressure() : 32 8652 : valueIS_(0.0) 33 : { 34 8652 : } 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 6323 : Pressure::Pressure(double pressure, Pressure::Units units) 61 : { 62 6323 : if(units == Pressure::UnitPascal) { 63 852 : valueIS_ = pressure; 64 5471 : } else if(units == Pressure::UnitHectoPascal) { 65 0 : valueIS_ = pressure * 100.0; 66 5471 : } else if(units == Pressure::UnitBar) { 67 0 : valueIS_ = 1.0E+5 * pressure; 68 5471 : } else if(units == Pressure::UnitMilliBar) { 69 5471 : 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 6323 : } 77 : 78 17019 : Pressure::~Pressure() 79 : { 80 17019 : } 81 : 82 2808 : double Pressure::get(std::string const &units) const 83 : { 84 2808 : if(units == "Pa" || units == "PA") { 85 2512 : return valueIS_; 86 296 : } else if(units == "hPa" || units == "HPA" || units == "hpa") { 87 0 : return 1.0E-2 * valueIS_; 88 296 : } else if(units == "bar" || units == "BAR") { 89 0 : return 1.0E-5 * valueIS_; 90 296 : } else if(units == "mb" || units == "MB") { 91 296 : 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 4793 : double Pressure::get(Pressure::Units units) const 103 : { 104 4793 : if(units == Pressure::UnitPascal) { 105 0 : return valueIS_; 106 4793 : } else if(units == Pressure::UnitHectoPascal) { 107 0 : return 1.0E-2 * valueIS_; 108 4793 : } else if(units == Pressure::UnitBar) { 109 0 : return 1.0E-5 * valueIS_; 110 4793 : } else if(units == Pressure::UnitMilliBar) { 111 4793 : 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