source: trunk/external-alma/components/SpectralComponents/LorentzianSpectralElement.cc@ 3037

Last change on this file since 3037 was 2980, checked in by Malte Marquarding, 10 years ago

Add a copy of casacore/components/SpectralComponents to external-alma directory to prepare for its removal from casacore-trunk. DOn;t activate in SConscript yet.

File size: 3.7 KB
Line 
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: aips2-request@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: LorentzianSpectralElement.cc 21451 2014-06-10 07:48:08Z gervandiepen $
27
28//# Includes
29#include <components/SpectralComponents/LorentzianSpectralElement.h>
30
31#include <casa/BasicSL/Constants.h>
32
33#include <scimath/Functionals/Lorentzian1D.h>
34
35#include <casa/iostream.h>
36
37namespace casa { //# NAMESPACE CASA - BEGIN
38
39LorentzianSpectralElement::LorentzianSpectralElement()
40: PCFSpectralElement(SpectralElement::LORENTZIAN, Vector<Double>(3)) {
41 _setFunction(
42 std::tr1::shared_ptr<Lorentzian1D<Double> >(
43 new Lorentzian1D<Double>(1)
44 )
45 );
46 setAmpl(1);
47 setCenter(0);
48 setFWHM(1);
49}
50
51LorentzianSpectralElement::LorentzianSpectralElement(
52 const Double ampl,
53 const Double center, const Double fwhm
54) : PCFSpectralElement(SpectralElement::LORENTZIAN, ampl, center, fwhm) {
55 if (fwhm == 0) {
56 throw AipsError("Lorentzian fwhm cannot equal 0");
57 }
58 _setFunction(
59 std::tr1::shared_ptr<Lorentzian1D<Double> >(
60 new Lorentzian1D<Double>(ampl, center, fwhm)
61 )
62 );
63}
64
65LorentzianSpectralElement::LorentzianSpectralElement(
66 const Vector<Double>& param
67) : PCFSpectralElement(SpectralElement::LORENTZIAN, param) {
68 if (param[2] == 0) {
69 throw AipsError("Lorentzian fwhm cannot equal 0");
70 }
71 _setFunction(
72 std::tr1::shared_ptr<Lorentzian1D<Double> >(
73 new Lorentzian1D<Double>(param[AMP], param[CENTER], param[WIDTH])
74 )
75 );
76}
77
78LorentzianSpectralElement::LorentzianSpectralElement(
79 const LorentzianSpectralElement &other
80) : PCFSpectralElement(other) {}
81
82LorentzianSpectralElement::~LorentzianSpectralElement() {}
83
84SpectralElement* LorentzianSpectralElement::clone() const {
85 return new LorentzianSpectralElement(*this);
86}
87
88LorentzianSpectralElement& LorentzianSpectralElement::operator=(
89 const LorentzianSpectralElement& other
90) {
91 if (this != &other) {
92 SpectralElement::operator=(other);
93 }
94 return *this;
95}
96
97Double LorentzianSpectralElement::getIntegral() const {
98 return getAmpl()*getFWHM()*C::pi_2;
99}
100
101ostream &operator<<(ostream &os, const LorentzianSpectralElement &elem) {
102 os << SpectralElement::fromType((elem.getType())) << " element: " << endl;
103 os << " Amplitude: " << elem.getAmpl() << ", " << elem.getAmplErr();
104 if (elem.fixedAmpl()) os << " (fixed)";
105 os << endl << " Center: " << elem.getCenter() << ", " << elem.getCenterErr();
106 if (elem.fixedCenter()) os << " (fixed)";
107 os << endl << " FWHM: " << elem.getFWHM() << ", " << elem.getFWHMErr();
108 if (elem.fixedFWHM()) os << " (fixed)";
109 os << endl;
110 return os;
111}
112
113} //# NAMESPACE CASA - END
114
Note: See TracBrowser for help on using the repository browser.