casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ConstantSpectrum.h
Go to the documentation of this file.
1 //# ConstantSpectrum.h: Model the spectral variation with a constant
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.h 18093 2004-11-30 17:51:10Z ddebonis $
27 
28 #ifndef COMPONENTS_CONSTANTSPECTRUM_H
29 #define COMPONENTS_CONSTANTSPECTRUM_H
30 
31 #include <casa/aips.h>
34 
35 namespace casacore{
36 
37 class MFrequency;
38 class RecordInterface;
39 class String;
40 template <class T> class Vector;
41 }
42 
43 namespace casa { //# NAMESPACE CASA - BEGIN
44 
45 
46 // <summary>Model the spectral variation with a constant</summary>
47 
48 // <use visibility=export>
49 
50 // <reviewed reviewer="" date="yyyy/mm/dd" tests="tConstantSpectrum" demos="dConstantSpectrum">
51 // </reviewed>
52 
53 // <prerequisite>
54 // <li> <linkto class="SpectralModel">SpectralModel</linkto>
55 // </prerequisite>
56 //
57 // <synopsis>
58 
59 // This class models the spectral variation of a component as constant,
60 // ie. unchanging with frequency. It is the simplest possible model for
61 // spectral variation.
62 
63 // This class like the other spectral models becomes more useful when used
64 // through the <linkto class=SkyComponent>SkyComponent</linkto> class, which
65 // incorperates the flux and spatial variation of the emission, or through the
66 // <linkto class=ComponentList>ComponentList</linkto> class, which handles
67 // groups of SkyComponent objects.
68 
69 // Because the flux is constant with frequency the concept of a reference
70 // frequency is meaningless with this class. But it can still be accessed using
71 // the <src>refFrequency</src> and <src>setRefFrequency</src>. However changing
72 // its value will not affect the behaviour of this class.
73 
74 // This class does not have any parameters and the <src>nParameters</src>
75 // function will return zero. It is an error that will generate an exception
76 // (in Debug mode) to call the <src>setParameters</src> and
77 // <src>parameters</src> functions with anything other than a zero length
78 // vector.
79 
80 // The <src>sample</src> functions always return 1.0.
81 
82 // This class also contains functions (<src>toRecord</src> &
83 // <src>fromRecord</src>) which perform the conversion between Records and
84 // ConstantSpectrum objects. These functions define how a ConstantSpectrum
85 // object is represented in glish. The format of the record that is generated
86 // and accepted by these functions is:
87 // <srcblock>
88 // c := [type = 'constant',
89 // frequency = [type = 'frequency',
90 // refer = 'lsr',
91 // m0 = [value = 1, unit = 'GHz']
92 // ]
93 // ]
94 // </srcblock>
95 // The frequency field contains a record representation of a frequency measure
96 // and its format is defined in the Measures module. Its refer field defines
97 // the reference frame for the direction and the m0 field defines the value of
98 // the reference frequency. The parsing of the type field is case
99 // insensitive.
100 // </synopsis>
101 
102 // <example>
103 // Its hard to think of a good example for this class as it is basically does
104 // nothing! In this example the spectral variation of a component is set to to
105 // a constant value.
106 // <srcblock>
107 // SkyComponent myComp(...);
108 // ...
109 // if (myComp.spectrum().type() != ComponentType::CONSTANT_SPECTRUM) {
110 // myComp.spectrum() = ConstantSpectrum();
111 // }
112 // </srcblock>
113 // </example>
114 //
115 // <motivation>
116 // A ConstantSpectrum class is needed for users who are not interested in
117 // modelling any spectral variation in their components.
118 // </motivation>
119 //
120 // <todo asof="1999/11/23">
121 // <li> Nothing I hope!
122 // </todo>
123 
124 // <linkfrom anchor="ConstantSpectrum" classes="SpectralModel SpectralIndex">
125 // <here>ConstantSpectrum</here> - Models the spectrum as constant
126 // </linkfrom>
127 
129 {
130 public:
131  // The default constructor is the only one you really need as this class has
132  // no parameters!
134 
135  // The copy constructor uses copy semantics
136  ConstantSpectrum(const ConstantSpectrum& other);
137 
138  // The destructor does nothing.
139  virtual ~ConstantSpectrum();
140 
141  // The assignment operator uses copy semantics.
143 
144  // return the actual spectral type. This function always returns
145  // ComponentType::CONSTANT_SPECTRUM
146  virtual ComponentType::SpectralShape type() const;
147 
148  // Return the scaling factor that indicates the flux is at the specified
149  // frequency assuming the flux at the reference frequency is one. This
150  // function always returns one, as the spectrum is constant.
151  virtual casacore::Double sample(const casacore::MFrequency& centerFrequency) const;
152 
153  //Original values returned
154  virtual void sampleStokes(const casacore::MFrequency& centerFrequency,
156 
157  // Same as the previous function except that many frequencies can be sampled
158  // at once. The reference frame must be the same for all the specified
159  // frequencies. Uses a customised implementation.
160  virtual void sample(casacore::Vector<casacore::Double>& scale,
162  const casacore::MFrequency::Ref& refFrame) const;
163 
164  //original values are returned
167  const casacore::MFrequency::Ref& refFrame) const;
168  // Return a pointer to a copy of this object upcast to a SpectralModel
169  // object. The class that uses this function is responsible for deleting the
170  // pointer. This is used to implement a virtual copy constructor.
171  virtual SpectralModel* clone() const;
172 
173  // return the number of parameters. There are no parameters for this spectral
174  // model. So calling <src>setParameters</src> or <src>parameters</src> with
175  // anything other than a zero length casacore::Vector will throw an exception (when
176  // compiled in debug mode).
177  // <group>
178  virtual casacore::uInt nParameters() const;
179  virtual void setParameters(const casacore::Vector<casacore::Double>& newSpectralParms);
181  virtual void setErrors(const casacore::Vector<casacore::Double>& newSpectralErrs);
183  // </group>
184 
185  // These functions convert between a casacore::Record and a ConstantSpectrum. These
186  // functions define how a ConstantSpectrum object is represented in glish and
187  // this is detailed in the synopsis above. These functions return false if
188  // the record is malformed and append an error message to the supplied string
189  // giving the reason.
190  // <group>
191  virtual casacore::Bool fromRecord(casacore::String& errorMessage,
192  const casacore::RecordInterface& record);
193  virtual casacore::Bool toRecord(casacore::String& errorMessage, casacore::RecordInterface& record) const;
194  // </group>
195 
196  // Convert the parameters of the spectrum to the specified units. As a
197  // constant spectrum has no parameters this function does nothing and always
198  // returns true.
199  virtual casacore::Bool convertUnit(casacore::String& errorMessage,
200  const casacore::RecordInterface& record);
201 
202  // casacore::Function which checks the internal data of this class for consistant
203  // values. Returns true if everything is fine otherwise returns false.
204  virtual casacore::Bool ok() const;
205 };
206 
207 } //# NAMESPACE CASA - END
208 
209 #endif
virtual void setParameters(const casacore::Vector< casacore::Double > &newSpectralParms)
virtual SpectralModel * clone() const
Return a pointer to a copy of this object upcast to a SpectralModel object.
std::vector< double > Vector
Definition: ds9context.h:24
virtual void sampleStokes(const casacore::MFrequency &centerFrequency, casacore::Vector< casacore::Double > &iquv) const
Original values returned.
virtual casacore::Bool toRecord(casacore::String &errorMessage, casacore::RecordInterface &record) const
Convert the class to an Record representation.
Model the spectral variation with a constant.
A Measure: wave characteristics.
Definition: MFrequency.h:161
virtual casacore::Bool convertUnit(casacore::String &errorMessage, const casacore::RecordInterface &record)
Convert the parameters of the spectrum to the specified units.
virtual casacore::Vector< casacore::Double > parameters() const
double Double
Definition: aipstype.h:55
virtual ~ConstantSpectrum()
The destructor does nothing.
virtual ComponentType::SpectralShape type() const
return the actual spectral type.
ConstantSpectrum()
The default constructor is the only one you really need as this class has no parameters! ...
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Base class for spectral models.
virtual casacore::Bool fromRecord(casacore::String &errorMessage, const casacore::RecordInterface &record)
These functions convert between a casacore::Record and a ConstantSpectrum.
virtual casacore::uInt nParameters() const
return the number of parameters.
virtual void setErrors(const casacore::Vector< casacore::Double > &newSpectralErrs)
SpectralShape
The different functional forms for the spectral variation.
virtual casacore::Vector< casacore::Double > errors() const
ConstantSpectrum & operator=(const ConstantSpectrum &other)
The assignment operator uses copy semantics.
virtual casacore::Bool ok() const
casacore::Function which checks the internal data of this class for consistant values.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual casacore::Double sample(const casacore::MFrequency &centerFrequency) const
Return the scaling factor that indicates the flux is at the specified frequency assuming the flux at ...
Abstract base class for Record classes.
unsigned int uInt
Definition: aipstype.h:51
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42