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 6773 : Pressure::Pressure() : 32 6773 : valueIS_(0.0) 33 : { 34 6773 : } 35 0 : Pressure::Pressure(double pressure) : 36 0 : valueIS_(pressure) 37 : { 38 0 : } 39 : 40 0 : Pressure::Pressure(double pressure, const std::string &units) 41 : { 42 0 : if(units == "Pa" || units == "PA") { 43 0 : valueIS_ = pressure; 44 0 : } else if(units == "hPa" || units == "HPA") { 45 0 : valueIS_ = pressure * 100.0; 46 0 : } else if(units == "bar" || units == "BAR") { 47 0 : valueIS_ = 1.0E+5 * pressure; 48 0 : } else if(units == "mb" || units == "MB") { 49 0 : 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 0 : } 59 : 60 3704 : Pressure::Pressure(double pressure, Pressure::Units units) 61 : { 62 3704 : if(units == Pressure::UnitPascal) { 63 845 : valueIS_ = pressure; 64 2859 : } else if(units == Pressure::UnitHectoPascal) { 65 0 : valueIS_ = pressure * 100.0; 66 2859 : } else if(units == Pressure::UnitBar) { 67 0 : valueIS_ = 1.0E+5 * pressure; 68 2859 : } else if(units == Pressure::UnitMilliBar) { 69 2859 : 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 3704 : } 77 : 78 12253 : Pressure::~Pressure() 79 : { 80 12253 : } 81 : 82 200 : double Pressure::get(std::string const &units) const 83 : { 84 200 : if(units == "Pa" || units == "PA") { 85 0 : return valueIS_; 86 200 : } else if(units == "hPa" || units == "HPA" || units == "hpa") { 87 0 : return 1.0E-2 * valueIS_; 88 200 : } else if(units == "bar" || units == "BAR") { 89 0 : return 1.0E-5 * valueIS_; 90 200 : } else if(units == "mb" || units == "MB") { 91 200 : 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 4405 : double Pressure::get(Pressure::Units units) const 103 : { 104 4405 : if(units == Pressure::UnitPascal) { 105 0 : return valueIS_; 106 4405 : } else if(units == Pressure::UnitHectoPascal) { 107 0 : return 1.0E-2 * valueIS_; 108 4405 : } else if(units == Pressure::UnitBar) { 109 0 : return 1.0E-5 * valueIS_; 110 4405 : } else if(units == Pressure::UnitMilliBar) { 111 4405 : 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