Line data Source code
1 : //# ConstantSpectrum.cc.cc:
2 : //# Copyright (C) 1998,1999,2000,2003
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: ConstantSpectrum.cc 20652 2009-07-06 05:04:32Z Malte.Marquarding $
27 :
28 : #include <components/ComponentModels/ConstantSpectrum.h>
29 : #include <casacore/casa/Arrays/Vector.h>
30 : #include <casacore/casa/Exceptions/Error.h>
31 : #include <casacore/casa/Containers/RecordInterface.h>
32 : #include <casacore/casa/Quanta/Quantum.h>
33 : #include <casacore/casa/Utilities/Assert.h>
34 : #include <casacore/casa/BasicSL/String.h>
35 :
36 : using namespace casacore;
37 : namespace casa { //# NAMESPACE CASA - BEGIN
38 :
39 65428 : ConstantSpectrum::ConstantSpectrum()
40 65428 : :SpectralModel()
41 : {
42 65428 : DebugAssert(ok(), AipsError);
43 65428 : }
44 :
45 1689 : ConstantSpectrum::ConstantSpectrum(const ConstantSpectrum& other)
46 1689 : :SpectralModel(other)
47 : {
48 1689 : DebugAssert(ok(), AipsError);
49 1689 : }
50 :
51 134231 : ConstantSpectrum::~ConstantSpectrum() {
52 67116 : DebugAssert(ok(), AipsError);
53 134231 : }
54 :
55 0 : ConstantSpectrum& ConstantSpectrum::operator=(const ConstantSpectrum& other) {
56 0 : SpectralModel::operator=(other);
57 0 : DebugAssert(ok(), AipsError);
58 0 : return *this;
59 : }
60 :
61 39678 : ComponentType::SpectralShape ConstantSpectrum::type() const {
62 39678 : DebugAssert(ok(), AipsError);
63 39678 : return ComponentType::CONSTANT_SPECTRUM;
64 : }
65 :
66 0 : Double ConstantSpectrum::sample(const MFrequency&) const {
67 0 : DebugAssert(ok(), AipsError);
68 0 : return 1.0;
69 : }
70 :
71 491 : void ConstantSpectrum::sampleStokes(const MFrequency&, Vector<Double>& iquv) const {
72 491 : DebugAssert(ok(), AipsError);
73 491 : if(iquv.nelements() != 4 ){//keeps compiler happy
74 : };
75 :
76 :
77 491 : }
78 :
79 0 : void ConstantSpectrum::sample(Vector<Double>& scale,
80 : const Vector<MFrequency::MVType>&,
81 : const MFrequency::Ref&) const {
82 0 : DebugAssert(ok(), AipsError);
83 0 : scale = 1.0;
84 0 : }
85 :
86 34838 : void ConstantSpectrum::sampleStokes(
87 : Matrix<Double>& iquv, const Vector<MFrequency::MVType>& freq,
88 : const MFrequency::Ref&
89 : ) const {
90 34838 : ThrowIf(iquv.shape() != IPosition(2, freq.size(), 4), "Incorrect Matrix shape");
91 34838 : }
92 :
93 1689 : SpectralModel* ConstantSpectrum::clone() const {
94 1689 : DebugAssert(ok(), AipsError);
95 1689 : SpectralModel* tmpPtr = new ConstantSpectrum(*this);
96 1689 : AlwaysAssert(tmpPtr != 0, AipsError);
97 1689 : return tmpPtr;
98 : }
99 :
100 155 : uInt ConstantSpectrum::nParameters() const {
101 155 : DebugAssert(ok(), AipsError);
102 155 : return 0;
103 : }
104 :
105 155 : void ConstantSpectrum::setParameters(const Vector<Double>& newSpectralParms) {
106 155 : DebugAssert(newSpectralParms.nelements() == nParameters(), AipsError);
107 155 : DebugAssert(ok(), AipsError);
108 : // Suppress compiler warning about unused variable
109 : // perhaps should just get rid of the DebugAssert statements
110 155 : if (newSpectralParms.empty()) {};
111 155 : }
112 :
113 127 : Vector<Double> ConstantSpectrum::parameters() const {
114 127 : DebugAssert(ok(), AipsError);
115 127 : return Vector<Double>(0);
116 : }
117 :
118 155 : void ConstantSpectrum::setErrors(const Vector<Double>& newSpectralErrs) {
119 155 : DebugAssert(ok(), AipsError);
120 : // Suppress compiler warning about unused variable
121 155 : if (newSpectralErrs.empty()) {};
122 155 : }
123 :
124 127 : Vector<Double> ConstantSpectrum::errors() const {
125 127 : DebugAssert(ok(), AipsError);
126 127 : Vector<Double> tmp(1,0.0);
127 127 : return tmp;
128 : }
129 :
130 30793 : Bool ConstantSpectrum::fromRecord(String& errorMessage,
131 : const RecordInterface& record) {
132 30793 : const Bool retVal = SpectralModel::fromRecord(errorMessage, record);
133 30793 : DebugAssert(ok(), AipsError);
134 30793 : return retVal;
135 : }
136 :
137 1168 : Bool ConstantSpectrum::toRecord(String& errorMessage,
138 : RecordInterface& record) const {
139 1168 : DebugAssert(ok(), AipsError);
140 1168 : return SpectralModel::toRecord(errorMessage, record);
141 : }
142 :
143 0 : Bool ConstantSpectrum::convertUnit(String&,
144 : const RecordInterface&) {
145 0 : DebugAssert(ok(), AipsError);
146 0 : return true;
147 : }
148 :
149 275575 : Bool ConstantSpectrum::ok() const {
150 275575 : return SpectralModel::ok();
151 : }
152 : // Local Variables:
153 : // compile-command: "gmake OPTLIB=1 ConstantSpectrum"
154 : // End:
155 :
156 : } //# NAMESPACE CASA - END
157 :
|