LCOV - code coverage report
Current view: top level - atmosphere/ATM - ATMFrequency.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 44 65 67.7 %
Date: 2024-10-10 11:40:37 Functions: 8 11 72.7 %

          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: ATMFrequency.cpp Exp $"
      20             :  *
      21             :  * who       when      what
      22             :  * --------  --------  ----------------------------------------------
      23             :  * pardo     24/03/09  created
      24             :  */
      25             : 
      26             : #include <stdio.h>
      27             : 
      28             : #include "ATMFrequency.h"
      29             : 
      30             : 
      31             : 
      32             : ATM_NAMESPACE_BEGIN
      33             : 
      34           0 : Frequency::Frequency() :
      35           0 :   valueIS_(0.0)
      36             : {
      37           0 : }
      38             : 
      39           8 : Frequency::Frequency(double frequency) :
      40           8 :   valueIS_(frequency)
      41             : {
      42           8 : }
      43             : 
      44          17 : Frequency::Frequency(double frequency, const std::string &units)
      45             : {
      46          17 :   valueIS_ = sput(frequency, units);
      47          17 : }
      48             : 
      49         653 : Frequency::Frequency(double frequency, Frequency::Units units)
      50             : {
      51         653 :   valueIS_ = sput(frequency, units);
      52         653 : }
      53             : 
      54           0 : Frequency::Frequency(const Frequency &frequency) :
      55           0 :   valueIS_(frequency.valueIS_)
      56             : {
      57           0 : }
      58             : 
      59         678 : Frequency::~Frequency()
      60             : {
      61         678 : }
      62             : 
      63         588 : double Frequency::sget(double value, const std::string &units)
      64             : {
      65         588 :   if(units == "THz" || units == "THZ") {
      66           0 :     return 1.0E-12 * value;
      67         588 :   } else if(units == "GHz" || units == "GHz" || units == "ghz") {
      68         567 :     return 1.0E-9 * value;
      69          21 :   } else if(units == "MHz" || units == "MHZ" || units == "mhz") {
      70           4 :     return 1.0E-6 * value;
      71          17 :   } else if(units == "kHz" || units == "KHZ" || units == "khz") {
      72           3 :     return 1.0E-3 * value;
      73          14 :   } else if(units == "Hz" || units == "HZ" || units == "hz") {
      74          14 :     return value;
      75             :   } else {
      76           0 :     return value;
      77             :   }
      78             : }
      79          17 : double Frequency::sput(double freq, const std::string &units)
      80             : {
      81          17 :   if(units == "THz" || units == "THZ") {
      82           0 :     return 1.0E12 * freq;
      83          17 :   } else if(units == "GHz" || units == "GHZ" || units == "ghz") {
      84          15 :     return 1.0E9 * freq;
      85           2 :   } else if(units == "MHz" || units == "MHZ" || units == "mhz") {
      86           0 :     return 1.0E6 * freq;
      87           2 :   } else if(units == "kHz" || units == "KHZ" || units == "khz") {
      88           0 :     return 1.0E3 * freq;
      89           2 :   } else if(units == "Hz" || units == "HZ" || units == "hz") {
      90           2 :     return freq;
      91             :   } else {
      92           0 :     return freq;
      93             :   }
      94             : }
      95             : 
      96          36 : double Frequency::sget(double value, Frequency::Units units)
      97             : {
      98          36 :   if(units == Frequency::UnitTeraHertz) {
      99           0 :     return 1.0E-12 * value;
     100          36 :   } else if(units == Frequency::UnitGigaHertz) {
     101          14 :     return 1.0E-9 * value;
     102          22 :   } else if(units == Frequency::UnitMegaHertz) {
     103           0 :     return 1.0E-6 * value;
     104          22 :   } else if(units == Frequency::UnitKiloHertz) {
     105           0 :     return 1.0E-3 * value;
     106          22 :   } else if(units == Frequency::UnitHertz) {
     107          22 :     return value;
     108             :   } else {
     109           0 :     return value;
     110             :   }
     111             : }
     112         653 : double Frequency::sput(double freq, Frequency::Units units)
     113             : {
     114         653 :   if(units == Frequency::UnitTeraHertz) {
     115           0 :     return 1.0E12 * freq;
     116         653 :   } else if(units == Frequency::UnitGigaHertz) {
     117           0 :     return 1.0E9 * freq;
     118         653 :   } else if(units == Frequency::UnitMegaHertz) {
     119           0 :     return 1.0E6 * freq;
     120         653 :   } else if(units == Frequency::UnitKiloHertz) {
     121           0 :     return 1.0E3 * freq;
     122         653 :   } else if(units == Frequency::UnitHertz) {
     123         653 :     return freq;
     124             :   } else {
     125           0 :     return freq;
     126             :   }
     127             : }
     128             : 
     129             : ATM_NAMESPACE_END

Generated by: LCOV version 1.16