casacore
Loading...
Searching...
No Matches
MDoppler.h
Go to the documentation of this file.
1// # MDoppler.h: A Measure: Doppler shift
2// # Copyright (C) 1995,1996,1997,1998,1999,2000,2002,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#ifndef MEASURES_MDOPPLER_H
27#define MEASURES_MDOPPLER_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/Arrays/ArrayFwd.h>
32#include <casacore/measures/Measures/MeasBase.h>
33#include <casacore/measures/Measures/MeasRef.h>
34#include <casacore/casa/Quanta/MVDoppler.h>
35
36namespace casacore { // # NAMESPACE CASACORE - BEGIN
37
38// # Forward Declarations
39class MDoppler;
40class MCDoppler;
41template <class M>
42class MeasConvert;
43template <class M>
44class ArrayMeasColumn;
45template <class M>
47template <class T>
48class Quantum;
49
50// # Typedefs
51
52// <summary>
53// A Measure: Doppler shift
54// </summary>
55
56// <use visibility=export>
57
58// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMeasure" demos="">
59// </reviewed>
60
61// <prerequisite>
62// <li> <linkto class=Measure>Measure</linkto> class
63// </prerequisite>
64//
65// <etymology>
66// From Measure and Doppler
67// </etymology>
68//
69// <synopsis>
70// MDoppler forms the derived Measure class for Doppler shifts.<br>
71// An MDoppler can be generated from a simple value (or an
72// <linkto class=MVDoppler>MVDoppler</linkto>), which is then
73// interpreted as a Doppler ratio, and a reference, with a RADIO type
74// as default.<br>
75// It can also be generated from a Quantity, where the interpretation
76// depends on the dimensionality of the Quantity:
77// <ul>
78// <li> None: a Doppler ratio
79// <li> Velocity: Doppler ratio calculated by dividing with c
80// </ul>
81// The different types of Doppler (with F = f/f0, the frequency ratio),
82// are:
83// <ul>
84// <li> MDoppler::Z (-1 + 1/F)
85// <li> MDoppler::RATIO (F) *
86// <li> MDoppler::RADIO (1 - F)
87// <li> MDoppler::OPTICAL == Z
88// <li> MDoppler::BETA ((1 - F<sup>2</sup>)/(1 + F<sup>2</sup>))
89// <li> MDoppler::GAMMA ((1 + F<sup>2</sup>)/2F) *
90// <li> MDoppler::RELATIVISTIC == BETA (== v/c)
91// <li> MDoppler::DEFAULT == RADIO
92// </ul>
93// Note that the ones with an '*' have no real interpretation (although the
94// calculation will proceed) if given as
95// a velocity.<br>
96// <p>
97// Conversion between the different types is done with the standard
98// <linkto class=MeasConvert>MeasConvert</linkto> class
99// (<src>MDoppler::Convert</src> in this case).<br>
100//
101// Dopplers can be created from an <linkto class=MFrequency>MFrequency</linkto>
102// object, or from an <linkto class=MRadialVelocity>MRadialVelocity</linkto>
103// object.<br>
104//
105// A <em>shiftFrequency()</em> method can shift frequencies.
106//
107// Dopplers do not need a reference frame.
108//
109// </synopsis>
110//
111// <example>
112// Conversion of a radio Doppler to an optical
113// <srcblock>
114// MDoppler radio(0.01); // A radio Doppler value
115// cout << "Doppler radio = " << radio << "; optical = " <<
116// MDoppler::Convert(radio, MDoppler::OPTICAL)() << // Convert
117// endl;
118// </srcblock>
119// Setting up a conversion
120// <srcblock>
121// MDoppler::Convert to_opt(MDoppler::RADIO, MDoppler::OPTICAL);
122// for (Double d=0; d<0.1; d += 0.005) {
123// cout << "radio = " << d << " to optical = " <<
124// to_opt(d) << endl;
125// </srcblock>
126// </example>
127//
128// <motivation>
129// </motivation>
130//
131// <todo asof="2000/06/15">
132// <li>
133// </todo>
134
135class MDoppler : public MeasBase<MVDoppler, MeasRef<MDoppler>> {
136 public:
137 // # Friends
138 // Conversion of data
139 friend class MeasConvert<MDoppler>;
140
141 // # Enumerations
142 // Types of known MDopplers
143 // <note role=warning> The order defines the order in the translation
144 // matrix FromTo
145 // in the getConvert routine. Do not change the order without
146 // changing the array. Additions should be made before N_types, and
147 // an additional row and column should be coded in FromTo, and
148 // in showType().</note>
160
161 // # Typedefs
162 // Measure value container for this class (i.e. MDoppler::MVType)
164 // Measure conversion routines for this class (i.e. MDoppler::MCType)
166 // Measure reference (i.e. MDoppler::Ref)
168 // Measure Convert (i.e. MDoppler::Convert)
170 // Measure table Columns (e.g., MDoppler::ScalarColumn)
173
174 // # Constructors
175 // <note role=tip> In the following constructors and other functions, all
176 // <em>MeasRef</em> can be replaced with simple <src>Measure::TYPE</src>
177 // where no offsets or frames are needed in the reference. </note>
178 // Default constructor; generates a zero rest Doppler
180 // Create from data and reference
181 // <group>
182 MDoppler(const MVDoppler &dt);
183 MDoppler(const MVDoppler &dt, const MDoppler::Ref &rf);
185 MDoppler(const Quantity &dt);
186 MDoppler(const Quantity &dt, const MDoppler::Ref &rf);
188 MDoppler(const Measure *dt);
189 MDoppler(const MeasValue *dt);
190 // </group>
191
192 // # Destructor
193 virtual ~MDoppler();
194
195 // # Operators
196
197 // # General Member Functions
198 // Tell me your type
199 // <group>
200 virtual const String &tellMe() const;
201 static const String &showMe();
202 static void assure(const Measure &in);
203 // </group>
204 // Translate reference code. The uInt version has a check for valid codes
205 // (i.e. it is a safe cast).
206 // <thrown>
207 // <li> AipsError in the uInt interface if illegal code given
208 // </thrown>
209 // <group>
211 static const String &showType(MDoppler::Types tp);
212 static const String &showType(uInt tp);
213 // </group>
214 // Translate string to reference code
215 // <group>
216 static Bool getType(MDoppler::Types &tp, const String &in);
218 // </group>
219 // Set the offset in the reference (False if non-matching Measure)
220 virtual Bool setOffset(const Measure &in);
221 // Set the reference type to the specified String. False if illegal
222 // string, reference set to DEFAULT.
223 virtual Bool setRefString(const String &in);
224 // Get the default reference type
225 virtual const String &getDefaultType() const;
226 // Get a list of all known reference codes. nall returns the number in list,
227 // nextra the number of specials (like planets) that should be at
228 // end of list). typ returns the list of corresponding types.
229 // <group>
230 virtual const String *allTypes(Int &nall, Int &nextra, const uInt *&typ) const;
231 static const String *allMyTypes(Int &nall, Int &nextra, const uInt *&typ);
232 // </group>
233 // Check if all internal tables of types (both enum and String) are
234 // complete and correct. This function is called automatically if and when
235 // necessary.
236 // <thrown>
237 // <li> AipsError if a (programming) error in the types.
238 // </thrown>
239 // <group>
240 virtual void checkTypes() const;
241 static void checkMyTypes();
242 // </group>
243 // Get the reference type (for records, including codes like R_)
244 virtual String getRefString() const;
245
246 // Get in specified units
247 Quantity get(const Unit &un) const;
248
249 // Shift the input frequencies to the output frequencies. In the case of
250 // simple Double inputs, it is assumed that the values are linearly dependent
251 // on frequency. I.e. frequencies given as wavelength or time cannot be used.
252 // <group>
255 // </group>
256
257 // Make a copy
258 // <group>
259 virtual Measure *clone() const;
260 // </group>
261
262 private:
263 // # Enumerations
264
265 // # Data
266
267 // # Member functions
268};
269
270} // namespace casacore
271
272#endif
MDoppler(const Quantity &dt, const MDoppler::Ref &rf)
static void assure(const Measure &in)
virtual Bool setOffset(const Measure &in)
Set the offset in the reference (False if non-matching Measure).
virtual const String & getDefaultType() const
Get the default reference type.
MDoppler(const Quantity &dt)
MDoppler(const Quantity &dt, MDoppler::Types rf)
MDoppler(const MVDoppler &dt, const MDoppler::Ref &rf)
Quantity get(const Unit &un) const
Get in specified units.
MCDoppler MCType
Measure conversion routines for this class (i.e.
Definition MDoppler.h:165
static const String & showMe()
MDoppler()
Tip: In the following constructors and other functions, all MeasRef can be replaced with simple Measu...
static Bool getType(MDoppler::Types &tp, const String &in)
Translate string to reference code.
MVDoppler MVType
Measure value container for this class (i.e.
Definition MDoppler.h:163
virtual void checkTypes() const
Check if all internal tables of types (both enum and String) are complete and correct.
MeasConvert< MDoppler > Convert
Measure Convert (i.e.
Definition MDoppler.h:169
static MDoppler::Types castType(uInt tp)
Translate reference code.
static const String * allMyTypes(Int &nall, Int &nextra, const uInt *&typ)
MDoppler(const MVDoppler &dt, MDoppler::Types rf)
virtual const String & tellMe() const
Tell me your type.
static void checkMyTypes()
Quantum< Vector< Double > > shiftFrequency(const Quantum< Vector< Double > > &freq) const
MDoppler(const MeasValue *dt)
static const String & showType(MDoppler::Types tp)
ScalarMeasColumn< MDoppler > ScalarColumn
Measure table Columns (e.g., MDoppler::ScalarColumn).
Definition MDoppler.h:171
Types
Types of known MDopplers Warning: The order defines the order in the translation matrix FromTo in th...
Definition MDoppler.h:149
Vector< Double > shiftFrequency(const Vector< Double > &freq) const
Shift the input frequencies to the output frequencies.
MeasRef< MDoppler > Ref
Measure reference (i.e.
Definition MDoppler.h:167
MDoppler(const MVDoppler &dt)
Create from data and reference.
Bool giveMe(MDoppler::Ref &mr, const String &in)
MDoppler(const Measure *dt)
ArrayMeasColumn< MDoppler > ArrayColumn
Definition MDoppler.h:172
virtual Bool setRefString(const String &in)
Set the reference type to the specified String.
virtual Measure * clone() const
Make a copy.
static const String & showType(uInt tp)
virtual String getRefString() const
Get the reference type (for records, including codes like R_).
virtual const String * allTypes(Int &nall, Int &nextra, const uInt *&typ) const
Get a list of all known reference codes.
String: the storage and methods of handling collections of characters.
Definition String.h:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
Quantum< Double > Quantity
Definition Quantum.h:40