casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MCRadialVelocity.h
Go to the documentation of this file.
00001 //# MCRadialVelocity.h: MRadialVelocity conversion routines 
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: MCRadialVelocity.h 21130 2011-10-18 07:39:05Z gervandiepen $
00028 
00029 #ifndef MEASURES_MCRADIALVELOCITY_H
00030 #define MEASURES_MCRADIALVELOCITY_H
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <measures/Measures/MeasBase.h>
00035 #include <measures/Measures/MeasRef.h>
00036 #include <measures/Measures/MCBase.h>
00037 #include <measures/Measures/MConvertBase.h>
00038 #include <measures/Measures/MRadialVelocity.h>
00039 #include <casa/OS/Mutex.h>
00040 
00041 namespace casa { //# NAMESPACE CASA - BEGIN
00042 
00043 //# Forward Declarations
00044 class MCRadialVelocity;
00045 class MDoppler;
00046 class MVPosition;
00047 class MVDirection;
00048 class Aberration;
00049 class String;
00050 
00051 //# Typedefs
00052 
00053 // <summary> MRadialVelocity conversion routines </summary>
00054 
00055 // <use visibility=local>
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 //   <li> <linkto class=MCBase>MCBase</linkto> base class
00063 //   <li> <linkto class=MConvertBase>overall conversion</linkto>  class
00064 // </prerequisite>
00065 //
00066 // <etymology>
00067 // Measure, Convert and RadialVelocity
00068 // </etymology>
00069 //
00070 // <synopsis>
00071 // Contains state machinery and cashing for actual conversions
00072 //
00073 // <example>
00074 // Get the Doppler shift for an oberved HI RadialVelocity of 100 km/s
00075 // <srcblock>
00076 //      #include <measures/Measures.h>
00077 //      #include <measures/Measures/MRadialVelocity.h>
00078 //      #include <measures/Measures/MDoppler.h>
00079 //      cout << "Redshift for 100 km/s: " <<
00080 //              MDoppler::Convert( MRadialVelocity( Quantity(100., "km/s"),
00081 //                                    MRadialVelocity::TOPO).toDoppler(QC::HI),
00082 //                                 MDoppler::Z)() << endl;
00083 // </srcblock>                             
00084 // </example>
00085 //
00086 // <motivation>
00087 // </motivation>
00088 //
00089 // <todo asof="2003/03/03">
00090 // </todo>
00091 
00092 class MCRadialVelocity : public MCBase {
00093   
00094 public:
00095   //# Friends
00096   // Conversion of data
00097   friend class MeasConvert<MRadialVelocity>;
00098   
00099   //# Constructors
00100   // Default constructor
00101   MCRadialVelocity();
00102   
00103   //# Destructor
00104   ~MCRadialVelocity();
00105 
00106   //# Member functions
00107   // Show the state of the conversion engine (mainly for debugging purposes)
00108   static String showState();
00109   
00110 private:
00111   //# Enumerations
00112   // The list of actual routines provided.
00113   // <note role=warning> Each <src>AA_BB</src> in the list points to routine
00114   // that can be used in the FromTo list in the getConvert routine.
00115   // In addition the type to which each is converted should be in the
00116   // ToRef array, again in the proper order. </note>
00117   enum Routes {
00118     LSRD_BARY,
00119     BARY_LSRD,
00120     BARY_GEO,
00121     GEO_TOPO,
00122     GEO_BARY,
00123     TOPO_GEO,
00124     LSRD_GALACTO,
00125     GALACTO_LSRD,
00126     LSRK_BARY,
00127     BARY_LSRK,
00128     BARY_LGROUP,
00129     LGROUP_BARY,
00130     BARY_CMB,
00131     CMB_BARY,
00132     N_Routes };
00133   
00134   //# Typedefs
00135   
00136   //# Operators
00137   
00138   //# General Member Functions
00139   
00140   //# Enumerations
00141   
00142   //# Cached Data
00143   MVPosition *MVPOS1;
00144   MVDirection *MVDIR1;
00145   Aberration *ABERFROM;
00146   Aberration *ABERTO;
00147 
00148   //# State machine data
00149   // Transition list
00150   static uInt ToRef_p[N_Routes][3];
00151   // Transition matrix
00152   static uInt FromTo_p[MRadialVelocity::N_Types][MRadialVelocity::N_Types];
00153   // Mutex for thread-safety.
00154   static MutexedInit theirMutexedInit;
00155 
00156   // Fill the global state in a thread-safe way.
00157   static void fillState()
00158     { theirMutexedInit.exec(); }
00159   
00160   //# Constructors
00161   // Copy constructor (not implemented)
00162   MCRadialVelocity(const MCRadialVelocity &other);
00163   // Assignment (not implemented)
00164   MCRadialVelocity &operator=(const MCRadialVelocity &other);
00165   
00166   //# Member functions
00167   // Create conversion function pointer
00168   virtual void getConvert(MConvertBase &mc,
00169                           const MRBase &inref,
00170                           const MRBase &outref);
00171   
00172   // Create help structures for Measure conversion routines
00173   virtual void initConvert(uInt which, MConvertBase &mc);
00174   
00175   // Delete the pointers used in the MeasConvert help structure cache
00176   virtual void clearConvert();
00177   
00178   // Routine to convert RadialVelocity from one reference frame to another
00179   virtual void doConvert(MeasValue &in,
00180                          MRBase &inref,
00181                          MRBase &outref,
00182                          const MConvertBase &mc);
00183   // Conversion routine to cater for inheritance question
00184   void doConvert(MVRadialVelocity &in,
00185                  MRBase &inref,
00186                  MRBase &outref,
00187                  const MConvertBase &mc);
00188   
00189 private:
00190   // Fill the global state in a thread-safe way.
00191   static void doFillState (void*);  
00192 };
00193 
00194 
00195 } //# NAMESPACE CASA - END
00196 
00197 #endif