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