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: 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: 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 404 : ConstantSpectrum::ConstantSpectrum()
40 404 : :SpectralModel()
41 : {
42 404 : DebugAssert(ok(), AipsError);
43 404 : }
44 :
45 1 : ConstantSpectrum::ConstantSpectrum(const ConstantSpectrum& other)
46 1 : :SpectralModel(other)
47 : {
48 1 : DebugAssert(ok(), AipsError);
49 1 : }
50 :
51 807 : ConstantSpectrum::~ConstantSpectrum() {
52 404 : DebugAssert(ok(), AipsError);
53 807 : }
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 400 : ComponentType::SpectralShape ConstantSpectrum::type() const {
62 400 : DebugAssert(ok(), AipsError);
63 400 : 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 0 : void ConstantSpectrum::sampleStokes(const MFrequency&, Vector<Double>& iquv) const {
72 0 : DebugAssert(ok(), AipsError);
73 0 : if(iquv.nelements() != 4 ){//keeps compiler happy
74 : };
75 :
76 :
77 0 : }
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 200 : void ConstantSpectrum::sampleStokes(
87 : Matrix<Double>& iquv, const Vector<MFrequency::MVType>& freq,
88 : const MFrequency::Ref&
89 : ) const {
90 200 : ThrowIf(iquv.shape() != IPosition(2, freq.size(), 4), "Incorrect Matrix shape");
91 200 : }
92 :
93 1 : SpectralModel* ConstantSpectrum::clone() const {
94 1 : DebugAssert(ok(), AipsError);
95 1 : SpectralModel* tmpPtr = new ConstantSpectrum(*this);
96 1 : AlwaysAssert(tmpPtr != 0, AipsError);
97 1 : return tmpPtr;
98 : }
99 :
100 0 : uInt ConstantSpectrum::nParameters() const {
101 0 : DebugAssert(ok(), AipsError);
102 0 : return 0;
103 : }
104 :
105 0 : void ConstantSpectrum::setParameters(const Vector<Double>& newSpectralParms) {
106 0 : DebugAssert(newSpectralParms.nelements() == nParameters(), AipsError);
107 0 : DebugAssert(ok(), AipsError);
108 : // Suppress compiler warning about unused variable
109 : // perhaps should just get rid of the DebugAssert statements
110 0 : if (newSpectralParms.empty()) {};
111 0 : }
112 :
113 0 : Vector<Double> ConstantSpectrum::parameters() const {
114 0 : DebugAssert(ok(), AipsError);
115 0 : return Vector<Double>(0);
116 : }
117 :
118 0 : void ConstantSpectrum::setErrors(const Vector<Double>& newSpectralErrs) {
119 0 : DebugAssert(ok(), AipsError);
120 : // Suppress compiler warning about unused variable
121 0 : if (newSpectralErrs.empty()) {};
122 0 : }
123 :
124 0 : Vector<Double> ConstantSpectrum::errors() const {
125 0 : DebugAssert(ok(), AipsError);
126 0 : Vector<Double> tmp(1,0.0);
127 0 : return tmp;
128 : }
129 :
130 200 : Bool ConstantSpectrum::fromRecord(String& errorMessage,
131 : const RecordInterface& record) {
132 200 : const Bool retVal = SpectralModel::fromRecord(errorMessage, record);
133 200 : DebugAssert(ok(), AipsError);
134 200 : return retVal;
135 : }
136 :
137 200 : Bool ConstantSpectrum::toRecord(String& errorMessage,
138 : RecordInterface& record) const {
139 200 : DebugAssert(ok(), AipsError);
140 200 : 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 2014 : Bool ConstantSpectrum::ok() const {
150 2014 : return SpectralModel::ok();
151 : }
152 : // Local Variables:
153 : // compile-command: "gmake OPTLIB=1 ConstantSpectrum"
154 : // End:
155 :
156 : } //# NAMESPACE CASA - END
157 :
|