casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MDoppler.h
Go to the documentation of this file.
00001 //# MDoppler.h: A Measure: Doppler shift
00002 //# Copyright (C) 1995,1996,1997,1998,1999,2000,2002,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 //#
00027 //# $Id: MDoppler.h 21298 2012-12-07 14:53:03Z gervandiepen $
00028 
00029 #ifndef MEASURES_MDOPPLER_H
00030 #define MEASURES_MDOPPLER_H
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <measures/Measures/MeasBase.h>
00035 #include <measures/Measures/MeasRef.h>
00036 #include <casa/Quanta/MVDoppler.h>
00037 
00038 namespace casa { //# NAMESPACE CASA - BEGIN
00039 
00040 //# Forward Declarations
00041 class MDoppler;
00042 class MCDoppler;
00043 template <class M> class MeasConvert;
00044 template <class M> class ArrayMeasColumn;
00045 template <class M> class ScalarMeasColumn;
00046 template <class T> class Vector;
00047 template <class T> class Quantum;
00048 
00049 //# Typedefs
00050 
00051 // <summary>
00052 // A Measure: Doppler shift
00053 // </summary>
00054 
00055 // <use visibility=export>
00056 
00057 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMeasure" demos="">
00058 // </reviewed>
00059 
00060 // <prerequisite>
00061 //   <li> <linkto class=Measure>Measure</linkto> class 
00062 // </prerequisite>
00063 //
00064 // <etymology>
00065 // From Measure and Doppler
00066 // </etymology>
00067 //
00068 // <synopsis>
00069 // MDoppler forms the derived Measure class for Doppler shifts.<br>
00070 // An MDoppler can be generated from a simple value (or an
00071 // <linkto class=MVDoppler>MVDoppler</linkto>), which is then
00072 // interpreted as a Doppler ratio, and a reference, with a RADIO type
00073 // as default.<br>
00074 // It can also be generated from a Quantity, where the interpretation
00075 // depends on the dimensionality of the Quantity:
00076 // <ul>
00077 // <li> None: a Doppler ratio
00078 // <li> Velocity: Doppler ratio calculated by dividing with c
00079 // </ul>
00080 // The different types of Doppler (with F = f/f0, the frequency ratio),
00081 // are:
00082 // <ul>
00083 // <li> MDoppler::Z             (-1 + 1/F)
00084 // <li> MDoppler::RATIO         (F)                             *
00085 // <li> MDoppler::RADIO         (1  - F)
00086 // <li> MDoppler::OPTICAL == Z
00087 // <li> MDoppler::BETA          ((1 - F<sup>2</sup>)/(1 + F<sup>2</sup>))
00088 // <li> MDoppler::GAMMA         ((1 + F<sup>2</sup>)/2F)        *
00089 // <li> MDoppler::RELATIVISTIC == BETA (== v/c)
00090 // <li> MDoppler::DEFAULT == RADIO
00091 // </ul>
00092 // Note that the ones with an '*' have no real interpretation (although the
00093 // calculation will proceed) if given as
00094 // a velocity.<br>
00095 // <p>
00096 // Conversion between the different types is done with the standard
00097 // <linkto class=MeasConvert>MeasConvert</linkto> class 
00098 // (<src>MDoppler::Convert</src> in this case).<br>
00099 // 
00100 // Dopplers can be created from an <linkto class=MFrequency>MFrequency</linkto>
00101 // object, or from an <linkto class=MRadialVelocity>MRadialVelocity</linkto>
00102 // object.<br>
00103 //
00104 // A <em>shiftFrequency()</em> method can shift frequencies.
00105 //
00106 // Dopplers do not need a reference frame.
00107 //
00108 // </synopsis>
00109 //
00110 // <example>
00111 // Conversion of a radio Doppler to an optical
00112 // <srcblock>
00113 //      MDoppler radio(0.01);           // A radio Doppler value
00114 //      cout << "Doppler radio = " << radio << "; optical = " <<
00115 //              MDoppler::Convert(radio, MDoppler::OPTICAL)() << // Convert 
00116 //              endl;
00117 // </srcblock>
00118 // Setting up a conversion
00119 // <srcblock>
00120 //      MDoppler::Convert to_opt(MDoppler::RADIO, MDoppler::OPTICAL);
00121 //      for (Double d=0; d<0.1; d += 0.005) {
00122 //              cout << "radio = " << d << " to optical = " <<
00123 //                      to_opt(d) << endl;
00124 // </srcblock>
00125 // </example>
00126 //
00127 // <motivation>
00128 // </motivation>
00129 //
00130 // <todo asof="2000/06/15">
00131 //      <li>
00132 // </todo>
00133 
00134 class MDoppler : public MeasBase<MVDoppler, MeasRef<MDoppler> > {
00135 
00136  public:
00137   //# Friends
00138   // Conversion of data
00139   friend class MeasConvert<MDoppler>;
00140   
00141   //# Enumerations
00142   // Types of known MDopplers
00143   // <note role=warning> The order defines the order in the translation
00144   // matrix FromTo
00145   // in the getConvert routine. Do not change the order without
00146   // changing the array. Additions should be made before N_types, and
00147   // an additional row and column should be coded in FromTo, and
00148   // in showType().</note>
00149   enum Types {
00150     RADIO, 
00151     Z,
00152     RATIO,
00153     BETA,
00154     GAMMA,
00155     N_Types,
00156     OPTICAL=Z,
00157     RELATIVISTIC=BETA,
00158     DEFAULT=RADIO };
00159   
00160   //# Typedefs
00161   // Measure value container for this class (i.e. MDoppler::MVType)
00162   typedef MVDoppler MVType;
00163   // Measure conversion routines for this class (i.e. MDoppler::MCType)
00164   typedef MCDoppler MCType;
00165   // Measure reference (i.e. MDoppler::Ref)
00166   typedef MeasRef<MDoppler> Ref;
00167   // Measure Convert (i.e. MDoppler::Convert)
00168   typedef MeasConvert<MDoppler> Convert;
00169   // Measure table Columns (e.g., MDoppler::ScalarColumn)
00170   typedef ScalarMeasColumn<MDoppler> ScalarColumn;
00171   typedef ArrayMeasColumn<MDoppler> ArrayColumn;
00172   // Reference enum Types (included originally for gcc 2.95)  
00173   typedef WHATEVER_SUN_TYPEDEF(MDoppler) Types Types;
00174 
00175   //# Constructors
00176   // <note role=tip> In the following constructors and other functions, all 
00177   // <em>MeasRef</em> can be replaced with simple <src>Measure::TYPE</src>
00178   // where no offsets or frames are needed in the reference. </note>
00179   // Default constructor; generates a zero rest Doppler
00180   MDoppler();
00181   // Create from data and reference
00182   // <group>
00183   MDoppler(const MVDoppler &dt);
00184   MDoppler(const MVDoppler &dt, const MDoppler::Ref &rf);
00185   MDoppler(const MVDoppler &dt, MDoppler::Types rf);
00186   MDoppler(const Quantity &dt);
00187   MDoppler(const Quantity &dt, const MDoppler::Ref &rf);
00188   MDoppler(const Quantity &dt, MDoppler::Types rf);
00189   MDoppler(const Measure *dt);
00190   MDoppler(const MeasValue *dt);
00191   // </group>
00192 
00193   //# Destructor
00194   virtual ~MDoppler();
00195   
00196   //# Operators
00197   
00198   //# General Member Functions
00199   // Tell me your type
00200   // <group>
00201   virtual const String &tellMe() const;
00202   static const String &showMe();
00203   virtual uInt type() const;
00204   static void assure(const Measure &in);
00205   // </group>
00206   // Translate reference code. The uInt version has a check for valid codes
00207   // (i.e. it is a safe cast).
00208   // <thrown>
00209   //   <li> AipsError in the uInt interface if illegal code given
00210   // </thrown>
00211   // <group>
00212   static MDoppler::Types castType(uInt tp);
00213   static const String &showType(MDoppler::Types tp);
00214   static const String &showType(uInt tp);
00215   // </group>
00216   // Translate string to reference code
00217   // <group>
00218   static Bool getType(MDoppler::Types &tp, const String &in);
00219   Bool giveMe(MDoppler::Ref &mr, const String &in);
00220   // </group>
00221   // Set the offset in the reference (False if non-matching Measure)
00222   virtual Bool setOffset(const Measure &in);
00223   // Set the reference type to the specified String. False if illegal
00224   // string, reference set to DEFAULT.
00225   virtual Bool setRefString(const String &in);
00226   // Get the default reference type
00227   virtual const String &getDefaultType() const;
00228   // Get a list of all known reference codes. nall returns the number in list,
00229   // nextra the number of specials (like planets) that should be at 
00230   // end of list). typ returns the list of corresponding types.
00231   // <group>
00232   virtual const String* allTypes(Int &nall, Int &nextra,
00233                                  const uInt *&typ) const;
00234   static const String* allMyTypes(Int &nall, Int &nextra,
00235                                   const uInt *&typ);
00236   // </group>
00237   // Check if all internal tables of types (both enum and String) are 
00238   // complete and correct. This function is called automatically if and when
00239   // necessary.
00240   // <thrown>
00241   //   <li> AipsError if a (programming) error in the types.
00242   // </thrown>
00243   // <group> 
00244   virtual void checkTypes() const;
00245   static void checkMyTypes();
00246   // </group>
00247   // Get the reference type (for records, including codes like R_)
00248   virtual String getRefString() const;
00249   // Get my type (as Register)
00250   static uInt myType();
00251 
00252   // Get in specified units
00253   Quantity get(const Unit &un) const;
00254 
00255   // Shift the input frequencies to the output frequencies. In the case of
00256   // simple Double inputs, it is assumed that the values are linearly dependent
00257   // on frequency. I.e. frequencies given as wavelength or time cannot be used.
00258   // <group>
00259   Vector<Double> shiftFrequency(const Vector<Double> &freq) const;
00260   Quantum<Vector<Double> >
00261     shiftFrequency(const Quantum<Vector<Double> > &freq) const;
00262   // </group>
00263 
00264   // Make a copy
00265   // <group>
00266   virtual Measure *clone() const;
00267   // </group>
00268   
00269  private:
00270   //# Enumerations
00271   
00272   //# Data
00273   
00274   //# Member functions
00275 
00276 
00277 };
00278 
00279 
00280 } //# NAMESPACE CASA - END
00281 
00282 #endif