LCOV - code coverage report
Current view: top level - components/SpectralComponents - LorentzianSpectralElement.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 46 0.0 %
Date: 2024-10-12 00:35:29 Functions: 0 10 0.0 %

          Line data    Source code
       1             : //# SpectralElement.cc: Describes (a set of related) spectral lines
       2             : //# Copyright (C) 2001,2004
       3             : //# Associated Universities, Inc. Washington DC, USA.
       4             : //#
       5             : //# This library is free software; you can redistribute it and/or modify it
       6             : //# under the terms of the GNU Library General Public License as published by
       7             : //# the Free Software Foundation; either version 2 of the License, or (at your
       8             : //# option) any later version.
       9             : //#
      10             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      11             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      13             : //# License for more details.
      14             : //#
      15             : //# You should have received a copy of the GNU Library General Public License
      16             : //# along with this library; if not, write to the Free Software Foundation,
      17             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      18             : //#
      19             : //# Correspondence concerning AIPS++ should be addressed as follows:
      20             : //#        Internet email: casa-feedback@nrao.edu.
      21             : //#        Postal address: AIPS++ Project Office
      22             : //#                        National Radio Astronomy Observatory
      23             : //#                        520 Edgemont Road
      24             : //#                        Charlottesville, VA 22903-2475 USA
      25             : //#
      26             : //# $Id: SpectralElement.cc 21024 2011-03-01 11:46:18Z gervandiepen $
      27             : 
      28             : //# Includes
      29             : #include <components/SpectralComponents/LorentzianSpectralElement.h>
      30             : 
      31             : #include <casacore/casa/BasicSL/Constants.h>
      32             : 
      33             : #include <casacore/scimath/Functionals/Lorentzian1D.h>
      34             : 
      35             : #include <iostream>
      36             : 
      37             : using namespace casacore;
      38             : namespace casa { //# NAMESPACE CASA - BEGIN
      39             : 
      40           0 : LorentzianSpectralElement::LorentzianSpectralElement()
      41           0 : : PCFSpectralElement(SpectralElement::LORENTZIAN, Vector<Double>(3)) {
      42           0 :         _setFunction(
      43           0 :                 std::shared_ptr<Lorentzian1D<Double> >(
      44           0 :                         new Lorentzian1D<Double>(1)
      45             :                 )
      46             :         );
      47           0 :         setAmpl(1);
      48           0 :         setCenter(0);
      49           0 :         setFWHM(1);
      50           0 : }
      51             : 
      52           0 : LorentzianSpectralElement::LorentzianSpectralElement(
      53             :         const Double ampl,
      54             :         const Double center, const Double fwhm
      55           0 : ) : PCFSpectralElement(SpectralElement::LORENTZIAN, ampl, center, fwhm) {
      56           0 :         if (fwhm == 0) {
      57           0 :                 throw AipsError("Lorentzian fwhm cannot equal 0");
      58             :         }
      59           0 :         _setFunction(
      60           0 :                 std::shared_ptr<Lorentzian1D<Double> >(
      61           0 :                         new Lorentzian1D<Double>(ampl, center, fwhm)
      62             :                 )
      63             :         );
      64           0 : }
      65             : 
      66           0 : LorentzianSpectralElement::LorentzianSpectralElement(
      67             :         const Vector<Double>& param
      68           0 : ) : PCFSpectralElement(SpectralElement::LORENTZIAN, param) {
      69           0 :         if (param[2] == 0) {
      70           0 :                 throw AipsError("Lorentzian fwhm cannot equal 0");
      71             :         }
      72           0 :         _setFunction(
      73           0 :                 std::shared_ptr<Lorentzian1D<Double> >(
      74           0 :                         new Lorentzian1D<Double>(param[AMP], param[CENTER], param[WIDTH])
      75             :                 )
      76             :         );
      77           0 : }
      78             : 
      79           0 : LorentzianSpectralElement::LorentzianSpectralElement(
      80             :         const LorentzianSpectralElement &other
      81           0 : ) : PCFSpectralElement(other) {}
      82             : 
      83           0 : LorentzianSpectralElement::~LorentzianSpectralElement() {}
      84             : 
      85           0 : SpectralElement* LorentzianSpectralElement::clone() const {
      86           0 :         return new LorentzianSpectralElement(*this);
      87             : }
      88             : 
      89           0 : LorentzianSpectralElement& LorentzianSpectralElement::operator=(
      90             :         const LorentzianSpectralElement& other
      91             : ) {
      92           0 :         if (this != &other) {
      93           0 :                 SpectralElement::operator=(other);
      94             :         }
      95           0 :         return *this;
      96             : }
      97             : 
      98           0 : Double LorentzianSpectralElement::getIntegral() const {
      99           0 :         return getAmpl()*getFWHM()*C::pi_2;
     100             : }
     101             : 
     102           0 : ostream &operator<<(ostream &os, const LorentzianSpectralElement &elem) {
     103           0 :         os << SpectralElement::fromType((elem.getType())) << " element: " << endl;
     104           0 :     os << "  Amplitude: " << elem.getAmpl() << ", " << elem.getAmplErr();
     105           0 :     if (elem.fixedAmpl()) os << " (fixed)";
     106           0 :     os << endl << "  Center:    " << elem.getCenter() << ", " << elem.getCenterErr();
     107           0 :     if (elem.fixedCenter()) os << " (fixed)";
     108           0 :     os << endl << "  FWHM:     " << elem.getFWHM() << ", " << elem.getFWHMErr();
     109           0 :     if (elem.fixedFWHM()) os << " (fixed)";
     110           0 :     os << endl;
     111           0 :     return os;
     112             : }
     113             : 
     114             : } //# NAMESPACE CASA - END
     115             : 

Generated by: LCOV version 1.16