casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MCEarthMagnetic.h
Go to the documentation of this file.
00001 //# MCEarthMagnetic.h: MEarthMagnetic conversion routines 
00002 //# Copyright (C) 1998,1999,2000,2002,2004
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: MCEarthMagnetic.h 21130 2011-10-18 07:39:05Z gervandiepen $
00028 
00029 #ifndef MEASURES_MCEARTHMAGNETIC_H
00030 #define MEASURES_MCEARTHMAGNETIC_H
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <measures/Measures/MEarthMagnetic.h>
00035 #include <measures/Measures/MeasBase.h>
00036 #include <measures/Measures/MeasRef.h>
00037 #include <measures/Measures/MCBase.h>
00038 #include <measures/Measures/MConvertBase.h>
00039 #include <measures/Measures/MeasMath.h>
00040 #include <casa/OS/Mutex.h>
00041 
00042 namespace casa { //# NAMESPACE CASA - BEGIN
00043 
00044 //# Forward Declarations
00045 class MCEarthMagnetic;
00046 class MVPosition;
00047 class EarthField;
00048 class String;
00049 template <class T> class Vector;
00050 
00051 //# Typedefs
00052 
00053 // <summary> MEarthMagnetic conversion routines  </summary>
00054 
00055 // <use visibility=local>
00056 
00057 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMEarthMagnetic" 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 EarthMagnetic
00068 // </etymology>
00069 //
00070 // <synopsis>
00071 // Contains state machinery and caching for actual conversions
00072 // </synopsis>
00073 //
00074 // <example>
00075 // See <linkto module=Measures>Measures</linkto> module description for
00076 // conversion examples.
00077 // </example>
00078 //
00079 // <motivation>
00080 // </motivation>
00081 //
00082 // <todo asof="1998/04/21">
00083 //      <li> Use MCDirection routines directly
00084 // </todo>
00085 
00086 class MCEarthMagnetic : public MCBase { 
00087   
00088 public:
00089 
00090   //# Friends
00091   // Conversion of data
00092   friend class MeasConvert<MEarthMagnetic>;
00093   
00094   //# Constructors
00095   // Default constructor
00096   MCEarthMagnetic();
00097   
00098   //# Destructor
00099   ~MCEarthMagnetic();
00100 
00101   //# Member functions
00102   // Show the state of the conversion engine (mainly for debugging purposes)
00103   static String showState();
00104 
00105 private:  
00106   //# Enumerations
00107   // The list of actual routines provided.
00108   // <note role=warning> Each <src>AA_BB</src> in the list points to routine
00109   // that can be used in the FromTo list in the getConvert routine.
00110   // In addition the type to which each is converted should be in the
00111   // ToRef array, again in the proper order. </note>
00112   enum Routes {
00113     GAL_J2000,
00114     GAL_B1950,
00115     J2000_GAL,
00116     B1950_GAL,
00117     J2000_B1950,
00118     B1950_J2000,
00119     J2000_JMEAN,
00120     B1950_BMEAN,
00121     JMEAN_J2000,
00122     JMEAN_JTRUE,
00123     BMEAN_B1950,
00124     BMEAN_BTRUE,
00125     JTRUE_JMEAN,
00126     BTRUE_BMEAN,
00127     J2000_JNAT,
00128     JNAT_J2000,
00129     B1950_APP,
00130     APP_B1950,
00131     APP_TOPO,
00132     HADEC_AZEL,
00133     HADEC_AZELGEO,
00134     AZEL_HADEC,
00135     AZELGEO_HADEC,
00136     HADEC_TOPO,
00137     AZEL_AZELSW,
00138     AZELGEO_AZELSWGEO,
00139     AZELSW_AZEL,
00140     AZELSWGEO_AZELGEO,
00141     APP_JNAT,
00142     JNAT_APP,
00143     J2000_ECLIP,
00144     ECLIP_J2000,
00145     JMEAN_MECLIP,
00146     MECLIP_JMEAN,
00147     JTRUE_TECLIP,
00148     TECLIP_JTRUE,
00149     GAL_SUPERGAL,
00150     SUPERGAL_GAL,
00151     ITRF_HADEC,
00152     HADEC_ITRF,
00153     TOPO_HADEC,
00154     TOPO_APP,
00155     ICRS_J2000,
00156     J2000_ICRS,
00157     N_Routes,
00158     // General for Models
00159     R_MODEL0,
00160     R_MODEL,
00161     // Individual models. Order should be the same as in MEarthMagnetic.h
00162     R_IGRF 
00163   };
00164   
00165   //# Typedefs
00166   
00167   //# Operators
00168   
00169   //# General Member Functions
00170   
00171   //# Enumerations
00172   
00173   //# Cached Data
00174   MVPosition *MVPOS1;
00175   EarthField *EFIELD;
00176   MeasMath measMath;
00177 
00178   //# State machine data
00179   // Transition list
00180   static uInt ToRef_p[N_Routes][3];
00181   // Transition matrix
00182   static uInt FromTo_p[MEarthMagnetic::N_Types][MEarthMagnetic::N_Types];
00183   // Mutex for thread-safety.
00184   static MutexedInit theirMutexedInit;
00185 
00186   // Fill the global state in a thread-safe way.
00187   static void fillState()
00188     { theirMutexedInit.exec(); }
00189 
00190   //# Constructors
00191   // Copy constructor (not implemented)
00192   MCEarthMagnetic(const MCEarthMagnetic &other);
00193   // Assignment (not implemented)
00194   MCEarthMagnetic &operator=(const MCEarthMagnetic &other);
00195   
00196   //# Member functions
00197   
00198   // Create conversion function pointer
00199   virtual void getConvert(MConvertBase &mc,
00200                           const MRBase &inref, 
00201                           const MRBase &outref);
00202   
00203   // Create help structures for Measure conversion routines
00204   virtual void initConvert(uInt which, MConvertBase &mc);
00205   
00206   // Delete the pointers used in the MeasConvert help structure cache
00207   virtual void clearConvert();
00208   
00209   // Routines to convert EarthMagnetics from one reference frame to another
00210   virtual void doConvert(MeasValue &in,
00211                          MRBase &inref,
00212                          MRBase &outref,
00213                          const MConvertBase &mc);
00214   // Conversion routine to cater for inheritance question
00215   void doConvert(MVEarthMagnetic &in,
00216                  MRBase &inref,
00217                  MRBase &outref,
00218                  const MConvertBase &mc);
00219   
00220 private:
00221   // Fill the global state in a thread-safe way.
00222   static void doFillState (void*);  
00223 };
00224 
00225 
00226 } //# NAMESPACE CASA - END
00227 
00228 #endif
00229