casacore
Loading...
Searching...
No Matches
VelocityMachine.h
Go to the documentation of this file.
1//# VelocityMachine.h: Converts between velocities and frequencies
2//# Copyright (C) 1998,1999,2000
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_VELOCITYMACHINE_H
27#define MEASURES_VELOCITYMACHINE_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/Quanta/Unit.h>
32#include <casacore/casa/Quanta/Quantum.h>
33#include <casacore/measures/Measures/MCFrequency.h>
34#include <casacore/measures/Measures/MCDoppler.h>
35#include <casacore/measures/Measures/MeasConvert.h>
36#include <casacore/casa/Arrays/ArrayFwd.h>
37
38namespace casacore { //# NAMESPACE CASACORE - BEGIN
39
40//# Forward Declarations
41class MeasFrame;
42
43// <summary> Converts between velocities and frequencies </summary>
44
45// <use visibility=export>
46
47// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tVelocityMachine.cc" demos="">
48// </reviewed>
49
50// <prerequisite>
51// <li> <linkto module=Measures>Measures</linkto> module
52// <li> <linkto class=MFrequency>MFrequency</linkto> class
53// <li> <linkto class=MDoppler>MDoppler</linkto> class
54// </prerequisite>
55//
56// <etymology>
57// From Velocity and machinery
58// </etymology>
59//
60// <synopsis>
61// The construction of a VelocityMachine class object creates a machine that
62// can calculate the velocity from a frequency, or vice versa, a frequency
63// from a velocity.
64//
65// To be able to do the conversions, the machine (or rather its constructors)
66// needs to know the following information:
67// <ul>
68// <li> Reference for frequencies. It should contain at least the reference
69// code, to specify what type of frequency we are talking about
70// (e.g. MFrequency::LSRK). The reference could also contain an offset.
71// In that case all
72// input frequencies are considered to be relative to this offset; all
73// output frequencies will have this offset removed.<br>
74// The reference can optionally contain a MeasFrame (which
75// specifies where, when and in which direction you are
76// observing). This frame is necessary if, in addition to
77// converting between velocity and frequency, you also want to
78// convert between different types (e.g. given an 'LSRK' velocity,
79// you want to know the 'TOPO' frequency), and if the offset is
80// in a different reference type. However, the MeasFrame
81// can also be given explicitly in the machine constructor as an
82// optional argument.
83// <li> Preferred 'frequency' units (e.g. GHz, or cm). These units are used
84// to output a frequency, or if an input frequency is given as a
85// simple double, these units will be implicitly assumed.
86// <li> Reference for velocity. It should contain at least the reference
87// code, to specify what type of velocity we are talking about
88// (e.g. MDoppler::OPTICAL, note
89// that MDoppler::BETA is the 'true' velocity).
90// The reference could also contain an offset. In that case all
91// input velocities are considered to be relative to this offset; all
92// output velocities will have this offset removed.
93// <li> Preferred velocity units (e.g. AU/a). These units are used
94// to output a velocity, or if an input velocity is given as a
95// simple double, these units will be implicitly assumed.
96// <li> The rest frequency to be used for converting between frequency and
97// velocity. It is given as an MVFrequency.
98// </ul>
99// To be able to convert between different types (say a velocity
100// referenced with respect to the 'LSRK', and a frequency referenced
101// with respect to 'TOPO', the following additional, optional
102// information can be included explicitly in the constructors:
103// <ul>
104// <li> A reference code for the velocity (given as a frequency reference
105// code (e.g. MFrequency::TOPO)). If given, all input frequencies
106// will be converted to the frequency belonging to this reference
107// code; all output frequencies will be converted from this
108// assumed reference to the specified Frequency reference. The
109// net effect is that all velocities will be assumed to refer to
110// this reference code. Note that in most cases the conversion
111// will have to know the 'when, where, which direction'
112// environment (the 'frame' -- a MeasFrame). This can be given
113// either implicitly in the 'reference for the frequency', or
114// explicitly (see next dot point).
115// <li> A frame (MeasFrame). This frame will be used in any conversion
116// between reference frames. If not given explicitly here, it will
117// tacitly be assumed that if a frame is necessary, it has been specified
118// in the frequency reference.
119// </ul>
120// Once the machine has been set up, operator() can be used to convert
121// between velocities and frequencies if the input argument type (e.g. an
122// MVFrequency) can be deduced. In other cases makeFrequency() or
123// makeVelocity() should be used (e.g. if the argument type is a
124// simple Double).
125// </synopsis>
126//
127// <example>
128// <srcblock>
129// // Define a time/position frame
130// MEpoch epo(MVEpoch(MVTime(98,5,16,0.5).day()));
131// MPosition pos;
132// MeasTable::Observatory(pos, "ATCA");
133// MeasFrame frame(epo, pos);
134// //
135// // Note that e.g. the time in the frame can be changed later
136// // Specify the frequency reference
137// MFrequency::Ref fr(MFrequency::LSRK);
138// //
139// // Specify the velocity reference
140// MDoppler::Ref vr(MDoppler::OPT);
141// //
142// // Specify the default units
143// Unit fu("eV");
144// Unit vu("AU/a");
145// //
146// // Get the rest frequency
147// MVFrequency rfrq(QC::HI);
148// //
149// // Set up a machine (no conversion of reference frame)
150// VelocityMachine exec(fr, fu, rfrq, vr, vu, frame);
151// //
152// // or as (with conversion of reference frame it could have been)
153// // VelocityMachine exec(fr, fu, rfrq, vr, vu, MFrequency::TOPO, frame);
154// // Given a current observational frequency of 5.87432837e-06 eV
155// // its velocity will be (in AU/yr)
156// cout << "Velocity: " << exec.makeVelocity(5.87432837e-06) << endl;
157// //
158// // Introducing an offset
159// MFrequency foff(MVFrequency(Quantity(5.87432837e-06, "eV")),
160// MFrequency::LSRK);
161// //
162// // and setting it in the reference, and regenerating machine:
163// fr.set(foff);
164// exec.set(fr);
165// //
166// // the following will give the same result:
167// cout << "Velocity: " << exec.makeVelocity(0.0) << endl;
168//
169// </srcblock>
170// See the test program for more examples
171// </example>
172//
173// <motivation>
174// To aid in converting series of frequencies and velocities
175// </motivation>
176//
177// <todo asof="1998/06/02">
178// <li> Nothing I know of
179// </todo>
180
182public:
183 //# Constructors
184 // Construct a machine from the input values (no frame conversion, implicit
185 // frame if necessary)
186 VelocityMachine(const MFrequency::Ref &freqRef, const Unit &freqUnits,
187 const MVFrequency &restFreq,
188 const MDoppler::Ref &velRef, const Unit &velUnits);
189
190 // Construct a machine from the input values (no frame conversion, explicit
191 // frame will be added to freqRef)
192 VelocityMachine(const MFrequency::Ref &freqRef, const Unit &freqUnits,
193 const MVFrequency &restFreq,
194 const MDoppler::Ref &velRef, const Unit &velUnits,
195 const MeasFrame &frame);
196
197 // Construct a machine from the input values (frame conversion, implicit
198 // frame assumed if necessary) with explicit velocity reference frame
199 // specified.
200 VelocityMachine(const MFrequency::Ref &freqRef, const Unit &freqUnits,
201 const MVFrequency &restFreq,
202 const MFrequency::Types &convertRef,
203 const MDoppler::Ref &velRef, const Unit &velUnits);
204
205 // Construct a machine from the input values (frame conversion, explicit
206 // frame) with explicit velocity reference frame
207 // specified, and added to freqref.
208 VelocityMachine(const MFrequency::Ref &freqref, const Unit &freqUnits,
209 const MVFrequency &restFreq,
210 const MFrequency::Types &convertRef,
211 const MDoppler::Ref &velRef, const Unit &velUnits,
212 const MeasFrame &frame);
213
214 // Copy constructor (copy semantics)
216
217 // Copy assignment (copy semantics)
219
220 //# Destructor
222
223 //# Operators
224 // Return velocity if frequency given, or a frequency if a velocity is given
225 // <group>
233 // </group>
234
235 //# Member functions
236 // Set or reset the specified part of the machine. The machinery will be
237 // reset to reflect the changes made.
238 // <group>
239 // Sets a new frequency reference. Note that if an explicit frame has been
240 // used in earlier constructors, the frame should again be set explicitly
241 // with set(MeasFrame).
242 void set(const MFrequency::Ref &in);
243 void set(const Unit &in);
244 // Sets the rest frequency
245 void set(const MVFrequency &in);
246 void set(const MFrequency::Types &in);
247 void set(const MDoppler::Ref &in);
248 // Sets the MeasFrame to be used in conversions.
249 void set(const MeasFrame &in);
250 // </group>
251
252 // Get the general information used in the machine (shadows the sets above
253 // and the constructor arguments. The MeasFrame should be explicitly
254 // asked for from the frequency reference by the user
255 // <group>
257 const Unit &getFrequencyUnits() const;
259 const Unit &getDopplerUnits() const;
262 // </group>
263 // Recalculate the machinery from the original inputs. Note that in all
264 // normal circumstances this function does not have to be used (the set()
265 // methods will do it automatically). At the moment I cannot think of
266 // any circumstance it should be used explicitly.
268
269private:
270
271 //# Constructors
272 // Construct an empty machine (not implemented)
274
275 //# Data
276 // Frequency reference
278 // Frequency units
279 // <group>
281 // </group>
282 // Rest frequency
284 // Velocity frame
286 // Velocity reference
288 // Velocity units
289 // <group>
292 // </group>
293 // Frequency conversion forward
295 // Frequency conversion backward
297 // Velocity conversion forward
299 // Velocity conversion backward
301 // Result
302 // <group>
307 // </group>
308
309 //# Private Member Functions
310 // Initialise machinery
311 void init();
312 // Copy data members
313 void copy(const VelocityMachine &other);
314};
315
316
317} //# NAMESPACE CASACORE - END
318
319#endif
Types
Types of known MFrequencies Warning: The order defines the order in the translation matrix FromTo in...
Definition MFrequency.h:173
VelocityMachine(const MFrequency::Ref &freqref, const Unit &freqUnits, const MVFrequency &restFreq, const MFrequency::Types &convertRef, const MDoppler::Ref &velRef, const Unit &velUnits, const MeasFrame &frame)
Construct a machine from the input values (frame conversion, explicit frame) with explicit velocity r...
const MFrequency::Types & getConversionReference() const
MDoppler::Convert cvvo_p
Velocity conversion forward.
const Quantum< Double > & operator()(const Quantum< Double > &in)
MVFrequency rest_p
Rest frequency.
void set(const MFrequency::Ref &in)
Set or reset the specified part of the machine.
VelocityMachine()
Construct an empty machine (not implemented)
VelocityMachine(const MFrequency::Ref &freqRef, const Unit &freqUnits, const MVFrequency &restFreq, const MFrequency::Types &convertRef, const MDoppler::Ref &velRef, const Unit &velUnits)
Construct a machine from the input values (frame conversion, implicit frame assumed if necessary) wit...
const MVFrequency & getRestFrequency() const
const Quantum< Double > & operator()(const MVDoppler &in)
Unit fun_p
Frequency units.
const Unit & getFrequencyUnits() const
MFrequency::Types vfm_p
Velocity frame.
const Quantum< Double > & operator()(const MVFrequency &in)
Return velocity if frequency given, or a frequency if a velocity is given.
void set(const MDoppler::Ref &in)
void set(const Unit &in)
VelocityMachine(const MFrequency::Ref &freqRef, const Unit &freqUnits, const MVFrequency &restFreq, const MDoppler::Ref &velRef, const Unit &velUnits, const MeasFrame &frame)
Construct a machine from the input values (no frame conversion, explicit frame will be added to freqR...
MFrequency::Convert cvvf_p
Frequency conversion backward.
void init()
Initialise machinery.
const Quantum< Double > & makeFrequency(Double in)
void set(const MFrequency::Types &in)
const Quantum< Double > & makeVelocity(Double in)
Quantum< Vector< Double > > vresf_p
const Unit & getDopplerUnits() const
const MDoppler::Ref & getDopplerReference() const
Unit vun_p
Velocity units.
VelocityMachine(const VelocityMachine &other)
Copy constructor (copy semantics)
const Quantum< Vector< Double > > & makeVelocity(const Vector< Double > &in)
VelocityMachine(const MFrequency::Ref &freqRef, const Unit &freqUnits, const MVFrequency &restFreq, const MDoppler::Ref &velRef, const Unit &velUnits)
Construct a machine from the input values (no frame conversion, implicit frame if necessary)
const MFrequency::Ref & getFrequencyReference() const
Get the general information used in the machine (shadows the sets above and the constructor arguments...
void set(const MVFrequency &in)
Sets the rest frequency.
void copy(const VelocityMachine &other)
Copy data members.
MFrequency::Convert cvfv_p
Frequency conversion forward.
Quantum< Vector< Double > > vresv_p
MDoppler::Convert cvov_p
Velocity conversion backward.
MDoppler::Ref vref_p
Velocity reference.
const Quantum< Vector< Double > > & makeFrequency(const Vector< Double > &in)
void set(const MeasFrame &in)
Sets the MeasFrame to be used in conversions.
void reCalculate()
Recalculate the machinery from the original inputs.
VelocityMachine & operator=(const VelocityMachine &other)
Copy assignment (copy semantics)
Quantum< Double > resv_p
Result.
MFrequency::Ref fref_p
Frequency reference.
this file contains all the compiler specific defines
Definition mainpage.dox:28
double Double
Definition aipstype.h:53