casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MVFrequency.h
Go to the documentation of this file.
00001 //# MVFrequency.h: Internal value for MFrequency
00002 //# Copyright (C) 1996,1997,1998,1999,2000,2001
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: MVFrequency.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00027 
00028 #ifndef CASA_MVFREQUENCY_H
00029 #define CASA_MVFREQUENCY_H
00030 
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <casa/Arrays/Vector.h>
00035 #include <casa/Quanta/QC.h>
00036 #include <casa/Quanta/Quantum.h>
00037 #include <casa/Quanta/MeasValue.h>
00038 #include <casa/iosfwd.h>
00039 
00040 namespace casa { //# NAMESPACE CASA - BEGIN
00041 
00042 //# Forward Declarations
00043 
00044 // <summary> Internal value for MFrequency </summary>
00045 
00046 // <use visibility=export>
00047 
00048 // <reviewed reviewer="tcornwel" date="1996/02/23" tests="tMeasMath" demos="">
00049 // </reviewed>
00050 
00051 // <prerequisite>
00052 // <li> <linkto class=MeasValue>MeasValue</linkto>
00053 // </prerequisite>
00054 //
00055 // <etymology>
00056 // From Measure, Value and Frequency
00057 // </etymology>
00058 //
00059 // <synopsis>
00060 // An MVFrequency is a simple Double, to be used in the MFrequency measure.
00061 // Requirements can be found in the 
00062 // <linkto class=MeasValue>MeasValue</linkto> base class.<br>
00063 // The only reasonable constructor is (but all MeasValue constructors are
00064 // present)
00065 // <src>MVFrequency(Double)</src> (with assumed Hz units);
00066 // and an <src>operator Double</src> takes
00067 // care of all other possibilities. Its external use is for
00068 //  <linkto class=MeasConvert>MeasConvert</linkto>, to distinguish between
00069 // input in internal Measure units, and values which have to have
00070 // units applied.<br>
00071 // The MVFrequency(Quantum) constructors recognise the type of wave
00072 // characteristics presented from its units. Recognised are:
00073 // <ul>
00074 //   <li> frequency (1/time)
00075 //   <li> time
00076 //   <li> angle/time
00077 //   <li> wavelength
00078 //   <li> 1/wavelength (in 2pi units)
00079 //   <li> energy (h.nu)
00080 //   <li> impulse
00081 // </ul>
00082 // <br> The frequency is returned in Hz with getValue(); or as a Quantity
00083 // in Hz with get(); or in one of the above units with get(unit).
00084 // </synopsis>
00085 //
00086 // <example>
00087 // See <linkto class=MFrequency>MFrequency</linkto>
00088 // </example>
00089 //
00090 // <motivation>
00091 // To aid coordinate transformations possibilities
00092 // </motivation>
00093 //
00094 // <todo asof="1996/04/15">
00095 // </todo>
00096 
00097 class MVFrequency : public MeasValue {
00098 
00099 public:
00100     
00101   //# Constructors
00102   // Default constructor: generate a zero value
00103   MVFrequency();
00104   // Copy constructor
00105   MVFrequency(const MVFrequency &other);
00106   // Copy assignment
00107   MVFrequency &operator=(const MVFrequency &other);
00108   // Constructor from Double, assuming Hz
00109   MVFrequency(Double d);
00110   // Constructor from Quantum : value taken will be the canonical value
00111   // <group>
00112   MVFrequency(const Quantity &other);
00113   MVFrequency(const Quantum<Vector<Double> > &other);
00114   // </group>
00115   // Constructor from Vector. A zero value will be taken for an empty vector,
00116   // the canonical value for a quantum vector.
00117   // <thrown>
00118   //  <li> AipsError if vector length > 1
00119   // </thrown>
00120   // <group>
00121   MVFrequency(const Vector<Double> &other);
00122   MVFrequency(const Vector<Quantity> &other);
00123   // </group>
00124   
00125   // Destructor
00126   ~MVFrequency();
00127   
00128   //# Operators
00129   // Conversion operator
00130   operator Double() const;
00131   
00132   // Addition
00133   // <group>
00134   MVFrequency &operator+=(const MVFrequency &other);
00135   MVFrequency &operator-=(const MVFrequency &other);
00136   // </group>
00137   // Comparisons
00138   // <group>
00139   Bool operator==(const MVFrequency &other) const;
00140   Bool operator!=(const MVFrequency &other) const;
00141   Bool near(const MVFrequency &other, Double tol = 1e-13) const;
00142   Bool nearAbs(const MVFrequency &other, Double tol = 1e-13) const;
00143   // </group>
00144   
00145   //# General member functions
00146   
00147   // Tell me your type
00148   // <group>
00149   virtual uInt type() const;
00150   static void assure(const MeasValue &in);
00151   // </group>
00152   
00153   // Print data
00154   virtual void print(ostream &os) const;
00155   // Clone
00156   virtual MeasValue *clone() const;
00157   // Adjust value: taken from base class, a NOP.
00158   // Get value in Hz
00159   Double getValue() const;
00160   // Get quantity in Hz
00161   Quantity get() const;
00162   // Get the wave characteristics in (recognised) specified units
00163   Quantity get(const Unit &unit) const;
00164   // Get the value in internal units
00165   virtual Vector<Double> getVector() const;
00166   // Set the value from internal units (set 0 for empty vector)
00167   virtual void putVector(const Vector<Double> &in);
00168   // Get the internal value as a <src>Vector<Quantity></src>. Usable in
00169   // records. The getXRecordValue() gets additional information for records.
00170   // Note that the Vectors could be empty.
00171   // <group>
00172   virtual Vector<Quantum<Double> > getRecordValue() const;
00173   // </group>
00174   // Set the internal value if correct values and dimensions
00175   virtual Bool putValue(const Vector<Quantum<Double> > &in);
00176   
00177 private:
00178   //# Data
00179   // Value
00180   Double val;
00181   
00182   //# Member functions
00183   // Get correct data type conversion factor from input Quantum
00184   Double makeF(Double v, const Unit &dt, Bool rev=False) const;
00185 };
00186 
00187 
00188 } //# NAMESPACE CASA - END
00189 
00190 #endif