LCOV - code coverage report
Current view: top level - atmosphere/ATM - ATMTemperature.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 3 6 50.0 %
Date: 2024-12-11 20:54:31 Functions: 3 7 42.9 %

          Line data    Source code
       1             : #ifndef _ATM_TEMPERATURE_H
       2             : #define _ATM_TEMPERATURE_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: ATMTemperature.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 <string>
      34             : 
      35             : using std::string;
      36             : 
      37             : ATM_NAMESPACE_BEGIN
      38             : 
      39             : 
      40             : /*! \brief Temperature value with units
      41             :  *
      42             :  *   This class defines physical parameters having units of Temperature.
      43             :  *   For example, the Radiance can be converted into Brightness Temperature.
      44             :  *   Default is K (International System), also used by the ATM library.
      45             :  */
      46             : class Temperature
      47             : {
      48             : public:
      49             :   enum Units {
      50             :     UnitKelvin,
      51             :     UnitMilliKelvin,
      52             :     UnitCelsius,
      53             :     UnitFahrenheit,
      54             :     NumTemperatureUnits
      55             :   };
      56             : 
      57             :   /** Default constructor */
      58             :   Temperature();
      59             :   /** A full constructor: Temperature value assumed by default to be in K (International System) */
      60             :   Temperature(double temperature);
      61             :   /** A full constructor: Temperature value + unit. Valid units are K [k], mK [mk], and C [c].
      62             :    *  If none of these implemented units is given, the SI value will be returned. */
      63             :   Temperature(double temperature, const string &units);
      64             :   Temperature(double temperature, Units units);
      65             : 
      66             :   /** Destructor */
      67   474490554 :   virtual ~Temperature() {};
      68             : 
      69             :   //@{
      70             :   /** Accessor to the temperature value in International System units (K) */
      71   427455361 :   double get() const { return valueIS_; }
      72             :   /** Accessor to the temperature value in specified units. Valid units are K [k], mK [mk], and C [c] */
      73             :   double get(const string &units) const;
      74             :   double get(Units units) const;
      75             :   //@}
      76             : 
      77       11581 :   Temperature& operator=(const Temperature &rhs){ if(&rhs != this) valueIS_ = rhs.valueIS_; return *this; }
      78           0 :   Temperature& operator=(double rhs) { valueIS_ = rhs; return *this; }
      79           0 :   Temperature operator+(const Temperature &rhs) { return Temperature(valueIS_ + rhs.get()); }
      80           0 :   Temperature operator-(const Temperature &rhs) { return Temperature(valueIS_ - rhs.get()); }
      81             :   Temperature operator*(double scf) { return Temperature(valueIS_ * scf); }
      82             :   Temperature operator*(float scf) { return Temperature(valueIS_ * (double) scf); }
      83             :   Temperature operator*(int scf) { return Temperature(valueIS_ * (double) scf); }
      84             :   Temperature operator*(unsigned int scf) { return Temperature(valueIS_ * (double) scf); }
      85             :   Temperature operator/(double scf) { return Temperature(valueIS_ / scf); }
      86             :   Temperature operator/(float scf) { return Temperature(valueIS_ / (double) scf); }
      87             :   Temperature operator/(int scf) { return Temperature(valueIS_ / (double) scf); }
      88             :   Temperature operator/(unsigned int scf) { return Temperature(valueIS_ / (double) scf); }
      89             :   bool operator<(const Temperature &rhs) const { return (valueIS_ < rhs.get()); }
      90             :   bool operator>(const Temperature &rhs) const { return (valueIS_ > rhs.get()); }
      91             :   bool operator<=(const Temperature &rhs) const { return (valueIS_ <= rhs.get()); }
      92             :   bool operator>=(const Temperature &rhs) const { return (valueIS_ >= rhs.get()); }
      93             :   bool operator==(const Temperature &rhs) const { return (valueIS_ == rhs.get()); }
      94             :   bool operator!=(const Temperature &rhs) const { return (valueIS_ != rhs.get()); }
      95             : 
      96             : private:
      97             :   double valueIS_;
      98             : }; // class Temperature
      99             : 
     100             : ATM_NAMESPACE_END
     101             : 
     102             : #endif /*!_ATM_TEMPERATURE_H*/
     103             : 
     104             : 

Generated by: LCOV version 1.16