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
182 public:
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, const MDoppler::Ref &velRef, const Unit &velUnits);
188
189 // Construct a machine from the input values (no frame conversion, explicit
190 // frame will be added to freqRef)
191 VelocityMachine(const MFrequency::Ref &freqRef, const Unit &freqUnits,
192 const MVFrequency &restFreq, const MDoppler::Ref &velRef, const Unit &velUnits,
193 const MeasFrame &frame);
194
195 // Construct a machine from the input values (frame conversion, implicit
196 // frame assumed if necessary) with explicit velocity reference frame
197 // specified.
198 VelocityMachine(const MFrequency::Ref &freqRef, const Unit &freqUnits,
199 const MVFrequency &restFreq, const MFrequency::Types &convertRef,
200 const MDoppler::Ref &velRef, const Unit &velUnits);
201
202 // Construct a machine from the input values (frame conversion, explicit
203 // frame) with explicit velocity reference frame
204 // specified, and added to freqref.
205 VelocityMachine(const MFrequency::Ref &freqref, const Unit &freqUnits,
206 const MVFrequency &restFreq, const MFrequency::Types &convertRef,
207 const MDoppler::Ref &velRef, const Unit &velUnits, const MeasFrame &frame);
208
209 // Copy constructor (copy semantics)
211
212 // Copy assignment (copy semantics)
214
215 // # Destructor
217
218 // # Operators
219 // Return velocity if frequency given, or a frequency if a velocity is given
220 // <group>
228 // </group>
229
230 // # Member functions
231 // Set or reset the specified part of the machine. The machinery will be
232 // reset to reflect the changes made.
233 // <group>
234 // Sets a new frequency reference. Note that if an explicit frame has been
235 // used in earlier constructors, the frame should again be set explicitly
236 // with set(MeasFrame).
237 void set(const MFrequency::Ref &in);
238 void set(const Unit &in);
239 // Sets the rest frequency
240 void set(const MVFrequency &in);
241 void set(const MFrequency::Types &in);
242 void set(const MDoppler::Ref &in);
243 // Sets the MeasFrame to be used in conversions.
244 void set(const MeasFrame &in);
245 // </group>
246
247 // Get the general information used in the machine (shadows the sets above
248 // and the constructor arguments. The MeasFrame should be explicitly
249 // asked for from the frequency reference by the user
250 // <group>
252 const Unit &getFrequencyUnits() const;
254 const Unit &getDopplerUnits() const;
257 // </group>
258 // Recalculate the machinery from the original inputs. Note that in all
259 // normal circumstances this function does not have to be used (the set()
260 // methods will do it automatically). At the moment I cannot think of
261 // any circumstance it should be used explicitly.
263
264 private:
265 // # Constructors
266 // Construct an empty machine (not implemented)
268
269 // # Data
270 // Frequency reference
272 // Frequency units
273 // <group>
275 // </group>
276 // Rest frequency
278 // Velocity frame
280 // Velocity reference
282 // Velocity units
283 // <group>
286 // </group>
287 // Frequency conversion forward
289 // Frequency conversion backward
291 // Velocity conversion forward
293 // Velocity conversion backward
295 // Result
296 // <group>
301 // </group>
302
303 // # Private Member Functions
304 // Initialise machinery
305 void init();
306 // Copy data members
307 void copy(const VelocityMachine &other);
308};
309
310} // namespace casacore
311
312#endif
MeasConvert< MDoppler > Convert
Measure Convert (i.e.
Definition MDoppler.h:169
MeasRef< MDoppler > Ref
Measure reference (i.e.
Definition MDoppler.h:167
MeasConvert< MFrequency > Convert
Measure conversion use (i.e.
Definition MFrequency.h:204
Types
Types of known MFrequencies Warning: The order defines the order in the translation matrix FromTo in...
Definition MFrequency.h:175
MeasRef< MFrequency > Ref
Measure reference (i.e.
Definition MFrequency.h:202
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.
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
double Double
Definition aipstype.h:53