Loading...
Searching...
No Matches
casacore::VelocityMachine Class Reference
measures package (libcasa_measures) » Measures_module

More...

`#include <VelocityMachine.h>`

## Public Member Functions

| 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).
| 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 freqRef).
| 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) with explicit velocity reference frame specified.
| 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 reference frame specified, and added to freqref.
| VelocityMachine (const VelocityMachine &other)
| Copy constructor (copy semantics).
VelocityMachine & | operator= (const VelocityMachine &other)
| Copy assignment (copy semantics).
| ~VelocityMachine ()
const Quantum< Double > & | operator() (const MVFrequency &in)
| Return velocity if frequency given, or a frequency if a velocity is given.
const Quantum< Double > & | operator() (const MVDoppler &in)
const Quantum< Double > & | operator() (const Quantum< Double > &in)
const Quantum< Double > & | makeVelocity (Double in)
const Quantum< Double > & | makeFrequency (Double in)
const Quantum< Vector< Double > > & | makeVelocity (const Vector< Double > &in)
const Quantum< Vector< Double > > & | makeFrequency (const Vector< Double > &in)
void | set (const MFrequency::Ref &in)
| Set or reset the specified part of the machine.
void | set (const Unit &in)
void | set (const MVFrequency &in)
| Sets the rest frequency.
void | set (const MFrequency::Types &in)
void | set (const MDoppler::Ref &in)
void | set (const MeasFrame &in)
| Sets the MeasFrame to be used in conversions.
const MFrequency::Ref & | getFrequencyReference () const
| Get the general information used in the machine (shadows the sets above and the constructor arguments.
const Unit & | getFrequencyUnits () const
const MDoppler::Ref & | getDopplerReference () const
const Unit & | getDopplerUnits () const
const MVFrequency & | getRestFrequency () const
const MFrequency::Types & | getConversionReference () const
void | reCalculate ()
| Recalculate the machinery from the original inputs.

## Private Member Functions

| VelocityMachine ()
| Construct an empty machine (not implemented).
void | init ()
| Initialise machinery.
void | copy (const VelocityMachine &other)
| Copy data members.

## Private Attributes

MFrequency::Ref | fref_p
| Frequency reference.
Unit | fun_p
| Frequency units.
MVFrequency | rest_p
| Rest frequency.
MFrequency::Types | vfm_p
| Velocity frame.
MDoppler::Ref | vref_p
| Velocity reference.
Unit | vun_p
| Velocity units.
Double | vfac_p
MFrequency::Convert | cvfv_p
| Frequency conversion forward.
MFrequency::Convert | cvvf_p
| Frequency conversion backward.
MDoppler::Convert | cvvo_p
| Velocity conversion forward.
MDoppler::Convert | cvov_p
| Velocity conversion backward.
Quantum< Double > | resv_p
| Result.
Quantum< Double > | resf_p
Quantum< Vector< Double > > | vresv_p
Quantum< Vector< Double > > | vresf_p

## Detailed Description

Converts between velocities and frequencies

### Intended use:

Public interface

### Review Status

Reviewed By:
  UNKNOWN
Date Reviewed:
  before2004/08/25
Test programs:
  tVelocityMachine

### Prerequisite

- Measures module
- MFrequency class
- MDoppler class

### Etymology

From Velocity and machinery

### Synopsis

The construction of a VelocityMachine class object creates a machine that can calculate the velocity from a frequency, or vice versa, a frequency from a velocity.

To be able to do the conversions, the machine (or rather its constructors) needs to know the following information:

- Reference for frequencies. It should contain at least the reference code, to specify what type of frequency we are talking about (e.g. MFrequency::LSRK). The reference could also contain an offset. In that case all input frequencies are considered to be relative to this offset; all output frequencies will have this offset removed.
  The reference can optionally contain a MeasFrame (which specifies where, when and in which direction you are observing). This frame is necessary if, in addition to converting between velocity and frequency, you also want to convert between different types (e.g. given an 'LSRK' velocity, you want to know the 'TOPO' frequency), and if the offset is in a different reference type. However, the MeasFrame can also be given explicitly in the machine constructor as an optional argument.
- Preferred 'frequency' units (e.g. GHz, or cm). These units are used to output a frequency, or if an input frequency is given as a simple double, these units will be implicitly assumed.
- Reference for velocity. It should contain at least the reference code, to specify what type of velocity we are talking about (e.g. MDoppler::OPTICAL, note that MDoppler::BETA is the 'true' velocity). The reference could also contain an offset. In that case all input velocities are considered to be relative to this offset; all output velocities will have this offset removed.
- Preferred velocity units (e.g. AU/a). These units are used to output a velocity, or if an input velocity is given as a simple double, these units will be implicitly assumed.
- The rest frequency to be used for converting between frequency and velocity. It is given as an MVFrequency.

To be able to convert between different types (say a velocity referenced with respect to the 'LSRK', and a frequency referenced with respect to 'TOPO', the following additional, optional information can be included explicitly in the constructors:

- A reference code for the velocity (given as a frequency reference code (e.g. MFrequency::TOPO)). If given, all input frequencies will be converted to the frequency belonging to this reference code; all output frequencies will be converted from this assumed reference to the specified Frequency reference. The net effect is that all velocities will be assumed to refer to this reference code. Note that in most cases the conversion will have to know the 'when, where, which direction' environment (the 'frame' – a MeasFrame). This can be given either implicitly in the 'reference for the frequency', or explicitly (see next dot point).
- A frame (MeasFrame). This frame will be used in any conversion between reference frames. If not given explicitly here, it will tacitly be assumed that if a frame is necessary, it has been specified in the frequency reference.

Once the machine has been set up, operator() can be used to convert between velocities and frequencies if the input argument type (e.g. an MVFrequency) can be deduced. In other cases makeFrequency() or makeVelocity() should be used (e.g. if the argument type is a simple Double).

### Example

// Define a time/position frame
MEpoch epo(MVEpoch(MVTime(98,5,16,0.5).day()));
MPosition pos;
MeasTable::Observatory(pos, "ATCA");
MeasFrame frame(epo, pos);
//
// Note that e.g. the time in the frame can be changed later
// Specify the frequency reference
MFrequency::Ref fr(MFrequency::LSRK);
//
// Specify the velocity reference
MDoppler::Ref vr(MDoppler::OPT);
//
// Specify the default units
Unit fu("eV");
Unit vu("AU/a");
//
// Get the rest frequency
MVFrequency rfrq(QC::HI);
//
// Set up a machine (no conversion of reference frame)
VelocityMachine exec(fr, fu, rfrq, vr, vu, frame);
//
// or as (with conversion of reference frame it could have been)
// VelocityMachine exec(fr, fu, rfrq, vr, vu, MFrequency::TOPO, frame);
// Given a current observational frequency of 5.87432837e-06 eV
// its velocity will be (in AU/yr)
cout << "Velocity: " << exec.makeVelocity(5.87432837e-06) << endl;
//
// Introducing an offset
MFrequency foff(MVFrequency(Quantity(5.87432837e-06, "eV")),
MFrequency::LSRK);
//
// and setting it in the reference, and regenerating machine:
fr.set(foff);
exec.set(fr);
//
// the following will give the same result:
cout << "Velocity: " << exec.makeVelocity(0.0) << endl;
casacore::MDoppler::Ref
MeasRef< MDoppler > Ref
Measure reference (i.e.
Definition MDoppler.h:163
casacore::MEpoch
Definition MEpoch.h:101
casacore::MFrequency
Definition MFrequency.h:158
casacore::MFrequency::LSRK
@ LSRK
Definition MFrequency.h:175
casacore::MFrequency::Ref
MeasRef< MFrequency > Ref
Measure reference (i.e.
Definition MFrequency.h:199
casacore::MPosition
Definition MPosition.h:76
casacore::MVEpoch
Definition MVEpoch.h:87
casacore::MVFrequency
Definition MVFrequency.h:95
casacore::MVTime
Definition MVTime.h:268
casacore::MeasFrame
Definition MeasFrame.h:151
casacore::MeasTable::Observatory
static Bool Observatory(MPosition &obs, const String &nam)
Get position of observatory nam (False if not present).
casacore::QC::HI
static const Quantum< Double > & HI()
HI line.
Definition QC.h:186
casacore::Unit
Definition Unit.h:187
casacore::VelocityMachine::VelocityMachine
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).
casacore::day
TableExprNode day(const TableExprNode &node)
Definition ExprNode.h:1527
casacore::Quantity
Quantum< Double > Quantity
Definition Quantum.h:39

See the test program for more examples

### Motivation

To aid in converting series of frequencies and velocities

### To Do

- Nothing I know of

Definition at line 181 of file VelocityMachine.h.

## Constructor & Destructor Documentation

## VelocityMachine() [1/6]

casacore::VelocityMachine::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).

Referenced by copy(), operator=(), and VelocityMachine().

## VelocityMachine() [2/6]

casacore::VelocityMachine::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 freqRef).

## VelocityMachine() [3/6]

casacore::VelocityMachine::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) with explicit velocity reference frame specified.

## VelocityMachine() [4/6]

casacore::VelocityMachine::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 reference frame specified, and added to freqref.

## VelocityMachine() [5/6]

casacore::VelocityMachine::VelocityMachine | ( | const VelocityMachine & | other | ) |

Copy constructor (copy semantics).

References VelocityMachine().

## ~VelocityMachine()

casacore::VelocityMachine::~VelocityMachine | ( |  | ) |

## VelocityMachine() [6/6]

casacore::VelocityMachine::VelocityMachine | ( |  | ) |

private

Construct an empty machine (not implemented).

## Member Function Documentation

## copy()

void casacore::VelocityMachine::copy | ( | const VelocityMachine & | other | ) |

private

Copy data members.

References VelocityMachine().

## getConversionReference()

const MFrequency::Types & casacore::VelocityMachine::getConversionReference | ( |  | ) | const

## getDopplerReference()

const MDoppler::Ref & casacore::VelocityMachine::getDopplerReference | ( |  | ) | const

## getDopplerUnits()

const Unit & casacore::VelocityMachine::getDopplerUnits | ( |  | ) | const

## getFrequencyReference()

const MFrequency::Ref & casacore::VelocityMachine::getFrequencyReference | ( |  | ) | const

Get the general information used in the machine (shadows the sets above and the constructor arguments.

The MeasFrame should be explicitly asked for from the frequency reference by the user

## getFrequencyUnits()

const Unit & casacore::VelocityMachine::getFrequencyUnits | ( |  | ) | const

## getRestFrequency()

const MVFrequency & casacore::VelocityMachine::getRestFrequency | ( |  | ) | const

## init()

void casacore::VelocityMachine::init | ( |  | ) |

private

Initialise machinery.

## makeFrequency() [1/2]

const Quantum< Vector< Double > > & casacore::VelocityMachine::makeFrequency | ( | const Vector< Double > & | in | ) |

## makeFrequency() [2/2]

const Quantum< Double > & casacore::VelocityMachine::makeFrequency | ( | Double | in | ) |

## makeVelocity() [1/2]

const Quantum< Vector< Double > > & casacore::VelocityMachine::makeVelocity | ( | const Vector< Double > & | in | ) |

## makeVelocity() [2/2]

const Quantum< Double > & casacore::VelocityMachine::makeVelocity | ( | Double | in | ) |

## operator()() [1/3]

const Quantum< Double > & casacore::VelocityMachine::operator() | ( | const MVDoppler & | in | ) |

## operator()() [2/3]

const Quantum< Double > & casacore::VelocityMachine::operator() | ( | const MVFrequency & | in | ) |

Return velocity if frequency given, or a frequency if a velocity is given.

## operator()() [3/3]

const Quantum< Double > & casacore::VelocityMachine::operator() | ( | const Quantum< Double > & | in | ) |

## operator=()

VelocityMachine & casacore::VelocityMachine::operator= | ( | const VelocityMachine & | other | ) |

Copy assignment (copy semantics).

References VelocityMachine().

## reCalculate()

void casacore::VelocityMachine::reCalculate | ( |  | ) |

Recalculate the machinery from the original inputs.

Note that in all normal circumstances this function does not have to be used (the set() methods will do it automatically). At the moment I cannot think of any circumstance it should be used explicitly.

## set() [1/6]

void casacore::VelocityMachine::set | ( | const MDoppler::Ref & | in | ) |

## set() [2/6]

void casacore::VelocityMachine::set | ( | const MeasFrame & | in | ) |

Sets the MeasFrame to be used in conversions.

## set() [3/6]

void casacore::VelocityMachine::set | ( | const MFrequency::Ref & | in | ) |

Set or reset the specified part of the machine.

The machinery will be reset to reflect the changes made.

Sets a new frequency reference. Note that if an explicit frame has been used in earlier constructors, the frame should again be set explicitly with set(MeasFrame).

## set() [4/6]

void casacore::VelocityMachine::set | ( | const MFrequency::Types & | in | ) |

## set() [5/6]

void casacore::VelocityMachine::set | ( | const MVFrequency & | in | ) |

Sets the rest frequency.

## set() [6/6]

void casacore::VelocityMachine::set | ( | const Unit & | in | ) |

## Member Data Documentation

## cvfv_p

MFrequency::Convert casacore::VelocityMachine::cvfv_p

private

Frequency conversion forward.

Definition at line 294 of file VelocityMachine.h.

## cvov_p

MDoppler::Convert casacore::VelocityMachine::cvov_p

private

Velocity conversion backward.

Definition at line 300 of file VelocityMachine.h.

## cvvf_p

MFrequency::Convert casacore::VelocityMachine::cvvf_p

private

Frequency conversion backward.

Definition at line 296 of file VelocityMachine.h.

## cvvo_p

MDoppler::Convert casacore::VelocityMachine::cvvo_p

private

Velocity conversion forward.

Definition at line 298 of file VelocityMachine.h.

## fref_p

MFrequency::Ref casacore::VelocityMachine::fref_p

private

Frequency reference.

Definition at line 277 of file VelocityMachine.h.

## fun_p

Unit casacore::VelocityMachine::fun_p

private

Frequency units.

Definition at line 280 of file VelocityMachine.h.

## resf_p

Quantum<Double> casacore::VelocityMachine::resf_p

private

Definition at line 304 of file VelocityMachine.h.

## rest_p

MVFrequency casacore::VelocityMachine::rest_p

private

Rest frequency.

Definition at line 283 of file VelocityMachine.h.

## resv_p

Quantum<Double> casacore::VelocityMachine::resv_p

private

Result.

Definition at line 303 of file VelocityMachine.h.

## vfac_p

Double casacore::VelocityMachine::vfac_p

private

Definition at line 291 of file VelocityMachine.h.

## vfm_p

MFrequency::Types casacore::VelocityMachine::vfm_p

private

Velocity frame.

Definition at line 285 of file VelocityMachine.h.

## vref_p

MDoppler::Ref casacore::VelocityMachine::vref_p

private

Velocity reference.

Definition at line 287 of file VelocityMachine.h.

## vresf_p

Quantum<Vector<Double> > casacore::VelocityMachine::vresf_p

private

Definition at line 306 of file VelocityMachine.h.

## vresv_p

Quantum<Vector<Double> > casacore::VelocityMachine::vresv_p

private

Definition at line 305 of file VelocityMachine.h.

## vun_p

Unit casacore::VelocityMachine::vun_p

private

Velocity units.

Definition at line 290 of file VelocityMachine.h.

The documentation for this class was generated from the following file:

- measures/Measures/VelocityMachine.h