LCOV - code coverage report
Current view: top level - atmosphere/ATM - ATMOpacity.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 13 41 31.7 %
Date: 2024-10-04 18:58:15 Functions: 4 11 36.4 %

          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: ATMOpacity.cpp Exp $"
      20             :  *
      21             :  * who       when      what
      22             :  * --------  --------  ----------------------------------------------
      23             :  * pardo     24/03/09  created
      24             :  */
      25             : 
      26             : #include <stdio.h>
      27             : 
      28             : #include "ATMOpacity.h"
      29             : 
      30             : 
      31             : 
      32             : ATM_NAMESPACE_BEGIN
      33             : 
      34           0 : Opacity::Opacity() :
      35           0 :   valueIS_(0.0)
      36             : {
      37           0 : }
      38             : 
      39       22555 : Opacity::Opacity(double opacity) :
      40       22555 :   valueIS_(opacity)
      41             : {
      42       22555 : }
      43             : 
      44           0 : Opacity::Opacity(double opacity, const std::string &units)
      45             : {
      46           0 :   valueIS_ = sput(opacity, units);
      47           0 : }
      48             : 
      49           0 : Opacity::Opacity(double opacity, Opacity::Units units)
      50             : {
      51           0 :   valueIS_ = sput(opacity, units);
      52           0 : }
      53             : 
      54           0 : Opacity::Opacity(const Opacity &opacity) :
      55           0 :   valueIS_(opacity.valueIS_)
      56             : {
      57           0 : }
      58             : 
      59       22555 : Opacity::~Opacity()
      60             : {
      61       22555 : }
      62             : 
      63          15 : double Opacity::sget(double value, const std::string &units)
      64             : {
      65          15 :   if(units == "db" || units == "DB") {
      66           0 :     return value * 4.34294482;
      67          15 :   } else if(units == "np" || units == "NP" || units == "neper" || units == "NEPER"){
      68          15 :     return value;
      69             :   } else {
      70             :     // Exception: Unknown unit, neper (np) used by default)
      71           0 :     return value;
      72             :   }
      73             : }
      74             : 
      75           0 : double Opacity::sput(double value, const std::string &units)
      76             : {
      77           0 :   if(units == "db" || units == "DB") {
      78           0 :     return value / 4.34294482;
      79           0 :   } else if(units == "np" || units == "NP" || units == "neper" || units == "NEPER") {
      80           0 :     return value;
      81             :   } else {
      82             :     // Exception: Unknown unit, neper (np) used by default)
      83           0 :     return value;
      84             :   }
      85             : }
      86             : 
      87          50 : double Opacity::sget(double value, Opacity::Units units)
      88             : {
      89          50 :   if(units == Opacity::UnitDeciBel) {
      90           0 :     return value * 4.34294482;
      91          50 :   } else if(units == Opacity::UnitNeper){
      92          50 :     return value;
      93             :   } else {
      94             :     // Exception: Unknown unit, neper (np) used by default)
      95           0 :     return value;
      96             :   }
      97             : }
      98             : 
      99           0 : double Opacity::sput(double value, Opacity::Units units)
     100             : {
     101           0 :   if(units == Opacity::UnitDeciBel) {
     102           0 :     return value / 4.34294482;
     103           0 :   } else if(units == Opacity::UnitNeper) {
     104           0 :     return value;
     105             :   } else {
     106             :     // Exception: Unknown unit, neper (np) used by default)
     107           0 :     return value;
     108             :   }
     109             : }
     110             : 
     111             : ATM_NAMESPACE_END
     112             : 

Generated by: LCOV version 1.16