VelocityMachine.h

Classes

VelocityMachine -- Converts between velocities and frequencies (full description)

class VelocityMachine

Interface

Public Members
VelocityMachine(const MFrequency::Ref &freqRef, const Unit &freqUnits, const Unit &restFreq, const MVFrequency::Ref &velRef, const Unit &velUnits)
VelocityMachine(const MFrequency::Ref &freqRef, const Unit &freqUnits, const Unit &restFreq, const MVFrequency::Ref &velRef, const Unit &velUnits, const MDoppler &frame)
VelocityMachine(const MFrequency::Ref &freqRef, const Unit &freqUnits, const Unit &restFreq, const MFrequency::Types &convertRef, const MDoppler::Ref &velRef, const Unit &velUnits)
VelocityMachine(const MFrequency::Ref &freqref, const Unit &freqUnits, const Unit &restFreq, const MFrequency::Types &convertRef, const MDoppler::Ref &velRef, const Unit &velUnits, const Types &frame)
VelocityMachine(const VelocityMachine &other)
VelocityMachine &operator=(const VelocityMachine &other)
~VelocityMachine()
const Quantum<Double> &operator()(const MVFrequency &in)
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)
void set(const Unit &in)
void set(const MVFrequency &in)
void set(const MFrequency::Types &in)
void set(const MDoppler::Ref &in)
void set(const MeasFrame &in)
const MFrequency::Ref &getFrequencyReference() const
const Unit &getFrequencyUnits() const
const MDoppler::Ref &getDopplerReference() const
const Unit &getDopplerUnits() const
const MVFrequency &getRestFrequency() const
const MFrequency::Types &getConversionReference() const
void reCalculate()
Private Members
VelocityMachine()
void init()
void copy(const VelocityMachine &other)

Description

Review Status

Date Reviewed:
yyyy/mm/dd
Programs:
Tests:

Prerequisite

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:

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: 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;
	
See the test program for more examples

Motivation

To aid in converting series of frequencies and velocities

To Do

Member Description

VelocityMachine(const MFrequency::Ref &freqRef, const Unit &freqUnits, const Unit &restFreq, const MVFrequency::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 Unit &restFreq, const MVFrequency::Ref &velRef, const Unit &velUnits, const MDoppler &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 Unit &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 Unit &restFreq, const MFrequency::Types &convertRef, const MDoppler::Ref &velRef, const Unit &velUnits, const Types &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)
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)

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

void set(const MVFrequency &in)

Set or reset the specified part of the machine. The machinery will be reset to reflect the changes made.

Sets the rest frequency

void set(const MeasFrame &in)

Set or reset the specified part of the machine. The machinery will be reset to reflect the changes made.

Sets the MeasFrame to be used in conversions.

void set(const MFrequency::Ref &in)
void set(const Unit &in)
void set(const MFrequency::Types &in)
void set(const MDoppler::Ref &in)

Set or reset the specified part of the machine. The machinery will be reset to reflect the changes made.

const MFrequency::Ref &getFrequencyReference() const
const Unit &getFrequencyUnits() const
const MDoppler::Ref &getDopplerReference() const
const Unit &getDopplerUnits() const
const MVFrequency &getRestFrequency() const
const MFrequency::Types &getConversionReference() 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

void 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.

VelocityMachine()

Construct an empty machine (not implemented)

void init()

Initialise machinery

void copy(const VelocityMachine &other)

Copy data members