casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
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 
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
178  MDoppler();
179  // Create from data and reference
180  // <group>
181  MDoppler(const MVDoppler &dt);
182  MDoppler(const MVDoppler &dt, const MDoppler::Ref &rf);
183  MDoppler(const MVDoppler &dt, MDoppler::Types rf);
184  MDoppler(const Quantity &dt);
185  MDoppler(const Quantity &dt, const MDoppler::Ref &rf);
186  MDoppler(const Quantity &dt, MDoppler::Types 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  virtual uInt type() const;
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>
210  static MDoppler::Types castType(uInt tp);
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);
217  Bool giveMe(MDoppler::Ref &mr, 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,
231  const uInt *&typ) const;
232  static const String* allMyTypes(Int &nall, Int &nextra,
233  const uInt *&typ);
234  // </group>
235  // Check if all internal tables of types (both enum and String) are
236  // complete and correct. This function is called automatically if and when
237  // necessary.
238  // <thrown>
239  // <li> AipsError if a (programming) error in the types.
240  // </thrown>
241  // <group>
242  virtual void checkTypes() const;
243  static void checkMyTypes();
244  // </group>
245  // Get the reference type (for records, including codes like R_)
246  virtual String getRefString() const;
247  // Get my type (as Register)
248  static uInt myType();
249 
250  // Get in specified units
251  Quantity get(const Unit &un) const;
252 
253  // Shift the input frequencies to the output frequencies. In the case of
254  // simple Double inputs, it is assumed that the values are linearly dependent
255  // on frequency. I.e. frequencies given as wavelength or time cannot be used.
256  // <group>
257  Vector<Double> shiftFrequency(const Vector<Double> &freq) const;
259  shiftFrequency(const Quantum<Vector<Double> > &freq) const;
260  // </group>
261 
262  // Make a copy
263  // <group>
264  virtual Measure *clone() const;
265  // </group>
266 
267  private:
268  //# Enumerations
269 
270  //# Data
271 
272  //# Member functions
273 
274 
275 };
276 
277 
278 } //# NAMESPACE CASACORE - END
279 
280 #endif
int Int
Definition: aipstype.h:50
MDoppler conversion routines.
Definition: MCDoppler.h:95
Conversion of Measures.
Definition: MDirection.h:43
std::vector< double > Vector
Definition: ds9context.h:24
virtual String getRefString() const
Get the reference type (for records, including codes like R_)
virtual void checkTypes() const
Check if all internal tables of types (both enum and String) are complete and correct.
Internal value for MDoppler.
Definition: MVDoppler.h:91
virtual const String & getDefaultType() const
Get the default reference type.
static void assure(const Measure &in)
A Measure: Doppler shift.
Definition: MDoppler.h:134
Physical quantities within reference frame.
Definition: Measure.h:235
ScalarMeasColumn< MDoppler > ScalarColumn
Measure table Columns (e.g., MDoppler::ScalarColumn)
Definition: MDoppler.h:170
virtual const String * allTypes(Int &nall, Int &nextra, const uInt *&typ) const
Get a list of all known reference codes.
Base class for all measures.
Definition: MeasBase.h:75
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
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
virtual Measure * clone() const
Make a copy.
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
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
Types
Each derived class should have a Types enumeration, specifying the recognised frame types...
Definition: Measure.h:254
virtual uInt type() const
Get the type (== Register() of derived Measure (faster than Strings) All should have: static uInt myT...
static const String & showMe()
virtual const String & tellMe() const
Tell me your type.
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.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Bool giveMe(MDoppler::Ref &mr, const String &in)
MCDoppler MCType
Measure conversion routines for this class (i.e.
Definition: MDoppler.h:164
Vector< Double > shiftFrequency(const Vector< Double > &freq) const
Shift the input frequencies to the output frequencies.
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