LCOV - code coverage report
Current view: top level - atmosphere/ATM - ATMFrequency.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 48 65 73.8 %
Date: 2024-12-11 20:54:31 Functions: 9 11 81.8 %

          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        1620 : Frequency::Frequency() :
      35        1620 :   valueIS_(0.0)
      36             : {
      37        1620 : }
      38             : 
      39        1722 : Frequency::Frequency(double frequency) :
      40        1722 :   valueIS_(frequency)
      41             : {
      42        1722 : }
      43             : 
      44        1637 : Frequency::Frequency(double frequency, const std::string &units)
      45             : {
      46        1637 :   valueIS_ = sput(frequency, units);
      47        1637 : }
      48             : 
      49    15761107 : Frequency::Frequency(double frequency, Frequency::Units units)
      50             : {
      51    15761107 :   valueIS_ = sput(frequency, units);
      52    15761107 : }
      53             : 
      54           0 : Frequency::Frequency(const Frequency &frequency) :
      55           0 :   valueIS_(frequency.valueIS_)
      56             : {
      57           0 : }
      58             : 
      59    15766086 : Frequency::~Frequency()
      60             : {
      61    15766086 : }
      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        1637 : double Frequency::sput(double freq, const std::string &units)
      80             : {
      81        1637 :   if(units == "THz" || units == "THZ") {
      82           0 :     return 1.0E12 * freq;
      83        1637 :   } else if(units == "GHz" || units == "GHZ" || units == "ghz") {
      84        1630 :     return 1.0E9 * freq;
      85           7 :   } else if(units == "MHz" || units == "MHZ" || units == "mhz") {
      86           5 :     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    15762204 : double Frequency::sget(double value, Frequency::Units units)
      97             : {
      98    15762204 :   if(units == Frequency::UnitTeraHertz) {
      99           0 :     return 1.0E-12 * value;
     100    15762204 :   } else if(units == Frequency::UnitGigaHertz) {
     101    15760448 :     return 1.0E-9 * value;
     102        1756 :   } else if(units == Frequency::UnitMegaHertz) {
     103           0 :     return 1.0E-6 * value;
     104        1756 :   } else if(units == Frequency::UnitKiloHertz) {
     105           0 :     return 1.0E-3 * value;
     106        1756 :   } else if(units == Frequency::UnitHertz) {
     107        1756 :     return value;
     108             :   } else {
     109           0 :     return value;
     110             :   }
     111             : }
     112    15761107 : double Frequency::sput(double freq, Frequency::Units units)
     113             : {
     114    15761107 :   if(units == Frequency::UnitTeraHertz) {
     115           0 :     return 1.0E12 * freq;
     116    15761107 :   } else if(units == Frequency::UnitGigaHertz) {
     117           0 :     return 1.0E9 * freq;
     118    15761107 :   } else if(units == Frequency::UnitMegaHertz) {
     119           0 :     return 1.0E6 * freq;
     120    15761107 :   } else if(units == Frequency::UnitKiloHertz) {
     121           0 :     return 1.0E3 * freq;
     122    15761107 :   } else if(units == Frequency::UnitHertz) {
     123    15761107 :     return freq;
     124             :   } else {
     125           0 :     return freq;
     126             :   }
     127             : }
     128             : 
     129             : ATM_NAMESPACE_END

Generated by: LCOV version 1.16