casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MVRadialVelocity.h
Go to the documentation of this file.
00001 //# MVRadialVelocity.h: Internal value for MRadialvelocity
00002 //# Copyright (C) 1996,1997,1998,1999,2000,2001,2003
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: MVRadialVelocity.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00027 
00028 #ifndef CASA_MVRADIALVELOCITY_H
00029 #define CASA_MVRADIALVELOCITY_H
00030 
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <casa/Arrays/Vector.h>
00035 #include <casa/Quanta/Quantum.h>
00036 #include <casa/Quanta/MeasValue.h>
00037 #include <casa/iosfwd.h>
00038 
00039 namespace casa { //# NAMESPACE CASA - BEGIN
00040 
00041 //# Forward Declarations
00042 template <class T> class Vector;
00043 template <class T> class Quantum;
00044 
00045 // <summary> Internal value for MRadialVelocity </summary>
00046 
00047 // <use visibility=export>
00048 
00049 // <reviewed reviewer="tcornwel" date="1996/02/23" tests="tMeasMath" demos="">
00050 // </reviewed>
00051 
00052 // <prerequisite>
00053 // <li> <linkto class=MeasValue>MeasValue</linkto>
00054 // </prerequisite>
00055 //
00056 // <etymology>
00057 // From Measure, Value and Radial Velocity
00058 // </etymology>
00059 //
00060 // <synopsis>
00061 // An MVRadialVelocity is a simple Double, to be used in the MRadialVelocity 
00062 // measure.
00063 // Requirements can be found in the 
00064 // <linkto class=MeasValue>MeasValue</linkto> base class.<br>
00065 // The only reasonable constructor is (but all MeasValue constructors are
00066 // present)
00067 // <src>MVRadialVelocity(Double)</src>; and an <src>operator Double</src> takes
00068 // care of all other possibilities. Its external use is for
00069 //  <linkto class=MeasConvert>MeasConvert</linkto>, to distinguish between
00070 // input in internal Measure units, and values which have to have
00071 // units applied.<br>
00072 // The MVRadialVelocity(Quantum) constructors recognise the type of wave
00073 // characteristics presented from its units. Recognised are:
00074 // <ul>
00075 //   <li> velocity (length/time)
00076 // </ul>
00077 // <br> The velocity is returned in m/s with getValue(); or as a Quantity
00078 // in m/s with get(); or in the specified units with get(unit).
00079 //
00080 // A <em>shiftFrequency()</em> method can shift frequencies.
00081 // </synopsis>
00082 //
00083 // <example>
00084 // See <linkto class=MRadialVelocity>MRadialVelocity</linkto>
00085 // </example>
00086 //
00087 // <motivation>
00088 // To aid coordinate transformations possibilities
00089 // </motivation>
00090 //
00091 // <todo asof="1996/04/15">
00092 // </todo>
00093 
00094 class MVRadialVelocity : public MeasValue {
00095   
00096 public:
00097   
00098   //# Constructors
00099   // Default constructor: generate a zero value
00100   MVRadialVelocity();
00101   // Copy constructor
00102   MVRadialVelocity(const MVRadialVelocity &other);
00103   // Copy assignment
00104   MVRadialVelocity &operator=(const MVRadialVelocity &other);
00105   // Constructor from Double (assume m/s)
00106   MVRadialVelocity(Double d);
00107   // Constructor from Quantum
00108   // <group>
00109   MVRadialVelocity(const Quantity &other);
00110   MVRadialVelocity(const Quantum<Vector<Double> > &other);
00111   // </group>
00112   // Constructor from Vector. A zero value will be taken for an empty vector,
00113   // the first element for a quantum vector.
00114   // <thrown>
00115   //  <li> AipsError if vector length > 1
00116   // </thrown>
00117   // <group>
00118   MVRadialVelocity(const Vector<Double> &other);
00119   MVRadialVelocity(const Vector<Quantity> &other);
00120   // </group>
00121   
00122   // Destructor
00123   ~MVRadialVelocity();
00124   
00125   //# Operators
00126   // Conversion operator
00127   operator Double() const;
00128   
00129   // Addition
00130   // <group>
00131   MVRadialVelocity &operator+=(const MVRadialVelocity &other);
00132   MVRadialVelocity &operator-=(const MVRadialVelocity &other);
00133   // </group>
00134   // Comparisons
00135   // <group>
00136   Bool operator==(const MVRadialVelocity &other) const;
00137   Bool operator!=(const MVRadialVelocity &other) const;
00138   Bool near(const MVRadialVelocity &other, Double tol = 1e-13) const;
00139   Bool nearAbs(const MVRadialVelocity &other, Double tol = 1e-13) const;
00140   // </group>
00141   
00142   //# General member functions
00143   
00144   // Tell me your type
00145   // <group>
00146   virtual uInt type() const;
00147   static void assure(const MeasValue &in);
00148   // </group>
00149   
00150   // Print data
00151   virtual void print(ostream &os) const;
00152   // Clone
00153   virtual MeasValue *clone() const;
00154   // Adjust value: taken from base class, a NOP.
00155   // Get value in m/s
00156   Double getValue() const;
00157   // Get quantity in m/s
00158   Quantity get() const;
00159   // Get the wave characteristics in (recognised) specified units
00160   Quantity get(const Unit &unit) const;
00161   // Get the value in internal units
00162   virtual Vector<Double> getVector() const;
00163   // Set the value from internal units (set 0 for empty vector)
00164   virtual void putVector(const Vector<Double> &in);
00165   // Get the internal value as a <src>Vector<Quantity></src>. Usable in
00166   // records. The getXRecordValue() gets additional information for records.
00167   // Note that the Vectors could be empty.
00168   // <group>
00169   virtual Vector<Quantum<Double> > getRecordValue() const;
00170   // </group>
00171   // Set the internal value if correct values and dimensions
00172   virtual Bool putValue(const Vector<Quantum<Double> > &in);
00173   // Shift the input frequencies to the output frequencies. In the case of
00174   // simple Double inputs, it is assumed that the values are linearly dependent
00175   // on frequency. I.e. frequencies given as wavelength or time cannot be used.
00176   // <group>
00177   Vector<Double> shiftFrequency(const Vector<Double> &freq) const;
00178   Quantum<Vector<Double> >
00179     shiftFrequency(const Quantum<Vector<Double> > &freq) const;
00180   // </group>
00181   
00182 private:
00183   //# Data
00184   // Value
00185   Double val;
00186   
00187   //# Member functions
00188   // Get correct data type conversion factor from input Quantum
00189   Double makeF(const Unit &dt) const;
00190 };
00191 
00192 
00193 } //# NAMESPACE CASA - END
00194 
00195 #endif