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