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/casa/Arrays/ArrayFwd.h>
35 #include <casacore/measures/Measures/MeasBase.h>
36 #include <casacore/measures/Measures/MeasRef.h>
37 #include <casacore/casa/Quanta/MVDoppler.h>
38 
39 namespace casacore { //# NAMESPACE CASACORE - BEGIN
40 
41 //# Forward Declarations
42 class MDoppler;
43 class MCDoppler;
44 template <class M> class MeasConvert;
45 template <class M> class ArrayMeasColumn;
46 template <class M> class ScalarMeasColumn;
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 
173  //# Constructors
174  // <note role=tip> In the following constructors and other functions, all
175  // <em>MeasRef</em> can be replaced with simple <src>Measure::TYPE</src>
176  // where no offsets or frames are needed in the reference. </note>
177  // Default constructor; generates a zero rest Doppler
179  // Create from data and reference
180  // <group>
181  MDoppler(const MVDoppler &dt);
182  MDoppler(const MVDoppler &dt, const MDoppler::Ref &rf);
184  MDoppler(const Quantity &dt);
185  MDoppler(const Quantity &dt, const MDoppler::Ref &rf);
187  MDoppler(const Measure *dt);
188  MDoppler(const MeasValue *dt);
189  // </group>
190 
191  //# Destructor
192  virtual ~MDoppler();
193 
194  //# Operators
195 
196  //# General Member Functions
197  // Tell me your type
198  // <group>
199  virtual const String &tellMe() const;
200  static const String &showMe();
201  static void assure(const Measure &in);
202  // </group>
203  // Translate reference code. The uInt version has a check for valid codes
204  // (i.e. it is a safe cast).
205  // <thrown>
206  // <li> AipsError in the uInt interface if illegal code given
207  // </thrown>
208  // <group>
210  static const String &showType(MDoppler::Types tp);
211  static const String &showType(uInt tp);
212  // </group>
213  // Translate string to reference code
214  // <group>
215  static Bool getType(MDoppler::Types &tp, const String &in);
216  Bool giveMe(MDoppler::Ref &mr, const String &in);
217  // </group>
218  // Set the offset in the reference (False if non-matching Measure)
219  virtual Bool setOffset(const Measure &in);
220  // Set the reference type to the specified String. False if illegal
221  // string, reference set to DEFAULT.
222  virtual Bool setRefString(const String &in);
223  // Get the default reference type
224  virtual const String &getDefaultType() const;
225  // Get a list of all known reference codes. nall returns the number in list,
226  // nextra the number of specials (like planets) that should be at
227  // end of list). typ returns the list of corresponding types.
228  // <group>
229  virtual const String* allTypes(Int &nall, Int &nextra,
230  const uInt *&typ) const;
231  static const String* allMyTypes(Int &nall, Int &nextra,
232  const uInt *&typ);
233  // </group>
234  // Check if all internal tables of types (both enum and String) are
235  // complete and correct. This function is called automatically if and when
236  // necessary.
237  // <thrown>
238  // <li> AipsError if a (programming) error in the types.
239  // </thrown>
240  // <group>
241  virtual void checkTypes() const;
242  static void checkMyTypes();
243  // </group>
244  // Get the reference type (for records, including codes like R_)
245  virtual String getRefString() const;
246 
247  // Get in specified units
248  Quantity get(const Unit &un) const;
249 
250  // Shift the input frequencies to the output frequencies. In the case of
251  // simple Double inputs, it is assumed that the values are linearly dependent
252  // on frequency. I.e. frequencies given as wavelength or time cannot be used.
253  // <group>
256  shiftFrequency(const Quantum<Vector<Double> > &freq) const;
257  // </group>
258 
259  // Make a copy
260  // <group>
261  virtual Measure *clone() const;
262  // </group>
263 
264  private:
265  //# Enumerations
266 
267  //# Data
268 
269  //# Member functions
270 
271 
272 };
273 
274 
275 } //# NAMESPACE CASACORE - END
276 
277 #endif
static const String & showType(uInt tp)
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.
static const String & showMe()
MDoppler(const Quantity &dt)
virtual const String & tellMe() const
Tell me your type.
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:164
virtual Measure * clone() const
Make a copy.
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:162
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:168
static MDoppler::Types castType(uInt tp)
Translate reference code.
static const String & showType(MDoppler::Types tp)
MDoppler(const MVDoppler &dt, MDoppler::Types rf)
static void checkMyTypes()
Vector< Double > shiftFrequency(const Vector< Double > &freq) const
Shift the input frequencies to the output frequencies.
MDoppler(const MeasValue *dt)
ScalarMeasColumn< MDoppler > ScalarColumn
Measure table Columns (e.g., MDoppler::ScalarColumn)
Definition: MDoppler.h:170
Types
Types of known MDopplers Warning: The order defines the order in the translation matrix FromTo in th...
Definition: MDoppler.h:149
MeasRef< MDoppler > Ref
Measure reference (i.e.
Definition: MDoppler.h:166
MDoppler(const MVDoppler &dt)
Create from data and reference.
Bool giveMe(MDoppler::Ref &mr, const String &in)
MDoppler(const Measure *dt)
static const String * allMyTypes(Int &nall, Int &nextra, const uInt *&typ)
ArrayMeasColumn< MDoppler > ArrayColumn
Definition: MDoppler.h:171
virtual Bool setRefString(const String &in)
Set the reference type to the specified String.
virtual String getRefString() const
Get the reference type (for records, including codes like R_)
Quantum< Vector< Double > > shiftFrequency(const Quantum< Vector< Double > > &freq) const
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:225
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51
int Int
Definition: aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42