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